我正在使用 c3js 并尝试渲染三层中的每一层,并将每个月流失的条形图分组在 x 轴层下。我的问题是数据结构应该是什么?
目前的数据是:
[
[
"x",
"Tier I",
"Tier II",
"Tier III"
],
[
[
"Apr 2015",
"6"
],
[
"May 2015",
"3"
],
[
"Jun 2015",
"61"
],
[
"Jul 2015",
"4"
]
],
[
[
"Apr 2015",
"13"
],
[
"May 2015",
"3"
],
[
"Jun 2015",
"0"
],
[
"Jul 2015",
"0"
]
],
[
[
"Apr 2015",
"4"
],
[
"May 2015",
"5"
],
[
"Jun 2015",
"4"
],
[
"Jul 2015",
"8"
]
]
当前的 c3 调用是:
var chart = c3.generate({
data: {
x: 'x',
columns: full,
type: 'bar'
},
bar: {
width: {
ratio: 0.8 // this makes bar width 50% of length between ticks
}
},
axis: {
x: {
type: 'categorized' // this is needed to load string x value
}
},
bindto: '#chart'
});
谢谢!