I\'m trying to create a stacked bar chart using Rails Chartkick gem and I\'m using Google charts API.
I have use this line to generate the bar chart using chartkick.
Use this format
data = [
{
name: "Fantasy & Sci Fi",
data: [["2010", 10], ["2020", 16], ["2030", 28]]
},
{
name: "Romance",
data: [["2010", 24], ["2020", 22], ["2030", 19]]
},
{
name: "Mystery/Crime",
data: [["2010", 20], ["2020", 23], ["2030", 29]]
}
]
You can replicate Stacked Bar Charts like this:
data = [
{
name: "Fantasy & Sci Fi",
data: [["2010", 10], ["2020", 16], ["2030", 28]]
},
{
name: "Romance",
data: [["2010", 24], ["2020", 22], ["2030", 19]]
},
{
name: "Mystery/Crime",
data: [["2010", 20], ["2020", 23], ["2030", 29]]
}
]
And in the template:
<%= bar_chart data, stacked: true %>