Page 1 of 1

Chart background text

Posted: Wed Oct 05, 2011 12:30 pm
by 16558880
Probably a simple question:

Is there an easy wey to write a background text behind the Chart grid?

I could not find this in the help..

Many thanks for any help!

MF

Re: Chart background text

Posted: Thu Oct 06, 2011 8:16 am
by yeray
Hello,

Yes, you could draw your text at OnBeforeDrawAxes event. For example:

Code: Select all

uses Series;

procedure TForm1.Chart1BeforeDrawAxes(Sender: TObject);
begin
  with Chart1.Canvas do
  begin
    Font.Size:=50;
    Brush.Style:=bsClear;
    TextOut(50,50,'My text');
  end;
end;

procedure TForm1.FormCreate(Sender: TObject);
begin
  Chart1.View3D:=false;
  Chart1.Legend.Visible:=false;

  Chart1.AddSeries(TLineSeries).FillSampleValues();

  Chart1.Axes.Left.Grid.Width:=5;
  Chart1.Axes.Left.Grid.Style:=psSolid;
  Chart1.Axes.Left.Grid.Color:=clRed;
end;