List of usage examples for com.google.gwt.visualization.client.visualizations LineChart LineChart
public LineChart(AbstractDataTable data, Options options)
From source file:com.google.sampling.experiential.client.ChartOMundo.java
License:Open Source License
static LineChart createLineChart(List<EventDAO> eventList, String chartTitle, String changingParameterKey) { String yAxis = changingParameterKey; String xAxis = "Date"; List<DateStat> statsByDate = DateStat.calculateParameterDailyStats(changingParameterKey, eventList); DataTable data = DataTable.create(); data.addRows(statsByDate.size());/*w w w . j av a2 s . co m*/ data.addColumn(ColumnType.DATE, xAxis); // data.addColumn(ColumnType.NUMBER, "min"); // data.addColumn(ColumnType.NUMBER, "med"); data.addColumn(ColumnType.NUMBER, "value"); data.addColumn(ColumnType.NUMBER, "trend"); // data.addColumn(ColumnType.NUMBER, "max"); Double min = null; Double max = null; Double trend = null; int row = 0; for (DateStat stat : statsByDate) { Date date = stat.getWhen(); Double dataValue = stat.getAverage(); // List<Double> values = stat.getValues(); // for (Double dataValue : values) { if (min == null || stat.getMin() < min) { min = stat.getMin(); } if (max == null || stat.getMax() > max) { max = stat.getMax(); } if (row == 1) { trend = dataValue; } else if (row > 1) { trend = recomputeTrend(trend, dataValue); } data.setValue(row, 0, date); // data.setValue(row, 1, stat.getMin()); // data.setValue(row, 2, stat.getMed()); data.setValue(row, 1, dataValue); if (trend != null) { data.setValue(row, 2, trend); } row++; // } } if (min == null) { min = 0.0; } if (max == null) { max = 0.0; } LineChart lineChart = new LineChart(data, createLineChartOptions(chartTitle, xAxis, yAxis, "#000033", min, max)); return lineChart; }
From source file:com.google.sampling.experiential.client.StatsPanel.java
License:Open Source License
static LineChart createLineChart(DateStat[] dateStats, String chartTitle, String changingParameterKey) { String yAxis = changingParameterKey; String xAxis = "Date"; DataTable data = DataTable.create(); data.addRows(dateStats.length);//from w w w .j av a 2 s.co m data.addColumn(ColumnType.DATE, xAxis); // data.addColumn(ColumnType.NUMBER, "min"); // data.addColumn(ColumnType.NUMBER, "med"); data.addColumn(ColumnType.NUMBER, "value"); // data.addColumn(ColumnType.NUMBER, "trend"); // data.addColumn(ColumnType.NUMBER, "max"); // List<DateStat> statsByDate = // DateStat.calculateParameterDailyStats(changingParameterKey, eventList); Double min = null; Double max = null; Double trend = null; int row = 0; for (DateStat stat : dateStats) { Date date = stat.getWhen(); // Double paramAvg = stat.getAverage(); List<Double> values = stat.getValues(); for (Double dataValue : values) { if (min == null || stat.getMin() < min) { min = stat.getMin(); } if (max == null || stat.getMax() > max) { max = stat.getMax(); } if (row == 1) { trend = dataValue; } else if (row > 1) { // trend = recomputeTrend(trend, dataValue); } data.setValue(row, 0, date); // data.setValue(row, 1, stat.getMin()); // data.setValue(row, 2, stat.getMed()); data.setValue(row, 1, dataValue); // if (trend != null) { // data.setValue(row, 2, trend); // } row++; } } if (min == null) { min = 0.0; } if (max == null) { max = 0.0; } LineChart lineChart = new LineChart(data, createLineChartOptions(chartTitle, xAxis, yAxis, "#000033", min, max)); return lineChart; }
From source file:edu.cudenver.bios.glimmpse.client.panels.LearCovariancePanel.java
License:Open Source License
public LearCovariancePanel() { VerticalPanel panel = new VerticalPanel(); chart = new LineChart(createTable(), createOptions()); final ListBox list = new ListBox(); for (int j = 0; j <= 10; j++) { list.addItem(Integer.toString(j)); }//from ww w.j av a 2 s. c o m list.addChangeHandler(new ChangeHandler() { public void onChange(ChangeEvent e) { ListBox lb = (ListBox) e.getSource(); data.setValue(0, 1, Integer.parseInt(lb.getItemText(lb.getSelectedIndex()))); chart.draw(data, options); } }); // add callbacks to adjust the decay rate rhoTextBox.addChangeHandler(this); deltaListBox.addChangeHandler(this); for (int i = 0; i <= 10; i++) deltaListBox.addItem(Integer.toString(i)); // layout the parameter inputs Grid grid = new Grid(2, 2); grid.setWidget(0, 0, new HTML("Correlation: ")); grid.setWidget(0, 1, rhoTextBox); grid.setWidget(1, 0, new HTML("Delta: ")); grid.setWidget(1, 1, deltaListBox); // layout panel panel.add(chart); panel.add(grid); initWidget(panel); }
From source file:n3phele.client.view.AccountHyperlinkView.java
License:Open Source License
public void onModuleLoad() { Runnable onLoadCallback = new Runnable() { public void run() { chartPanel = get();/*ww w .ja va 2s. c o m*/ setChartTableData(); if (historyTable.isCellPresent(2, 0)) historyTable.clearCell(2, 0); historyTable.setWidget(2, 0, chart); historyTable.setWidget(2, 0, new LineChart(createTable(), createOptions(chartTitle))); historyTable.getCellFormatter().setHorizontalAlignment(2, 0, HasHorizontalAlignment.ALIGN_CENTER); vsTable.setWidget(1, 0, dataGrid); vsTable.getCellFormatter().setHorizontalAlignment(1, 0, HasHorizontalAlignment.ALIGN_CENTER); } }; VisualizationUtils.loadVisualizationApi(onLoadCallback, LineChart.PACKAGE); }
From source file:n3phele.client.view.AccountHyperlinkView.java
License:Open Source License
private void setChartTableData() { ChangeHandler dropBoxEvent = new ChangeHandler() { public void onChange(ChangeEvent event) { if (options.isItemSelected(0)) { costOption = "normal"; if (historyTable.isCellPresent(2, 0)) historyTable.clearCell(2, 0); chart = new LineChart(createTable(), createOptions(chartTitle)); historyTable.setWidget(2, 0, chart); } else { costOption = "cumulative"; if (historyTable.isCellPresent(2, 0)) historyTable.clearCell(2, 0); chart = new LineChart(createTable(), createOptions(chartTitle)); historyTable.setWidget(2, 0, chart); }// w w w . j a v a 2 s .co m } }; vsTable.getColumnFormatter().setWidth(0, chartPanel.getOffsetWidth() + "px"); historyTable.getColumnFormatter().setWidth(0, chartPanel.getOffsetWidth() + "px"); HorizontalPanel chartOptionsTable = new HorizontalPanel(); if (options.getItemCount() < 2) { options.insertItem("Cost", 0); options.insertItem("Cumulative Cost", 1); } options.setWidth("126px"); options.addChangeHandler(dropBoxEvent); chartOptionsTable.add(options); chartOptionsTable.setCellWidth(options, "160px"); hours = new Button("24 hours", new ClickHandler() { public void onClick(ClickEvent event) { requestChartData("24hours"); chartTitle = "24 Hours Costs Chart"; if (historyTable.isCellPresent(2, 0)) historyTable.clearCell(2, 0); chart = new LineChart(createTable(), createOptions(chartTitle)); historyTable.setWidget(2, 0, chart); } }); hours.setWidth("70px"); chartOptionsTable.add(hours); days = new Button("7 days", new ClickHandler() { public void onClick(ClickEvent event) { // getProcessByDay(7); requestChartData("7days"); chartTitle = "7 Days Costs Chart"; if (historyTable.isCellPresent(2, 0)) historyTable.clearCell(2, 0); chart = new LineChart(createTable(), createOptions(chartTitle)); historyTable.setWidget(2, 0, chart); } }); days.setWidth("70px"); chartOptionsTable.add(days); month = new Button("30 days", new ClickHandler() { public void onClick(ClickEvent event) { // getProcessByDay(30); requestChartData("30days"); chartTitle = "30 Days Costs Chart"; if (historyTable.isCellPresent(2, 0)) historyTable.clearCell(2, 0); chart = new LineChart(createTable(), createOptions(chartTitle)); historyTable.setWidget(2, 0, chart); } }); month.setWidth("70px"); chartOptionsTable.add(month); historyTable.setWidget(1, 0, chartOptionsTable); historyTable.getCellFormatter().setHorizontalAlignment(1, 0, HasHorizontalAlignment.ALIGN_CENTER); if (historyTable.isCellPresent(2, 0)) historyTable.clearCell(2, 0); historyTable.setWidget(2, 0, chart); historyTable.getCellFormatter().setHorizontalAlignment(2, 0, HasHorizontalAlignment.ALIGN_CENTER); vsTable.setWidget(1, 0, dataGrid); vsTable.getCellFormatter().setHorizontalAlignment(1, 0, HasHorizontalAlignment.ALIGN_CENTER); }
From source file:n3phele.client.view.AccountHyperlinkView.java
License:Open Source License
public void updateChartTable() { Options options = null;// ww w . j a v a2s . c o m setChartTableData(); if (chartValues == null) return; switch (chartValues.size()) { case 24: chartTitle = "24 Hours Costs Chart"; options = createOptions("24 Hours Costs Chart"); break; case 30: chartTitle = "30 Days Costs Chart"; options = createOptions("30 Days Costs Chart"); break; case 7: chartTitle = "7 Days Costs Chart"; options = createOptions("7 Days Costs Chart"); break; } if (historyTable.isCellPresent(2, 0)) historyTable.clearCell(2, 0); chart = new LineChart(createTable(), createOptions(chartTitle)); historyTable.setWidget(2, 0, chart); AbstractDataTable data = createTable(); chart.draw(data, options); }
From source file:n3phele.client.view.AccountHyperlinkView.java
License:Open Source License
public void refreshChart() { if (chart == null || historyTable == null) return;//from w ww .j av a 2 s.c om requestChartData("24hours"); if (chartValues == null) return; if (historyTable.isCellPresent(2, 0)) historyTable.clearCell(2, 0); chart = new LineChart(createTable(), createOptions(chartTitle)); historyTable.setWidget(2, 0, chart); }
From source file:org.ebayopensource.turmeric.monitoring.client.view.graph.LineChartGraphRenderer.java
License:Open Source License
@Override public Visualization<? extends AbstractDrawOptions> createVisualization() { return new LineChart(createDataTable(), (Options) createOptions()); }