2014-01-10 37 views
1

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

你已經在你的陰謀調用獲得太多了套的數據參數[] 。應該是:

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

小提琴here

即使修復了這個問題,您的「繪圖」也只是右側網格邊界上的一條垂直線。

enter image description here

+0

不錯的一個!改變時代的我也看到傾斜的數據 – bobbyrne01