Skip to content Skip to sidebar Skip to footer

Updating Flot Data And Axis

I have created a highly interactive graph. all of the interactions have been achieved without re-initiating the flot object. re-initiating the flot object causes the interactions t

Solution 1:

The method you are missing is the setupGrid. This will recreate the axises without re-initing the plot.

In general my workflow for modfiying an existing plot is something like this:

var series = plot.getData(); // reference to your series
series[0].data = someNewArray;
series[0].color = 'blue'; // modify existing series
series.push({data: [[0, 5], [1, 1], [2, 7]], color: 'green'}); // add a new one
plot.setData(series); // you need to set the data so that flot will re-process any newly added seriesvar opts = plot.getOptions() // get a reference to the options
opts.xaxes[0].min = -1; // adjust an axis min, use the xaxes property NOT the xaxis// there is no need to "setOptions"...
plot.setupGrid() // if you need to redraw the axis/grid
plot.draw()

Post a Comment for "Updating Flot Data And Axis"