We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

How can apply GradientFill for a series - java?

Hi,

Can you provide the code snippet for GradientFill using aspose.cells for java?
I tried the following which seems to be not working.


for (int i = 0; i < chart.getNSeries().size(); i++) {

ASeries series = chart.getNSeries().get(i);

/*PatternFill pf = new PatternFill();
pf.setBackgroundColor(wb.getPalette().getColor(i));
pf.setForegroundColor(wb.getPalette().getColor(i));
series.getArea().setFill(pf);*/

GradientFill gf = new GradientFill();
gf.setColor1(wb.getPalette().getColor(i));
gf.setColor2(wb.getPalette().getColor(i * 2));
series.getArea().setFill(gf);

}

Hi,

Well, you need to call setGradientColorType method to specify gradient color types before setting colors. This works like MS Excel, by default there is no color type set for the Gradient fill tab.


See the following code:

for (int i = 0; i < chart.getNSeries().size(); i++) {

ASeries series = chart.getNSeries().get(i);

/*PatternFill pf = new PatternFill();
pf.setBackgroundColor(wb.getPalette().getColor(i));
pf.setForegroundColor(wb.getPalette().getColor(i));
series.getArea().setFill(pf);*/

GradientFill gf = new GradientFill();

gf.setGradientColorType(GradientColorType.TWO_COLORS);

gf.setColor1(wb.getPalette().getColor(i));
gf.setColor2(wb.getPalette().getColor(i * 2));
series.getArea().setFill(gf);

}



Thank you.