How to display the resource name in the allocation.

Set the Options to include OwnerDrawAllocations, then insert the following code into the OnOwnerDrawAllocation event handler. Ensure that the RowHeight property is set to a large enough value for the font being used, or else no text will be shown.

Screen shot
procedure TMyForm.RACOwnerDraw(Sender: TObject;
                               Resource: TssResource;
                               Allocation: TssResourceAllocation;
                               Canvas: TCanvas;
                               Rct: TRect);
  yb, yt, xs, xe, tw, th: integer;
  xs := Rct.Left;
  xe := Rct.Right;
  yt := Rct.Top;
  yb := Rct.Bottom;
  with Canvas do begin
    // for simplicity ignore the Resource.Style
    // and just draw blocks
    if xs = xe then begin
      MoveTo(xs, yt);
      LineTo(xs, yb);
    end else
      Rectangle(xs, yt, xe, yb);
    // don't show the description if we're
    // drawing the shadow
    if Pen.Color <> RAC.ChartAppearance.ShadowColor then begin
      tw := TextWidth(Resource.Name);
      th := TextHeight(Resource.Name);
      // is there room for the text in the rectangle?
      if (xe - xs > tw) and (yb - yt > th) then begin
        Brush.Style := bsClear;
        TextOut((xe + xs - tw) div 2, (yb + yt - th) div 2, Resource.Name);
      end; // else leave the block unlabelled
What People Say

Great component...
Danny Banks, FMI Solutions Limited
More …

No malware No spam
McAfee Site Report
Web of Trust