Free Support Forum - aspose.com

Label color per series

Hi,


I am trying to set different label color per series. Below is what i am trying, however it is not working.

series1.getLabels().getDefaultDataLabelFormat().getTextFormat().getPortionFormat().setFontHeight(10);
series1.getLabels().getDefaultDataLabelFormat().getTextFormat().getPortionFormat().getFillFormat().setFillType(FillType.Solid);
series1.getLabels().getDefaultDataLabelFormat().getTextFormat().getPortionFormat().getFillFormat().getSolidFillColor()
.setColor(Color.RED);

series2.getLabels().getDefaultDataLabelFormat().getTextFormat().getPortionFormat().setFontHeight(10);
series2.getLabels().getDefaultDataLabelFormat().getTextFormat().getPortionFormat().getFillFormat().setFillType(FillType.Solid);
series2.getLabels().getDefaultDataLabelFormat().getTextFormat().getPortionFormat().getFillFormat().getSolidFillColor()
.setColor(Color.BLUE);

series3.getLabels().getDefaultDataLabelFormat().getTextFormat().getPortionFormat().setFontHeight(10);
series3.getLabels().getDefaultDataLabelFormat().getTextFormat().getPortionFormat().getFillFormat().setFillType(FillType.Solid);
series3.getLabels().getDefaultDataLabelFormat().getTextFormat().getPortionFormat().getFillFormat().getSolidFillColor()
.setColor(Color.BLACK);

Can you please help?

Hi,


Thank you for your interest in Aspose.Slides.

I have observed your comments and like to request you to please share with us a sample presentation created using PowerPoint to explain your requirements so that we may proceed further to help you out.

Best Regards,

Hi,


Thank you for sharing the file with us.

I have worked over your requirements and like to request you to please try using following sample code on your end to serve the purpose.

//Create an instance of Presentation class
Presentation pres = new Presentation();

//Get reference of the slide
ISlide sld = pres.getSlides().get_Item(0);

//Adding a chart on slide
IChart ch = sld.getShapes().addChart(ChartType.ClusteredColumn, 20, 20, 500, 300);
IChartSeries series = ch.getChartData().getSeries().get_Item(0);
series.getLabels().get_Item(0).getDataLabelFormat().getFormat().getFill().setFillType(FillType.NoFill);
//series.getLabels().get_Item(0).getDataLabelFormat().getFormat().getFill().getSolidFillColor().setColor(Color.GREEN);
//Setting the position of label from axis
IDataLabel lbl = series.getDataPoints().get_Item(0).getLabel();
lbl.getDataLabelFormat().setShowSeriesName(false);
lbl.getDataLabelFormat().setShowLegendKey(true);
lbl.getDataLabelFormat().setShowCategoryName(false);
lbl.getDataLabelFormat().setShowValue(true);
lbl.getTextFormat().getPortionFormat().getFillFormat().setFillType(FillType.Solid);
lbl.getTextFormat().getPortionFormat().getFillFormat().getSolidFillColor().setColor(Color.RED);
//Write the presentation to disk
pres.save(“D:\test.pptx”, SaveFormat.Pptx);

I hope this will be helpful. Please share if I may help you further in this regard.

Best Regards,

Didn’t work for me.

Hi,

Please share with us if you are looking to set the color of label of some particular series or not? The code sample shared by me works perfect if this is your requirement as in the attached image (requirement.JPG). Also, the code sample shared by me is in accordance with the title of your post and the code sample shared by you . If you have different requirements then please share with us a screenshot to explicitly explain your requirements. I will be able to proceed further as soon as this information is shared by you.


Best Regards,