How to stop mouse scrolling if certain criteria reached?

TeeChart VCL for Borland/CodeGear/Embarcadero RAD Studio, Delphi and C++ Builder.
Post Reply
sswang
Newbie
Newbie
Posts: 24
Joined: Wed Mar 28, 2012 12:00 am

How to stop mouse scrolling if certain criteria reached?

Post by sswang » Thu Oct 18, 2012 4:00 am

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!

Narcís
Site Admin
Site Admin
Posts: 14730
Joined: Mon Jun 09, 2003 4:00 am
Location: Banyoles, Catalonia
Contact:

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

Post by Narcís » Thu Oct 18, 2012 7:14 am

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;
Best Regards,
Narcís Calvet / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Image Image Image Image Image Image
Instructions - How to post in this forum

sswang
Newbie
Newbie
Posts: 24
Joined: Wed Mar 28, 2012 12:00 am

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

Post by sswang » Mon Oct 22, 2012 7:08 am

Thanks!

Post Reply