Announcement

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

    #16
    Ehy, maybe you already know, but the error occurs just in java mode.
    So, if you do something like that:

    Code:
    if (GWT.isScript()){
       yourSmartGWTLayout.addMember(getYourGoogleVisualizationComponent());
    }
    when you run the compiled js, you should see the chart correctly..

    Comment


      #17
      Hello,

      I am using smartgwt 2.5 downloaded from the nightlies on the 1st June.
      Google Visualization 1.2-rc2

      I have the chart showing correctly in a smartgwt component using the following code

      Code:
      import com.google.gwt.visualization.client.AbstractDataTable;
      import com.google.gwt.visualization.client.AbstractDataTable.ColumnType;
      import com.google.gwt.visualization.client.DataTable;
      import com.google.gwt.visualization.client.VisualizationUtils;
      import com.google.gwt.visualization.client.visualizations.corechart.LineChart;
      import com.google.gwt.visualization.client.visualizations.corechart.Options;
      import com.smartgwt.client.widgets.Canvas;
      
      /**
       *
       * @author jeni
       */
      public class TestPanel extends Canvas {
      
          private Canvas content = new Canvas();
      
          public TestPanel() {
              content.setWidth(800);
              content.setHeight(800);
      
              Runnable onLoadCallback = new Runnable() {
      
                  public void run() {
      
                      // Create a pie chart visualization.
                      LineChart line = new LineChart(createTable(), createOptions());
      
                      line.setHeight("500px");
                      line.setWidth("500px");
                      content.addChild(line);
                  }
              };
      
              // Load the visualization api, passing the onLoadCallback to be called
              // when loading is done.
              VisualizationUtils.loadVisualizationApi(onLoadCallback, LineChart.PACKAGE);
              addChild(content);
          }
      
          private Options createOptions() {
              Options options = Options.create();
              options.setWidth(400);
              options.setHeight(240);
              options.setTitle("My Daily Activities");
              return options;
          }
      
          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;
          }
      }
      I was a little confused for a while by only a portion of the chart appearing but setting the size on the actual LineChart object fixed this.

      Hope this is helpful.

      Regards
      Jeni

      Comment

      Working...
      X