MaxLabelsWidth error

TeeChart VCL for Borland/CodeGear/Embarcadero RAD Studio, Delphi and C++ Builder.
Post Reply
Jarek
Newbie
Newbie
Posts: 5
Joined: Tue Sep 21, 2010 12:00 am
Contact:

MaxLabelsWidth error

Post by Jarek » Tue Mar 15, 2011 7:39 am

Hello,

In my application, I use a chart with many custom axes with different ranges. In order to place the axes so that their labels not overlap I use MaxLabelsWidth() function to get the space needed by each axis for its labels. I’ve noticed that for some values of maximum of axis the MaxLabelsWidth() function returns a wrong value. I’ve checked the ranges of (0,100), (0,200), up to (0,1000) and obtained wrong results for the following ranges: (0,300), (0,400), (0,800) and (0,900).

Thanks for help

Jarek
Attachments
MaxLAbelsWidthError.zip
Test project
(90.24 KiB) Downloaded 399 times
MaxLabelsWidthError.jpg
Screenshot
MaxLabelsWidthError.jpg (258.05 KiB) Viewed 4753 times

Yeray
Site Admin
Site Admin
Posts: 9612
Joined: Tue Dec 05, 2006 12:00 am
Location: Girona, Catalonia
Contact:

Re: MaxLabelsWidth error

Post by Yeray » Tue Mar 15, 2011 4:00 pm

Hi Jarek,

You should force a chart repaint before getting the axes max labels width. I'd add all the axes and repaint the chart only once. You could also repaint the chart after adding each custom axis but of course this would mean a lot of repaints as you have many custom axes.

Code: Select all

Chart1->Draw();
Best Regards,
ImageYeray Alonso
Development & Support
Steema Software
Av. Montilivi 33, 17003 Girona, Catalonia (SP)
Image Image Image Image Image Image Please read our Bug Fixing Policy

Jarek
Newbie
Newbie
Posts: 5
Joined: Tue Sep 21, 2010 12:00 am
Contact:

Re: MaxLabelsWidth error

Post by Jarek » Tue Mar 22, 2011 8:43 am

Thank you for your reply.

Unfortunately, the proposed solution is not applicable for my application.

In my application I delete and recreate all axes each time the displayed data are changed so the solution that causes additional flickering is unacceptable for me. Whats more, additional redrawing of the chart after all axes are created doubles the time needed for the view to be rendered.

I’ve used the same code in TeeChart version 7 ant it worked properly - the widths of the labels were correctly calculated by the MaxLabelsWidth() function and the additional redraw was unnecessary.

I’ve analyzed your code and found that if I call InternalCalcPositions() for each axis after its creation and before MaxLabelsWidth() call the later function returns proper values. InternalCalcPositions is a private function so getting access to it isn't pretty. Could you consider modifying MaxLabelsWidth so that calling InternalCalcPositions wouldn't be necessary or propose other workaround?

Regards,

Yeray
Site Admin
Site Admin
Posts: 9612
Joined: Tue Dec 05, 2006 12:00 am
Location: Girona, Catalonia
Contact:

Re: MaxLabelsWidth error

Post by Yeray » Fri Mar 25, 2011 4:51 pm

hi Jarek,

I've added it to the wish list to be investigated for further releases (TV52015463).
In the meanwhile, if you are source code customer, you could make the InternalCalcPositions method public.
Best Regards,
ImageYeray Alonso
Development & Support
Steema Software
Av. Montilivi 33, 17003 Girona, Catalonia (SP)
Image Image Image Image Image Image Please read our Bug Fixing Policy

Post Reply