Home forums Report Bugs the axis date is wrong

Tagged: 

This topic contains 1 reply, has 2 voices, and was last updated by  Bivek Singh 1 week ago.

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #13511

    cntigercn
    Member

    the following code show that the xaxis date is one more than the real date;

    <!DOCTYPE HTML>
    <html>
    <head>
    <script type=”text/javascript”>
    window.onload = function () {
    var chart = new CanvasJS.Chart(“chartContainer”,
    {
    title: {
    text: “Date Time Formatting”
    },
    axisX:{
    valueFormatString: “YY-MM-DD”,
    labelAngle: -50
    },
    axisY: {
    valueFormatString: “#,###”
    },

    data: [
    {
    type: “area”,
    color: “rgba(0,75,141,0.7)”,
    dataPoints: [

    { x: new Date(2016, 05, 13), y: 0},
    { x: new Date(2016, 05, 17), y: 20 },
    { x: new Date(2016, 05, 29), y: 30 },
    { x: new Date(2016, 06, 2), y: 10},
    { x: new Date(2016, 06, 6), y: 21},
    { x: new Date(2016, 06, 14), y: 50} ,
    { x: new Date(2016, 06, 22), y: 75},
    { x: new Date(2016, 06, 30), y: 10},
    { x: new Date(2016, 07, 4), y: 12},
    { x: new Date(2016, 07, 8), y: 15},
    { x: new Date(2016, 07, 16), y: 17},
    { x: new Date(2016, 08, 5), y: 20},
    { x: new Date(2016, 08, 9), y: 22},
    { x: new Date(2016, 08, 17), y: 25},
    { x: new Date(2016, 08, 21), y: 27},
    { x: new Date(2016, 08, 25), y: 30} ,
    { x: new Date(2016, 9, 2), y: 30} ,
    { x: new Date(2016, 09, 6), y: 30} ,
    { x: new Date(2016, 9, 10), y: 30} ,
    { x: new Date(2016, 09, 18), y: 30} ,
    { x: new Date(2016, 09, 22), y: 30} ,
    { x: new Date(2016, 10, 4), y: 30} ,
    { x: new Date(2016, 10, 12), y: 30} ,
    { x: new Date(2016, 10, 20), y: 30} ,
    { x: new Date(2016, 10, 24), y: 30} ,
    ]
    }

    ]
    });

    chart.render();
    }
    </script>
    <script type=”text/javascript” src=”/assets/script/canvasjs.min.js”></script>
    </head>
    <body>
    <div id=”chartContainer” style=”height: 300px; width: 100%;”>
    </div>
    </body>
    </html>

    #13519

    Bivek Singh
    Moderator

    cntigercn,

    In JavaScript, Months are indexed from 0 to 11. Please refer this post.

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

You must be logged in to reply to this topic.