Search in sources :

Example 1 with PlotOptionsArea

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

the class Polar method initDemo.

@Override
public void initDemo() {
    Chart chart = new Chart();
    Configuration conf = chart.getConfiguration();
    conf.getChart().setPolar(true);
    conf.setTitle("Polar Chart");
    Pane pane = new Pane(0, 360);
    conf.addPane(pane);
    XAxis xAxis = new XAxis();
    xAxis.setTickInterval(45);
    xAxis.setMin(0);
    xAxis.setMax(360);
    Labels labels = new Labels();
    labels.setFormatter("function() {return this.value + '°';}");
    xAxis.setLabels(labels);
    YAxis yAxis = new YAxis();
    yAxis.setMin(0);
    conf.addxAxis(xAxis);
    conf.addyAxis(yAxis);
    PlotOptionsSeries series = new PlotOptionsSeries();
    PlotOptionsColumn column = new PlotOptionsColumn();
    series.setPointStart(0);
    series.setPointInterval(45);
    column.setPointPadding(0);
    column.setGroupPadding(0);
    conf.setPlotOptions(series, column);
    ListSeries col = new ListSeries(8, 7, 6, 5, 4, 3, 2, 1);
    ListSeries line = new ListSeries(1, 2, 3, 4, 5, 6, 7, 8);
    ListSeries area = new ListSeries(1, 8, 2, 7, 3, 6, 4, 5);
    col.setPlotOptions(new PlotOptionsColumn());
    col.setName(ChartType.COLUMN.toString());
    line.setPlotOptions(new PlotOptionsLine());
    line.setName(ChartType.LINE.toString());
    area.setPlotOptions(new PlotOptionsArea());
    area.setName(ChartType.AREA.toString());
    conf.setSeries(col, line, area);
    add(chart);
}
Also used : Configuration(com.vaadin.flow.component.charts.model.Configuration) PlotOptionsColumn(com.vaadin.flow.component.charts.model.PlotOptionsColumn) ListSeries(com.vaadin.flow.component.charts.model.ListSeries) PlotOptionsLine(com.vaadin.flow.component.charts.model.PlotOptionsLine) PlotOptionsArea(com.vaadin.flow.component.charts.model.PlotOptionsArea) Labels(com.vaadin.flow.component.charts.model.Labels) Pane(com.vaadin.flow.component.charts.model.Pane) 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 2 with PlotOptionsArea

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

the class DynamicChangingChart method getPolarConfiguration.

public Configuration getPolarConfiguration() {
    Configuration configuration = new Configuration();
    configuration.getChart().setPolar(true);
    configuration.setTitle("Polar Chart");
    Pane pane = new Pane(0, 360);
    configuration.addPane(pane);
    XAxis xAxis = new XAxis();
    xAxis.setTickInterval(45);
    xAxis.setMin(0);
    xAxis.setMax(360);
    Labels labels = new Labels();
    labels.setFormatter("function() {return this.value + '°';}");
    xAxis.setLabels(labels);
    YAxis yAxis = new YAxis();
    yAxis.setMin(0);
    configuration.addxAxis(xAxis);
    configuration.addyAxis(yAxis);
    PlotOptionsSeries series = new PlotOptionsSeries();
    PlotOptionsColumn column = new PlotOptionsColumn();
    series.setPointStart(0);
    series.setPointInterval(45);
    column.setPointPadding(0);
    column.setGroupPadding(0);
    configuration.setPlotOptions(series, column);
    ListSeries col = new ListSeries(8, 7, 6, 5, 4, 3, 2, 1);
    ListSeries line = new ListSeries(1, 2, 3, 4, 5, 6, 7, 8);
    ListSeries area = new ListSeries(1, 8, 2, 7, 3, 6, 4, 5);
    col.setPlotOptions(new PlotOptionsColumn());
    col.setName(ChartType.COLUMN.toString());
    line.setPlotOptions(new PlotOptionsLine());
    line.setName(ChartType.LINE.toString());
    area.setPlotOptions(new PlotOptionsArea());
    area.setName(ChartType.AREA.toString());
    configuration.setSeries(col, line, area);
    return configuration;
}
Also used : Configuration(com.vaadin.flow.component.charts.model.Configuration) PlotOptionsColumn(com.vaadin.flow.component.charts.model.PlotOptionsColumn) ListSeries(com.vaadin.flow.component.charts.model.ListSeries) PlotOptionsLine(com.vaadin.flow.component.charts.model.PlotOptionsLine) PlotOptionsArea(com.vaadin.flow.component.charts.model.PlotOptionsArea) Labels(com.vaadin.flow.component.charts.model.Labels) Pane(com.vaadin.flow.component.charts.model.Pane) 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 3 with PlotOptionsArea

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

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

Configuration (com.vaadin.flow.component.charts.model.Configuration)4 ListSeries (com.vaadin.flow.component.charts.model.ListSeries)4 PlotOptionsArea (com.vaadin.flow.component.charts.model.PlotOptionsArea)4 XAxis (com.vaadin.flow.component.charts.model.XAxis)4 YAxis (com.vaadin.flow.component.charts.model.YAxis)4 Chart (com.vaadin.flow.component.charts.Chart)3 Labels (com.vaadin.flow.component.charts.model.Labels)2 Pane (com.vaadin.flow.component.charts.model.Pane)2 PlotOptionsColumn (com.vaadin.flow.component.charts.model.PlotOptionsColumn)2 PlotOptionsLine (com.vaadin.flow.component.charts.model.PlotOptionsLine)2 PlotOptionsSeries (com.vaadin.flow.component.charts.model.PlotOptionsSeries)2 AxisTitle (com.vaadin.flow.component.charts.model.AxisTitle)1 Legend (com.vaadin.flow.component.charts.model.Legend)1 PlotBand (com.vaadin.flow.component.charts.model.PlotBand)1 Title (com.vaadin.flow.component.charts.model.Title)1 Tooltip (com.vaadin.flow.component.charts.model.Tooltip)1