Page 1 of 1

MaxLabelsWidth returns value too high

Posted: Wed Oct 10, 2007 12:09 pm
by 9339922
I have one TLineSeries in Chart and try to connect it to LeftAxis or custom axis.

When series is connected to LeftAxis width of left axis area is automatically adjusted so that all labels are visible and area is not to wide. I can set Minimum/Maximum of LeftAxis to 1 .. 100 or 1.1111 .. 100 and first label is always 10 and last 100. Left axis area width is correct.

When series is connected to custom axis (LeftAsix is not connected to any series) I have to set Chart MarginLeft property to make place for custom axis. Width of left margin is equal to value returned by function customAxis->MaxLabelsWidth(). When I set Minimum/Maximum of custom axis to 1 .. 100 first label is 10 and last 100. MaxLabelsWidth returns correct value.

But when I set Minimum/Maximum of custom axis to 1.1111 .. 100 MaxLabelsWidth returns number too big . It looks like value returned by MaxLabelsWidth is big enough to make place to draw number 1.1111. But first label of axis is 10 not 1.1111.

What should I do to calculate max width of labels drawn by custom axis?

Posted: Wed Oct 10, 2007 1:43 pm
by narcis
Hi Jarek,

First of all, please notice that you should only retrieve MaxLabelsWidth when the chart has being fully drawn and therefore the property has a valid value. So you could use this property in TChart's OnAfterDraw event or make a Chart1.Draw(); call before using the property to force the chart being drawn. You should also be aware that making Draw calls you can easily fall in an endless painting loop.

If this doesn't help please send us a simple example project we can run "as-is" to reproduce the problem here. You can send your files at news://www.steema.net/steema.public.attachments newsgroup or at our upload page.

Thanks in advance.