Home Forums Chart Support Push data to chart

Push data to chart

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

    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

    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.