Page 1 of 1

Custom labels and axis labels

Posted: Thu Jun 30, 2005 8:49 am
by 9232125
I have a vertical axis with labels.
Now, I need to add a custom label, showing the last value of the series.
If I add the new custom label with this code

lastValue := mySeries.YValues[k];

with mySeries.GetVertAxis.Items.Add(lastValue) do
begin
Transparent := False;
Transparency := 50;
Color := clBlue;
end;

all previous labels become invisible.
How can I add a custom label without hiding all other labels?

Thanks
FM

Posted: Thu Jun 30, 2005 10:51 am
by narcis
Hi FM,

To achieve what you request you should use Canvas.TextOut method in the AfterDraw event:

Code: Select all

procedure TForm1.Chart1AfterDraw(Sender: TObject);
begin
  Chart1.Canvas.Font.Color:=clRed;
  Chart1.Canvas.TextOut(Chart1.Axes.Left.PosAxis-25,
                        Series1.CalcYPos(Series1.LastValueIndex),
                        FloatToStr(Series1.YValue[Series1.LastValueIndex]));
end;

Posted: Fri Jul 01, 2005 7:59 am
by 9232125
Great! Exactly what I need.

Many thanks, Narcìs.

Best Regards

FM