store.add(TestData.getTeamSales());
// chart
String url = !Examples.isExplorer() ? "../../" : "";
url += "gxt/chart/open-flash-chart.swf";
final Chart chart = new Chart(url);
ChartListener listener = new ChartListener() {
public void chartClick(ChartEvent ce) {
int row = ce.getChartConfig().getValues().indexOf(ce.getDataType());
int col = ce.getChartModel().getChartConfigs().indexOf(ce.getChartConfig()) + 1;
CellSelectionModel<TeamSales> csm = (CellSelectionModel<TeamSales>) teamSalesGrid.getSelectionModel();
if (selRadio.getValue()) {
csm.selectCell(row, col);
} else {
teamSalesGrid.startEditing(row, col);
}
}
};
ChartModel model = new ChartModel("Team Sales by Month",
"font-size: 14px; font-family: Verdana; text-align: center;");
model.setBackgroundColour("#fefefe");
model.setLegend(new Legend(Position.TOP, true));
model.setScaleProvider(ScaleProvider.ROUNDED_NEAREST_SCALE_PROVIDER);
BarChart bar = new BarChart(BarStyle.GLASS);
bar.setColour("#00aa00");
BarDataProvider barProvider = new BarDataProvider("alphasales", "month");
barProvider.bind(store);
bar.setDataProvider(barProvider);
bar.addChartListener(listener);
model.addChartConfig(bar);
bar = new BarChart(BarStyle.GLASS);
bar.setColour("#0000cc");
barProvider = new BarDataProvider("betasales");
barProvider.bind(store);
bar.setDataProvider(barProvider);
bar.addChartListener(listener);
model.addChartConfig(bar);
bar = new BarChart(BarStyle.GLASS);
bar.setColour("#ff6600");
barProvider = new BarDataProvider("gammasales");
barProvider.bind(store);
bar.setDataProvider(barProvider);
bar.addChartListener(listener);
model.addChartConfig(bar);
LineChart line = new LineChart();
line.setAnimateOnShow(true);
line.setText("Average");
line.setColour("#FF0000");
LineDataProvider lineProvider = new LineDataProvider("avgsales");
lineProvider.bind(store);
line.setDataProvider(lineProvider);
model.addChartConfig(line);
chart.setChartModel(model);
// grid
NumberPropertyEditor npe = new NumberPropertyEditor(Integer.class);
ArrayList<ColumnConfig> cols = new ArrayList<ColumnConfig>();