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);
}
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;
}
Aggregations