嘿伙计们,有谁知道如何在javascript中重新加载flot图?例如,我想在每次更改输入值时重绘图形.我尝试了一些在flot API中找到的方法,比如draw()和setupGrid(),没有任何运气.
这是一些示例代码:
$("#some_input_box").change(function(){
plot.draw(); // redraw graph
});
Run Code Online (Sandbox Code Playgroud)
Ryl*_*ley 30
你是在正确的轨道上draw,并setupGrid,这里就是你需要做的:
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();
Run Code Online (Sandbox Code Playgroud)
或者,重新打电话也不会太糟糕$.plot.以上方式更有效,但......