Home forums Using CanvasJS Push data to chart

This topic contains 1 reply, has 2 voices, and was last updated by  Sunil Urs 3 years, 5 months ago.

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

    JohnDoe117
    Participant

    Hi, I’m trying to use CanvasJS to create a chart, and want to inject the data into it from a piece of Java code. I want to be able to push the data from a POJO set as an attribute of the HttpRequest, or something similar. What’s the best way to do that?

    I’ve seen that I can use

    
    var dps = [];
    dps.push(x:0, y:other[0]});
    

    but that only adds one point at a time, I want to set the entire series in a single assignment.

    #4770

    Sunil Urs
    Keymaster

    You can an assign an entire array as below – like any other JavaScript array.

    var dps = [{x:0, y:3}, {x:1, y:5}, {x:2, y:4}]

    The required array can be created within a for loop on the client side or on the server side by directly outputting the values into the HTML page.

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

You must be logged in to reply to this topic.