0

I am trying to set the color for the horizontal bar chart (XDDFBarChartData) for the negative value and I am able to do it for achieve it using the solution mentioned in:

java apache poi bar chart populate negative bar with color

And then I am explicitly changing the bar color to orange using the Byte Color [] before plotting the chart using below code :

final byte[][] colors = new byte[][] { new byte[] {(byte)255, 100, 0} }

chart.getCTChart()
     .getPlotArea()
     .getBarChartArray(0)
     .getSerArray(0)
     .addNewDPt()
     .addNewIdx()
     .setVal(0);

chart.getCTChart()
     .getPlotArea()
     .getBarChartArray(0)
     .getSerArray(0)
     .getDPtArray(0)
     .addNewSpPr()
     .addNewSolidFill()
     .addNewSrgbClr()
     .setVal(colors[0]);

chart.plot(data);

However, the invertNegative flag is set to true for only this particular point, so it always shows as white. The color of the bar is displayed when we manually uncheck the flag in Excel.

How do we set the invertNegative flag to false for the chart for that particular value ?

chart.getCTChart()
     .getPlotArea()
     .getBarChartArray(0)
     .getSerArray(0)
     .addNewDPt()
     .addNewIdx()
     .setVal(0);

chart.getCTChart()
     .getPlotArea()
     .getBarChartArray(0)
     .getSerArray(0)
     .getDPtArray(0)
     .addNewSpPr()
     .addNewSolidFill()
     .addNewSrgbClr()
     .setVal(colors[0]);

0 Answers0