use of com.vaadin.addon.charts.model.PlotOptionsWaterfall in project charts by vaadin.
the class ChartTypes method chartTypesWaterfallPlotoptions.
public void chartTypesWaterfallPlotoptions() {
// Define the colors
Chart chart = new Chart();
Configuration conf = chart.getConfiguration();
final Color balanceColor = SolidColor.BLACK;
final Color positiveColor = SolidColor.BLUE;
final Color negativeColor = SolidColor.RED;
// Configure the colors
PlotOptionsWaterfall options = new PlotOptionsWaterfall();
options.setUpColor(positiveColor);
options.setColor(negativeColor);
// Configure the labels
DataLabels labels = new DataLabels(true);
labels.setVerticalAlign(VerticalAlign.TOP);
labels.setY(-20);
labels.setFormatter("Math.floor(this.y/1000) + 'k'");
Style style = new Style();
style.setColor(SolidColor.BLACK);
style.setFontWeight(FontWeight.BOLD);
labels.setStyle(style);
options.setDataLabels(labels);
options.setPointPadding(0);
conf.setPlotOptions(options);
}
use of com.vaadin.addon.charts.model.PlotOptionsWaterfall 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