use of com.vaadin.addon.charts.model.Tooltip in project charts by vaadin.
the class ColumnRange 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);
// RangeSeries has some helper constructors of which example below, but
// here we use the raw DataSeries API
// RangeSeries data = new RangeSeries("Temperatures", getRawData());
DataSeries data = new DataSeries();
data.setName("Temperatures");
for (Number[] minMaxPair : getRawData()) {
DataSeriesItem item = new DataSeriesItem();
item.setLow(minMaxPair[0]);
item.setHigh(minMaxPair[1]);
data.add(item);
}
conf.setSeries(data);
return chart;
}
use of com.vaadin.addon.charts.model.Tooltip in project charts by vaadin.
the class ColumnSite method getChart.
@Override
protected Component getChart() {
Chart chart = new Chart(ChartType.COLUMN);
Configuration conf = chart.getConfiguration();
conf.setTitle("Earnings");
conf.setSubTitle("2011 - 2014");
XAxis xAxis = conf.getxAxis();
xAxis.setCategories("2011", "2012", "2013", "2014");
YAxis yAxis = conf.getyAxis();
yAxis.setTitle("B€");
Tooltip tooltip = conf.getTooltip();
tooltip.setPointFormat("{series.name}: {point.y} B€");
conf.addSeries(new ListSeries("Revenue", 1.5, 1.8, 1.2, 2.3));
conf.addSeries(new ListSeries("Expenses", 1.2, 1.1, 1.3, 0.9));
conf.addSeries(new ListSeries("Net income", -0.3, 0.7, -0.1, 1.4));
return chart;
}
use of com.vaadin.addon.charts.model.Tooltip in project charts by vaadin.
the class PieSite method getChart.
@Override
protected Component getChart() {
Chart chart = new Chart(ChartType.PIE);
Configuration conf = chart.getConfiguration();
conf.setTitle("Revenue by industry");
conf.setSubTitle("2015");
Tooltip tooltip = conf.getTooltip();
tooltip.setPointFormat("<b>{point.percentage:.1f}%</b>");
PlotOptionsPie plotOptions = new PlotOptionsPie();
plotOptions.setAllowPointSelect(true);
plotOptions.setCursor(Cursor.POINTER);
plotOptions.setShowInLegend(true);
DataLabels dataLabels = plotOptions.getDataLabels();
dataLabels.setEnabled(true);
dataLabels.setFormat("{point.name}: {point.y:.1f} M€");
conf.setPlotOptions(plotOptions);
DataSeries series = new DataSeries("Revenue");
series.add(new DataSeriesItem("Aerospace", 90.0));
series.add(new DataSeriesItem("Medical", 53.6));
series.add(new DataSeriesItem("Agriculture", 25.6));
series.add(new DataSeriesItem("Automotive", 17.0));
series.add(new DataSeriesItem("Consumers", 12.4));
series.add(new DataSeriesItem("Subsidies", 1.4));
conf.setSeries(series);
return chart;
}
use of com.vaadin.addon.charts.model.Tooltip in project charts by vaadin.
the class AreaRange method getChart.
@Override
protected Component getChart() {
Chart chart = new Chart(ChartType.AREARANGE);
Configuration conf = chart.getConfiguration();
conf.setTitle("Temperature variation by day");
conf.getxAxis().setType(DATETIME);
conf.getxAxis().setCrosshair(new Crosshair());
conf.addyAxis(new YAxis());
Tooltip tooltip = new Tooltip();
tooltip.setShared(true);
tooltip.setValueSuffix("°C");
conf.setTooltip(tooltip);
RangeSeries data = new RangeSeries("Temperatures", getRawData());
conf.setSeries(data);
chart.drawChart(conf);
return chart;
}
use of com.vaadin.addon.charts.model.Tooltip in project charts by vaadin.
the class LinesWithComplexHtmlTooltip method getChart.
@Override
protected Component getChart() {
Chart chart = new Chart();
chart.setHeight("450px");
chart.setWidth("100%");
Tooltip tooltip = new Tooltip();
tooltip.setShared(true);
tooltip.setUseHTML(true);
tooltip.setHeaderFormat("<small>{point.key}</small><table>");
tooltip.setPointFormat("<tr><td style=\"color: {series.color}\">{series.name}: </td><td style=\"text-align: right\"><b>{point.y} EUR</b></td></tr>");
tooltip.setFooterFormat("</table>");
Configuration configuration = chart.getConfiguration();
configuration.setTitle("Complex tooltip");
configuration.setTooltip(tooltip);
configuration.getxAxis().setCategories("Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec");
ListSeries ls = new ListSeries();
ls.setName("Short");
ls.setData(29.9, 71.5, 106.4, 129.2, 144.0, 176.0, 135.6, 148.5, 216.4, 194.1, 95.6, 54.4);
configuration.addSeries(ls);
ls = new ListSeries();
ls.setName("Long named series");
Number[] data = new Number[] { 129.9, 171.5, 106.4, 129.2, 144.0, 176.0, 135.6, 148.5, 216.4, 194.1, 195.6, 154.4 };
for (int i = 0; i < data.length / 2; i++) {
Number number = data[i];
data[i] = data[data.length - i - 1];
data[data.length - i - 1] = number;
}
ls.setData(data);
configuration.addSeries(ls);
chart.drawChart(configuration);
return chart;
}
Aggregations