Wrap text - AxisTickLabela

Hi,

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,
Vinay

Hi,

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,
Vinay

Hi,

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.

e.g
explicitly put line feed while adding data to the source cells in your code:
dataWorkSheet.Cells[0, 3].PutValue(“Barndfour”);
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
chart.CategoryAxis.TickLabels.RotationAngle =45;


Thank you.

Hi,

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,
Vinay

Hi,

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.

Thank you.

Hi,

We want the labels to be visible properly. We appreciate that.
Thank you.

Is it possible to configure the chart image generation, such that the image appears as it is in the excel.

Thanks,
Vinay

Hi,

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.

Thank you.

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.


The workaround I found is to insert a line break character (C# (char)10 or [Alt][Enter] in Excel) at a fixed length within long strings. This causes Excel to display “ABCDEFGHIJ…” in the label rather than “ABCDEFGHIJKLMNOPQRSTUVWXYZ”.

Hope this helps.

Jeff

Hi,


As I said and you also mentioned it is MS Excel’s behavior rather than an issue.
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.

The workaround I found is to insert a line break character (C# (char)10 or [Alt][Enter] in Excel) at a fixed length within long strings. This causes Excel to display “ABCDEFGHIJ…” in the label rather than “ABCDEFGHIJKLMNOPQRSTUVWXYZ”.

I think you may try to extend the row/column widths or use Auto-Fit rows/columns feature, alternatively you may use wrap text feature. See some documents on it:
http://www.aspose.com/documentation/.net-components/aspose.cells-for-.net/adjusting-row-height-column-width.html
http://www.aspose.com/documentation/.net-components/aspose.cells-for-.net/autofit-rows-columns.html
http://www.aspose.com/documentation/.net-components/aspose.cells-for-.net/line-break-and-text-wrapping.html


Thank you.