Search in sources :

Example 11 with DataSeriesItem

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

the class ColumnWithNativeLazyDrilldownMultipleSeries method createSeries.

private void createSeries(int index) {
    DataSeries series = new DataSeries();
    DataSeriesItem item = new DataSeriesItem("MSIE", 55.11 - index - index - index);
    item.setId("MSIE" + index);
    series.addItemWithDrilldown(item);
    item = new DataSeriesItem("Firefox", 21.63 - index);
    item.setId("Firefox" + index);
    series.addItemWithDrilldown(item);
    item = new DataSeriesItem("Chrome", 11.94 + index);
    item.setId("Chrome" + index);
    series.addItemWithDrilldown(item);
    item = new DataSeriesItem("Safari", 7.15 + index + index);
    item.setId("Safari" + index);
    series.addItemWithDrilldown(item);
    item = new DataSeriesItem("Opera", 2.14 + index);
    item.setId("Opera" + index);
    series.addItemWithDrilldown(item);
    conf.addSeries(series);
}
Also used : DataSeries(com.vaadin.flow.component.charts.model.DataSeries) DataSeriesItem(com.vaadin.flow.component.charts.model.DataSeriesItem)

Example 12 with DataSeriesItem

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

the class ColumnLineAndPie method initDemo.

@Override
public void initDemo() {
    Chart chart = new Chart();
    Configuration conf = chart.getConfiguration();
    conf.setTitle("Combined Chart");
    conf.setExporting(true);
    XAxis x = new XAxis();
    x.setCategories(new String[] { "Apples", "Oranges", "Pears", "Bananas", "Plums" });
    conf.addxAxis(x);
    Style labelStyle = new Style();
    labelStyle.setTop("8px");
    labelStyle.setLeft("40px");
    conf.setLabels(new HTMLLabels(labelStyle, new HTMLLabelItem("Total fruit consumption")));
    DataSeries series = new DataSeries();
    PlotOptionsColumn plotOptions = new PlotOptionsColumn();
    series.setPlotOptions(plotOptions);
    series.setName("Jane");
    series.setData(3, 2, 1, 3, 4);
    conf.addSeries(series);
    series = new DataSeries();
    plotOptions = new PlotOptionsColumn();
    series.setPlotOptions(plotOptions);
    series.setName("John");
    series.setData(2, 3, 5, 7, 6);
    conf.addSeries(series);
    series = new DataSeries();
    plotOptions = new PlotOptionsColumn();
    series.setPlotOptions(plotOptions);
    series.setName("Joe");
    series.setData(4, 3, 3, 9, 0);
    conf.addSeries(series);
    series = new DataSeries();
    PlotOptionsSpline splinePlotOptions = new PlotOptionsSpline();
    series.setPlotOptions(splinePlotOptions);
    series.setName("Average");
    series.setData(3, 2.67, 3, 6.33, 3.33);
    conf.addSeries(series);
    series = new DataSeries();
    series.setPlotOptions(new PlotOptionsPie());
    series.setName("Total consumption");
    DataSeriesItem item = new DataSeriesItem("Jane", 13);
    series.add(item);
    item = new DataSeriesItem("John", 23);
    series.add(item);
    item = new DataSeriesItem("Joe", 19);
    series.add(item);
    PlotOptionsPie plotOptionsPie = new PlotOptionsPie();
    plotOptionsPie.setSize("100px");
    plotOptionsPie.setCenter("100px", "80px");
    plotOptionsPie.setShowInLegend(false);
    series.setPlotOptions(plotOptionsPie);
    conf.addSeries(series);
    add(chart);
}
Also used : HTMLLabelItem(com.vaadin.flow.component.charts.model.HTMLLabelItem) PlotOptionsPie(com.vaadin.flow.component.charts.model.PlotOptionsPie) Configuration(com.vaadin.flow.component.charts.model.Configuration) PlotOptionsColumn(com.vaadin.flow.component.charts.model.PlotOptionsColumn) Style(com.vaadin.flow.component.charts.model.style.Style) DataSeries(com.vaadin.flow.component.charts.model.DataSeries) PlotOptionsSpline(com.vaadin.flow.component.charts.model.PlotOptionsSpline) Chart(com.vaadin.flow.component.charts.Chart) XAxis(com.vaadin.flow.component.charts.model.XAxis) DataSeriesItem(com.vaadin.flow.component.charts.model.DataSeriesItem) HTMLLabels(com.vaadin.flow.component.charts.model.HTMLLabels)

Example 13 with DataSeriesItem

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

the class ScatterAndPolygon method initDemo.

@Override
public void initDemo() {
    final Chart chart = new Chart(ChartType.SCATTER);
    Configuration conf = chart.getConfiguration();
    chart.setId("chart");
    conf.getChart().setZoomType(Dimension.XY);
    conf.disableCredits();
    conf.setTitle("Height vs Weight");
    conf.setSubTitle("Polygon series in Vaadin Charts.");
    Tooltip tooltip = conf.getTooltip();
    tooltip.setHeaderFormat("<b>{series.name}</b><br>");
    tooltip.setPointFormat("{point.x} cm, {point.y} kg");
    XAxis xAxis = conf.getxAxis();
    xAxis.setStartOnTick(true);
    xAxis.setEndOnTick(true);
    xAxis.setShowLastLabel(true);
    xAxis.setTitle("Height (cm)");
    YAxis yAxis = conf.getyAxis();
    yAxis.setTitle("Weight (kg)");
    PlotOptionsScatter plotOptionsScatter = new PlotOptionsScatter();
    DataSeries scatter = new DataSeries();
    scatter.setPlotOptions(plotOptionsScatter);
    scatter.setName("Observations");
    fillScatter(scatter);
    DataSeries polygon = new DataSeries();
    PlotOptionsPolygon plotOptionsPolygon = new PlotOptionsPolygon();
    plotOptionsPolygon.setEnableMouseTracking(false);
    polygon.setPlotOptions(plotOptionsPolygon);
    polygon.setName("Target");
    polygon.add(new DataSeriesItem(153, 42));
    polygon.add(new DataSeriesItem(149, 46));
    polygon.add(new DataSeriesItem(149, 55));
    polygon.add(new DataSeriesItem(152, 60));
    polygon.add(new DataSeriesItem(159, 70));
    polygon.add(new DataSeriesItem(170, 77));
    polygon.add(new DataSeriesItem(180, 70));
    polygon.add(new DataSeriesItem(180, 60));
    polygon.add(new DataSeriesItem(173, 52));
    polygon.add(new DataSeriesItem(166, 45));
    conf.addSeries(polygon);
    conf.addSeries(scatter);
    add(chart);
}
Also used : Configuration(com.vaadin.flow.component.charts.model.Configuration) PlotOptionsScatter(com.vaadin.flow.component.charts.model.PlotOptionsScatter) PlotOptionsPolygon(com.vaadin.flow.component.charts.model.PlotOptionsPolygon) Tooltip(com.vaadin.flow.component.charts.model.Tooltip) 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 14 with DataSeriesItem

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

the class ScatterAndPolygon method fillScatter.

private void fillScatter(DataSeries series) {
    // NOSONAR
    Random random = new Random(13);
    for (int i = 0; i < 100; i++) {
        double x = random.nextDouble() * 30 + 150;
        double y = 60;
        if (random.nextBoolean()) {
            y += random.nextDouble() * 15;
            if (random.nextBoolean() && x > 170) {
                y += random.nextDouble() * 30;
            }
        } else {
            y -= random.nextDouble() * 20;
        }
        series.add(new DataSeriesItem(x, y));
    }
}
Also used : Random(java.util.Random) DataSeriesItem(com.vaadin.flow.component.charts.model.DataSeriesItem)

Example 15 with DataSeriesItem

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

the class DynamicChanges method getInitialData.

private List<DataSeriesItem> getInitialData() {
    List<DataSeriesItem> data = new ArrayList<>();
    data.add(new DataSeriesItem("Firefox", 45.0));
    data.add(new DataSeriesItem("IE", 26.8));
    DataSeriesItem chrome = new DataSeriesItem("Chrome", 12.8);
    chrome.setSliced(true);
    chrome.setSelected(true);
    data.add(chrome);
    data.add(new DataSeriesItem("Safari", 8.5));
    data.add(new DataSeriesItem("Opera", 6.2));
    data.add(new DataSeriesItem("Others", 0.7));
    return data;
}
Also used : ArrayList(java.util.ArrayList) DataSeriesItem(com.vaadin.flow.component.charts.model.DataSeriesItem)

Aggregations

DataSeriesItem (com.vaadin.flow.component.charts.model.DataSeriesItem)29 DataSeries (com.vaadin.flow.component.charts.model.DataSeries)26 Chart (com.vaadin.flow.component.charts.Chart)20 Configuration (com.vaadin.flow.component.charts.model.Configuration)20 XAxis (com.vaadin.flow.component.charts.model.XAxis)10 YAxis (com.vaadin.flow.component.charts.model.YAxis)10 Tooltip (com.vaadin.flow.component.charts.model.Tooltip)9 DataLabels (com.vaadin.flow.component.charts.model.DataLabels)6 PlotOptionsColumn (com.vaadin.flow.component.charts.model.PlotOptionsColumn)5 StockPrices (com.vaadin.flow.component.charts.examples.timeline.util.StockPrices)4 AbstractChartExample (com.vaadin.flow.component.charts.examples.AbstractChartExample)3 ChartType (com.vaadin.flow.component.charts.model.ChartType)3 DataLabelsFunnel (com.vaadin.flow.component.charts.model.DataLabelsFunnel)3 PlotLine (com.vaadin.flow.component.charts.model.PlotLine)3 PlotOptionsPie (com.vaadin.flow.component.charts.model.PlotOptionsPie)3 PlotOptionsScatter (com.vaadin.flow.component.charts.model.PlotOptionsScatter)3 RangeSelector (com.vaadin.flow.component.charts.model.RangeSelector)3 AxisTitle (com.vaadin.flow.component.charts.model.AxisTitle)2 Cursor (com.vaadin.flow.component.charts.model.Cursor)2 Legend (com.vaadin.flow.component.charts.model.Legend)2