use of com.vaadin.addon.charts.model.Tooltip in project charts by vaadin.
the class ContainerSeriesWithHighAndLow method getChart.
@Override
protected Component getChart() {
Chart chart = new Chart(ChartType.COLUMNRANGE);
Configuration conf = chart.getConfiguration();
conf.getChart().setInverted(true);
conf.setTitle("Temperature variation by month");
conf.setSubTitle("Observed in Vik i Sogn, Norway, 2009");
XAxis xAxis = new XAxis();
xAxis.setCategories("Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec");
conf.addxAxis(xAxis);
YAxis yAxis = new YAxis();
yAxis.setTitle("Temperature ( °C )");
conf.addyAxis(yAxis);
Tooltip tooltip = new Tooltip();
tooltip.setValueSuffix("°C");
conf.setTooltip(tooltip);
PlotOptionsColumnrange columnRange = new PlotOptionsColumnrange();
columnRange.setDataLabels(new DataLabelsRange(true));
columnRange.getDataLabels().setFormatter("function() {return this.y + '°C';}");
conf.setPlotOptions(columnRange);
conf.getLegend().setEnabled(false);
IndexedContainer vaadinContainer = new IndexedContainer();
vaadinContainer.addContainerProperty("min", Number.class, null);
vaadinContainer.addContainerProperty("max", Number.class, null);
for (Number[] minMaxPair : getRawData()) {
Item item = vaadinContainer.getItem(vaadinContainer.addItem());
item.getItemProperty("min").setValue(minMaxPair[0]);
item.getItemProperty("max").setValue(minMaxPair[1]);
}
ContainerDataSeries data = new ContainerDataSeries(vaadinContainer);
data.setLowPropertyId("min");
data.setHighPropertyId("max");
data.setName("Temperatures");
conf.setSeries(data);
return chart;
}
use of com.vaadin.addon.charts.model.Tooltip in project charts by vaadin.
the class DualAxesLineAndColumn method getChart.
@Override
protected Component getChart() {
Chart chart = new Chart();
Configuration conf = chart.getConfiguration();
conf.getChart().setZoomType(ZoomType.XY);
conf.setTitle("Average Monthly Temperature and Rainfall in Tokyo");
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 primary = new YAxis();
primary.setTitle("Temperature");
Style style = new Style();
style.setColor(getThemeColors()[1]);
primary.getTitle().setStyle(style);
conf.addyAxis(primary);
YAxis snd = new YAxis();
snd.setTitle("Rainfall");
snd.setOpposite(true);
style = new Style();
style.setColor(new SolidColor("#4572A7"));
snd.getTitle().setStyle(style);
conf.addyAxis(snd);
Tooltip tooltip = new Tooltip();
tooltip.setFormatter("this.x +': '+ this.y + (this.series.name == 'Rainfall' ? ' mm' : '°C')");
conf.setTooltip(tooltip);
Legend legend = new Legend();
legend.setLayout(LayoutDirection.VERTICAL);
legend.setAlign(HorizontalAlign.LEFT);
legend.setX(120);
legend.setVerticalAlign(VerticalAlign.TOP);
legend.setY(100);
legend.setFloating(true);
conf.setLegend(legend);
DataSeries series = new DataSeries();
series.setPlotOptions(new PlotOptionsColumn());
series.setName("Rainfall");
series.setData(49.9, 71.5, 106.4, 129.2, 144.0, 176.0, 135.6, 148.5, 216.4, 194.1, 95.6, 54.4);
series.setyAxis(1);
conf.addSeries(series);
series = new DataSeries();
PlotOptionsSpline plotOptions = new PlotOptionsSpline();
series.setPlotOptions(plotOptions);
series.setName("Temperature");
series.setData(7.0, 6.9, 9.5, 14.5, 18.2, 21.5, 25.2, 26.5, 23.3, 18.3, 13.9, 9.6);
plotOptions.setColor(getThemeColors()[1]);
conf.addSeries(series);
return chart;
}
use of com.vaadin.addon.charts.model.Tooltip 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.Tooltip 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;
}
use of com.vaadin.addon.charts.model.Tooltip in project charts by vaadin.
the class StackedPercentageColumn 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.setMin(0);
yAxis.setTitle(new AxisTitle("Total fruit consumption"));
conf.addyAxis(yAxis);
Tooltip tooltip = new Tooltip();
tooltip.setFormatter("this.series.name +': '+ this.y +' ('+ Math.round(this.percentage) +'%)'");
conf.setTooltip(tooltip);
PlotOptionsColumn plotOptions = new PlotOptionsColumn();
plotOptions.setStacking(Stacking.PERCENT);
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