Determining Series Name, and X and Y Values
Determining Series Name, and X and Y Values
I am creating a Delphi 2005 VCL application. I want to add DBCharts at runtime. The user determines how many DBCharts will be created by choosing some paramters. What I need is the ability to know the series and X and y value when the user clicks on the DBChart. Can someone suggest some code?
-
- Site Admin
- Posts: 14730
- Joined: Mon Jun 09, 2003 4:00 am
- Location: Banyoles, Catalonia
- Contact:
Hi McMClark,
You need to retrieve the values according to axes and screen coordinates. You can use something like this in DBChart's OnMouseMove event:
You need to retrieve the values according to axes and screen coordinates. You can use something like this in DBChart's OnMouseMove event:
Code: Select all
procedure TForm1.DBChart1MouseMove(Sender: TObject; Shift: TShiftState; X,
Y: Integer);
var
i, index: Integer;
XVal, YVal: double;
begin
for i:=0 to DBChart1.SeriesCount-1 do
begin
index:=DBChart1[i].Clicked(X,Y);
if (index <>-1) then
begin
XVal:=DBChart1[i].GetHorizAxis.CalcPosPoint(X);
YVal:=DBChart1[i].GetVertAxis.CalcPosPoint(Y);
Label1.Caption:=DBChart1[i].Name+': '+FloatToStr(XVal)+' - '+FloatToStr(YVal);
end;
end;
end;
Best Regards,
Narcís Calvet / Development & Support Steema Software Avinguda Montilivi 33, 17003 Girona, Catalonia Tel: 34 972 218 797 http://www.steema.com |
Instructions - How to post in this forum |
-
- Site Admin
- Posts: 14730
- Joined: Mon Jun 09, 2003 4:00 am
- Location: Banyoles, Catalonia
- Contact:
Hi McMClark,
Yes, but if you want it to be displayed when clicking the series you may better use OnMouseDown event.
Yes, but if you want it to be displayed when clicking the series you may better use OnMouseDown event.
Best Regards,
Narcís Calvet / Development & Support Steema Software Avinguda Montilivi 33, 17003 Girona, Catalonia Tel: 34 972 218 797 http://www.steema.com |
Instructions - How to post in this forum |