Page 1 of 1

DrawAxisLabel - Formatting

Posted: Tue Oct 19, 2010 3:25 pm
by 10551564
Hi,

I draw additional labels to the bottom axis using BottomAxis.DrawAxisLabel.

The attached picture shows the labels 200 and 500 added.
drawaxislabel.JPG
drawaxislabel.JPG (34.84 KiB) Viewed 3851 times
Now I want the custom labels to get the same format as the default labels from the bottom axis.
How can I set the properties for the custom labels (f.e. font style, font size, ...)?

Best regards

Heinz

Re: DrawAxisLabel - Formatting

Posted: Tue Oct 19, 2010 4:14 pm
by yeray
Hi Heinz,

I'm afraid you have to assign the properties you want to the Canvas before calling the DrawAxisLabel method. Something like this:

Code: Select all

procedure TForm1.Chart1AfterDraw(Sender: TObject);
var val: Double;
begin
  val:=250;

  Chart1.Canvas.Font.Style:=Chart1.Axes.Bottom.LabelsFont.Style;
  Chart1.Canvas.Font.Color:=Chart1.Axes.Bottom.LabelsFont.Color;
  Chart1.Canvas.Font.Size:=Chart1.Axes.Bottom.LabelsFont.Size;
  Chart1.Canvas.Font.Name:=Chart1.Axes.Bottom.LabelsFont.Name;

  with Chart1.Axes.Bottom do DrawAxisLabel(CalcXPosValue(val), PosAxis+TickLength+2, 0, FloatToStr(val));
end;

Re: DrawAxisLabel - Formatting

Posted: Wed Oct 20, 2010 9:42 am
by 10551564
Hello Yeray,

that was the missing link.

Many thanks and best regards

Heinz