I have been struggling like mad to solve an apparently basic question. Imagine you have a scatter plot, with say ... 10 markers. I suppose this plot has been generated using plotly within a Shiny environment.
One can easily get the coordinates of these markers using the event_data("plotly_click") code.
Now imagine you do not need the coordinates of these markers, but the coordinates generated by a mouse click but precisely where no marker exists (for example because you would like to set a new marker exactly there, and you would like to re-use the information coming from that mouse click).
I cannot obtain such a behavior using onclick(), or whatever.
Any idea ?
You could add a D3 event listener to your plot
and then
d3.event.layerXresp.layerY)document.getElementsByClassName('bg')[0].attributes['x'])myPlot.layout.xaxis.range[0])The new
xandyvalue are then pushed to the existing graphComplete R code
Interactive Javascript example
Shiny example