Search in sources :

Example 1 with PlotOptionsWaterfall

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

the class WaterfallChart method initDemo.

@Override
public void initDemo() {
    Chart chart = new Chart(ChartType.WATERFALL);
    DataSeries dataSeries = new DataSeries();
    dataSeries.add(new DataSeriesItem("Start", 120000));
    dataSeries.add(new DataSeriesItem("Product Revenue", 569000));
    dataSeries.add(new DataSeriesItem("Service Revenue", 231000));
    WaterFallSum positiveBalance = new WaterFallSum("Positive Balance");
    positiveBalance.setIntermediate(true);
    dataSeries.add(positiveBalance);
    dataSeries.add(new DataSeriesItem("Fixed Costs", -342000));
    dataSeries.add(new DataSeriesItem("Variable Costs", -233000));
    WaterFallSum balance = new WaterFallSum("Balance");
    dataSeries.add(balance);
    PlotOptionsWaterfall opts = new PlotOptionsWaterfall();
    DataLabels dataLabels = new DataLabels(true);
    dataLabels.setVerticalAlign(VerticalAlign.TOP);
    dataLabels.setY(-30);
    dataLabels.setFormatter("function() { return this.y / 1000 + 'k'; }");
    opts.setDataLabels(dataLabels);
    dataSeries.setPlotOptions(opts);
    Configuration configuration = chart.getConfiguration();
    configuration.addSeries(dataSeries);
    configuration.getxAxis().setType(AxisType.CATEGORY);
    add(chart);
}
Also used : DataLabels(com.vaadin.flow.component.charts.model.DataLabels) Configuration(com.vaadin.flow.component.charts.model.Configuration) PlotOptionsWaterfall(com.vaadin.flow.component.charts.model.PlotOptionsWaterfall) DataSeries(com.vaadin.flow.component.charts.model.DataSeries) WaterFallSum(com.vaadin.flow.component.charts.model.WaterFallSum) Chart(com.vaadin.flow.component.charts.Chart) DataSeriesItem(com.vaadin.flow.component.charts.model.DataSeriesItem)

Aggregations

Chart (com.vaadin.flow.component.charts.Chart)1 Configuration (com.vaadin.flow.component.charts.model.Configuration)1 DataLabels (com.vaadin.flow.component.charts.model.DataLabels)1 DataSeries (com.vaadin.flow.component.charts.model.DataSeries)1 DataSeriesItem (com.vaadin.flow.component.charts.model.DataSeriesItem)1 PlotOptionsWaterfall (com.vaadin.flow.component.charts.model.PlotOptionsWaterfall)1 WaterFallSum (com.vaadin.flow.component.charts.model.WaterFallSum)1