With TeeChart Pro 6.01, since the 'multiline' axis label property appears not to work, I use TeeSplitInLines in the OnGetAxisLabel event to successfully split long bottom-axis labels rotated at 90 degrees.
But then the chart does not resize the axis label space to make use of the extra space now available. The label space remains the same size as if I hadn't split the labels.
How do I get the chart to recalculate the space required by multiline labels?
Multiline axis labels
Hi.
The easiest solution is to do it manually after (or if you know that you'll be splitting axis labels before) you split single line text. All you have to do is set the chart axis LabelsSize property to:
LabelsSize= Label font text size * number of text rows.
The easiest solution is to do it manually after (or if you know that you'll be splitting axis labels before) you split single line text. All you have to do is set the chart axis LabelsSize property to:
LabelsSize= Label font text size * number of text rows.
Marjan Slatinek,
http://www.steema.com
http://www.steema.com
Multiline axis labels
But the labels are rotated at 90 degrees, so the number of rows isn't relevant. It's the length of the longest line of text anywhere along the axis. Is there a way of calculating that?
Hi.
Yes, there is a way to do this. In the OnGetAxisLabel event, when you split lines, calculate the width of each section. You can use TChart.CAnvas.TextWidth method to do this. Do this on all sections and all labels and then use the biggest value to set axis label size.
Yes, there is a way to do this. In the OnGetAxisLabel event, when you split lines, calculate the width of each section. You can use TChart.CAnvas.TextWidth method to do this. Do this on all sections and all labels and then use the biggest value to set axis label size.
Marjan Slatinek,
http://www.steema.com
http://www.steema.com
The OnAfterDraw event is of course the first one I thought of. But it doesn't help. If you change the value of a chart's BottomAxis.LabelsSize in the OnAfterDraw event it does not force the chart to redraw itself with the new labels size. Surely if it did, the whole process would become infinitely recursive. So, the question remains: how do you get a chart to recalculate itself after changing an axis label size? Remember, because the 'MultiLine' axis label property doesn't work, we are optimising the multiline label length manually within the OnGetAxisLabel event, so we don't know what that length is going to be before the chart is drawn.