Page 1 of 1
Multiline axis labels
Posted: Wed Aug 11, 2004 8:54 am
by 8575649
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?
Posted: Wed Aug 11, 2004 9:06 am
by Marjan
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.
Multiline axis labels
Posted: Wed Aug 11, 2004 10:36 am
by 8575649
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?
Posted: Thu Aug 19, 2004 3:57 pm
by Marjan
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.
Posted: Thu Aug 19, 2004 5:25 pm
by 8575649
Okay, I can calculate what the axis LabelsSize property needs to be, but when do you set it? There's an 'OnBeforeDrawAxes' event, but no 'OnAfterDrawAxes' event.
Posted: Thu Sep 02, 2004 2:10 pm
by Pep
Hi,
how about using the OnAfterDraw event ?
Posted: Wed Sep 22, 2004 2:04 pm
by 8575649
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.