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);
var
  yb, yt, xs, xe, tw, th: integer;
begin
  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
    end;
  end;
end;
What People Say

I did want to drop you a note and tell you what a wonderful component. It's a must have component if you are a serious Delphi developer.
Miguel Henley, Brazil
More …

No malware No spam
McAfee Site Report
Web of Trust