Page 1 of 1

Chart brush for custom drawing

Posted: Thu Oct 02, 2014 9:18 am
by 16570117
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.

Re: Chart brush for custom drawing

Posted: Thu Oct 02, 2014 11:15 am
by yeray
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;

Re: Chart brush for custom drawing

Posted: Thu Oct 02, 2014 12:25 pm
by 16570117
Thank you for clarifying.