How to limit the chart to a fixed time span.

You may want to limit the chart to a specific date/time range while allowing the user to drag the chart within that range. To do this implement an OnDragPlot event handler:

procedure TForm1.RACDragPlot(Sender: TObject;
                             var StartDateTime,
                                 EndDateTime: TDateTime);
  span: TDateTime;
  // prevent the chart being scrolled outside a given range
  // FMinDate should be a TDateTime holding the earliest allowed date/time
  // FMaxDate should be a TDateTime holding the latest allowed date/time
  span := EndDateTime - StartDateTime;
  if StartDateTime < FMinDate then begin
    EndDateTime := FMinDate + span;
    StartDateTime := FMinDate;
  end else if EndDateTime > FMaxDate then begin
    StartDateTime := FMaxDate - span;
    EndDateTime := FMaxDate;

Note: This event handler can be invoked many times a second while the user is dragging the chart. It is important that it completes quickly in order to maintain a responsive user experience.

What People Say

This is a great component. I've been using it for a year. It's well written, performance is top notch, and the couple of time I've asked for support, I've gotten it right away from the author.
Steve McForest
More …

No malware No spam
McAfee Site Report
Web of Trust