Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Is it possible to get the 3D points if we have the 2D co-ordinates? #27

Closed
Ravikanth-Koravenibh opened this issue Jan 18, 2024 · 4 comments

Comments

@Ravikanth-Koravenibh
Copy link

@Niekes Is it possible to get the 3D points if we have the 2D coordinates similar to what the d3.scale.invert does. An application of this would be to be able to identify the point a user clicks. Sorry for directly tagging.

@Niekes
Copy link
Owner

Niekes commented Jan 19, 2024

@Ravikanth-Koravenibh Can you give an example of the input and expected output of the data?

@Ravikanth-Koravenibh
Copy link
Author

Ravikanth-Koravenibh commented Apr 24, 2024

Hi @Niekes , sorry for the very delayed response got busy in some other items.
example
lets assume i have created a scatterplot similar to the example here https://codepen.io/Niekes/pen/poGMpLw
but i want to add a ability to click on any point on the plot to display more info on that point in a different component on UI. lets think that might be
image
the orange point near 8 in the above image.
By binding the click event to svg i will be able to get the co-ordinates of that point. But to get the actual value of that point if this is a plain d3 plot i can use the d3.scale.invert(corresponding co-ordinate) to get the value. which I can use to identify the data point from my data array and get the respective details and show on the other component.
For example in the added picture to get the correct y value of the orange point i can click on it to get the co-ordinate and pass to the invert
yscale3d.invert(co-ordinate)~=8
similar i can do for X. Similar to this
https://d3js.org/d3-scale/linear#linear_invert
https://d3js.org/d3-selection/events#pointer
So basically, ability for the user to get the actual data value of a co-ordinate value that we can get from events like click

@DevangBarot-BH
Copy link

also looking into similar issue, @Niekes @Ravikanth-Koravenibh any findings on the same ?

@Niekes
Copy link
Owner

Niekes commented May 24, 2024

Hi @Ravikanth-Koravenibh,

I am not sure if I understand your problem correctly. d3-3d.js only works if you give it real 3d data and you have always access to that data. Just add .on("click", (event, d) => console.log(d)) at line 93 before .merge(points) and click on a point. Than you get all available data.

is that what you are looking for?

@Niekes Niekes closed this as completed Aug 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants