Home forums Report Bugs DateTime is shown incorrect when year rolls over

This topic contains 2 replies, has 2 voices, and was last updated by  Vishwas R 9 months ago.

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #24011

    I have asked his question on stackoverflow with graphs. Basically I am plotting data from Dec 12, 2018 to Jan 11, 2019. It looks in the following format

    dataPoints.push({ x: new Date(2018,12,13,06,09,38), y: 384 });
    dataPoints.push({ x: new Date(2018,12,13,06,12,46), y: 386 });
    dataPoints.push({ x: new Date(2018,12,13,06,15,53), y: 379 });
    dataPoints.push({ x: new Date(2018,12,13,06,19,02), y: 377 });
    ….
    ….
    dataPoints.push({ x: new Date(2019,01,11,17,11,12), y: 632 });
    dataPoints.push({ x: new Date(2019,01,11,17,13,35), y: 616 });
    dataPoints.push({ x: new Date(2019,01,11,17,15,49), y: 614 });

    As you can see, dates on y-axis are completely wrong (off by a month).
    Canvas.JS datetime plotted inccorect

    Is this a bug. What am I doing wrong

    var options = {
    zoomEnabled: true,
    animationEnabled: true,
    title: {
    text: selectedText
    },
    axisX:{
    title: “Timeline”,
    gridThickness: 1

    },
    axisY: {
    title: “KVA”,
    includeZero: false,
    lineThickness: 1
    },
    data: [{
    type: “column”,
    dataPoints:dataPoints
    }] // random data
    };

    #24012

    My mistake, I had to subtract 1 from month, which I didn’t. Now fixed.

    #24021

    @hammad1001,

    Glad you figured it out :)


    Vishwas R
    Team CanvasJS

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

You must be logged in to reply to this topic.