I have a float graph that is already rendering one data series, i.e.
var plot = $.plot($('#placeholder'), [data1], options);
At a later point, I will receive some new data that I want to also plot on this same graph, as a separate data series. Is there a way I can just add this new data series to the existing graph, and not have to construct the whole graph again? That is, I want to avoid having to make another call like this:
var plot = $.plot($('#placeholder'), [data1, data2], options);
and instead make a call like this:
plot.addSeries([data2], option);
Thanks!
@Black Box Operations has the general details quite well. There's some problems before the latest version (0.7) with memory leaks when you repeatedly call
$.plot(...)
. Either upgrade to the latest version, or look into doingplot.setData()
,plot.setupGrid()
andplot.draw()
You can get the details of the setData, setupGrid, and draw methods from the API.txt
Create an ajax call that pulls your information and sends it to a method capable of handling multiple graphs by resetting the graph's information. First, grab the element that holds your graph and store it in a variable, then create an ajax call that pulls the information you need to create your graph. On success, call resetGraph and pass it the information.
Now when you need to change your graph, simply fire off a call to your script, grab the information, send it to resetGraph on success, and it will update accordingly.