Page 1 of 1

MaxLabelsWidth error

Posted: Tue Mar 15, 2011 7:39 am
by 16557284
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

Re: MaxLabelsWidth error

Posted: Tue Mar 15, 2011 4:00 pm
by yeray
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();

Re: MaxLabelsWidth error

Posted: Tue Mar 22, 2011 8:43 am
by 16557284
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,

Re: MaxLabelsWidth error

Posted: Fri Mar 25, 2011 4:51 pm
by yeray
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.