Multiline axis labels

TeeChart VCL for Borland/CodeGear/Embarcadero RAD Studio, Delphi and C++ Builder.
Post Reply
toreba
Newbie
Newbie
Posts: 15
Joined: Thu Feb 06, 2003 5:00 am
Location: UK

Multiline axis labels

Post by toreba » Wed Aug 11, 2004 8:54 am

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?

Marjan
Site Admin
Site Admin
Posts: 745
Joined: Fri Nov 07, 2003 5:00 am
Location: Slovenia
Contact:

Post by Marjan » Wed Aug 11, 2004 9:06 am

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.
Marjan Slatinek,
http://www.steema.com

toreba
Newbie
Newbie
Posts: 15
Joined: Thu Feb 06, 2003 5:00 am
Location: UK

Multiline axis labels

Post by toreba » Wed Aug 11, 2004 10:36 am

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?

Marjan
Site Admin
Site Admin
Posts: 745
Joined: Fri Nov 07, 2003 5:00 am
Location: Slovenia
Contact:

Post by Marjan » Thu Aug 19, 2004 3:57 pm

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.
Marjan Slatinek,
http://www.steema.com

toreba
Newbie
Newbie
Posts: 15
Joined: Thu Feb 06, 2003 5:00 am
Location: UK

Post by toreba » Thu Aug 19, 2004 5:25 pm

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.

Pep
Site Admin
Site Admin
Posts: 3274
Joined: Fri Nov 14, 2003 5:00 am
Contact:

Post by Pep » Thu Sep 02, 2004 2:10 pm

Hi,

how about using the OnAfterDraw event ?

toreba
Newbie
Newbie
Posts: 15
Joined: Thu Feb 06, 2003 5:00 am
Location: UK

Post by toreba » Wed Sep 22, 2004 2:04 pm

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.

Post Reply