Search in sources :

Example 6 with Tooltip

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;
}
Also used : Configuration(com.vaadin.addon.charts.model.Configuration) PlotOptionsColumnrange(com.vaadin.addon.charts.model.PlotOptionsColumnrange) DataLabelsRange(com.vaadin.addon.charts.model.DataLabelsRange) Tooltip(com.vaadin.addon.charts.model.Tooltip) DataSeries(com.vaadin.addon.charts.model.DataSeries) Chart(com.vaadin.addon.charts.Chart) XAxis(com.vaadin.addon.charts.model.XAxis) DataSeriesItem(com.vaadin.addon.charts.model.DataSeriesItem) YAxis(com.vaadin.addon.charts.model.YAxis)

Example 7 with Tooltip

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;
}
Also used : Configuration(com.vaadin.addon.charts.model.Configuration) ListSeries(com.vaadin.addon.charts.model.ListSeries) Tooltip(com.vaadin.addon.charts.model.Tooltip) Chart(com.vaadin.addon.charts.Chart) XAxis(com.vaadin.addon.charts.model.XAxis) YAxis(com.vaadin.addon.charts.model.YAxis)

Example 8 with Tooltip

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;
}
Also used : PlotOptionsPie(com.vaadin.addon.charts.model.PlotOptionsPie) DataLabels(com.vaadin.addon.charts.model.DataLabels) Configuration(com.vaadin.addon.charts.model.Configuration) Tooltip(com.vaadin.addon.charts.model.Tooltip) DataSeries(com.vaadin.addon.charts.model.DataSeries) Chart(com.vaadin.addon.charts.Chart) DataSeriesItem(com.vaadin.addon.charts.model.DataSeriesItem)

Example 9 with Tooltip

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;
}
Also used : Configuration(com.vaadin.addon.charts.model.Configuration) RangeSeries(com.vaadin.addon.charts.model.RangeSeries) Crosshair(com.vaadin.addon.charts.model.Crosshair) Tooltip(com.vaadin.addon.charts.model.Tooltip) Chart(com.vaadin.addon.charts.Chart) YAxis(com.vaadin.addon.charts.model.YAxis)

Example 10 with Tooltip

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;
}
Also used : Configuration(com.vaadin.addon.charts.model.Configuration) ListSeries(com.vaadin.addon.charts.model.ListSeries) Tooltip(com.vaadin.addon.charts.model.Tooltip) Chart(com.vaadin.addon.charts.Chart)

Aggregations

Tooltip (com.vaadin.addon.charts.model.Tooltip)46 Chart (com.vaadin.addon.charts.Chart)44 Configuration (com.vaadin.addon.charts.model.Configuration)42 XAxis (com.vaadin.addon.charts.model.XAxis)39 YAxis (com.vaadin.addon.charts.model.YAxis)39 ListSeries (com.vaadin.addon.charts.model.ListSeries)24 PlotOptionsColumn (com.vaadin.addon.charts.model.PlotOptionsColumn)20 AxisTitle (com.vaadin.addon.charts.model.AxisTitle)16 DataSeries (com.vaadin.addon.charts.model.DataSeries)16 Legend (com.vaadin.addon.charts.model.Legend)14 SolidColor (com.vaadin.addon.charts.model.style.SolidColor)14 DataLabels (com.vaadin.addon.charts.model.DataLabels)13 Title (com.vaadin.addon.charts.model.Title)12 DataSeriesItem (com.vaadin.addon.charts.model.DataSeriesItem)10 Series (com.vaadin.addon.charts.model.Series)7 Style (com.vaadin.addon.charts.model.style.Style)7 Labels (com.vaadin.addon.charts.model.Labels)5 DataLabelsRange (com.vaadin.addon.charts.model.DataLabelsRange)4 PlotOptionsArea (com.vaadin.addon.charts.model.PlotOptionsArea)4 PlotOptionsColumnrange (com.vaadin.addon.charts.model.PlotOptionsColumnrange)4