Moving Data Labels in Radar Chart in Java Throws an InvalidOperationException

Hi Team,

we have an use case that, in Radar chart series, will have to move one of the Data Label series away from the edge point (default position) but aspose library methods were not supporting to do so.

code snippet:

ChartSeries series = chartSeries.get_Item(seriesIndex); // will get series based on the seriesIndex 0 / 1
IChartDataCell cellData = chartDataWorkBook.getCell(
    defaultWorksheetIndex,
    index + 1,
    seriesIndex + 1,
    domain.getScore()); // setting the celldata

series.getDataPoints().addDataPointForRadarSeries(cellData); // setting cellData to the series
series.getLabels().getDefaultDataLabelFormat().setShowValue(true); // enabling data labels to show
series.getLabels().getDefaultDataLabelFormat().setPosition(LegendDataLabelPosition.BestFit); // option to move the data labels 

Output: InvalidOperationException

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

@Madhu1689,
Thank you for contacting support.

Radar charts do not support the movement of data labels in PowerPoint documents. Therefore, the exception occurs in your application. Please compare the formatting settings for a Radar chart and Clustered Column chart, for example: compare.png (259.4 KB)

@andrey.potapov thanks for the quick reply…

is there a way that we can move data labels based on the current X & Y position.

approach is like, get the current label X & Y values and then add some additional X / Y based on the number categories to place / move the labels.

any inputs on this greatly appreciated.

@Madhu1689,
The IDataLabel interface includes the ILayoutable interface that allows you to change the position (X and Y properties) of data labels.

foreach (var series in chart.ChartData.Series)
{
    foreach (var dataPoint in series.DataPoints)
    {
        var x = dataPoint.Label.X;
        var y = dataPoint.Label.Y;

        // Change the position...
    }
}

Please note that the X and Y values are specified as a fraction of the width and height of the chart accordingly.

More examples: