How to center a specific allocation in the display.


This example will cause the specified allocation to be displayed centrally in the plot area.
procedure TForm1.CentreOnAllocation(const Allocation: TssResourceAllocation);
var
  d, m: TDateTime;
  i: integer;
begin
  if Assigned(Allocation) then begin
    RAC.BeginUpdate;
    try
      // Centre horizontally
      d := (RAC.EndAt - RAC.StartAt) / 2.0;
      m := (Allocation.EndAt + Allocation.StartAt) / 2.0;
      RAC.SetDateTime(m - d, m + d);

      // Centre vertically
      i := RAC.IndexOf(Allocation.Resource) - RAC.NumDisplayedResources div 2;
      if i < 0 then
        i := 0
      else if i > RAC.Count - RAC.NumDisplayedResources + 1 then
        i := RAC.Count - RAC.NumDisplayedResources + 1;
      RAC.FirstDisplayedIndex := i;
    finally
      RAC.EndUpdate;
    end;
  end;
end;
What People Say

Resource Allocation Chart is one of those rare components that really fires the imagination. It looks great and is extremely flexible. A must for any application that allocates time slots.
Trevor Pegley, Visionhall
More …

No malware No spam
McAfee Site Report
Web of Trust