Page 1 of 1

How to Limit Panning of Chart

Posted: Wed Jul 29, 2015 4:21 pm
by 16475082
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

Re: How to Limit Panning of Chart

Posted: Thu Jul 30, 2015 7:37 am
by narcis
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;