Search code examples
dojodojox.charting

Dojox datachart live update?


As per the title, I'm really wondering how do I do live updates in datachart ?? As this site is old SitePen datachart, they were still on Dojo 1.3 with Persevere 1.0, where now Dojo had gone to 1.6 and Persevere 2.0. Google shows 1.6 ady has new Data Api. I'm really confused about what to do now. How can I make a successful live update on my chart without really refreshing it... Somebody please help me > <


Solution

  • http://dojotoolkit.org/documentation/tutorials/1.6/charting/ : This tutorial does a good job explaining the basics of DOJO charting.

    Presuming you have a basic chart created:

    var chart1 = new dojox.charting.Chart2D("chart");
    chart1.addPlot("default", {type: "Lines"}); chart1.addAxis("x"); chart1.addAxis("y", {vertical: true}); chart1.addSeries("Series 1", [1,2,3,4,5]); chart1.render();

    To update this chart with new data you just need to update the data series and then render the chart again:

    chart1.updateSeries("Series 1", [5,4,3,2,1]);
    chart1.render();

    Each time you do this the chart will be updated to reflect the new data series. If you have a legend that needs to up updated, it will need to be refreshed separately (using legend.refresh())