use of com.vaadin.addon.charts.model.ListSeries in project charts by vaadin.
the class ToggledSeriesVisibility method getChart.
@Override
protected Component getChart() {
chart = new Chart(ChartType.COLUMN);
Configuration conf = chart.getConfiguration();
conf.setTitle("Monthly Average Rainfall");
conf.setSubTitle("Source: WorldClimate.com");
XAxis x = new XAxis();
x.setCategories("Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec");
conf.addxAxis(x);
YAxis y = new YAxis();
y.setMin(0);
y.setTitle("Rainfall (mm)");
conf.addyAxis(y);
Legend legend = new Legend();
legend.setLayout(LayoutDirection.VERTICAL);
legend.setBackgroundColor(new SolidColor("#FFFFFF"));
legend.setAlign(HorizontalAlign.LEFT);
legend.setVerticalAlign(VerticalAlign.TOP);
legend.setX(100);
legend.setY(70);
legend.setFloating(true);
legend.setShadow(true);
conf.setLegend(legend);
Tooltip tooltip = new Tooltip();
tooltip.setFormatter("this.x +': '+ this.y +' mm'");
conf.setTooltip(tooltip);
PlotOptionsColumn plot = new PlotOptionsColumn();
plot.setPointPadding(0.2);
plot.setBorderWidth(0);
conf.addSeries(tokyo);
conf.addSeries(newYork);
conf.addSeries(berlin);
conf.addSeries(london);
chart.addLegendItemClickListener(new LegendItemClickListener() {
@Override
public void onClick(LegendItemClickEvent event) {
/*
* Visibility of the series is also toggled from legend clicks
* by default. Still developers might wish to override this
* behavior if the visibility is also controlled by other
* components like here or if e.g. multiple charts are bound
* together (hiding series in one chart should hide related data
* in other chart as well).
*/
ListSeries series = (ListSeries) event.getSeries();
/*
* Toggle checked in option group. As a side effect (via value
* change listener, see setup method) the visibility will change
* in the chart as well.
*/
if (series.isVisible()) {
checkBoxGroup.deselect(series);
} else {
checkBoxGroup.select(series);
}
}
});
chart.drawChart(conf);
return chart;
}
use of com.vaadin.addon.charts.model.ListSeries in project charts by vaadin.
the class ScatterWithRegressionLine method getChart.
@Override
protected Component getChart() {
Chart chart = new Chart();
Configuration conf = chart.getConfiguration();
Color[] colors = getThemeColors();
XAxis x = new XAxis();
x.setMin(-0.5);
x.setMax(5.5);
conf.addxAxis(x);
YAxis y = new YAxis();
y.setMin(0);
conf.addyAxis(y);
conf.setTitle("Scatter plot with regression line");
DataSeries series = new DataSeries();
PlotOptionsLine plotOptions = new PlotOptionsLine();
plotOptions.setColor(colors[1]);
series.setPlotOptions(plotOptions);
series.setName("Regression Line");
List<DataSeriesItem> list = new ArrayList<DataSeriesItem>();
list.add(new DataSeriesItem(0, 1.11));
list.add(new DataSeriesItem(5, 4.51));
series.setData(list);
plotOptions.setMarker(new Marker(true));
plotOptions.setEnableMouseTracking(true);
Hover hover = new Hover();
hover.setLineWidth(0);
States states = new States();
states.setHover(hover);
plotOptions.setStates(states);
conf.addSeries(series);
ListSeries listSeries = new ListSeries("Observations", 1, 1.5, 2.8, 3.5, 3.9, 4.2);
PlotOptionsScatter plotOptions2 = new PlotOptionsScatter();
listSeries.setPlotOptions(plotOptions2);
Marker marker = new Marker(true);
marker.setRadius(4);
plotOptions2.setMarker(marker);
conf.addSeries(listSeries);
chart.drawChart(conf);
return chart;
}
use of com.vaadin.addon.charts.model.ListSeries in project charts by vaadin.
the class ColumnWithShapedLabels method getChart.
@Override
protected Component getChart() {
Chart chart = new Chart(ChartType.COLUMN);
Configuration conf = chart.getConfiguration();
conf.setTitle(new Title("Stacked column chart"));
XAxis xAxis = new XAxis();
xAxis.setCategories(new String[] { "Apples", "Oranges", "Pears", "Grapes", "Bananas" });
conf.addxAxis(xAxis);
YAxis yAxis = new YAxis();
yAxis.setMin(0);
yAxis.setTitle(new AxisTitle("Total fruit consumption"));
conf.addyAxis(yAxis);
PlotOptionsColumn plotOptions = new PlotOptionsColumn();
plotOptions.setStacking(Stacking.NORMAL);
DataLabels labels = new DataLabels(true);
labels.setBackgroundColor(SolidColor.BURLYWOOD);
labels.setColor(new SolidColor("white"));
labels.setShape(Shape.DIAMOND);
Style style = new Style();
style.setTextShadow("0 0 3px black");
labels.setStyle(style);
plotOptions.setDataLabels(labels);
conf.setPlotOptions(plotOptions);
conf.addSeries(new ListSeries("John", new Number[] { 5, 3, 4, 7, 2 }));
conf.addSeries(new ListSeries("Jane", new Number[] { 2, 2, 3, 2, 1 }));
conf.addSeries(new ListSeries("Joe", new Number[] { 3, 4, 4, 2, 5 }));
chart.drawChart(conf);
return chart;
}
use of com.vaadin.addon.charts.model.ListSeries in project charts by vaadin.
the class StackedAndGroupedColumn method getChart.
@Override
protected Component getChart() {
Chart chart = new Chart(ChartType.COLUMN);
Configuration conf = chart.getConfiguration();
conf.setTitle(new Title("Total fruit consumption, grouped by gender"));
XAxis xAxis = new XAxis();
xAxis.setCategories(new String[] { "Apples", "Oranges", "Pears", "Grapes", "Bananas" });
conf.addxAxis(xAxis);
YAxis yAxis = new YAxis();
yAxis.setAllowDecimals(false);
yAxis.setMin(0);
yAxis.setTitle(new AxisTitle("Number of fruits"));
conf.addyAxis(yAxis);
Tooltip tooltip = new Tooltip();
tooltip.setFormatter("function() { return '<b>'+ this.x +'</b><br/>'" + "+this.series.name +': '+ this.y +'<br/>'+'Total: '+ this.point.stackTotal; }");
conf.setTooltip(tooltip);
PlotOptionsColumn plotOptions = new PlotOptionsColumn();
plotOptions.setStacking(Stacking.NORMAL);
conf.setPlotOptions(plotOptions);
ListSeries serie = new ListSeries("John", new Number[] { 5, 3, 4, 7, 2 });
serie.setStack("male");
conf.addSeries(serie);
serie = new ListSeries("Joe", new Number[] { 3, 4, 4, 2, 5 });
serie.setStack("male");
conf.addSeries(serie);
serie = new ListSeries("Jane", new Number[] { 2, 5, 6, 2, 1 });
serie.setStack("female");
conf.addSeries(serie);
serie = new ListSeries("Janet", new Number[] { 3, 0, 4, 4, 3 });
serie.setStack("female");
conf.addSeries(serie);
chart.drawChart(conf);
return chart;
}
use of com.vaadin.addon.charts.model.ListSeries in project charts by vaadin.
the class StackedBar method getChart.
@Override
protected Component getChart() {
Chart chart = new Chart(ChartType.BAR);
Configuration conf = chart.getConfiguration();
conf.setTitle("Stacked bar chart");
XAxis x = new XAxis();
x.setCategories("Apples", "Oranges", "Pears", "Grapes", "Bananas");
conf.addxAxis(x);
YAxis y = new YAxis();
y.setMin(0);
y.setTitle("Total fruit consumption");
conf.addyAxis(y);
Legend legend = new Legend();
legend.setBackgroundColor(new SolidColor("#FFFFFF"));
legend.setReversed(true);
Tooltip tooltip = new Tooltip();
tooltip.setFormatter("this.series.name +': '+ this.y");
conf.setTooltip(tooltip);
PlotOptionsSeries plot = new PlotOptionsSeries();
plot.setStacking(Stacking.NORMAL);
conf.setPlotOptions(plot);
conf.addSeries(new ListSeries("John", 5, 3, 4, 7, 2));
conf.addSeries(new ListSeries("Jane", 2, 2, 3, 2, 1));
conf.addSeries(new ListSeries("Joe", 3, 4, 4, 2, 5));
chart.drawChart(conf);
return chart;
}
Aggregations