Reputation: 3462
Hello Im trying to plot some data on angularjs using chart.js , but Im getting a weird ordering of my data, which results in a weird chart like this:
This are my options:
vm.options = {
type:'line',
fill: false,
backgroundColor: 'transparent',
scales: {
xAxes: [{
type: 'time',
position: 'bottom'
}]
}
};
I tried ordering the date of my data like this:
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);
});
But the result is the image above. Can anyone help me spot the problem?
Upvotes: 0
Views: 1964
Reputation: 2468
Though it is an old post but I am answering so that somebody may get benefit from it!
I have faced similar problem with my ionic3 app. I had a problematic graph with wrong order,though my dataset was in right order (I have used a slider to adjust the value) .The problem was solved by applying a loading controller of ionic framework. You need to give time to complete the response and render before the final display.
Hope it will help you.
Upvotes: 0