get subset of histogram data from plotly selection

Hi everyone!

I was hoping to use JS to grab to the subset of my data within a histogram -- I see the counts on hover but I'd like to get those specific rows and use them to filter my data in R.

ggplotly(
  ggplot(iris, aes(y = Sepal.Length)) +
  geom_histogram()
) %>%
htmlwidgets::onRender("
    function(el) { 
      el.on('plotly_click', function(d) { 
        // not sure what the subset of my bar is within `d`
       let a = d.points.blahblah
       // then I probably need to use Shiny.setInputValue('filtered_data',   a)
      });
    }
  ")

Does this workflow make sense? Is there an easier way to do this in R? ANY help appreciated!!!

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.