2012-09-22 103 views
1

我使用從GChartgchart沒有出現

 public void displayGChart(final ArrayList<ResultDTO> result){ 

     GChart c = new GChart(); 
     c.setChartTitle("<b>x<sup>2</sup> vs x</b>"); 
     c. setChartSize(150, 150); 
     c. addCurve(); 
     for (int i = 0; i < 10; i++) 
      c. getCurve().addPoint(i,i*i); 
     c.getCurve().setLegendLabel("x<sup>2</sup>"); 
     c. getXAxis().setAxisLabel("x"); 
     c. getYAxis().setAxisLabel("x<sup>2</sup>"); 


    verticalPanel.add(c); 
    verticalPanel.add(new Label("test")); 
} 
當我運行的應用程序

這個簡單的例子,我沒有錯誤,我可以看到我的瀏覽器,但沒有別的這種「測試」,沒有圖表出現..

我添加了罐子,

  <inherits name='com.googlecode.gchart.GChart' /> 

任何想法可能是什麼原因

回答

2

請致電c.update();

verticalPanel.add(c); 
    c.update(); 
    verticalPanel.add(new Label("test")); 

這也說明如下::http://clientsidegchart.googlecode.com/svn/trunk/javadoc/com/googlecode/gchart/client/package-summary.html

沒有圖表添加圖表到面板上,這樣後?這些例子只定義了圖表。要實際顯示它,您必須添加並更新它:

// Use this typical GChart boilerplate to test out these examples: 
    GChart gchart = new GChartExample00(); 
    RootPanel.get().add(gchart); 
    gchart.update();