use of com.vaadin.addon.charts.model.PlotOptionsColumn in project charts by vaadin.
the class ColumnWithRotatedLabels method getChart.
@Override
protected Component getChart() {
Chart chart = new Chart(ChartType.COLUMN);
Configuration conf = chart.getConfiguration();
conf.getChart().setMargin(50, 80, 100, 50);
conf.setTitle(new Title("World's largest cities per 2008"));
XAxis xAxis = new XAxis();
xAxis.setCategories("Tokyo", "Jakarta", "New York", "Seoul", "Manila", "Mumbai", "Sao Paulo", "Mexico City", "Dehli", "Osaka", "Cairo", "Kolkata", "Los Angeles", "Shanghai", "Moscow", "Beijing", "Buenos Aires", "Guangzhou", "Shenzhen", "Istanbul");
Labels labels = new Labels();
labels.setRotation(-45);
labels.setAlign(HorizontalAlign.RIGHT);
Style style = new Style();
style.setFontSize("13px");
style.setFontFamily("Verdana, sans-serif");
labels.setStyle(style);
xAxis.setLabels(labels);
conf.addxAxis(xAxis);
YAxis yAxis = new YAxis();
yAxis.setMin(0);
yAxis.setTitle(new AxisTitle("Population (millions)"));
conf.addyAxis(yAxis);
Legend legend = new Legend();
legend.setEnabled(false);
conf.setLegend(legend);
Tooltip tooltip = new Tooltip();
tooltip.setFormatter("'<b>'+ this.x +'</b><br/>'+'Population in 2008: '" + "+ Highcharts.numberFormat(this.y, 1) +' millions'");
conf.setTooltip(tooltip);
ListSeries serie = new ListSeries("Population", new Number[] { 34.4, 21.8, 20.1, 20, 19.6, 19.5, 19.1, 18.4, 18, 17.3, 16.8, 15, 14.7, 14.5, 13.3, 12.8, 12.4, 11.8, 11.7, 11.2 });
DataLabels dataLabels = new DataLabels();
dataLabels.setEnabled(true);
dataLabels.setRotation(-90);
dataLabels.setColor(new SolidColor(255, 255, 255));
dataLabels.setAlign(HorizontalAlign.RIGHT);
dataLabels.setX(4);
dataLabels.setY(10);
dataLabels.setFormatter("this.y");
PlotOptionsColumn plotOptionsColumn = new PlotOptionsColumn();
plotOptionsColumn.setDataLabels(dataLabels);
serie.setPlotOptions(plotOptionsColumn);
conf.addSeries(serie);
chart.drawChart(conf);
return chart;
}
use of com.vaadin.addon.charts.model.PlotOptionsColumn in project charts by vaadin.
the class ColumnWithShapedTooltip method getChart.
@Override
protected Component getChart() {
Chart chart = new Chart(ChartType.COLUMN);
chart.setId("chart");
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);
conf.setPlotOptions(plotOptions);
Tooltip tooltip = new Tooltip();
tooltip.setFormatter("function() { return '<b>'+ this.x +'</b><br/>" + "'+this.series.name +': '+ this.y +'<br/>'+'Total: '+ this.point.stackTotal;}");
tooltip.setShape(Shape.CIRCLE);
conf.setTooltip(tooltip);
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.PlotOptionsColumn 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.PlotOptionsColumn 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;
}
use of com.vaadin.addon.charts.model.PlotOptionsColumn in project charts by vaadin.
the class BasicColumnWithPointWidthAndRange method getChart.
@Override
protected Component getChart() {
chart = new Chart(ChartType.COLUMN);
Configuration conf = chart.getConfiguration();
conf.setTitle("Visualize point width and point range");
plotOptions = new PlotOptionsColumn();
// plotOptions.setPointRange(10);
plotOptions.setPointWidth(100);
conf.setPlotOptions(plotOptions);
DataSeries dataSeries = new DataSeries();
dataSeries.addData(new Number[][] { { 0, 1 }, { 2, 2 }, { 10, 3 } });
conf.setSeries(dataSeries);
chart.drawChart(conf);
return chart;
}
Aggregations