Search in sources :

Example 1 with WaterFallSum

use of com.vaadin.addon.charts.model.WaterFallSum in project charts by vaadin.

the class ChartTypes method chartTypesWaterfallDataModel.

public void chartTypesWaterfallDataModel() {
    // Define the colors
    Chart chart = new Chart();
    Configuration conf = chart.getConfiguration();
    // The data
    DataSeries series = new DataSeries();
    // The beginning balance
    DataSeriesItem start = new DataSeriesItem("Start", 306503);
    SolidColor balanceColor = SolidColor.KHAKI;
    start.setColor(balanceColor);
    series.add(start);
    // Deltas
    series.add(new DataSeriesItem("Predators", -3330));
    series.add(new DataSeriesItem("Slaughter", -103332));
    series.add(new DataSeriesItem("Reproduction", +104052));
    WaterFallSum end = new WaterFallSum("End");
    end.setColor(balanceColor);
    // Not intermediate (default)
    end.setIntermediate(false);
    series.add(end);
    conf.addSeries(series);
}
Also used : Configuration(com.vaadin.addon.charts.model.Configuration) SolidColor(com.vaadin.addon.charts.model.style.SolidColor) DataSeries(com.vaadin.addon.charts.model.DataSeries) WaterFallSum(com.vaadin.addon.charts.model.WaterFallSum) Chart(com.vaadin.addon.charts.Chart) DataSeriesItem(com.vaadin.addon.charts.model.DataSeriesItem)

Example 2 with WaterFallSum

use of com.vaadin.addon.charts.model.WaterFallSum in project charts by vaadin.

the class WaterfallChartExample method getChart.

@Override
protected Component getChart() {
    Chart chart = new Chart();
    Configuration conf = chart.getConfiguration();
    conf.setTitle((String) null);
    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 positiveBalanse = new WaterFallSum("Positive Balance");
    positiveBalanse.setColor(sumColor);
    positiveBalanse.setIntermediate(true);
    dataSeries.add(positiveBalanse);
    dataSeries.add(new DataSeriesItem("Fixed Costs", -342000));
    dataSeries.add(new DataSeriesItem("Variable Costs", -233000));
    WaterFallSum balance = new WaterFallSum("Balance");
    balance.setColor(sumColor);
    dataSeries.add(balance);
    PlotOptionsWaterfall opts = new PlotOptionsWaterfall();
    opts.setColor(color);
    opts.setUpColor(upColor);
    DataLabels dataLabels = new DataLabels(true);
    dataLabels.setVerticalAlign(VerticalAlign.TOP);
    dataLabels.setY(-30);
    dataLabels.setFormatter("this.y / 1000 + 'k'");
    opts.setDataLabels(dataLabels);
    dataSeries.setPlotOptions(opts);
    conf.addSeries(dataSeries);
    conf.getxAxis().setType(AxisType.CATEGORY);
    return chart;
}
Also used : DataLabels(com.vaadin.addon.charts.model.DataLabels) Configuration(com.vaadin.addon.charts.model.Configuration) PlotOptionsWaterfall(com.vaadin.addon.charts.model.PlotOptionsWaterfall) DataSeries(com.vaadin.addon.charts.model.DataSeries) WaterFallSum(com.vaadin.addon.charts.model.WaterFallSum) Chart(com.vaadin.addon.charts.Chart) DataSeriesItem(com.vaadin.addon.charts.model.DataSeriesItem)

Aggregations

Chart (com.vaadin.addon.charts.Chart)2 Configuration (com.vaadin.addon.charts.model.Configuration)2 DataSeries (com.vaadin.addon.charts.model.DataSeries)2 DataSeriesItem (com.vaadin.addon.charts.model.DataSeriesItem)2 WaterFallSum (com.vaadin.addon.charts.model.WaterFallSum)2 DataLabels (com.vaadin.addon.charts.model.DataLabels)1 PlotOptionsWaterfall (com.vaadin.addon.charts.model.PlotOptionsWaterfall)1 SolidColor (com.vaadin.addon.charts.model.style.SolidColor)1