Search in sources :

Example 6 with Tooltip

use of com.vaadin.flow.component.charts.model.Tooltip in project flow-components by vaadin.

the class PieWithLegend method initDemo.

@Override
public void initDemo() {
    chart = new Chart(ChartType.PIE);
    Configuration conf = chart.getConfiguration();
    conf.setTitle("Browser market shares in January, 2018");
    Tooltip tooltip = new Tooltip();
    tooltip.setValueDecimals(1);
    conf.setTooltip(tooltip);
    PlotOptionsPie plotOptions = new PlotOptionsPie();
    plotOptions.setAllowPointSelect(true);
    plotOptions.setCursor(Cursor.POINTER);
    plotOptions.setShowInLegend(true);
    conf.setPlotOptions(plotOptions);
    DataSeries series = new DataSeries();
    DataSeriesItem chrome = new DataSeriesItem("Chrome", 61.41);
    chrome.setSliced(true);
    chrome.setSelected(true);
    series.add(chrome);
    series.add(new DataSeriesItem("Internet Explorer", 11.84));
    series.add(new DataSeriesItem("Firefox", 10.85));
    series.add(new DataSeriesItem("Edge", 4.67));
    series.add(new DataSeriesItem("Safari", 4.18));
    series.add(new DataSeriesItem("Sogou Explorer", 1.64));
    series.add(new DataSeriesItem("Opera", 6.2));
    series.add(new DataSeriesItem("QQ", 1.2));
    series.add(new DataSeriesItem("Others", 2.61));
    conf.setSeries(series);
    chart.setVisibilityTogglingDisabled(true);
    listenerRegistration = chart.addPointLegendItemClickListener(event -> {
        showNotification("Legend item click" + " : " + event.getItemIndex() + " : " + event.getItem().getName());
    });
    add(chart);
}
Also used : DataSeriesItem(com.vaadin.flow.component.charts.model.DataSeriesItem) ChartType(com.vaadin.flow.component.charts.model.ChartType) Tooltip(com.vaadin.flow.component.charts.model.Tooltip) Chart(com.vaadin.flow.component.charts.Chart) Registration(com.vaadin.flow.shared.Registration) PlotOptionsPie(com.vaadin.flow.component.charts.model.PlotOptionsPie) DataSeries(com.vaadin.flow.component.charts.model.DataSeries) AbstractChartExample(com.vaadin.flow.component.charts.examples.AbstractChartExample) Cursor(com.vaadin.flow.component.charts.model.Cursor) Configuration(com.vaadin.flow.component.charts.model.Configuration) PlotOptionsPie(com.vaadin.flow.component.charts.model.PlotOptionsPie) Configuration(com.vaadin.flow.component.charts.model.Configuration) Tooltip(com.vaadin.flow.component.charts.model.Tooltip) DataSeries(com.vaadin.flow.component.charts.model.DataSeries) Chart(com.vaadin.flow.component.charts.Chart) DataSeriesItem(com.vaadin.flow.component.charts.model.DataSeriesItem)

Example 7 with Tooltip

use of com.vaadin.flow.component.charts.model.Tooltip in project flow-components by vaadin.

the class AreaSplineRange method initDemo.

@Override
public void initDemo() {
    final Chart chart = new Chart(ChartType.AREASPLINERANGE);
    Configuration configuration = chart.getConfiguration();
    configuration.getTitle().setText("Temperature variation by day");
    Tooltip tooltip = configuration.getTooltip();
    tooltip.setValueSuffix("°C");
    DataSeries dataSeries = new DataSeries("Temperatures");
    for (StockPrices.RangeData data : StockPrices.fetchDailyTempRanges()) {
        dataSeries.add(new DataSeriesItem(data.getDate(), data.getMin(), data.getMax()));
    }
    configuration.setSeries(dataSeries);
    chart.setTimeline(true);
    add(chart);
}
Also used : StockPrices(com.vaadin.flow.component.charts.examples.timeline.util.StockPrices) Configuration(com.vaadin.flow.component.charts.model.Configuration) Tooltip(com.vaadin.flow.component.charts.model.Tooltip) DataSeries(com.vaadin.flow.component.charts.model.DataSeries) Chart(com.vaadin.flow.component.charts.Chart) DataSeriesItem(com.vaadin.flow.component.charts.model.DataSeriesItem)

Example 8 with Tooltip

use of com.vaadin.flow.component.charts.model.Tooltip in project flow-components by vaadin.

the class AreaRange method initDemo.

@Override
public void initDemo() {
    chart = new Chart(ChartType.AREARANGE);
    Configuration conf = chart.getConfiguration();
    conf.setTitle("Temperature variation by day");
    conf.getxAxis().setType(AxisType.DATETIME);
    conf.getxAxis().setCrosshair(new Crosshair());
    Tooltip tooltip = new Tooltip();
    tooltip.setShared(true);
    tooltip.setValueSuffix("°C");
    conf.setTooltip(tooltip);
    RangeSeries data = new RangeSeries("Temperatures", getRawData());
    conf.setSeries(data);
    chart.drawChart();
    add(chart);
}
Also used : Configuration(com.vaadin.flow.component.charts.model.Configuration) RangeSeries(com.vaadin.flow.component.charts.model.RangeSeries) Crosshair(com.vaadin.flow.component.charts.model.Crosshair) Tooltip(com.vaadin.flow.component.charts.model.Tooltip) Chart(com.vaadin.flow.component.charts.Chart)

Example 9 with Tooltip

use of com.vaadin.flow.component.charts.model.Tooltip in project flow-components by vaadin.

the class AreaSpline method initDemo.

@Override
public void initDemo() {
    Chart chart = new Chart(ChartType.AREASPLINE);
    Configuration conf = chart.getConfiguration();
    conf.setTitle(new Title("Average fruit consumption during one week"));
    Legend legend = new Legend();
    legend.setLayout(LayoutDirection.VERTICAL);
    legend.setAlign(HorizontalAlign.LEFT);
    legend.setFloating(true);
    legend.setVerticalAlign(VerticalAlign.TOP);
    legend.setX(150);
    legend.setY(100);
    conf.setLegend(legend);
    XAxis xAxis = new XAxis();
    xAxis.setCategories(new String[] { "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday" });
    PlotBand plotBand = new PlotBand(4.5, 6.5, SolidColor.BLUE);
    plotBand.setZIndex(1);
    xAxis.setPlotBands(plotBand);
    conf.addxAxis(xAxis);
    YAxis yAxis = new YAxis();
    yAxis.setTitle(new AxisTitle("Fruit units"));
    conf.addyAxis(yAxis);
    Tooltip tooltip = new Tooltip();
    // Customize tooltip formatting
    tooltip.setShared(true);
    tooltip.setValueSuffix(" units");
    conf.setTooltip(tooltip);
    PlotOptionsArea plotOptions = new PlotOptionsArea();
    conf.setPlotOptions(plotOptions);
    ListSeries o = new ListSeries("John", 3, 4, 3, 5, 4, 10);
    // You can also add values separately
    o.addData(12);
    conf.addSeries(o);
    conf.addSeries(new ListSeries("Jane", 1, 3, 4, 3, 3, 5, 4));
    add(chart);
}
Also used : Legend(com.vaadin.flow.component.charts.model.Legend) Configuration(com.vaadin.flow.component.charts.model.Configuration) PlotOptionsArea(com.vaadin.flow.component.charts.model.PlotOptionsArea) ListSeries(com.vaadin.flow.component.charts.model.ListSeries) Tooltip(com.vaadin.flow.component.charts.model.Tooltip) Title(com.vaadin.flow.component.charts.model.Title) AxisTitle(com.vaadin.flow.component.charts.model.AxisTitle) PlotBand(com.vaadin.flow.component.charts.model.PlotBand) AxisTitle(com.vaadin.flow.component.charts.model.AxisTitle) Chart(com.vaadin.flow.component.charts.Chart) XAxis(com.vaadin.flow.component.charts.model.XAxis) YAxis(com.vaadin.flow.component.charts.model.YAxis)

Example 10 with Tooltip

use of com.vaadin.flow.component.charts.model.Tooltip in project flow-components by vaadin.

the class BarWithNegativeStack method initDemo.

@Override
public void initDemo() {
    Chart chart = new Chart(ChartType.BAR);
    Configuration conf = chart.getConfiguration();
    conf.setTitle("Population pyramid for Germany, midyear 2010");
    conf.setSubTitle("Source: www.census.gov");
    final String[] categories = new String[] { "0-4", "5-9", "10-14", "15-19", "20-24", "25-29", "30-34", "35-39", "40-44", "45-49", "50-54", "55-59", "60-64", "65-69", "70-74", "75-79", "80-84", "85-89", "90-94", "95-99", "100 +" };
    XAxis x1 = new XAxis();
    conf.addxAxis(x1);
    x1.setCategories(categories);
    x1.setReversed(false);
    XAxis x2 = new XAxis();
    conf.addxAxis(x2);
    x2.setCategories(categories);
    x2.setOpposite(true);
    x2.setReversed(false);
    x2.setLinkedTo(x1);
    YAxis y = new YAxis();
    y.setMin(-4000000);
    y.setMax(4000000);
    y.setTitle(new AxisTitle(""));
    conf.addyAxis(y);
    PlotOptionsSeries plot = new PlotOptionsSeries();
    plot.setStacking(Stacking.NORMAL);
    conf.setPlotOptions(plot);
    Tooltip tooltip = new Tooltip();
    tooltip.setFormatter("function() {return '<b>'+ this.series.name +', age '+ this.point.category +'</b><br/>'+ 'Population: '+ Highcharts.numberFormat(Math.abs(this.point.y), 0)}");
    conf.setTooltip(tooltip);
    conf.addSeries(new ListSeries("Male", -1746181, -1884428, -2089758, -2222362, -2537431, -2507081, -2443179, -2664537, -3556505, -3680231, -3143062, -2721122, -2229181, -2227768, -2176300, -1329968, -836804, -354784, -90569, -28367, -3878));
    conf.addSeries(new ListSeries("Female", 1656154, 1787564, 1981671, 2108575, 2403438, 2366003, 2301402, 2519874, 3360596, 3493473, 3050775, 2759560, 2304444, 2426504, 2568938, 1785638, 1447162, 1005011, 330870, 130632, 21208));
    add(chart);
}
Also used : Configuration(com.vaadin.flow.component.charts.model.Configuration) ListSeries(com.vaadin.flow.component.charts.model.ListSeries) Tooltip(com.vaadin.flow.component.charts.model.Tooltip) AxisTitle(com.vaadin.flow.component.charts.model.AxisTitle) Chart(com.vaadin.flow.component.charts.Chart) XAxis(com.vaadin.flow.component.charts.model.XAxis) PlotOptionsSeries(com.vaadin.flow.component.charts.model.PlotOptionsSeries) YAxis(com.vaadin.flow.component.charts.model.YAxis)

Aggregations

Tooltip (com.vaadin.flow.component.charts.model.Tooltip)23 Chart (com.vaadin.flow.component.charts.Chart)20 Configuration (com.vaadin.flow.component.charts.model.Configuration)19 XAxis (com.vaadin.flow.component.charts.model.XAxis)17 YAxis (com.vaadin.flow.component.charts.model.YAxis)17 DataSeries (com.vaadin.flow.component.charts.model.DataSeries)11 ListSeries (com.vaadin.flow.component.charts.model.ListSeries)11 DataSeriesItem (com.vaadin.flow.component.charts.model.DataSeriesItem)9 PlotOptionsColumn (com.vaadin.flow.component.charts.model.PlotOptionsColumn)7 AxisTitle (com.vaadin.flow.component.charts.model.AxisTitle)5 PlotOptionsSeries (com.vaadin.flow.component.charts.model.PlotOptionsSeries)5 DataLabels (com.vaadin.flow.component.charts.model.DataLabels)4 Crosshair (com.vaadin.flow.component.charts.model.Crosshair)3 Labels (com.vaadin.flow.component.charts.model.Labels)3 Legend (com.vaadin.flow.component.charts.model.Legend)3 StockPrices (com.vaadin.flow.component.charts.examples.timeline.util.StockPrices)2 ChartType (com.vaadin.flow.component.charts.model.ChartType)2 PlotLine (com.vaadin.flow.component.charts.model.PlotLine)2 PlotOptionsPie (com.vaadin.flow.component.charts.model.PlotOptionsPie)2 RangeSeries (com.vaadin.flow.component.charts.model.RangeSeries)2