Home forums Using CanvasJS Incorrect month

Tagged: , ,

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #28036

    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.

    #28059

    @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

    #28060

    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)

    #28098

    @guysnelling,

    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.


    Vishwas R
    Team CanvasJS

Viewing 4 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic.