I am trying to wrap the text of the TickLabels of Axis.
Currently the placement is set to ‘Horizontal’ and the TickLabels are overlapping.
But I am not finding an appropriate property to do this.
Please let me know how this can be achieved.
Thanks & regards,
I have created a Column chart and have inserted TickLabels on the x-axis.
Whe I set the font size of the TickLabels to 10, then the TickLabel text wraps properly and the text is displayed in a readable way.
But when I increase the font size the TickLabels overlap.
I have attached the sample code and the output files. Please let me know how to avoid the overlapping of TickLabels.
Thanks and regards,
Well, I think it is not an issue of Aspose.Cells by any means rather MS Excel behavior. As you may check, MS Excel will overlaps tick labels when you increase font size e.g to 12 or so. The reason may be as the font size gets increased but the tick labels does not find enough space to render it find so, it will be overlapped. If you decrease the font size, the space would be enough for the tick labels different positions.
For your situation, I think you may try:
1) You may try to wrap the source tick labels data/text in the cells explicitly.
explicitly put line feed while adding data to the source cells in your code:
dataWorkSheet.Cells[0, 4].PutValue(“Barndfive\n sub four”);
dataWorkSheet.Cells[0, 5].PutValue(“Brandsix\n sub three”);
dataWorkSheet.Cells[0, 6].PutValue(“Brandseven\n sub five”);
dataWorkSheet.Cells[0, 7].PutValue(“Brandeight\n sub five”);
2) You may set a rotation angle for the tick labels e.g
With the Excel, the Ticklabels get overlapped if there is less space.
But in the image attached, the TickLabels are wrapped.
Will you please let me what is happening in this case.
Thanks and regards,
To make better readability, Aspose.Cells’ Chart-to-Image feature would wrap the labels if possible for the generated image of the chart. Do you need to render the image (same as MS Excel’s chart with overlapped tick labels)? please let us know.
By the way, some of our users are happy with it to always get the chart’s image with better readability regarding labels.
We want the labels to be visible properly. We appreciate that.
Is it possible to configure the chart image generation, such that the image appears as it is in the excel.
Well, since the category labels are too many and a bit lengthy, the plot area cannot render all of them properly and hence they look overlapped. I think, for your best need, you should set CategoryAxis.TickLabels.RotationAngle and CategoryAxis.TickLabelSpacing to set some proper values for your requirement accordingly. We will continue look into this issue.
I have also run into this issue. This is a problem with Excel’s behavior. Long string values used for category axis labels do not get wrapped and cause the chart image to get pushed very high onto the page.
If the category labels are too many and lengthy, the plot area cannot render all of them properly and hence they look overlapped. You may also try to set CategoryAxis.TickLabels.RotationAngle and CategoryAxis.TickLabelSpacing to set some proper values for your requirement accordingly.