Search in sources :

Example 6 with DataLabels

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

the class ColumnWithMultiLevelDrilldown method initDemo.

@Override
public void initDemo() {
    final Chart chart = new Chart(ChartType.COLUMN);
    chart.setId("chart");
    final Configuration conf = chart.getConfiguration();
    conf.setTitle("Global happiness index");
    conf.setSubTitle("Source: www.happyplanetindex.org");
    conf.getLegend().setEnabled(false);
    XAxis x = new XAxis();
    x.setType(AxisType.CATEGORY);
    conf.addxAxis(x);
    YAxis y = new YAxis();
    y.setTitle("Total percent market share");
    conf.addyAxis(y);
    PlotOptionsColumn column = new PlotOptionsColumn();
    column.setCursor(Cursor.POINTER);
    column.setDataLabels(new DataLabels(true));
    conf.setPlotOptions(column);
    DataSeries regionsSeries = new DataSeries();
    regionsSeries.setName("Regions");
    PlotOptionsColumn plotOptionsColumn = new PlotOptionsColumn();
    plotOptionsColumn.setColorByPoint(true);
    regionsSeries.setPlotOptions(plotOptionsColumn);
    DataSeriesItem regionItem = new DataSeriesItem("Latin America and Caribbean", 60);
    DataSeries countriesSeries = new DataSeries("Countries");
    countriesSeries.setId("Latin America and Caribbean Countries");
    DataSeriesItem countryItem = new DataSeriesItem("Costa Rica", 64);
    DataSeries detailsSeries = new DataSeries("Details");
    detailsSeries.setId("Details Costa Rica");
    String[] categories = new String[] { "Life Expectancy", "Well-being (0-10)", "Footprint (gha/capita)" };
    Number[] ys = new Number[] { 79.3, 7.3, 2.5 };
    detailsSeries.setData(categories, ys);
    countriesSeries.addItemWithDrilldown(countryItem, detailsSeries);
    countryItem = new DataSeriesItem("Colombia", 59.8);
    detailsSeries = new DataSeries("Details");
    detailsSeries.setId("Details Colombia");
    ys = new Number[] { 73.7, 6.4, 1.8 };
    detailsSeries.setData(categories, ys);
    countriesSeries.addItemWithDrilldown(countryItem, detailsSeries);
    countryItem = new DataSeriesItem("Belize", 59.3);
    detailsSeries = new DataSeries("Details");
    detailsSeries.setId("Details Belize");
    ys = new Number[] { 76.1, 6.5, 2.1 };
    detailsSeries.setData(categories, ys);
    countriesSeries.addItemWithDrilldown(countryItem, detailsSeries);
    countryItem = new DataSeriesItem("El Salvador", 58.9);
    detailsSeries = new DataSeries("Details");
    detailsSeries.setId("Details El Salvador");
    ys = new Number[] { 72.2, 6.7, 2.0 };
    detailsSeries.setData(categories, ys);
    countriesSeries.addItemWithDrilldown(countryItem, detailsSeries);
    regionsSeries.addItemWithDrilldown(regionItem, countriesSeries);
    regionItem = new DataSeriesItem("Western Nations", 50);
    countriesSeries = new DataSeries("Countries");
    countriesSeries.setId("Western Nations Countries");
    countryItem = new DataSeriesItem("New Zealand", 51.6);
    detailsSeries = new DataSeries("Details");
    detailsSeries.setId("Details New Zealand");
    ys = new Number[] { 80.7, 7.2, 4.3 };
    detailsSeries.setData(categories, ys);
    countriesSeries.addItemWithDrilldown(countryItem, detailsSeries);
    countryItem = new DataSeriesItem("Norway", 51.4);
    detailsSeries = new DataSeries("Details");
    detailsSeries.setId("Details Norway");
    ys = new Number[] { 81.1, 7.6, 4.8 };
    detailsSeries.setData(categories, ys);
    countriesSeries.addItemWithDrilldown(countryItem, detailsSeries);
    countryItem = new DataSeriesItem("Switzerland", 50.3);
    detailsSeries = new DataSeries("Details");
    detailsSeries.setId("Details Switzerland");
    ys = new Number[] { 82.3, 7.5, 5.0 };
    detailsSeries.setData(categories, ys);
    countriesSeries.addItemWithDrilldown(countryItem, detailsSeries);
    countryItem = new DataSeriesItem("United Kingdom", 47.9);
    detailsSeries = new DataSeries("Details");
    detailsSeries.setId("Details United Kingdom");
    ys = new Number[] { 80.2, 7.0, 4.7 };
    detailsSeries.setData(categories, ys);
    countriesSeries.addItemWithDrilldown(countryItem, detailsSeries);
    regionsSeries.addItemWithDrilldown(regionItem, countriesSeries);
    regionItem = new DataSeriesItem("Middle East and North Africa", 53);
    countriesSeries = new DataSeries("Countries");
    countriesSeries.setId("Middle East and North Africa Countries");
    countryItem = new DataSeriesItem("Israel", 55.2);
    detailsSeries = new DataSeries("Details");
    detailsSeries.setId("Details Israel");
    ys = new Number[] { 81.6, 7.4, 4.0 };
    detailsSeries.setData(categories, ys);
    countriesSeries.addItemWithDrilldown(countryItem, detailsSeries);
    countryItem = new DataSeriesItem("Algeria", 52.2);
    detailsSeries = new DataSeries("Details");
    detailsSeries.setId("Details Algeria");
    ys = new Number[] { 73.1, 5.2, 1.6 };
    detailsSeries.setData(categories, ys);
    countriesSeries.addItemWithDrilldown(countryItem, detailsSeries);
    countryItem = new DataSeriesItem("Jordan", 51.7);
    detailsSeries = new DataSeries("Details");
    detailsSeries.setId("Details Jordan");
    ys = new Number[] { 73.4, 5.7, 2.1 };
    detailsSeries.setData(categories, ys);
    countriesSeries.addItemWithDrilldown(countryItem, detailsSeries);
    countryItem = new DataSeriesItem("Palestine", 51.2);
    detailsSeries = new DataSeries("Details");
    detailsSeries.setId("Details Palestine");
    ys = new Number[] { 72.8, 4.8, 1.4 };
    detailsSeries.setData(categories, ys);
    countriesSeries.addItemWithDrilldown(countryItem, detailsSeries);
    regionsSeries.addItemWithDrilldown(regionItem, countriesSeries);
    regionItem = new DataSeriesItem("Sub-Saharan Africa", 42);
    countriesSeries = new DataSeries("Countries");
    countriesSeries.setId("Sub-Saharan Africa Countries");
    countryItem = new DataSeriesItem("Nigeria", 51.6);
    detailsSeries = new DataSeries("Details");
    detailsSeries.setId("Details Nigeria");
    ys = new Number[] { 66.7, 4.6, 1.2 };
    detailsSeries.setData(categories, ys);
    countriesSeries.addItemWithDrilldown(countryItem, detailsSeries);
    countryItem = new DataSeriesItem("Malawi", 42.5);
    detailsSeries = new DataSeries("Details");
    detailsSeries.setId("Details Malawi");
    ys = new Number[] { 54.2, 5.1, 0.8 };
    detailsSeries.setData(categories, ys);
    countriesSeries.addItemWithDrilldown(countryItem, detailsSeries);
    countryItem = new DataSeriesItem("Ghana", 40.3);
    detailsSeries = new DataSeries("Details");
    detailsSeries.setId("Details Ghana");
    ys = new Number[] { 64.2, 4.6, 1.7 };
    detailsSeries.setData(categories, ys);
    countriesSeries.addItemWithDrilldown(countryItem, detailsSeries);
    countryItem = new DataSeriesItem("Ethiopia", 39.2);
    detailsSeries = new DataSeries("Details");
    detailsSeries.setId("Details Ethiopia");
    ys = new Number[] { 59.3, 4.4, 1.1 };
    detailsSeries.setData(categories, ys);
    countriesSeries.addItemWithDrilldown(countryItem, detailsSeries);
    regionsSeries.addItemWithDrilldown(regionItem, countriesSeries);
    regionItem = new DataSeriesItem("South Asia", 53);
    countriesSeries = new DataSeries("Countries");
    countriesSeries.setId("South Asia Countries");
    countryItem = new DataSeriesItem("Bangladesh", 56.3);
    detailsSeries = new DataSeries("Details");
    detailsSeries.setId("Details Bangladesh");
    ys = new Number[] { 68.9, 5.0, 0.7 };
    detailsSeries.setData(categories, ys);
    countriesSeries.addItemWithDrilldown(countryItem, detailsSeries);
    countryItem = new DataSeriesItem("Pakistan", 54.1);
    detailsSeries = new DataSeries("Details");
    detailsSeries.setId("Details Pakistan");
    ys = new Number[] { 65.4, 5.3, 0.8 };
    detailsSeries.setData(categories, ys);
    countriesSeries.addItemWithDrilldown(countryItem, detailsSeries);
    countryItem = new DataSeriesItem("India", 50.9);
    detailsSeries = new DataSeries("Details");
    detailsSeries.setId("Details India");
    ys = new Number[] { 65.4, 5.0, 0.9 };
    detailsSeries.setData(categories, ys);
    countriesSeries.addItemWithDrilldown(countryItem, detailsSeries);
    countryItem = new DataSeriesItem("Sri Lanka", 51.2);
    detailsSeries = new DataSeries("Details");
    detailsSeries.setId("Details Sri Lanka");
    ys = new Number[] { 74.9, 4.2, 1.2 };
    detailsSeries.setData(categories, ys);
    countriesSeries.addItemWithDrilldown(countryItem, detailsSeries);
    regionsSeries.addItemWithDrilldown(regionItem, countriesSeries);
    regionItem = new DataSeriesItem("East Asia", 55);
    countriesSeries = new DataSeries("Countries");
    countriesSeries.setId("East Asia Countries");
    countryItem = new DataSeriesItem("Vietnam", 60.4);
    detailsSeries = new DataSeries("Details");
    detailsSeries.setId("Details Vietnam");
    ys = new Number[] { 75.2, 5.8, 1.4 };
    detailsSeries.setData(categories, ys);
    countriesSeries.addItemWithDrilldown(countryItem, detailsSeries);
    countryItem = new DataSeriesItem("Indonesia", 55.5);
    detailsSeries = new DataSeries("Details");
    detailsSeries.setId("Details Indonesia");
    ys = new Number[] { 69.4, 5.5, 1.1 };
    detailsSeries.setData(categories, ys);
    countriesSeries.addItemWithDrilldown(countryItem, detailsSeries);
    countryItem = new DataSeriesItem("Thailand", 53.5);
    detailsSeries = new DataSeries("Details");
    detailsSeries.setId("Details Thailand");
    ys = new Number[] { 74.1, 6.2, 2.4 };
    detailsSeries.setData(categories, ys);
    countriesSeries.addItemWithDrilldown(countryItem, detailsSeries);
    countryItem = new DataSeriesItem("Philippines", 52.4);
    detailsSeries = new DataSeries("Details");
    detailsSeries.setId("Details Philippines");
    ys = new Number[] { 68.7, 4.9, 1.0 };
    detailsSeries.setData(categories, ys);
    countriesSeries.addItemWithDrilldown(countryItem, detailsSeries);
    regionsSeries.addItemWithDrilldown(regionItem, countriesSeries);
    conf.addSeries(regionsSeries);
    add(chart);
}
Also used : DataLabels(com.vaadin.flow.component.charts.model.DataLabels) Configuration(com.vaadin.flow.component.charts.model.Configuration) PlotOptionsColumn(com.vaadin.flow.component.charts.model.PlotOptionsColumn) DataSeries(com.vaadin.flow.component.charts.model.DataSeries) Chart(com.vaadin.flow.component.charts.Chart) XAxis(com.vaadin.flow.component.charts.model.XAxis) DataSeriesItem(com.vaadin.flow.component.charts.model.DataSeriesItem) YAxis(com.vaadin.flow.component.charts.model.YAxis)

Example 7 with DataLabels

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

the class ColumnWithNativeLazyDrilldownByIndex method initDemo.

@Override
public void initDemo() {
    final Chart chart = new Chart(ChartType.COLUMN);
    chart.setId("chart");
    conf = chart.getConfiguration();
    conf.setTitle("Browser market share, April, 2011");
    conf.setSubTitle("Click the columns to view versions. Click again to view brands.");
    conf.getLegend().setEnabled(false);
    XAxis x = new XAxis();
    x.setType(AxisType.CATEGORY);
    conf.addxAxis(x);
    YAxis y = new YAxis();
    y.setTitle("Total percent market share");
    conf.addyAxis(y);
    PlotOptionsColumn column = new PlotOptionsColumn();
    column.setCursor(Cursor.POINTER);
    column.setDataLabels(new DataLabels(true));
    conf.setPlotOptions(column);
    Tooltip tooltip = new Tooltip();
    tooltip.setEnabled(false);
    conf.setTooltip(tooltip);
    topCategories = new String[] { "MSIE", "Firefox", "Chrome", "Safari", "Opera" };
    DataSeries series = new DataSeries();
    series.setName("Browser brands");
    PlotOptionsColumn plotOptionsColumn = new PlotOptionsColumn();
    plotOptionsColumn.setColorByPoint(true);
    series.setPlotOptions(plotOptionsColumn);
    DataSeriesItem item = new DataSeriesItem("MSIE", 55.11);
    series.addItemWithDrilldown(item);
    item = new DataSeriesItem("Firefox", 21.63);
    series.addItemWithDrilldown(item);
    item = new DataSeriesItem("Chrome", 11.94);
    series.addItemWithDrilldown(item);
    item = new DataSeriesItem("Safari", 7.15);
    series.addItemWithDrilldown(item);
    item = new DataSeriesItem("Opera", 2.14);
    series.addItemWithDrilldown(item);
    conf.addSeries(series);
    drillSeries = new HashMap<String, DataSeries>();
    DataSeries drill = new DataSeries("MSIE versions");
    String[] categories = new String[] { "MSIE 6.0", "MSIE 7.0", "MSIE 8.0", "MSIE 9.0" };
    Number[] ys = new Number[] { 10.85, 7.35, 33.06, 2.81 };
    drill.setData(categories, ys);
    drill.setId("MSIE");
    drillSeries.put("MSIE", drill);
    drill = new DataSeries("Firefox versions");
    categories = new String[] { "Firefox 2.0", "Firefox 3.0", "Firefox 3.5", "Firefox 3.6", "Firefox 4.0" };
    ys = new Number[] { 0.20, 0.83, 1.58, 13.12, 5.43 };
    drill.setData(categories, ys);
    drill.setId("Firefox");
    drillSeries.put("Firefox", drill);
    drill = new DataSeries("Chrome versions");
    categories = new String[] { "Chrome 5.0", "Chrome 6.0", "Chrome 7.0", "Chrome 8.0", "Chrome 9.0", "Chrome 10.0", "Chrome 11.0", "Chrome 12.0" };
    ys = new Number[] { 0.12, 0.19, 0.12, 0.36, 0.32, 9.91, 0.50, 0.22 };
    drill.setData(categories, ys);
    drill.setId("Chrome");
    drillSeries.put("Chrome", drill);
    drill = new DataSeries("Safari versions");
    categories = new String[] { "Safari 5.0", "Safari 4.0", "Safari Win 5.0", "Safari 4.1", "Safari/Maxthon", "Safari 3.1", "Safari 4.1" };
    ys = new Number[] { 4.55, 1.42, 0.23, 0.21, 0.20, 0.19, 0.14 };
    drill.setData(categories, ys);
    drill.setId("Safari");
    drillSeries.put("Safari", drill);
    drill = new DataSeries("Opera versions");
    categories = new String[] { "Opera 9.x", "Opera 10.x", "Opera 11.x" };
    ys = new Number[] { 0.12, 0.37, 1.65 };
    drill.setData(categories, ys);
    drill.setId("Opera");
    drillSeries.put("Opera", drill);
    chart.setDrilldownCallback(event -> getPointDrilldown(event.getItemIndex()));
    add(chart);
}
Also used : DataLabels(com.vaadin.flow.component.charts.model.DataLabels) Tooltip(com.vaadin.flow.component.charts.model.Tooltip) XAxis(com.vaadin.flow.component.charts.model.XAxis) PlotOptionsColumn(com.vaadin.flow.component.charts.model.PlotOptionsColumn) DataSeries(com.vaadin.flow.component.charts.model.DataSeries) Chart(com.vaadin.flow.component.charts.Chart) DataSeriesItem(com.vaadin.flow.component.charts.model.DataSeriesItem) YAxis(com.vaadin.flow.component.charts.model.YAxis)

Example 8 with DataLabels

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

the class DynamicExtremes method initDemo.

@Override
public void initDemo() {
    Chart chart = new Chart();
    Configuration configuration = chart.getConfiguration();
    configuration.getChart().setType(ChartType.LINE);
    configuration.getChart().setMarginRight(130);
    configuration.getChart().setMarginBottom(25);
    configuration.getTitle().setText("Monthly Average Temperature");
    configuration.getSubTitle().setText("Source: WorldClimate.com");
    configuration.getxAxis().setCategories("Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec");
    YAxis yAxis = configuration.getyAxis();
    yAxis.setMin(-10d);
    yAxis.setMax(30d);
    yAxis.setTitle(new AxisTitle("Temperature (°C)"));
    yAxis.getTitle().setAlign(VerticalAlign.HIGH);
    configuration.getTooltip().setFormatter("return '<b>'+ this.series.name +'</b><br/>'+this.x +': '+ this.y +'°C'");
    PlotOptionsLine plotOptions = new PlotOptionsLine();
    plotOptions.setDataLabels(new DataLabels(true));
    configuration.setPlotOptions(plotOptions);
    Legend legend = configuration.getLegend();
    legend.setLayout(LayoutDirection.VERTICAL);
    legend.setAlign(HorizontalAlign.RIGHT);
    legend.setVerticalAlign(VerticalAlign.TOP);
    legend.setX(-10d);
    legend.setY(100d);
    ListSeries ls = new ListSeries();
    ls.setName("Tokyo");
    ls.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);
    configuration.addSeries(ls);
    ls = new ListSeries();
    ls.setName("New York");
    ls.setData(-0.2, 0.8, 5.7, 11.3, 17.0, 22.0, 24.8, 24.1, 20.1, 14.1, 8.6, 2.5);
    configuration.addSeries(ls);
    ls = new ListSeries();
    ls.setName("Berlin");
    ls.setData(-0.9, 0.6, 3.5, 8.4, 13.5, 17.0, 18.6, 17.9, 14.3, 9.0, 3.9, 1.0);
    configuration.addSeries(ls);
    ls = new ListSeries();
    ls.setName("London");
    ls.setData(3.9, 4.2, 5.7, 8.5, 11.9, 15.2, 17.0, 16.6, 14.2, 10.3, 6.6, 4.8);
    configuration.addSeries(ls);
    NativeButton toggleExtremesButton = new NativeButton("Toggle extremes", e -> {
        if (setExtremes) {
            chart.getConfiguration().getyAxes().getAxis(0).setExtremes(10, 15);
        } else {
            chart.getConfiguration().resetZoom();
        }
        setExtremes = !setExtremes;
    });
    toggleExtremesButton.setId("toggleExtremesButton");
    add(chart, toggleExtremesButton);
}
Also used : NativeButton(com.vaadin.flow.component.html.NativeButton) Legend(com.vaadin.flow.component.charts.model.Legend) DataLabels(com.vaadin.flow.component.charts.model.DataLabels) Configuration(com.vaadin.flow.component.charts.model.Configuration) PlotOptionsLine(com.vaadin.flow.component.charts.model.PlotOptionsLine) ListSeries(com.vaadin.flow.component.charts.model.ListSeries) AxisTitle(com.vaadin.flow.component.charts.model.AxisTitle) Chart(com.vaadin.flow.component.charts.Chart) YAxis(com.vaadin.flow.component.charts.model.YAxis)

Example 9 with DataLabels

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

the class BasicLineWithCallouts method initDemo.

@Override
public void initDemo() {
    Chart chart = new Chart();
    Configuration configuration = chart.getConfiguration();
    configuration.getChart().setType(ChartType.LINE);
    configuration.getTitle().setText("CALLOUT: Monthly Average Temperature");
    configuration.getSubTitle().setText("Source: WorldClimate.com");
    configuration.getxAxis().setCategories("Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec");
    YAxis yAxis = configuration.getyAxis();
    yAxis.setTitle(new AxisTitle("Temperature (°C)"));
    configuration.getTooltip().setFormatter("'<b>'+ this.series.name +'</b><br/>'+this.x +': '+ this.y +'°C'");
    PlotOptionsLine plotOptions = new PlotOptionsLine();
    plotOptions.setEnableMouseTracking(false);
    configuration.setPlotOptions(plotOptions);
    DataSeries ds = new DataSeries();
    ds.setName("Tokyo");
    ds.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);
    DataLabels callout = new DataLabels(true);
    callout.setShape(Shape.CALLOUT);
    callout.setY(-12);
    ds.get(5).setDataLabels(callout);
    configuration.addSeries(ds);
    ds = new DataSeries();
    ds.setName("London");
    ds.setData(3.9, 4.2, 5.7, 8.5, 11.9, 15.2, 17.0, 16.6, 14.2, 10.3, 6.6, 4.8);
    ds.get(6).setDataLabels(callout);
    configuration.addSeries(ds);
    add(chart);
}
Also used : DataLabels(com.vaadin.flow.component.charts.model.DataLabels) Configuration(com.vaadin.flow.component.charts.model.Configuration) PlotOptionsLine(com.vaadin.flow.component.charts.model.PlotOptionsLine) DataSeries(com.vaadin.flow.component.charts.model.DataSeries) AxisTitle(com.vaadin.flow.component.charts.model.AxisTitle) Chart(com.vaadin.flow.component.charts.Chart) YAxis(com.vaadin.flow.component.charts.model.YAxis)

Example 10 with DataLabels

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

the class GaugeWithDualAxes method initDemo.

@Override
public void initDemo() {
    // NOSONAR
    final Random random = new Random(0);
    final Chart chart = new Chart();
    final Configuration configuration = chart.getConfiguration();
    configuration.getChart().setType(ChartType.GAUGE);
    configuration.setTitle("Speedometer with dual axes");
    configuration.getChart().setWidth(500);
    configuration.getPane().setStartAngle(-150);
    configuration.getPane().setEndAngle(150);
    YAxis yAxis = new YAxis();
    yAxis.setClassName("kmh");
    yAxis.setMin(0);
    yAxis.setMax(200);
    yAxis.setOffset(-25);
    Labels labels = new Labels();
    labels.setDistance(-20);
    labels.setRotation("auto");
    yAxis.setLabels(labels);
    yAxis.setTickLength(5);
    yAxis.setMinorTickLength(5);
    yAxis.setEndOnTick(false);
    YAxis yAxis2 = new YAxis();
    yAxis2.setClassName("mph");
    yAxis2.setMin(0);
    yAxis2.setMax(124);
    yAxis2.setOffset(-20);
    labels = new Labels();
    labels.setDistance(12);
    labels.setRotation("auto");
    yAxis2.setLabels(labels);
    yAxis2.setTickPosition(TickPosition.OUTSIDE);
    yAxis2.setMinorTickPosition(TickPosition.OUTSIDE);
    yAxis2.setTickLength(5);
    yAxis2.setMinorTickLength(5);
    yAxis2.setEndOnTick(false);
    configuration.addyAxis(yAxis);
    configuration.addyAxis(yAxis2);
    final ListSeries series = new ListSeries("Speed", 80);
    PlotOptionsGauge plotOptionsGauge = new PlotOptionsGauge();
    plotOptionsGauge.setDataLabels(new DataLabels());
    plotOptionsGauge.getDataLabels().setFormatter("function() {return '<span class=\"kmh\">'+ this.y + ' km/h</span><br/>' + '<span class=\"mph\">' + Math.round(this.y * 0.621) + ' mph</span>';}");
    plotOptionsGauge.setTooltip(new SeriesTooltip());
    plotOptionsGauge.getTooltip().setValueSuffix(" km/h");
    series.setPlotOptions(plotOptionsGauge);
    configuration.addSeries(series);
    runWhileAttached(chart, () -> {
        Integer oldValue = series.getData()[0].intValue();
        Integer newValue = (int) (oldValue + (random.nextDouble() - 0.5) * 20.0);
        series.updatePoint(0, newValue);
    }, 5000, 12000);
    chart.drawChart();
    add(chart);
}
Also used : PlotOptionsGauge(com.vaadin.flow.component.charts.model.PlotOptionsGauge) DataLabels(com.vaadin.flow.component.charts.model.DataLabels) Random(java.util.Random) Configuration(com.vaadin.flow.component.charts.model.Configuration) ListSeries(com.vaadin.flow.component.charts.model.ListSeries) Labels(com.vaadin.flow.component.charts.model.Labels) DataLabels(com.vaadin.flow.component.charts.model.DataLabels) Chart(com.vaadin.flow.component.charts.Chart) YAxis(com.vaadin.flow.component.charts.model.YAxis) SeriesTooltip(com.vaadin.flow.component.charts.model.SeriesTooltip)

Aggregations

DataLabels (com.vaadin.flow.component.charts.model.DataLabels)16 Chart (com.vaadin.flow.component.charts.Chart)15 Configuration (com.vaadin.flow.component.charts.model.Configuration)12 YAxis (com.vaadin.flow.component.charts.model.YAxis)10 DataSeries (com.vaadin.flow.component.charts.model.DataSeries)9 DataSeriesItem (com.vaadin.flow.component.charts.model.DataSeriesItem)6 PlotOptionsColumn (com.vaadin.flow.component.charts.model.PlotOptionsColumn)6 XAxis (com.vaadin.flow.component.charts.model.XAxis)6 Tooltip (com.vaadin.flow.component.charts.model.Tooltip)4 AxisTitle (com.vaadin.flow.component.charts.model.AxisTitle)3 ListSeries (com.vaadin.flow.component.charts.model.ListSeries)3 Level (com.vaadin.flow.component.charts.model.Level)2 PlotOptionsLine (com.vaadin.flow.component.charts.model.PlotOptionsLine)2 SeriesTooltip (com.vaadin.flow.component.charts.model.SeriesTooltip)2 SolidColor (com.vaadin.flow.component.charts.model.style.SolidColor)2 Div (com.vaadin.flow.component.html.Div)2 NativeButton (com.vaadin.flow.component.html.NativeButton)2 Text (com.vaadin.flow.component.Text)1 AbstractChartExample (com.vaadin.flow.component.charts.examples.AbstractChartExample)1 AxisType (com.vaadin.flow.component.charts.model.AxisType)1