Page 1 of 1

How to stop mouse scrolling if certain criteria reached?

Posted: Thu Oct 18, 2012 4:00 am
by 16562051
Dear Steema support,

I'd like to prevent an user from doing horizontal mouse scrolling, if the data they browse has reached either side of its end, so the empty area of chart will not be shown? thanks!

Re: How to stop mouse scrolling if certain criteria reached?

Posted: Thu Oct 18, 2012 7:14 am
by narcis
Hi sswang,

Yes, you can use OnScroll event as shown below.

Code: Select all

uses Series;

procedure TForm1.FormCreate(Sender: TObject);
begin
  Chart1.AddSeries(TLineSeries).FillSampleValues(100);
  Chart1.Axes.Bottom.SetMinMax(25,75);
end;

procedure TForm1.Chart1Scroll(Sender: TObject);
var range : Double;
    xMin  : Double;
    xMax  : Double;
begin
  With Chart1.Axes.Bottom do
  begin
    xMin:=Chart1[0].MinXValue;
    xMax:=Chart1[0].MaxXValue;
    range:=Maximum-Minimum;

    if Minimum < xMin then SetMinMax(xMin,xMin+range);
    if Maximum > xMax then SetMinMax(xMax-range,xMax);
  end;
end;

Re: How to stop mouse scrolling if certain criteria reached?

Posted: Mon Oct 22, 2012 7:08 am
by 16562051
Thanks!