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

Free Support Forum - aspose.com

Datalabels overlapping on axis label when value is zero


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


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 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:
Sample code:

       Chart chart = worksheet.getCharts().get(0);
        ChartPointCollection points = chart.getNSeries().get(1).getPoints();
        int pointsCount = points.getCount();
        for(int i= 0; i < pointsCount; i++)
            DataLabels label = points.get(i).getDataLabels();

Hope, this helps a bit.