@Thilakbabu,
Please try using the following code example:
Presentation presentation = new Presentation();
ISlide slide = presentation.getSlides().get_Item(0);
IChart chart = slide.getShapes().addChart(ChartType.Waterfall, 50, 50, 600, 400);
IChartDataWorkbook workbook = chart.getChartData().getChartDataWorkbook();
workbook.clear(0);
String[] categories = {"PrevYear", "January", "February", "March", "April", "May", "June", "July", "August", "YTD"};
double[] values = {-9, 1, 3, 4, -3, 2, 7, 3, 6, 23};
// populate data
IChartDataWorkbook dataWorkbook = chart.getChartData().getChartDataWorkbook();
for (int i = 0; i < categories.length; i++) {
dataWorkbook.getCell(0, i + 1, 0, categories[i]); // Categories
dataWorkbook.getCell(0, i + 1, 1, values[i]); // Values
}
// set the chart data range
chart.getChartData().setRange("Sheet1!$A$1:$B$" + (categories.length + 1));
IChartSeries series = chart.getChartData().getSeries().get_Item(0);
// hide the connector lines
series.setShowConnectorLines(false);
// hide the series labels
series.getLabels().hide();
for (int i = 0; i < series.getDataPoints().size(); i++)
{
// apply SetAsTotal and Color to the first and last data points
if (i == 0 || i == series.getDataPoints().size() - 1)
{
series.getDataPoints().get_Item(i).setSetAsTotal(true);
series.getDataPoints().get_Item(i).getFormat().getFill().setFillType(FillType.Solid);
series.getDataPoints().get_Item(i).getFormat().getFill().getSolidFillColor().setColor(new Color(128, 128, 128));
continue;
}
// apply Color to the decreased values
if (series.getDataPoints().get_Item(i).getValue().toDouble() < 0)
{
series.getDataPoints().get_Item(i).setSetAsTotal(false);
series.getDataPoints().get_Item(i).getFormat().getFill().setFillType(FillType.Solid);
series.getDataPoints().get_Item(i).getFormat().getFill().getSolidFillColor().setColor(new Color(170, 33, 63));
}
else // apply Color to the increased values
{
series.getDataPoints().get_Item(i).setSetAsTotal(false);
series.getDataPoints().get_Item(i).getFormat().getFill().setFillType(FillType.Solid);
series.getDataPoints().get_Item(i).getFormat().getFill().getSolidFillColor().setColor(new Color(0, 138, 40));
}
}
// hide the grid lines
chart.getAxes().getVerticalAxis().getMajorGridLinesFormat().getLine().getFillFormat().setFillType(FillType.NoFill);
presentation.save("Waterfall.pptx", SaveFormat.Pptx);
presentation.dispose();
The result:
Waterfall.zip (31.5 KB)
We couldn’t do this in PowerPoint. Unfortunately, the legend element cannot be deleted or renamed. We can only implement what PowerPoint itself supports. If you have a presentation where this was done, please share it for analysis.