C3条形图是否支持JSON数据?我试图让一个简单的例子工作,但找不到任何关于如何实现这样的事情的文档或例子:
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
}
}
});
最佳答案
问题是缺少 axis
值。这是一个工作 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
}
}
});
关于javascript - C3条形图-JSON输入,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26520294/