Datalabels overlapping on axis label when value is zero

Hi,

When the values are 0’s, the Datalabels overlapping on axis labels.

Attaching sample excel with chart for your reference.
bar-with-zero.zip (10.1 KB)

Thanks in Advance

@SriG,

Probably, the chart in your attached file is generated by Aspose.Cells? Aspose.Cells follows MS Excel standards and specifications when creating the chart. Could you please share your expected chart in a sample file (where datalabels are not overlapping on axis when value is zero) here. You may create your desired chart in MS Excel manually. We will check and help you on how to do it with Aspose.Cells.

Yes @Amjad_Sahi
The above chart attached is generated by Aspose.Cells.

Attaching below the MS Excel generated manually with zero values and the data labels and x-axis labels are not overlapping. If we could be able to do it using Aspose.Cells, it’d be helpful.
bar-datalabels-zero.zip (11.3 KB)

Thanks

@SriG,

Thanks for the file.

You need to set position of the series points labels accordingly for your needs. See the following sample code for your reference and try it for your scenario/case accordingly. I have tested using it and it works fine:
e.g.
Sample code:

......
       Chart chart = worksheet.getCharts().get(0);
        chart.getNSeries().get(1).getDataLabels().setShowValue(true);
        ChartPointCollection points = chart.getNSeries().get(1).getPoints();
        int pointsCount = points.getCount();
        for(int i= 0; i < pointsCount; i++)
        {
            DataLabels label = points.get(i).getDataLabels();
            label.setPosition(LabelPositionType.CENTER);
            //or 
            //label.setPosition(LabelPositionType.INSIDE_BASE);
            label.setNeverOverlap(true);
        }
.. 

Hope, this helps a bit.