use of com.vaadin.addon.charts.model.style.SolidColor 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.style.SolidColor 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.style.SolidColor 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;
}
use of com.vaadin.addon.charts.model.style.SolidColor in project charts by vaadin.
the class InvertedAxes method getChart.
@Override
protected Component getChart() {
Chart chart = new Chart(ChartType.AREA);
Configuration conf = chart.getConfiguration();
conf.getChart().setInverted(true);
conf.setTitle(new Title("Average fruit consumption during one week"));
XAxis xAxis = new XAxis();
xAxis.setCategories("Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday");
conf.addxAxis(xAxis);
YAxis yAxis = new YAxis();
yAxis.setTitle(new AxisTitle("Number of units"));
yAxis.setMin(0);
conf.addyAxis(yAxis);
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", 3, 4, 3, 5, 4, 10, 12));
conf.addSeries(new ListSeries("Jane", 1, 3, 4, 3, 3, 5, 4));
chart.drawChart(conf);
return chart;
}
use of com.vaadin.addon.charts.model.style.SolidColor 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;
}
Aggregations