use of com.vaadin.addon.charts.model.Tooltip in project charts by vaadin.
the class SVGGeneratorTest method createConf.
private Configuration createConf() {
Configuration conf = new Configuration();
conf.setTitle("Historic World Population by Region");
conf.setSubTitle("Source: Wikipedia.org");
XAxis x = new XAxis();
x.setCategories("Africa", "America", "Asia", "Europe", "Oceania");
x.setTitle(new AxisTitle((String) null));
conf.addxAxis(x);
YAxis y = new YAxis();
y.setMin(0);
AxisTitle title = new AxisTitle("Population (millions)");
title.setAlign(VerticalAlign.HIGH);
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);
return conf;
}
use of com.vaadin.addon.charts.model.Tooltip in project charts by vaadin.
the class Basic3DColumn 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");
conf.addxAxis(x);
YAxis y = new YAxis();
y.setMin(0);
y.setTitle("Rainfall (mm)");
conf.addyAxis(y);
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);
plot.setGroupZPadding(10);
conf.setPlotOptions(plot);
Options3d options3d = new Options3d();
options3d.setEnabled(true);
options3d.setAlpha(5);
options3d.setBeta(30);
options3d.setDepth(100);
options3d.setViewDistance(200);
Frame frame = new Frame();
options3d.setFrame(frame);
conf.getChart().setOptions3d(options3d);
conf.addSeries(new ListSeries("Tokyo", 49.9, 71.5, 106.4, 129.2));
conf.addSeries(new ListSeries("New York", 83.6, 78.8, 98.5, 93.4));
conf.addSeries(new ListSeries("London", 48.9, 38.8, 39.3, 41.4));
conf.addSeries(new ListSeries("Berlin", 42.4, 33.2, 34.5, 39.7));
chart.drawChart(conf);
return chart;
}
use of com.vaadin.addon.charts.model.Tooltip in project charts by vaadin.
the class CompareMultipleSeries method getChart.
@Override
protected Component getChart() {
final Chart chart = new Chart();
chart.setHeight("450px");
chart.setWidth("100%");
chart.setTimeline(true);
Configuration configuration = chart.getConfiguration();
configuration.getTitle().setText("AAPL Stock Price");
YAxis yAxis = new YAxis();
Labels label = new Labels();
label.setFormatter("(this.value > 0 ? ' + ' : '') + this.value + '%'");
yAxis.setLabels(label);
PlotLine plotLine = new PlotLine();
plotLine.setValue(2);
plotLine.setWidth(2);
plotLine.setColor(SolidColor.SILVER);
yAxis.setPlotLines(plotLine);
configuration.addyAxis(yAxis);
Tooltip tooltip = new Tooltip();
tooltip.setPointFormat("<span style=\"color:{series.color}\">{series.name}</span>: <b>{point.y}</b> ({point.change}%)<br/>");
tooltip.setValueDecimals(2);
configuration.setTooltip(tooltip);
DataSeries aaplSeries = new DataSeries();
aaplSeries.setName("AAPL");
for (StockPrices.PriceData data : StockPrices.fetchAaplPrice()) {
DataSeriesItem item = new DataSeriesItem();
item.setX(data.getDate());
item.setY(data.getPrice());
aaplSeries.add(item);
}
DataSeries googSeries = new DataSeries();
googSeries.setName("GOOG");
for (StockPrices.PriceData data : StockPrices.fetchGoogPrice()) {
DataSeriesItem item = new DataSeriesItem();
item.setX(data.getDate());
item.setY(data.getPrice());
googSeries.add(item);
}
DataSeries msftSeries = new DataSeries();
msftSeries.setName("MSFT");
for (StockPrices.PriceData data : StockPrices.fetchMsftPrice()) {
DataSeriesItem item = new DataSeriesItem();
item.setX(data.getDate());
item.setY(data.getPrice());
msftSeries.add(item);
}
configuration.setSeries(aaplSeries, googSeries, msftSeries);
PlotOptionsSeries plotOptionsSeries = new PlotOptionsSeries();
plotOptionsSeries.setCompare(PERCENT);
configuration.setPlotOptions(plotOptionsSeries);
RangeSelector rangeSelector = new RangeSelector();
rangeSelector.setSelected(4);
configuration.setRangeSelector(rangeSelector);
chart.drawChart(configuration);
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;
}
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;
}
Aggregations