List of usage examples for com.google.gwt.visualization.client.visualizations ScatterChart ScatterChart
public ScatterChart(AbstractDataTable data, Options options)
From source file:com.google.sampling.experiential.client.ChartOMundo.java
License:Open Source License
private ScatterChart createScatterChart(List<EventDAO> eventList, String chartTitle, String key1, String key2) { String xAxis = key1;//from ww w . j a v a 2 s. c o m String yAxis = key2; DataTable data = DataTable.create(); data.addRows(eventList.size()); data.addColumn(ColumnType.NUMBER, xAxis); data.addColumn(ColumnType.NUMBER, yAxis); int row = 0; // String debugPoints = ""; for (EventDAO event : eventList) { String key1ValStr = event.getWhatByKey(key1); String key2ValStr = event.getWhatByKey(key2); // debugPoints += key1ValStr + "," + key2ValStr +"<br/>"; if (key1ValStr == null || key2ValStr == null) { continue; } Class key1ValueClass = getDataTypeOf(key1ValStr); Class key2ValueClass = getDataTypeOf(key2ValStr); if (key1ValueClass.equals(Double.class)) { data.setValue(row, 0, Double.valueOf(key1ValStr)); } else { data.setValue(row, 0, Long.valueOf(key1ValStr)); } if (key2ValueClass.equals(Double.class)) { data.setValue(row, 1, Double.valueOf(key2ValStr)); } else { data.setValue(row, 1, Long.valueOf(key2ValStr)); } row++; } // Window.alert("Points:<br/>" + debugPoints); ScatterChart scatterChart = new ScatterChart(data, createScatterChartOptions(chartTitle, xAxis, yAxis, "#000033", 0, 0)); return scatterChart; }
From source file:com.rhizospherejs.gwt.showcase.client.gviz.GoogleVisualizationTab.java
License:Open Source License
private GoogleVisualizationTab() { initWidget(ui.createAndBindUi(this)); dobInput.setValue(new Date()); dobInput.setFormat(new DateBox.DefaultFormat(DateTimeFormat.getFormat(PredefinedFormat.DATE_SHORT))); // Ensures that both the Google Visualization APIs and Rhizosphere libraries // are loaded. VisualizationUtils.loadVisualizationApi(new Runnable() { @Override/* ww w . j ava 2s .co m*/ public void run() { RhizosphereLoader.getInstance().ensureInjected(new Runnable() { @Override public void run() { // Populate the DataTable with some sample data. initDataTable(); // Setup configuration options for both Rhizosphere and the // scatterplot. initOptions(); DataView view = DataView.create(dataTable); view.setColumns(new int[] { 1, 2 }); scatterChart = new ScatterChart(view, scatterChartOptions); chartContainer.clear(); chartContainer.add(scatterChart); rhizosphere = new GVizRhizosphere(dataTable, rhizosphereOptions); rhizosphere.setWidth("400px"); rhizosphere.setHeight("400px"); rhizosphereContainer.clear(); rhizosphereContainer.add(rhizosphere); } }); } }, "corechart"); }