I have just started working with CanvasJS today.
My datasource is an external API from which I receive JSON.
I build the datapoints array and feed it date objects and integers using
dataPoints.push({label: new Date(json.dataset.data[key][0]), y: json.dataset.data[key][1]});
I set the X axis labels with the following
axisX:{
labelFormatter: function (e) {
return CanvasJS.formatDate( e.value, "MMM YYYY");
}
}
The line graph is perfect and hovering shows dates formatted “Wed Aug 17 2016 19:00:00 GMT-0500 (Central Daylight Time)”.
The X axis shows a first label of Jun 2017 which should be the last entry. The others all show Dec 1968 indicating that the date was not parsable.
But the dates are correctly displayed in the line itself so one assumes they were successfully converted to Date objects and used there.
How do I correct this?
http://jsfiddle.net/wevy4c92/1/