Does the C3 bar chart support JSON data? I am trying to get a simple example working but could not find any documentation or examples on how to achieve something like this:
var chart = c3.generate({
data: {
type: 'bar',
json: [
{ 'indicator': 'X', 'total': 100 },
{ 'indicator': 'Y', 'total': 200 },
{ 'indicator': 'Z', 'total': 300 }
],
keys: {
x: 'indicator',
value: ['total']
}
},
bar: {
width: {
ratio: 0.5
}
}
});
Problem was the missing axis
value. Here is a working JS fiddle.
var chart = c3.generate({
data: {
type: 'bar',
json: [
{ 'indicator': 'X', 'total': 100 },
{ 'indicator': 'Y', 'total': 200 },
{ 'indicator': 'Z', 'total': 300 }
],
keys: {
x: 'indicator',
value: ['total']
}
},
axis: {
x: {
type: 'category'
}
},
bar: {
width: {
ratio: 0.5
}
}
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With