Hi
I have an intraday chart where the X axis has the hours from 08:00 to 18:00. Throughout the day the chart updates as time goes by.
I would like to add an Annotation to the right of the last added value. How can I find the X and Y coordinates of the last values to be added to a chart?
E.g. at 13:04 I added the value 34,567 but from the resolution I have on the Y axis I can't see what the exact value is so I need to add an annotation (which is easy, but what is the position I need?)
Marius
Find coordinates of last value
Re: Find coordinates of last value
Hi Marius,
You need to use series' CalcXPos and CalcYPos functions. Here you have an example:
You need to use series' CalcXPos and CalcYPos functions. Here you have an example:
Code: Select all
uses Series, TeeTools;
var Line1: TLineSeries;
Annotation1: TAnnotationTool;
procedure TForm1.FormCreate(Sender: TObject);
begin
Chart1.View3D:=false;
Line1:=Chart1.AddSeries(TLineSeries.Create(self)) as TLineSeries;
Line1.Pointer.Visible:=true;
Line1.XValues.DateTime:=true;
Chart1.Legend.Visible:=false;
Annotation1:=Chart1.Tools.Add(TAnnotationTool.create(self)) as TAnnotationTool;
Chart1.MarginRight:=10;
end;
procedure TForm1.Timer1Timer(Sender: TObject);
begin
Line1.AddXY(Now,random*100);
Annotation1.Text:=FormatFloat('#.##0', Line1.YValue[Line1.Count-1]);
Chart1.Draw;
Annotation1.Left:=Line1.CalcXPos(Line1.Count-1);
Annotation1.Top:=Line1.CalcYPos(Line1.Count-1);
end;
Best Regards,
Yeray Alonso Development & Support Steema Software Av. Montilivi 33, 17003 Girona, Catalonia (SP) | |
Please read our Bug Fixing Policy |