0

Here I am trying to display my PieChart.

After I put the below code

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

        // Create a pie chart visualization.
        PieChart pie = new PieChart(createTable(), createOptions());

        pie.addSelectHandler(createSelectHandler(pie));
        panel.add(pie);
      }
    };

    // Load the visualization api, passing the onLoadCallback to be called
    // when loading is done.
    VisualizationUtils.loadVisualizationApi(onLoadCallback, PieChart.PACKAGE);
  }

As GWT omits Runnable (? as a single thread javascript model),It never coming inside the run method (I really banging my head why they gave that sample code).

After Having some clues here, I wrote

<script type="text/javascript">
        google.load("visualization", "1", {'packages' : ["corechart"] });
</script>

After adding this,NOt even a single line change in the stackTrace.And after my whole night gone,I remained with the following stackTrace.

com.google.gwt.core.client.JavaScriptException: (TypeError): $wnd.google.visualization is undefined
    at com.google.gwt.dev.shell.BrowserChannelServer.invokeJavascript(BrowserChannelServer.java:248)
    at com.google.gwt.dev.shell.ModuleSpaceOOPHM.doInvoke(ModuleSpaceOOPHM.java:136)
    at com.google.gwt.dev.shell.ModuleSpace.invokeNative(ModuleSpace.java:561)
    at com.google.gwt.dev.shell.ModuleSpace.invokeNativeObject(ModuleSpace.java:269)

After seeing the error i found some solution which provoke me to add script tag in my host page $wnd.google.visualization is undefined

Even no luck.

Am i missing something ??

Any clues on this ??

P.S I added charts,visualization jars and inherited in my gwt.xml file

Community
  • 1
  • 1
Suresh Atta
  • 120,458
  • 37
  • 198
  • 307

1 Answers1

4

add the following snippet to html document:

 <script type="text/javascript" src="http://www.google.com/jsapi"></script>
 <script type="text/javascript">
    google.load("visualization", "1", {'packages' : ["corechart"] });
 </script>
Dipak
  • 6,532
  • 8
  • 63
  • 87