Home forums Using CanvasJS Pushing a datapoint in front

This topic contains 5 replies, has 2 voices, and was last updated by  darkri 4 months, 2 weeks ago.

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #11457

    darkri
    Member

    Hello and thank you for this wonderful tool.

    I am trying to add a datapoint on the go to the graph and using chart.options.data[0].dataPoints.push({ y: 25 - Math.random() * 10}); works fine when we are adding a new point to the end of the graph.

    However should I wish to add a a new point at the beginning of the graph (on x-axis) using the unshift method instead of push the y axis gets draw accordingly but the x axis stays the same and doesn’t take the gap like pushing does.

    Any help wpuld be great.

    #11459

    Sanjoy
    Moderator

    Hi,

    In this case you have to assign x value also or you need to increase auto assigned x value for each dataPoints. Please check this example.

    #11467

    darkri
    Member

    Brilliant thank you

    #11611

    darkri
    Member

    Hello again,

    I have noticed that when assigning a negative value to x I am getting unwanted values on the x axis (on certain graph widths) however this isn’t the issues with positive number assigned to x values.

    This link is a forked version of yours with two graphs, one for negative x values and one for positive x values:
    http://jsfiddle.net/Kustuldi/cfbhkz8z/

    Any help would be great,
    Regards Chris

    #11613

    Sanjoy
    Moderator

    Thanks, for reporting the issue. It’s a bug, and we have just fixed the same. Here is an internal build for you.

    #11615

    darkri
    Member

    Fixed it thank you

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

You must be logged in to reply to this topic.