Free Support Forum - aspose.com

Scatter Chart Label Override issue

HI,

@mudassir.fayyaz
@Adnan.Ahmad

We are generating normal Scatter Chart with Diamond as a marker.
In some cases we are having datapoint very close to each other so in this situation datalabel are getting overlapped.
Is there any way to find out if datapoints are overriden or not ?

ThanksScatter-Datapoint-Overriding-Issue.PNG (3.5 KB)

@prashant.barwe,

I have observed the requirements shared by you and like to mention that there is no direct or authentic approach to identify the overlapping labels. However, there are X,Y properties representing the position of Datalable.You may try comparing the X,Y values of two labels with some offset difference to see if they are overlapping or not. This approach may work on your end.

Hi ,

@mudassir.fayyaz

We are using Aspose 16.8.0 Java . In this while getting X and Y values of datalabel getting 0.0.

chartDataPointCollection.get_Item(0).getLabel().getActualX();

chartDataPointCollection.get_Item(0).getLabel().getActualY();

we are always getting 0.0 .

@prashant.barwe,

0,0 for X,Y is returned in case when automatic label position is used. If you set the position label manually, you will have X,Y values.

Hi,

@mudassir.fayyaz

I am unable to get it the X and Y values.
Can you please help me by providing sample code for what i have to set initially and what value of X and Y i will get then.

Thank you.

@prashant.barwe,

I suggest you to please consider using following sample code on your end to get an idea about setting label positions.

public static void TestLabelPosition()
{
    Presentation pres = new Presentation();

    IChart chart =pres.getSlides().get_Item(0).getShapes().addChart(ChartType.ClusteredColumn,20,20,400,400);
    chart.getChartData().getSeries().get_Item(0).getLabels().getDefaultDataLabelFormat().setShowValue(true);
         
    //Top right position
    chart.getChartData().getSeries().get_Item(0).getDataPoints().get_Item(0).getLabel().setX(-1);
    chart.getChartData().getSeries().get_Item(0).getDataPoints().get_Item(0).getLabel().setY(-1);

    
    //Actual Label position on desired label
    chart.getChartData().getSeries().get_Item(0).getDataPoints().get_Item(1).getLabel().setX(0);
    chart.getChartData().getSeries().get_Item(0).getDataPoints().get_Item(1).getLabel().setY(0);

    
    //Bottom Right
    chart.getChartData().getSeries().get_Item(0).getDataPoints().get_Item(2).getLabel().setX(1);
    chart.getChartData().getSeries().get_Item(0).getDataPoints().get_Item(2).getLabel().setY(1);

    pres.save("C:\\Aspose Data\\LabelPostions2.pptx", SaveFormat.Pptx);

}

I hope the share information will be helpful.

Hi,

@mudassir.fayyaz

Thanks for your response.

The code which you have provided is for placing the data labels at different position.
But we are searching that , is there any way to find out that the two data labels are overriding or not ?

Regards

@prashant.barwe,

I have observed your requirements and suggest you to please explore the options of label widths and heights and calculating if that is intersecting with other label somehow or not. There is no API feature to detect this by you may use these properties to develop your own approach to find overlapping labels on your end.

ChartData().getSeries().get_Item(0).getDataPoints().get_Item(2).getLabel().getWidht();
ChartData().getSeries().get_Item(0).getDataPoints().get_Item(2).getLabel().getHeight();