How to Limit Panning of Chart

TeeChart VCL for Borland/CodeGear/Embarcadero RAD Studio, Delphi and C++ Builder.
Post Reply
mf360v
Newbie
Newbie
Posts: 3
Joined: Fri Jul 17, 2015 12:00 am
Contact:

How to Limit Panning of Chart

Post by mf360v » Wed Jul 29, 2015 4:21 pm

Hello,

I can click and hold down the mouse button to pan the chart left to right. That's great. However this panning just goes on "forever" well outside the upper and lower limits of the values displayed along the bottom axis. What is the reason for this? If I have a range of months, say from Jan 1, 2010 to July 2015 displayed on the chart, what possible reason would I want to pan before or after this set of values? All you get is a blank chart. So I can pan, and pan, and pan, and pan and see absolutely nothing. Why? Shouldn't the chart stop at the upper or lower limits of the axis? Displaying a totally blank chart is completely useless and utterly confusing to an end-user. Is there some property that can be set to prevent panning beyond the upper and lower limits of the axis? I tried setting "InsideBounds" to True, as this seems a logical choice, but that does nothing to prevent panning outside the bounds.

Thanks,

Mike

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

Re: How to Limit Panning of Chart

Post by Narcís » Thu Jul 30, 2015 7:37 am

Hi Mike,

Yes, it is possible limit panning using the OnScroll event like this:

Code: Select all

uses Series, Math;

procedure TForm1.FormCreate(Sender: TObject);
begin
  Chart1.View3D := False;
  Chart1.MaxPointsPerPage := 5;
  Chart1.AddSeries(TLineSeries.Create(Self)).FillSampleValues;
end;

procedure TForm1.Chart1Scroll(Sender: TObject);
begin
  Chart1.Axes.Bottom.Minimum := Max (Chart1.Axes.Bottom.Minimum, Chart1[0].MinXValue);
  Chart1.Axes.Bottom.Maximum := Min (Chart1.Axes.Bottom.Maximum, Chart1[0].MaxXValue);
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

Post Reply