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

Free Support Forum - aspose.com

Set Position DataLabel in a chart not working

Hello,

I’m trying to fix the position of the datalabel in a Donut chart by doing as below :

IChartSeries iChartSeries = ichart.getChartData().getSeries().add(iChartDataWorkbook.getCell(defaultWorksheetIndex, 0, 1, “Serie_1”), ichart.getType());

iChartSeries.getLabels().getDefaultDataLabelFormat().setShowPercentage(true);

iChartSeries.getLabels().getDefaultDataLabelFormat().setPosition(LegendDataLabelPosition.BestFit);

But it did not work, I had this error :

class com.aspose.slides.exceptions.InvalidOperationException: Wrong label position for this type of series. Possible values: supports only default value
com.aspose.slides.DataLabelFormat.setPosition(Unknown Source)

Thanks.

@Abder,

I have observed the part of sample code and requirements shared by you. Actually, Doughnut chart that you are trying to add does not have any label position setting options even in PowerPoint. For this reason, a valid exception in being thrown when you try to set the label position on your end. Please observe this image for your kind reference, where you can see that there are no label position options for said chart type. You need to catch such exception or use label position options that suits chart type, if there are any.