use of com.vaadin.addon.charts.model.ListSeries in project charts by vaadin.
the class ColumnWithNegativeValues method getChart.
@Override
protected Component getChart() {
Chart chart = new Chart(ChartType.COLUMN);
Configuration conf = chart.getConfiguration();
conf.setTitle(new Title("Column chart with negative values"));
PlotOptionsColumn column = new PlotOptionsColumn();
column.setMinPointLength(3);
conf.setPlotOptions(column);
XAxis xAxis = new XAxis();
xAxis.setCategories("Apples", "Oranges", "Pears", "Grapes", "Bananas");
conf.addxAxis(xAxis);
Tooltip tooltip = new Tooltip();
tooltip.setFormatter("function() { return ''+ this.series.name +': '+ this.y +'';}");
conf.setTooltip(tooltip);
conf.setCredits(new Credits(false));
conf.addSeries(new ListSeries("John", 5, 0.1, 4, 7, 2));
conf.addSeries(new ListSeries("Jane", 2, -2, -0.1, 2, 1));
conf.addSeries(new ListSeries("Joe", 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 BasicBarNoTitle method getChart.
@Override
protected Component getChart() {
Chart chart = new Chart(ChartType.BAR);
Configuration conf = chart.getConfiguration();
conf.getTitle().setText(null);
XAxis x = new XAxis();
x.setCategories("Africa", "America", "Asia", "Europe", "Oceania");
x.setTitle((String) null);
conf.addxAxis(x);
YAxis y = new YAxis();
y.setMin(0);
AxisTitle title = new AxisTitle("Population (millions)");
title.setAlign(VerticalAlign.MIDDLE);
y.setTitle(title);
conf.addyAxis(y);
Tooltip tooltip = new Tooltip();
tooltip.setFormatter("this.series.name +': '+ this.y +' millions'");
conf.setTooltip(tooltip);
PlotOptionsBar plot = new PlotOptionsBar();
plot.setDataLabels(new DataLabels(true));
conf.setPlotOptions(plot);
Legend legend = new Legend();
legend.setLayout(LayoutDirection.VERTICAL);
legend.setAlign(HorizontalAlign.RIGHT);
legend.setVerticalAlign(VerticalAlign.TOP);
legend.setX(-100);
legend.setY(100);
legend.setFloating(true);
legend.setBorderWidth(1);
legend.setBackgroundColor(new SolidColor("#FFFFFF"));
legend.setShadow(true);
conf.setLegend(legend);
conf.disableCredits();
List<Series> series = new ArrayList<Series>();
series.add(new ListSeries("Year 1800", 107, 31, 635, 203, 2));
series.add(new ListSeries("Year 1900", 133, 156, 947, 408, 6));
series.add(new ListSeries("Year 2008", 973, 914, 4054, 732, 34));
conf.setSeries(series);
chart.drawChart(conf);
return chart;
}
use of com.vaadin.addon.charts.model.ListSeries in project charts by vaadin.
the class BasicColumn method getChart.
@Override
protected Component getChart() {
Chart 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(new ListSeries("Tokyo", 49.9, 71.5, 106.4, 129.2, 144.0, 176.0, 135.6, 148.5, 216.4, 194.1, 95.6, 54.4));
conf.addSeries(new ListSeries("New York", 83.6, 78.8, 98.5, 93.4, 106.0, 84.5, 105.0, 104.3, 91.2, 83.5, 106.6, 92.3));
conf.addSeries(new ListSeries("London", 48.9, 38.8, 39.3, 41.4, 47.0, 48.3, 59.0, 59.6, 52.4, 65.2, 59.3, 51.2));
conf.addSeries(new ListSeries("Berlin", 42.4, 33.2, 34.5, 39.7, 52.6, 75.5, 57.4, 60.4, 47.6, 39.1, 46.8, 51.1));
chart.drawChart(conf);
return chart;
}
use of com.vaadin.addon.charts.model.ListSeries in project charts by vaadin.
the class AreaSpline method getChart.
@Override
protected Component getChart() {
Chart chart = new Chart(ChartType.AREASPLINE);
chart.setHeight("450px");
Configuration conf = chart.getConfiguration();
conf.setTitle(new Title("Average fruit consumption during one week"));
Legend legend = new Legend();
legend.setLayout(LayoutDirection.VERTICAL);
legend.setAlign(HorizontalAlign.LEFT);
legend.setFloating(true);
legend.setVerticalAlign(VerticalAlign.TOP);
legend.setX(150);
legend.setY(100);
conf.setLegend(legend);
XAxis xAxis = new XAxis();
xAxis.setCategories(new String[] { "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday" });
// add blue background for the weekend
PlotBand plotBand = new PlotBand(4.5, 6.5, LIGHT_BLUE);
plotBand.setZIndex(1);
xAxis.setPlotBands(plotBand);
conf.addxAxis(xAxis);
YAxis yAxis = new YAxis();
yAxis.setTitle(new AxisTitle("Fruit units"));
conf.addyAxis(yAxis);
Tooltip tooltip = new Tooltip();
// Customize tooltip formatting
tooltip.setHeaderFormat("");
tooltip.setPointFormat("{series.name}: {point.y} units");
// Same could be achieved by defining following JS formatter funtion:
// tooltip.setFormatter("function(){ return this.x +': '+ this.y +' units';}");
// ... or its shorthand form:
// tooltip.setFormatter("this.x +': '+ this.y +' units'");
conf.setTooltip(tooltip);
PlotOptionsArea plotOptions = new PlotOptionsArea();
plotOptions.setFillOpacity(0.5);
conf.setPlotOptions(plotOptions);
ListSeries o = new ListSeries("John", 3, 4, 3, 5, 4, 10);
// Add last value separately
o.addData(12);
conf.addSeries(o);
conf.addSeries(new ListSeries("Jane", 1, 3, 4, 3, 3, 5, 4));
chart.drawChart(conf);
return chart;
}
use of com.vaadin.addon.charts.model.ListSeries in project charts by vaadin.
the class AreaWithMissingPoints method getChart.
@Override
protected Component getChart() {
Chart chart = new Chart(ChartType.AREA);
Configuration conf = chart.getConfiguration();
conf.getChart().setSpacingBottom(30);
conf.setTitle(new Title("Fruit consumption *"));
Subtitle subTitle = new Subtitle("* Jane\'s banana consumption is unknown");
subTitle.setFloating(true);
subTitle.setY(15);
subTitle.setAlign(HorizontalAlign.RIGHT);
subTitle.setVerticalAlign(VerticalAlign.BOTTOM);
conf.setSubTitle(subTitle);
XAxis xAxis = new XAxis();
xAxis.setCategories("Apples", "Pears", "Oranges", "Bananas", "Grapes", "Plums", "Strawberries", "Raspberries");
conf.addxAxis(xAxis);
Legend legend = new Legend();
legend.setLayout(LayoutDirection.VERTICAL);
legend.setAlign(HorizontalAlign.LEFT);
legend.setFloating(true);
legend.setVerticalAlign(VerticalAlign.TOP);
legend.setX(150);
legend.setY(100);
legend.setBorderWidth(1);
legend.setBackgroundColor(new SolidColor("#ffffff"));
conf.setLegend(legend);
PlotOptionsArea plotOptions = new PlotOptionsArea();
plotOptions.setFillOpacity(0.5);
conf.setPlotOptions(plotOptions);
conf.addSeries(new ListSeries("John", 0, 1, 4, 4, 5, 2, 3, 7));
conf.addSeries(new ListSeries("Jane", 1, 0, 3, null, 3, 1, 2, 1));
chart.drawChart(conf);
return chart;
}
Aggregations