用flot,json系列绘制时间

时间:2014-01-10 01:07:16

标签: javascript json flot

没有绘制JSON数据?

使用Javascript:

var datasets = JSON.parse(xmlhttp.responseText);                
alert(JSON.stringify(datasets[0]));

var plotarea = $("#placeholder");
$.plot(plotarea, [[datasets[0].points]], {
    xaxis: {
        mode: "time",
        min: (new Date(2013, 11, 1)).getTime(),
        max: (new Date()).getTime()
    }
});

输出:

{"name":"Test.txt","points":[[1389313796000,2],[1389314796000,4]]}

渲染图: enter image description here

1 个答案:

答案 0 :(得分:1)

你的情节调用中的数据参数中有一组[ ]太多。应该是:

$.plot(plotarea, [datasets[0].points], { 

小提琴here

即使修复了这个问题,你的“情节”只是右边网格边框的垂直线。

enter image description here