I’m setting the colour of data points on a stacked bar chart. In the template PPTX, ‘Invert if negative’ is not set on the series or any of the data points. After clearing the series in code, and adding new points using ChartSeries.addPointForBarSeries, I’m calling:
Presentation pres = new Presentation("testing.pptx");
//Access first slide
ISlide sld = pres.getSlides().get_Item(0);
IChart chart = null;
for (int i = 0; i < sld.getShapes().size(); i++)
{
if (sld.getShapes().get_Item(i).getAlternativeText().compareTo("testchart") == 0)
chart = (IChart) sld.getShapes().get_Item(i);
}
IChartSeries series = chart.getChartData().getSeries().get_Item(0);
series.getDataPoints().clear();
int defaultWorksheetIndex = 0;
IChartDataWorkbook fact = chart.getChartData().getChartDataWorkbook();
IChartDataPoint p1 = series.getDataPoints().addDataPointForBarSeries(fact.getCell(defaultWorksheetIndex, 1, 2, -15));
IChartDataPoint p2 = series.getDataPoints().addDataPointForBarSeries(fact.getCell(defaultWorksheetIndex, 2, 2, 10));
// Comment out these two lines and the 'Invert if negative' checkbox will get set by Aspose.Slides
IFillFormat fill = p1.getFormat().getFill();
fill.getSolidFillColor().setColor(Color.RED);
fill.setFillType(FillType.Solid);
//Save presentation with chart
pres.save("output.pptx", SaveFormat.Pptx);