0
我一直在努力解決這個問題一個小時,我無法弄清楚爲什麼Morris圖表將某種時間值放入X ax。Morris.js xKey添加無意義值
首先,我的JSON如下:
{"data":[{"date":"2015-06-08","payed":"18.08","to_pay":"18.08"},
{"date":"2015-06-11","payed":"70.24","to_pay":"108.24"}]}
而且我創建圖表是這樣的:
var json = JSON.parse(response);
Morris.Line({
element: 'recebimentos-chart',
data: json.data,
xkey: 'date',
ykeys: ['to_pay', 'payed'],
labels: ['To pay', 'Payed'],
gridTextColor: '#000',
lineColors: ['#EA8A67', '#22aa22'],
});
而現在的問題:爲什麼在神的天堂是X斧頭寫的圖像顯示的價值?
正如你可以看到我的JSON有兩個不同的日期。如果我只有一個日期(無論是哪一個)圖表做工不錯(它輸出的X斧的日期值),例如:
{"data":[{"date":"2015-06-11","payed":"18.08","to_pay":"18.08"},
{"date":"2015-06-11","payed":"70.24","to_pay":"108.24"}]}
編輯1:嘗試在JSFiddle我發現問題是圖表的寬度。具有小寬度的圖表呈現正確的日期,具有大的寬度它呈現小時(??)
的問題是,我需要呈現一個大的圖表..
您的回答是正確的,我會接受它。另外,我會回答我的問題,說添加設置「parseTime:false」也解決了這個問題。謝謝。 – Linesofcode