Using Google Visualization in GWT 2.0

Posted by nick on Stack Overflow See other posts from Stack Overflow or by nick
Published on 2010-04-29T20:43:07Z Indexed on 2010/04/29 20:47 UTC
Read the original article Hit count: 485

Filed under:
|

I'm working on learning GWT (total newb) and have a question regarding the Visualiztion API provided by Google. This page: http://code.google.com/p/gwt-google-apis/wiki/VisualizationGettingStarted

Describes getting started with a pie chart (which is what I need). However I'm trying to do this in a composite UI using UiBinder. To that end I don't know how to handle the callback correctly that is shown:

public class SimpleViz implements EntryPoint {
  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);
  }

My First assumption is this would go in the UiBinder constructor, correct? Yet this assumes that I want to place the element in the RootLayoutPanel, and I don't. I can't see an elegant and obvious way of placing it in the binder. I submit that even this guess may be wrong. Any ideas from the experts?

© Stack Overflow or respective owner

Related posts about gwt

Related posts about google-visualization