christophergandrud / networkD3

D3 JavaScript Network Graphs from R
http://christophergandrud.github.io/networkD3
649 stars 270 forks source link

Pass info from D3 back to [R] #272

Closed TS404 closed 4 years ago

TS404 commented 4 years ago

Could data be passed back from the visualisation to an object in [R]?

For example. on this simple shiny app I'd ideally like to be able to populate a list in [R] based on nodes that are clicked. Currently, I have to do it via a checkbox list and clicking the nodes just calls a basic 'alert("You clicked " + d.name);'.

(Also asked at r2d3-I79)

cjyetman commented 4 years ago

You'll need to look into Shiny Reactivity, which is not part of this package.

Here is one example of using Shiny Reactivity with a networkD3 plot.

Also in general, please provide a minimal reproducible example when asking for support.

cjyetman commented 4 years ago

Also FYI, networkD3 does not use r2d3, so they likely will not help you over there.

TS404 commented 4 years ago

Ah, thank you! That makes sense. Doubly thank you for the MRD link. I'll aim to do so in future.