Home Forums Chart Support Push function not working properly – please help

Push function not working properly – please help

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

    Dear,

    When I use the push function
    dps.push({x: 0, y: 64.44});
    dps.push({x: 5, y: 64.44});
    it’s drawing properly the graph with dataPoints=dps

    When I try to insert the same values from JSON string
    dps.push({x: 5, y: obj[0].Avg005});
    dps.push({x: 10, y: obj[0].Avg010);
    the graph is not drawing:

    My json string in data
    [{“Avg000″:”0″,”Avg005″:”64.44″,”Avg010″:”64.44″,”Avg015″:”43.22″,”Avg020″:”45.91″,”Avg025″:”41.82″,”Avg030″:”0”}]
    and part of the code:
    var obj=jQuery.parseJSON(data);
    console.log(obj[0].Avg005); (shows 64.44 in the console)
    //value = parseFloat(obj[0].Avg005).toFixed(2); (I tried to force it to be decimal but it did not work either)
    // dps.push({x: 5, y: value); (I tried to force it to be decimal but it did not work either)
    dps.push({x: 5, y: obj[0]Avg005 });
    dps.push({x: 10, y: obj[0]Avg010 });

    #26513

    @paul_canvas,

    and part of the code:
    var obj=jQuery.parseJSON(data);
    console.log(obj[0].Avg005); (shows 64.44 in the console)
    //value = parseFloat(obj[0].Avg005).toFixed(2); (I tried to force it to be decimal but it did not work either)
    // dps.push({x: 5, y: value); (I tried to force it to be decimal but it did not work either)
    dps.push({x: 5, y: obj[0]Avg005 });
    dps.push({x: 10, y: obj[0]Avg010 });

    It seems like you are not parsing y-value properly. Parsing it properly as dps.push({x: 5, y: parseFloat(obj[0].Avg005) }); should work fine in this case.

    If you are still facing the issue, kindly create JSFiddle reproducing the issue you are facing so that we can look into the code, understand the scenario better and help you resolve the same?

    In order to help us in understanding the issue, please have a reproducible demo of your chart. This one step can assure you a speedy response. Fork out our template JSFiddle and reproduce the chart at your end. Try to keep it to the bare minimum by removing unnecessary code.

    From what we have observed, sometimes things get delayed mostly when we are not able to reproduce the issue or not able to understand the exact requirements or the solution that we provide may not work properly due to the variation in chart-options being used by you and us.

    Having a JSFiddle helps us in figuring out the issue and many a times we can just edit your code on JSFiddle to fix the issue right-away.


    Vishwas R
    Team CanvasJS

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

You must be logged in to reply to this topic.