I am trying to make a stacked barchart in C3.js with a JSON with the fields product, month, amount_sale, for example:
[{"product": "Pulp", "month": "january", "sale_amount": 320},
{"product": "Pulp", "month": "february", "sale_amount": 160},
{"product": "Beef", "month": "january", "sale_amount": 210},
{"product": "Beef", "month": "february", "sale_amount": 90}]
Then i try to generate a stacked bar graph that shows for each product the sale amount in each month, with the following code:
var chart = c3.generate({
data: {
json: data,
keys: {
x: "product",
value: ["sale_amount"]
},
type: "bar",
groups: [["month"]]
},
axis: {
x: {
type: "category"
}
}
});
But the graph shows me the product on the X axis but it does not take the month group, this can we see in:
https://codepen.io/NetWilson05/pen/bGmdMZR
what am i doing wrong?