C3 - 折线图。没有显示行

时间:2016-09-27 09:18:12

标签: jquery charts c3.js

我正在尝试使用JSON输入来淹没C3折线图。但由于某种原因,它没有显示线条,只显示了点。

    chart = c3.generate({
    data: {
        x: 'x',
        json: [
{"period":"2016-09-18","mp-demo-1":30},
{"period":"2016-09-19","mp-demo-1":13},
{"period":"2016-09-20","mp-demo-1":39},
{"period":"2016-09-21","mp-demo-1":43},
{"period":"2016-09-22","mp-demo-1":27},
{"period":"2016-09-23","mp-demo-1":10},
{"period":"2016-09-24","mp-demo-1":10},
{"period":"2016-09-25","mp-demo-1":20},
{"period":"2016-09-26","mp-demo-1":18},
{"period":"2016-09-18","MP7":20},
{"period":"2016-09-19","MP7":33},
{"period":"2016-09-20","MP7":29},
{"period":"2016-09-21","MP7":23},
{"period":"2016-09-22","MP7":17},
{"period":"2016-09-23","MP7":10},
{"period":"2016-09-24","MP7":40},
{"period":"2016-09-25","MP7":30},
{"period":"2016-09-26","MP7":10}
],
        keys: {
            x: 'period',
            value: ['mp-demo-1', 'MP7']
        }
    },
    axis: {
        x: {
          type: 'timeseries',
          tick: {
            format: '%Y-%m-%d'
          }        
        }
    }
});

这是我的小提琴 - fiddle。这里缺少什么?

1 个答案:

答案 0 :(得分:2)

也许尝试将两个值移动到json中的同一个对象:

{"period":"2016-09-18","mp-demo-1":30, "MP7":20},

http://jsfiddle.net/14gsxv0w/