Pan chart with scrollbars

TeeChart VCL for Borland/CodeGear/Embarcadero RAD Studio, Delphi and C++ Builder.
Post Reply
PoLabs
Newbie
Newbie
Posts: 35
Joined: Fri Feb 05, 2010 12:00 am

Pan chart with scrollbars

Post by PoLabs » Thu Jul 26, 2012 10:36 am

Hi,

I have a chart with some data on it. So here it is what I would like to have.

I am using chart mouse zoom events. When I zoom I would like to show bottom and right scrollbars to show custumer that he is seeing only zoomed part of chart but he can (with scrollbars) move around whole chart area. Similar like zooming functionality in different software (Word, Excel etc.. where you can scroll through zoomed page). So when zooming I would like to show scrollbars which are used to move (offset) zoomed part in ranges of unzoomed chart. How can I do this?

So far I made custom zoom history list. When I zoom I calculate position of new axes maximum/minimum values and store it to list. With this I can call ZoomRect with some Rect. So when I change eg. bootom scrollbar I just add dx (new val - prev val) to current zoom coordinates (left and right). I first call UndoZoom and afterwards I call ZoomRect with Rect + dx. This method actually works but the problem is that between calls UndoZoom and ZoomRect I need to call Chart.Repaint which results in screen flickering (which is kind a logical). So this method is actuall bad/useless approach.

I tried with some ScrollBy(dx, dy) but it moves chart and then suddenly resets position back to default. So this does not work.

What do you suggest? How can I do this manual scroll of zoomed area?

Thanks for your help.
Aljosa


p.s. I attached screenshots. First picture is unzoomed normal screen. Second picture is zoomed screen with scrollbars I would like to use. So when I change scrollbars this should move zoomed area in desired way.
Attachments
scroll.png
scroll.png (37.27 KiB) Viewed 4296 times

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

Re: Pan chart with scrollbars

Post by Yeray » Fri Jul 27, 2012 9:13 am

Hi Aljosa,

If the UndoZoom an ZoomRect functions don't work exactly as you wish, I'd suggest you to directly use the axes SetMinMax function to control the zoom and scroll.
If you find problems with it, please don't hesitate to let us know, arranging a simple example project we can run as-is to reproduce the situation.
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

PoLabs
Newbie
Newbie
Posts: 35
Joined: Fri Feb 05, 2010 12:00 am

Re: Pan chart with scrollbars

Post by PoLabs » Mon Jul 30, 2012 9:12 am

Works perfectly! Thank you for the idea!

Br,
Aljosa

Post Reply