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?
MaxLabelsWidth returns value too high
-
- Site Admin
- Posts: 14730
- Joined: Mon Jun 09, 2003 4:00 am
- Location: Banyoles, Catalonia
- Contact:
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.
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.
Best Regards,
Narcís Calvet / Development & Support Steema Software Avinguda Montilivi 33, 17003 Girona, Catalonia Tel: 34 972 218 797 http://www.steema.com |
Instructions - How to post in this forum |