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

Thanks for the component. It's quite amazing, powerful and unique.
Raymond Kennington, Programming Solutions (see the full quote)
More …

No malware No spam
McAfee Site Report
Web of Trust