我正在使用gwt中的Google可视化工具构建一个显示半实时数据(每分钟刷新一次)的应用程序。由于我对GWT很新,所以我遵循了这个指南:
http://code.google.com/p/gwt-google-apis/wiki/VisualizationGettingStarted
我现在得到了这个代码:
public void onModuleLoad() {
// Create a callback to be called when the visualization API has been loaded.
Runnable onLoadCallback = new Runnable() {
public void run() {
Panel panel = RootPanel.get("graph_box");
// Create a chart visualization.
AnnotatedTimeLine graph = new AnnotatedTimeLine(createTable(), createOptions(), "1000px", "500px");
graph.addStyleName("timeLine");
panel.add(graph);
}
};
// Load the visualization api, passing the onLoadCallback to be called when loading is done.
VisualizationUtils.loadVisualizationApi(onLoadCallback, AnnotatedTimeLine.PACKAGE);
Timer timeoutTimer = new Timer() {
public void run() {
Window.alert("Reloaded chart.");
}
};
timeoutTimer.scheduleRepeating(1000 * 3);
}
我不清楚如何在我的调度程序中调用AnnotatedTimeLine(https://developers.google.com/chart/interactive/docs/gallery/annotatedtimeline)的draw()函数,以便重绘自己,而无需重新加载整个页面。
答案 0 :(得分:0)
为什么不在方法之外声明AnnotatedTimeLine graph
(作为类的一个字段),以便可以从外部访问它(在Timer.run()方法中)?