Page 1 of 1

Knowing when chart is scrolled.

Posted: Tue Feb 19, 2008 6:26 pm
by 10546805
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.

Posted: Wed Feb 20, 2008 8:47 am
by yeray
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.

Posted: Wed Feb 20, 2008 3:36 pm
by 10546805
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.

Posted: Thu Feb 21, 2008 9:42 am
by yeray
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;

Posted: Fri Feb 22, 2008 2:52 pm
by 10546805
Thank you Yeray,
I will use that code for now as it will certainly fit with what I'm trying to accomplish.