c3.js 删除非连续日期的时间序列之间的空格

c3.js remove empty spaces between timeseries with non consecutive days

我用 c3.js 制作了一个条形图,我需要在图中添加非连续的天数

问题是图表添加了空天数

http://c3js.org/samples/timeseries.html

我使用了这个代码,可以在页面中复制和粘贴代码并查看实时结果

var chart = c3.generate({
    data: {
        x: 'x',
        type: 'bar',
        columns: [
            ['x', '2013-01-01', '2013-01-02', '2013-01-03', '2013-01-04', '2013-01-05', '2013-01-07', '2013-01-09', '2013-01-10', '2013-01-11'],
            ['data1', 30, 200, 100, 400, 150, 250, 250, 250, 250],
            ['data2', 130, 340, 200, 500, 250, 350, 250, 250, 250]
        ]
    },
    axis: {
        x: {
            type: 'timeseries',
            tick: {
                format: '%Y-%m-%d'
            }
        }
    }
});

您可以使用类别轴而不是时间序列轴。检查示例:

var chart = c3.generate({
data: {
    x: 'x',
    type: 'bar',
    columns: [
        ['x', '2013-01-01', '2013-01-02', '2013-01-03', '2013-01-04', '2013-01-05', '2013-01-07', '2013-01-09', '2013-01-10', '2013-01-11'],
        ['data1', 30, 200, 100, 400, 150, 250, 250, 250, 250],
        ['data2', 130, 340, 200, 500, 250, 350, 250, 250, 250]
    ],

},
axis: {
    x: {
        type: 'category',
        tick: {
       centered: true
   }
    }
}});