试试这个JSFiddle
var chart = c3.generate({
bindto: '#chart',
data: {
columns: [
['data1', 30000, 20000, 10000, 40000, 0, 0, 0, 0],
['data2', 0, 0, 0, 0, 15000, 25000, 50000, 10000],
['data3', 0, 0, 0, 0, 15000, 25000, 50000, 10000]
],
order:false,
type: 'bar',
groups: [
['data2', 'data3']
]
},
bar: {
width: {
ratio: 0.70
}
},
axis: {
x: {
type: 'category',
categories:["mar-2017" , "April-2017","May-2017","June-2017","July-2017","August-2017","September-2017","October-2017"],
tick: {
rotate: 30,
format: '%b%Y'
}
}
}
});
或者我认为你的日期格式是不正确的JSON数据, 您也可以用时间序列尝试如下
var chart = c3.generate({
bindto: '#chart',
data: {
x: 'x',
columns: [
['x', '2017-01-01' , '2017-02-01','2017-03-01','2017-04-01','2017-05-01','2017-06-01','2017-07-01','2017-08-01'],
['data1', 30000, 20000, 10000, 40000, 0, 0, 0, 0],
['data2', 0, 0, 0, 0, 15000, 25000, 50000, 10000], ['data3', 0, 0, 0, 0, 15000, 25000, 50000, 10000]
],
order:false,
type: 'bar',
groups: [
['data2', 'data3']
]
},
bar: {
width: {
ratio: 0.70
}
},
axis: {
x: {
type: 'timeseries',
tick: {
rotate: 30,
format: '%b %Y'
}
}
}
});
快乐编码
请提供一些代码你试过 –
尝试x轴类型作为类别。 http://c3js.org/reference.html#axis-x-type –
我已经使用'timeseries'类型的x轴 – sakshi