d3-3d
d3-3d copied to clipboard
Is it possible to get the 3D points if we have the 2D co-ordinates?
@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.
@Ravikanth-Koravenibh Can you give an example of the input and expected output of the data?
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
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
also looking into similar issue, @Niekes @Ravikanth-Koravenibh any findings on the same ?
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?