Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
Clear All
new posts

    problem with GWT Visualization Core Chart Package and SmartGWT

    Here is my class:
    Code:
    package com.pp.test.client;
    
    import com.pp.test.shared.FieldVerifier;
    import com.google.gwt.core.client.EntryPoint;
    import com.google.gwt.core.client.GWT;
    import com.google.gwt.event.dom.client.ClickEvent;
    import com.google.gwt.event.dom.client.ClickHandler;
    import com.google.gwt.event.dom.client.KeyCodes;
    import com.google.gwt.event.dom.client.KeyUpEvent;
    import com.google.gwt.event.dom.client.KeyUpHandler;
    import com.google.gwt.user.client.rpc.AsyncCallback;
    import com.google.gwt.user.client.ui.Button;
    import com.google.gwt.user.client.ui.DialogBox;
    import com.google.gwt.user.client.ui.HTML;
    import com.google.gwt.user.client.ui.Label;
    import com.google.gwt.user.client.ui.RootPanel;
    import com.google.gwt.user.client.ui.TextBox;
    import com.google.gwt.user.client.ui.VerticalPanel;
    
    import com.google.gwt.core.client.EntryPoint;
    import com.google.gwt.core.client.JsArray;
    import com.google.gwt.user.client.Window;
    import com.google.gwt.user.client.ui.Panel;
    import com.google.gwt.user.client.ui.RootPanel;
    import com.google.gwt.visualization.client.AbstractDataTable;
    import com.google.gwt.visualization.client.VisualizationUtils;
    import com.google.gwt.visualization.client.DataTable;
    import com.google.gwt.visualization.client.Selection;
    import com.google.gwt.visualization.client.AbstractDataTable.ColumnType;
    import com.google.gwt.visualization.client.events.SelectHandler;
    import com.google.gwt.visualization.client.visualizations.PieChart;
    import com.google.gwt.visualization.client.visualizations.PieChart.Options;
    
    public class Chart 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, "corechart");
      }
    
      private Options createOptions() {
        Options options = Options.create();
        options.setWidth(400);
        options.setHeight(240);
        options.set3D(true);
        options.setTitle("My Daily Activities");
        return options;
      }
    
      private SelectHandler createSelectHandler(final PieChart chart) {
        return new SelectHandler() {
          @Override
          public void onSelect(SelectEvent event) {
            String message = "";
            
            // May be multiple selections.
            JsArray<Selection> selections = chart.getSelections();
    
            for (int i = 0; i < selections.length(); i++) {
              // add a new line for each selection
              message += i == 0 ? "" : "\n";
              
              Selection selection = selections.get(i);
    
              if (selection.isCell()) {
                // isCell() returns true if a cell has been selected.
                
                // getRow() returns the row number of the selected cell.
                int row = selection.getRow();
                // getColumn() returns the column number of the selected cell.
                int column = selection.getColumn();
                message += "cell " + row + ":" + column + " selected";
              } else if (selection.isRow()) {
                // isRow() returns true if an entire row has been selected.
                
                // getRow() returns the row number of the selected row.
                int row = selection.getRow();
                message += "row " + row + " selected";
              } else {
                // unreachable
                message += "Pie chart selections should be either row selections or cell selections.";
                message += "  Other visualizations support column selections as well.";
              }
            }
            
            Window.alert(message);
          }
        };
      }
    
      private AbstractDataTable createTable() {
        DataTable data = DataTable.create();
        data.addColumn(ColumnType.STRING, "Task");
        data.addColumn(ColumnType.NUMBER, "Hours per Day");
        data.addRows(2);
        data.setValue(0, 0, "Work");
        data.setValue(0, 1, 14);
        data.setValue(1, 0, "Sleep");
        data.setValue(1, 1, 10);
        return data;
      }
    }
    The only thing I am changing is weather or not I am loading the SmartGWT library in my xml file:

    Code:
    <?xml version="1.0" encoding="UTF-8"?>
    <module rename-to='chart'>
      <inherits name='com.google.gwt.user.User'/>
      <inherits name='com.google.gwt.user.theme.standard.Standard'/>
      <inherits name='com.google.gwt.visualization.Visualization'/>
    
      <entry-point class='com.pp.test.client.Chart'/>
    
      <source path='client'/>
      <source path='shared'/>
    
    </module>
    If Smart GWT is loaded then the graph does not render.
    Alternatively, if you change VisualizationUtils.loadVisualizationApi(onLoadCallback, "corechart"); to load PieChart.Package, then the chart renders.

    However Google has announced that they are moving everything into core chart.

    I am wondering if there is a workaround.

    Thanks,
    Matt

    #2
    Matt,

    Have you found the solution to address this issue?

    Thanks,
    Kevin

    Comment


      #3
      Yes, use GXT instead.

      Comment


        #4
        Isomorphic,

        Any plan to address this issue?

        -Kevin

        Comment


          #5
          Isomorphic,

          This is important to us. One way or another. Please respond.

          -Kevin
          Last edited by knguyen; 18 Feb 2011, 10:31.

          Comment


            #6
            We have investigated this and found a conflict in the extensions to native JavaScript objects.
            We're currently looking at how best to resolve this.

            Comment


              #7
              These issues should now be resolved - please try the next nightly build and let us know i it still doesn't work for you.

              Comment

              Working...
              X