Search in sources :

Example 11 with ListSeries

use of com.vaadin.flow.component.charts.model.ListSeries 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 12 with ListSeries

use of com.vaadin.flow.component.charts.model.ListSeries 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)

Example 13 with ListSeries

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

the class Column method initDemo.

@Override
public void initDemo() {
    Chart chart = new Chart();
    Configuration configuration = chart.getConfiguration();
    configuration.setTitle("Monthly Average Rainfall");
    configuration.setSubTitle("Source: WorldClimate.com");
    chart.getConfiguration().getChart().setType(ChartType.COLUMN);
    configuration.addSeries(new ListSeries("Tokyo", 49.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(new ListSeries("New York", 83.6, 78.8, 98.5, 93.4, 106.0, 84.5, 105.0, 104.3, 91.2, 83.5, 106.6, 92.3));
    configuration.addSeries(new ListSeries("London", 48.9, 38.8, 39.3, 41.4, 47.0, 48.3, 59.0, 59.6, 52.4, 65.2, 59.3, 51.2));
    configuration.addSeries(new ListSeries("Berlin", 42.4, 33.2, 34.5, 39.7, 52.6, 75.5, 57.4, 60.4, 47.6, 39.1, 46.8, 51.1));
    XAxis x = new XAxis();
    x.setCrosshair(new Crosshair());
    x.setCategories("Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec");
    configuration.addxAxis(x);
    YAxis y = new YAxis();
    y.setMin(0);
    y.setTitle("Rainfall (mm)");
    configuration.addyAxis(y);
    Tooltip tooltip = new Tooltip();
    tooltip.setShared(true);
    configuration.setTooltip(tooltip);
    add(chart);
}
Also used : Configuration(com.vaadin.flow.component.charts.model.Configuration) ListSeries(com.vaadin.flow.component.charts.model.ListSeries) Crosshair(com.vaadin.flow.component.charts.model.Crosshair) Tooltip(com.vaadin.flow.component.charts.model.Tooltip) Chart(com.vaadin.flow.component.charts.Chart) XAxis(com.vaadin.flow.component.charts.model.XAxis) YAxis(com.vaadin.flow.component.charts.model.YAxis)

Example 14 with ListSeries

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

the class ColumnWithNegativeValues method initDemo.

@Override
public void initDemo() {
    Chart chart = new Chart(ChartType.COLUMN);
    Configuration conf = chart.getConfiguration();
    conf.setTitle(new Title("Column chart with negative values"));
    PlotOptionsColumn column = new PlotOptionsColumn();
    column.setMinPointLength(3);
    conf.setPlotOptions(column);
    XAxis xAxis = new XAxis();
    xAxis.setCategories("Apples", "Oranges", "Pears", "Grapes", "Bananas");
    conf.addxAxis(xAxis);
    Tooltip tooltip = new Tooltip();
    tooltip.setFormatter("function() { return ''+ this.series.name +': '+ this.y +'';}");
    conf.setTooltip(tooltip);
    conf.setCredits(new Credits(false));
    conf.addSeries(new ListSeries("John", 5, 0.1, 4, 7, 2));
    conf.addSeries(new ListSeries("Jane", 2, -2, -0.1, 2, 1));
    conf.addSeries(new ListSeries("Joe", 3, 4, 4, -2, 5));
    add(chart);
}
Also used : Credits(com.vaadin.flow.component.charts.model.Credits) Configuration(com.vaadin.flow.component.charts.model.Configuration) PlotOptionsColumn(com.vaadin.flow.component.charts.model.PlotOptionsColumn) ListSeries(com.vaadin.flow.component.charts.model.ListSeries) Tooltip(com.vaadin.flow.component.charts.model.Tooltip) Title(com.vaadin.flow.component.charts.model.Title) Chart(com.vaadin.flow.component.charts.Chart) XAxis(com.vaadin.flow.component.charts.model.XAxis)

Example 15 with ListSeries

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

the class Area method initDemo.

@Override
public void initDemo() {
    Chart chart = new Chart(ChartType.AREA);
    final Configuration configuration = chart.getConfiguration();
    configuration.setTitle("Historic and Estimated Worldwide Population Growth by Region");
    configuration.setSubTitle("Source: Wikipedia.org");
    XAxis xAxis = configuration.getxAxis();
    xAxis.setCategories("1750", "1800", "1850", "1900", "1950", "1999", "2050");
    xAxis.setTickmarkPlacement(TickmarkPlacement.ON);
    YAxis yAxis = configuration.getyAxis();
    yAxis.setTitle("Billions");
    yAxis.getLabels().setFormatter("function () { return this.value / 1000;}");
    configuration.getTooltip().setValueSuffix(" millions");
    PlotOptionsArea plotOptionsArea = new PlotOptionsArea();
    plotOptionsArea.setStacking(Stacking.NORMAL);
    configuration.setPlotOptions(plotOptionsArea);
    configuration.addSeries(new ListSeries("Asia", 502, 635, 809, 947, 1402, 3634, 5268));
    configuration.addSeries(new ListSeries("Africa", 106, 107, 111, 133, 221, 767, 1766));
    configuration.addSeries(new ListSeries("Europe", 163, 203, 276, 408, 547, 729, 628));
    configuration.addSeries(new ListSeries("America", 18, 31, 54, 156, 339, 818, 1201));
    configuration.addSeries(new ListSeries("Oceania", 2, 2, 2, 6, 13, 30, 46));
    add(chart);
}
Also used : Configuration(com.vaadin.flow.component.charts.model.Configuration) PlotOptionsArea(com.vaadin.flow.component.charts.model.PlotOptionsArea) ListSeries(com.vaadin.flow.component.charts.model.ListSeries) Chart(com.vaadin.flow.component.charts.Chart) XAxis(com.vaadin.flow.component.charts.model.XAxis) YAxis(com.vaadin.flow.component.charts.model.YAxis)

Aggregations

ListSeries (com.vaadin.flow.component.charts.model.ListSeries)26 Configuration (com.vaadin.flow.component.charts.model.Configuration)24 YAxis (com.vaadin.flow.component.charts.model.YAxis)21 Chart (com.vaadin.flow.component.charts.Chart)17 XAxis (com.vaadin.flow.component.charts.model.XAxis)17 Tooltip (com.vaadin.flow.component.charts.model.Tooltip)11 PlotOptionsSeries (com.vaadin.flow.component.charts.model.PlotOptionsSeries)7 Labels (com.vaadin.flow.component.charts.model.Labels)5 Legend (com.vaadin.flow.component.charts.model.Legend)5 PlotOptionsColumn (com.vaadin.flow.component.charts.model.PlotOptionsColumn)5 AxisTitle (com.vaadin.flow.component.charts.model.AxisTitle)4 PlotOptionsArea (com.vaadin.flow.component.charts.model.PlotOptionsArea)4 Test (org.junit.Test)4 Crosshair (com.vaadin.flow.component.charts.model.Crosshair)3 DataLabels (com.vaadin.flow.component.charts.model.DataLabels)3 Pane (com.vaadin.flow.component.charts.model.Pane)3 PlotOptionsLine (com.vaadin.flow.component.charts.model.PlotOptionsLine)3 SeriesTooltip (com.vaadin.flow.component.charts.model.SeriesTooltip)3 NativeButton (com.vaadin.flow.component.html.NativeButton)3 ArrayList (java.util.ArrayList)3