【发布时间】:2016-05-12 10:03:20
【问题描述】:
在使用类型作为时间序列时,我遇到了 c3js 中重叠的问题
OUTPUT screenshot of Below code
如下图所示,我添加代码也供您参考
var chart = c3.generate({
bindto: '#chart',
data: {
//x : 'indicator',
xFormat: '%Y%m%d',
json: [
{ 'indicator': '20160101', 'total': 100 ,'total2': 130 ,'total3': 10 },
{ 'indicator': '20160211', 'total': 200,'total2': 136 ,'total3': 50 },
{ 'indicator': '20150518', 'total': 300,'total2': 230 ,'total3': 60 },
{ 'indicator': '20160111', 'total': 100 ,'total2': 130 ,'total3': 10 },
{ 'indicator': '20161212', 'total': 200,'total2': 136 ,'total3': 50 },
{ 'indicator': '20160528', 'total': 300,'total2': 230 ,'total3': 60 },
{ 'indicator': '20141101', 'total': 100 ,'total2': 130 ,'total3': 10 },
{ 'indicator': '20161211', 'total': 200,'total2': 136 ,'total3': 50 },
{ 'indicator': '20160418', 'total': 300,'total2': 230 ,'total3': 60 }
],
groups: [
['total','total2','total3']
],
keys: {
x: 'indicator',
value: ['total','total2','total3']
},
type: 'bar',
order: 'asc'
},
zoom: {
enabled: true
},
axis: {
x: {
// type: 'category',
type : 'timeseries',
tick: {
fit: true,
outer: false,
// format: function (x) {
// if (x.getDate() === 1) {
// return x.toLocaleDateString();
// }
// }
format: function (x) { return x.getFullYear(); }
}
}
},
bar: {
width: {
// 6 - items in dataset part of bar width calcuation
// 28 - items that should have been considered in dataset # of
// months between start and end
// 0.6 - the default bar.with.ratio
// ratio: 6 / 28 * 0.6
ratio:0.5
}
}
});
你能帮忙吗?
提前谢谢你
【问题讨论】:
标签: c3.js