bubbles
bubbles copied to clipboard
feature request: return bubble index to shiny on bubble click
Hi,
in some Shiny contexts it would be useful to know on which bubble a user has clicked. This can be added quite easily by adding something like this to the code in bubble.js
newNode.append("circle")
.style("fill", "#FFFFFF")
.on("click",function(d,i){
var id = el.id + "_index";
Shiny.onInputChange(id,i);
});
Assuming the chart was rendered via a call like
output$bubbles <- renderBubbles({
...
})
the user can then get the index back via input$bubbles_index
.
In Shiny this works nicely, but for a stand alone htmlWidget the code probably will be a tad different as the Shiny object in Shiny.onInputChange doesn't exist. Added the d (data) content, together with the index i could also be useful of course.
kind regards, Herman
Maybe a way to interact with the input?