0
您好,我試圖使用chart.js在angularjs上繪製一些數據,但是我得到了一個奇怪的數據排序,這導致了一個奇怪的圖表,如下所示:Chart.js圖表中的錯誤訂單在X軸上的時間
這是我的選擇:
vm.options = {
type:'line',
fill: false,
backgroundColor: 'transparent',
scales: {
xAxes: [{
type: 'time',
position: 'bottom'
}]
}
};
我想訂購我的數據是這樣的日期:
vm.data.sort(function(a,b){
// Turn your strings into dates, and then subtract them
// to get a value that is either negative, positive, or zero.
return new Date(b.time) - new Date(a.time);
});
但結果是上面的圖像。任何人都可以幫助我發現問題嗎?
後用同樣的問題 –
你嘗試交換a和b小提琴? '返回新日期(a.time) - 新日期(b.time);' –