Friday, May 23, 2014

How to update dynamically jqplot

How to update a jqplot dynamically
Call js function redrawPlot with the new data as a parameter to update chart. Example
redrawPlot([13,17,19,11,14,16,18,12,15]);


<script  type="text/javascript">
var plot;

function createPlot(series){
        plot = $.jqplot('chartdiv', [series]);
}

 function redrawPlot(series){
        if(plot){
            createPlot(series);
            plot.replot();
        }

    }

Let's assume we have jqplot created like this
$(document).ready(function(){
  plot = $.jqplot ('chart1', [[3,7,9,1,4,6,8,2,5]]);
});
</script>


No comments:

Post a Comment