admin管理员组文章数量:1327804
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
}
}
});
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
}
}
});
Share
Improve this question
edited Oct 23, 2014 at 2:54
armandino
asked Oct 23, 2014 at 2:21
armandinoarmandino
18.6k17 gold badges74 silver badges85 bronze badges
1 Answer
Reset to default 6Problem 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
}
}
});
本文标签: javascriptC3 bar chartJSON inputStack Overflow
版权声明:本文标题:javascript - C3 bar chart - JSON input - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1742226623a2436436.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论