morris.js绘制错误的价值

时间:2014-03-07 18:24:42

标签: javascript jquery morris.js

我正在使用morris.js绘制图形,但它在折线图上绘制了错误的值。弹出窗口显示3,但该行显示为4

enter image description here

绘制图表的代码:

var overviewChart = Morris.Area({
element: 'overviewChart',
  data: $.parseJSON($('#userBlocks').html()),
  xkey: 'y',
  ykeys: ['Blocks', 'Scans'],
  labels: ['Blocks', 'Scans'],
  lineColors: ['#A5C3F7', '#999']
});

为JSON数据解析的文本:

 [{"y":"2014-02-07","Blocks":0,"Scans":0},{"y":"2014-02-08","Blocks":0,"Scans":0},{"y":"2014-02-09","Blocks":0,"Scans":0},{"y":"2014-02-10","Blocks":0,"Scans":0},{"y":"2014-02-11","Blocks":0,"Scans":0},{"y":"2014-02-12","Blocks":0,"Scans":0},{"y":"2014-02-13","Blocks":0,"Scans":0},{"y":"2014-02-14","Blocks":0,"Scans":0},{"y":"2014-02-15","Blocks":0,"Scans":0},{"y":"2014-02-16","Blocks":0,"Scans":0},{"y":"2014-02-17","Blocks":0,"Scans":0},{"y":"2014-02-18","Blocks":0,"Scans":0},{"y":"2014-02-19","Blocks":0,"Scans":0},{"y":"2014-02-20","Blocks":0,"Scans":0},{"y":"2014-02-21","Blocks":0,"Scans":0},{"y":"2014-02-22","Blocks":0,"Scans":0},{"y":"2014-02-23","Blocks":0,"Scans":0},{"y":"2014-02-24","Blocks":0,"Scans":0},{"y":"2014-02-25","Blocks":0,"Scans":0},{"y":"2014-02-26","Blocks":0,"Scans":0},{"y":"2014-02-27","Blocks":0,"Scans":0},{"y":"2014-02-28","Blocks":0,"Scans":0},{"y":"2014-03-01","Blocks":0,"Scans":0},{"y":"2014-03-02","Blocks":0,"Scans":0},{"y":"2014-03-03","Blocks":0,"Scans":0},{"y":"2014-03-04","Blocks":0,"Scans":0},{"y":"2014-03-05","Blocks":0,"Scans":0},{"y":"2014-03-06","Blocks":0,"Scans":0},{"y":"2014-03-07","Blocks":1,"Scans":3}]

好像灰线正在加3 + 1 = 4而不只是3.有没有办法让它只有3?

1 个答案:

答案 0 :(得分:0)

我的错。只需将Morris.Area更改为Morris.Line