Knowing when chart is scrolled.

TeeChart VCL for Borland/CodeGear/Embarcadero RAD Studio, Delphi and C++ Builder.
Post Reply
Metegrity
Newbie
Newbie
Posts: 13
Joined: Tue Sep 25, 2007 12:00 am
Contact:

Knowing when chart is scrolled.

Post by Metegrity » Tue Feb 19, 2008 6:26 pm

Hi.

I've been trying to figure out the best way (with respect to my situation) to tell when the chart is scrolled.

I'm aware of the OnScroll event which is triggered but it's not exactly when I want to assume that the chart in fact was scrolled.

What I'm after is something similar to the Chart.Zoomed property, yet are unable to find anything to that extent.

Could you perhaps suggest a way to check in code if the chart is scrolled?

I suppose one way to do it would be to set a flag (Boolean) variable within the OnScroll event and just check for that variable, but I would like to keep away from that.

Thank you.

Marcin D.

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

Post by Yeray » Wed Feb 20, 2008 8:47 am

Hi Marcin,

Have you tried the OnZoom and OnUndoZoom events?

Or could you please explain more accurately what are you exactly trying to achieve? We are not sure to understand what do you exactly want to do here.
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

Metegrity
Newbie
Newbie
Posts: 13
Joined: Tue Sep 25, 2007 12:00 am
Contact:

Post by Metegrity » Wed Feb 20, 2008 3:36 pm

The issue is not with the Zoom but the Scroll of the graph.

Basically I have a Unit file which contains some functions that are activated through certain Actions within the main form.

Through some of these functions I would like to check if the chart was Scrolled.

I am using the TChart.Zoomed property which knows when the chart has been zoomed. I'm trying to figure out which property or variable contained within the TChart (or TDBChart to be more particular) would allow me to check if the chart was scrolled. Obviously ideally there would be something such as TChart.Scrolled but there isn't ?

Like I said, I'm aware of the OnScroll, and OnZoom events. But I wanted to keep away from using those - the reason being such that I'm trying to write universal code which we can use through our software and don't want to "hard code" anything into the TChart object itself but run external functions on it which handle certain behaviors.

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

Post by Yeray » Thu Feb 21, 2008 9:42 am

Hi Marcin,

I've added to the wish list the possibility to add the property you suggested (Scrolled) in further releases. By the meanwhile the only solution I can think for now would be to store, for example, minimum values for X and Y axes at the starting of the application. Then you could have a public method that checks if any of them are have changed. Could be something like:

Code: Select all

public
  function Scrolled:boolean;

var XPos, YPos: Double;

procedure TForm1.FormCreate(Sender: TObject);
begin
  Chart1.Draw;
  XPos := Chart1.Axes.Bottom.Minimum;
  YPos := Chart1.Axes.Left.Minimum;
end;

function TForm1.Scrolled: boolean;
begin
  if (XPos = Chart1.Axes.Bottom.Minimum) and (YPos = Chart1.Axes.Left.Minimum) then
    result := false
  else
    result := true;
end;
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

Metegrity
Newbie
Newbie
Posts: 13
Joined: Tue Sep 25, 2007 12:00 am
Contact:

Post by Metegrity » Fri Feb 22, 2008 2:52 pm

Thank you Yeray,
I will use that code for now as it will certainly fit with what I'm trying to accomplish.

Post Reply