Chart brush for custom drawing

TeeChart VCL for Borland/CodeGear/Embarcadero RAD Studio, Delphi and C++ Builder.
Post Reply
PoLabs
Newbie
Newbie
Posts: 17
Joined: Mon Sep 01, 2014 12:00 am

Chart brush for custom drawing

Post by PoLabs » Thu Oct 02, 2014 9:18 am

Hi,

I am doing some custom drawing in OnAfterDraw event handler. I have problems with using Chart.Canvas.TextOut and transparent text. I tried different brush settings but I still have some issues.

I usually do Chart.Canvas.Brush.Style := bsClear but I get TextOut with black background. So I tried also Chart.Canvas.Font.Brush.... etc...

Could you explain to me when and how to use different Brushes and when do you use them to draw something?

Chart.Brush (TBrush)
Chart.Canvas.Brush (TTeeBrush)
Chart.Canvad.Font.Brush(TTeeBrush)

Which one should I use to display on Canvas some text with TextOut and transparent background?

Thanks in advance.

Yeray
Site Admin
Site Admin
Posts: 9613
Joined: Tue Dec 05, 2006 12:00 am
Location: Girona, Catalonia
Contact:

Re: Chart brush for custom drawing

Post by Yeray » Thu Oct 02, 2014 11:15 am

Hello,

You have to use the Canvas BackMode (cbmOpaque/cbmTransparent) to deactivate/activate transparency and set the color you wish at the Canvas BackColor. Ie:

Code: Select all

uses Series, TeCanvas;

procedure TForm1.Chart1AfterDraw(Sender: TObject);
begin
  with Chart1.Canvas do
  begin
    BackMode:=cbmOpaque;
    BackColor:=clRed;
    TextOut(100, 100, 'Opaque Text Background');

    BackMode:=cbmTransparent;
    TextOut(100, 120, 'Transparent Text');
  end;
end;

procedure TForm1.FormCreate(Sender: TObject);
begin
  Chart1.AddSeries(TLineSeries).FillSampleValues;

  Chart1.View3D := false;
end;
Best Regards,
ImageYeray Alonso
Development & Support
Steema Software
Av. Montilivi 33, 17003 Girona, Catalonia (SP)
Image Image Image Image Image Image Please read our Bug Fixing Policy

PoLabs
Newbie
Newbie
Posts: 17
Joined: Mon Sep 01, 2014 12:00 am

Re: Chart brush for custom drawing

Post by PoLabs » Thu Oct 02, 2014 12:25 pm

Thank you for clarifying.

Post Reply