用Java刷新/重新加载Flot [英] Refresh/Reload Flot In Javascript

查看:81
本文介绍了用Java刷新/重新加载Flot的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,有人知道如何在javascript中重新加载浮动图吗?例如,我想在每次输入值更改时重画图形.我尝试尝试在 flot API 中找到的一些方法,例如 draw() setupGrid(),没有任何运气.

Hey Guys, does anyone know how to reload a flot graph in javascript? For instance, I want to redraw the graph every time an input value is changed. I tried experimenting with a few methods found in the flot API, such as draw() and setupGrid() without any luck.

下面是一些示例代码:

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

推荐答案

您在使用drawsetupGrid的正确轨道上,这是您需要做的:

You are on the right track with draw and setupGrid, here's what you need to do:

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也不会太糟.上面的方法更有效,但是...

Alternatively, it's not too much worse to just re-call $.plot. The above way is more efficient, but...

这篇关于用Java刷新/重新加载Flot的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆