在Javascript中刷新/重新加载Flot

嘿伙计们,有谁知道如何在javascript中重新加载flot图? 例如,我想在每次更改输入值时重绘图形。 我尝试了一些在flot API中找到的方法,比如draw()setupGrid(),没有任何运气。

这是一些示例代码:

$("#some_input_box").change(function(){ plot.draw(); // redraw graph }); 

你在drawsetupGrid的正确轨道上,这是你需要做的:

 var plot = $.plot($('#placeholder'),data,options); //time passes, you now want to replot var newData = [[0,2],[1,3],[2,5]]; plot.setData(newData); plot.setupGrid(); //only necessary if your new data will change the axes or grid plot.draw(); 

或者,重新调用$.plot也不会太糟糕。 以上方式更有效,但……