2014-02-21 21 views
0

我正在建設一個應用程序,顯示半實時數據(刷新每分鐘)使用谷歌可視化工具gwt。因爲我是很新的GWT我按照本指南:GWT - 谷歌vizualization工具 - 安排圖表刷新

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); 
} 

,我並不清楚如何調用Draw()函數AnnotatedTimeLine(https://developers.google.com/chart/interactive/docs/gallery/annotatedtimeline)在我的調度程序中,以便重繪本身,而不重新加載整個頁面。

回答

0

爲什麼不在方法之外聲明AnnotatedTimeLine graph(作爲類的字段),以便可以從外部訪問它(在Timer.run()方法中)?