Storing obejcts behind points, and getting the Z value
Storing obejcts behind points, and getting the Z value
I have a situation where i am using a TTowerSeries with an X,Y,Z axis. When a user clicks a point in the chart i want to return an object associated with the point that has been clicked.
In essence i have a list of X values, and assigned to each X value is a list of Z values. When a user clicks on the chart i first get the X value point position and then use this to look up the Z values, but i am having problems looking up the Z value, i can not seem to get the current position of the depth axis (Z).
Is there an easier way to store an object behind a point, so when the bar is clicked it returns an object. Or alternatively how do i get the Z axis position and value?
In essence i have a list of X values, and assigned to each X value is a list of Z values. When a user clicks on the chart i first get the X value point position and then use this to look up the Z values, but i am having problems looking up the Z value, i can not seem to get the current position of the depth axis (Z).
Is there an easier way to store an object behind a point, so when the bar is clicked it returns an object. Or alternatively how do i get the Z axis position and value?
-
- Site Admin
- Posts: 14730
- Joined: Mon Jun 09, 2003 4:00 am
- Location: Banyoles, Catalonia
- Contact:
Hi linkhrsys,
You can try using a TNearestTool and something like the code below on TChart's OnMouseMove event.
You can try using a TNearestTool and something like the code below on TChart's OnMouseMove event.
Code: Select all
procedure TForm1.Chart1MouseMove(Sender: TObject; Shift: TShiftState; X,
Y: Integer);
var index: Integer;
begin
index:=ChartTool1.GetNearestPoint(Series1,X,Y);
Chart1.Title.Text[0]:='X: '+FloatToStr(Series1.XValues[index])+
', Y: '+FloatToStr(Series1.YValues[index])+
', Z: '+FloatToStr(Series1.ZValues[index]);
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:
Excellent! I'm glad to hear that fits your needs.
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 |
After having used the solution you posted and fully testing it, we find it is very hard to select a bar using this method.
Is there no possible way that on mouseclick could return index of the bar being clicked on a 3d axis, instead of using the tool GetNearestPoint which is inacurrate. This would have to take into account if the bar being clicked is visible, and not another bar behind on the Y axis.
Is there no possible way that on mouseclick could return index of the bar being clicked on a 3d axis, instead of using the tool GetNearestPoint which is inacurrate. This would have to take into account if the bar being clicked is visible, and not another bar behind on the Y axis.
Hi,
how about using the following code :
how about using the following code :
Code: Select all
procedure TForm1.Chart1MouseMove(Sender: TObject; Shift: TShiftState; X,
Y: Integer);
var ValueIndex: Integer;
ZPos: Integer;
begin
{ get 2d position }
ValueIndex := Series1.Clicked(X,Y);
if ValueIndex <> -1 then
begin
ZPos := Series1.CalcZPos(ValueIndex); { ZPosition for Canvas }
end;
end;
Pep Jorge
http://support.steema.com
http://support.steema.com
Hi,
yes, it could be for special case, note that TeeChart uses Y=Y(X,Z) and not more "usual" Z=Z(X,Y)).
This one is not an easy task. Determining X position (once you know the Z position) is easy. But determining Z position (depth axis) is a lot more difficult. We still haven't fully developed 3D<->2D transformation routines for this feature.
At the moment the only solution I can think of is the one I said to you, but this method could not give you 100% accurate results in special cases.
yes, it could be for special case, note that TeeChart uses Y=Y(X,Z) and not more "usual" Z=Z(X,Y)).
This one is not an easy task. Determining X position (once you know the Z position) is easy. But determining Z position (depth axis) is a lot more difficult. We still haven't fully developed 3D<->2D transformation routines for this feature.
At the moment the only solution I can think of is the one I said to you, but this method could not give you 100% accurate results in special cases.
Pep Jorge
http://support.steema.com
http://support.steema.com