Page 1 of 1
Determining Series Name, and X and Y Values
Posted: Sat Apr 08, 2006 2:59 pm
by 9337074
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?
Posted: Mon Apr 10, 2006 8:27 am
by narcis
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:
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;
Posted: Fri Apr 14, 2006 1:44 pm
by 9337074
I am not sure if I asked for the correct thing. Will your code give the x and y axis value of the point clicked on the series?
Posted: Tue Apr 18, 2006 9:46 am
by narcis
Hi McMClark,
Yes, but if you want it to be displayed when clicking the series you may better use OnMouseDown event.