You must be logged in to post your query.
Home › Forums › Chart Support › Incorrect month
Tagged: date, month, x-axis
I am having a problem with dates in the X-axis of a line chart. I see the problem also exists in the documentation at https://canvasjs.com/docs/charts/basics-of-creating-html5-chart/formatting-date-time/
You will see that in the DATE TIME FORMATTING chart the third point is “23 Jul 12: 30” but the code in the “try it yourself window shows “{ x: new Date(2012, 06, 23), y: 30 }, ” for that point.
Why does the code show “06” (June) while the chart shows “Jul” (July)?
I have the same problem with my charts shows the month incremented by 1.
@guysnelling,
In JavaScript month starts from 0(January) and ends at 11(December). So while displaying they are incremented by 1.
— Vishwas R Team CanvasJS
Well that’s annoying. I will have to manipulate my input dates to correct the month field. But since this is a date field, couldn’t CanvasJS increment the month automatically? (Feature/bug suggestion)
CanvasJS is a JavaScript library and follows JavaScript Date-Formats and is not a bug. However, you can use ISO format to pass month from 1 to 12 (Example: “2015-03-25” is considered as March 25, 2015). You can adopt the one of the format to fit your requirements.
You must be logged in to reply to this topic. Login/Register