use of com.vaadin.addon.charts.model.StackLabels in project charts by vaadin.
the class OverrideStackingForSpecificSeries 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"));
StackLabels sLabels = new StackLabels(true);
Style slStyle = new Style();
slStyle.setFontWeight(FontWeight.BOLD);
slStyle.setColor(new SolidColor("gray"));
sLabels.setStyle(slStyle);
yAxis.setStackLabels(sLabels);
conf.addyAxis(yAxis);
Tooltip tooltip = new Tooltip();
tooltip.setFormatter("'<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);
DataLabels labels = new DataLabels();
labels.setEnabled(true);
labels.setColor(new SolidColor("white"));
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 }));
ListSeries series = new ListSeries("Joe", new Number[] { 3, 4, 4, 2, 5 });
PlotOptionsColumn joePlotOptions = new PlotOptionsColumn();
joePlotOptions.setStacking(Stacking.NONE);
series.setPlotOptions(joePlotOptions);
conf.addSeries(series);
chart.drawChart(conf);
return chart;
}
use of com.vaadin.addon.charts.model.StackLabels in project charts by vaadin.
the class StackedColumn 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"));
StackLabels sLabels = new StackLabels(true);
yAxis.setStackLabels(sLabels);
conf.addyAxis(yAxis);
Legend legend = new Legend();
legend.setAlign(HorizontalAlign.RIGHT);
legend.setFloating(true);
legend.setVerticalAlign(VerticalAlign.TOP);
legend.setX(-100);
legend.setY(20);
conf.setLegend(legend);
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);
DataLabels labels = new DataLabels(true);
Style style = new Style();
style.setTextShadow("0 0 3px black");
labels.setStyle(style);
labels.setColor(new SolidColor("white"));
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;
}
Aggregations