Problem resizing a chart after drawing

TeeChart VCL for Borland/CodeGear/Embarcadero RAD Studio, Delphi and C++ Builder.
Post Reply
Whookie
Newbie
Newbie
Posts: 25
Joined: Mon Dec 12, 2016 12:00 am

Problem resizing a chart after drawing

Post by Whookie » Wed Mar 22, 2017 9:40 pm

Hi,
yet another problem I run into with my 'colorbar' emulation. What I tried to achive is to have a fixed size ColorBar but the Charts width should adjust to the width of the right-axis labels. I've attached a sample application. Just run it (you need Codesite installed) and see the log output (do not move with the mouse across anything on that app. yet!).

In the log you can see that in the AfterDraw event the previous Width was 98 and the new Width is 109.

Now just move the mouse over one of the labels and see the width of the chart "jumping" (in the log you can see that the with ist staying at 109)

Now click the 'Change scale' button (don't move the mouse across the labels).
In the chart you can see the lables change (getting wider) and the color bar is shrinking but In the log you can see that the old width was 109 and is changed to 121.

You could move over one of the lables again and see how the 'physical' Width changes again BUT instead press the 'set' button. Now the Width is adjusted but only with the following trick:

Code: Select all

  CMapChart.Width := CMapChart.Width+1;
  CMapChart.Width := CMapChart.Width-1;
Note also that this trick is not working in the AfterDraw event...

So I hope you know a way to adjust the charts width when the lables get bigger or smaller?
Attachments
Heatmap.7z
(6.15 KiB) Downloaded 612 times

Whookie
Newbie
Newbie
Posts: 25
Joined: Mon Dec 12, 2016 12:00 am

Re: Problem resizing a chart after drawing

Post by Whookie » Wed Mar 22, 2017 11:35 pm

In addition if you turn off Hover support, moving over the labels with the mouse does not resize the grid anymore

Whookie
Newbie
Newbie
Posts: 25
Joined: Mon Dec 12, 2016 12:00 am

Re: Problem resizing a chart after drawing

Post by Whookie » Wed Mar 22, 2017 11:53 pm

Playing around with the app I found a way to change the width by using PostMessage, this brought up another problem (beside te flickering caused by the delayed adjustment of the Width property).

The attached demo allows to switch the scale by klicking 'Change scale' button but when cycling through the different settings you can see, that the absolute with of the colorbar is a little bit different for each situation. It seems the calculation of MaxLabelsWidth isn't accurate for my purpose?

What I would need is, that everything left of the lables does not change a single pixel. The label itself and the width of the chart should adjust to always show the values (and of course switching the scales should be flicker free).
Attachments
Heatmap2.7z
(6.26 KiB) Downloaded 650 times

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

Re: Problem resizing a chart after drawing

Post by Yeray » Fri Mar 24, 2017 2:45 pm

Hello,

I haven't looked at the last message here yet, but I can explain the behaviour in the first application.
Note that, changing the width at OnAfterDraw event, has no visible effect until the next time the chart is drawn. This happens because when this event is called, the chart has already been drawn.
And the chart is being redrawn when you move the mouse over the labels - so the changes made at OnAfterDraw are considered - if the Hover feature is enabled.

I think all this is a behaviour to expect.
At this point, I'm not sure to understand what are you trying to achieve that made you think this is an abnormal behaviour.
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

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

Re: Problem resizing a chart after drawing

Post by Yeray » Fri Mar 24, 2017 3:06 pm

Hello,

I think I now understand what you are trying to do.
Try adding this at your OnCreate:

Code: Select all

  CMapChart.CustomChartRect:=True;
  CMapChart.ChartRect:=Rect(3, 16, 58, 380);
  CMapChart.RightAxis.ResizeChart:=False;
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

Whookie
Newbie
Newbie
Posts: 25
Joined: Mon Dec 12, 2016 12:00 am

Re: Problem resizing a chart after drawing

Post by Whookie » Fri Mar 24, 2017 7:53 pm

:D very nice, that did the trick!!!

Whookie
Newbie
Newbie
Posts: 25
Joined: Mon Dec 12, 2016 12:00 am

Re: Problem resizing a chart after drawing

Post by Whookie » Mon Mar 27, 2017 12:46 pm

... but it didn't solve the resize - issue.

So I switched to custom labels (i finally was able do access the custom labels demo) and do the resize after the custom labels are set.

So just in case someone needs that sort of behaviour, I attatched my latest working sample application...
Attachments
Heatmap.7z
(5.53 KiB) Downloaded 631 times

Whookie
Newbie
Newbie
Posts: 25
Joined: Mon Dec 12, 2016 12:00 am

Re: Problem resizing a chart after drawing

Post by Whookie » Mon Mar 27, 2017 3:40 pm

I run yet in another problem I was not able to solve. This time I supplied a "real" filter form my application and now when resising the bar (height) there is a black line appearing with some height-values:
blackline.PNG
blackline.PNG (2.5 KiB) Viewed 15457 times
I have again attached a sample application. Please run it and resize the form (just the height!) and you will see that black line come and go depending on the forms height...


There seems to be also a problem with custom labels and resizeing the chart (again only the height).
If you run the sample and just resize the Forms height with the mouse you can see the number of labels increase as the bar gets taller or reduce as it gets smaller (see the image above as the numbers of labels has already decreased).
Now if you start the application again and first press "change scale" and then make ist smaller you get:
labeloverflow.PNG
labeloverflow.PNG (3.07 KiB) Viewed 15458 times
I'm sure this is because of the custom labels I use now. The question is: How can I let the chart deside how many labels are optimal for the current charts size but have them custom?

Whookie
Newbie
Newbie
Posts: 25
Joined: Mon Dec 12, 2016 12:00 am

Re: Problem resizing a chart after drawing

Post by Whookie » Mon Mar 27, 2017 3:43 pm

...and here's sample....
Attachments
Heatmap.7z
(6.36 KiB) Downloaded 620 times

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

Re: Problem resizing a chart after drawing

Post by Yeray » Mon Apr 03, 2017 1:25 pm

Hello,

I've added it to the public tracker:
http://bugs.teechart.net/show_bug.cgi?id=1829
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