How to add non-standard graphics to the chart.

This example uses the same technique as FAQ 34, but instead of drawing a line at the current date and time, it displays a logo

This technique is very powerful and enables the addition of many non-standard elements to the chart. The key to this technique is to implement an OnDrawProgress event handler. This event is fired at various stages in the drawing process, and so allows additional graphics to be added at each stage. For example, you may want to add graphics on top of the plot background, but behind allocations and their shadows — in this particular case, you'd draw your graphics when the "Progress" argument is equal to dpBackgroundDone. These are the values and meanings of the Progress argument.

dpBeforeStartBefore any drawing has been done. Can be used as a reset.
dpFrameDoneThe outer frame has been drawn.
dpBackgroundDoneThe background has been drawn, including any alternating colour.
dpLabelsDoneThe resource name and date/time labels have been drawn. This is the earliest point at which the TssResource.PlotRect is valid.
dpShadowsDoneThe allocation shadows have been drawn.
dpAllocationsDoneThe allocations have been drawn.
dpAllDoneAll drawing is finished.

This example draws a logo in the bottom-right corner of the chart area. The logo is drawn on top of the background and shadows, but underneath the allocations.

Screen shot

procedure TForm1.FormCreate(Sender: TObject);
  FLogo := TBitmap.Create;
  FLogo.Transparent := true;
  FLogo.TransparentMode := tmAuto;
  FLogo.LoadFromResourceName(HInstance, 'logo.bmp');

procedure TForm1.FormDestroy(Sender: TObject);

procedure TForm1.RACDrawProgress(Sender: TObject;
                                 Canvas: TCanvas;
                                 DrawRect: TRect;
                                 Progress: TssDrawProgress);
  if Progress = dpShadowsDone then begin
    // display our logo
    if Assigned(FLogo) then
      Canvas.Draw(RAC.PlotRect.Right - FLogo.Width - 10,
                  RAC.PlotRect.Bottom - FLogo.Height - 10,

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

What People Say

Great product and great service even before we bought.
Marco Napoli, hotel SalesPro
More …

No malware No spam
McAfee Site Report
Web of Trust