Join GitHub today
GitHub is home to over 31 million developers working together to host and review code, manage projects, and build software together.Sign up
addPolygons() now responds to crosstalk events #391
library(plotly) library(leaflet) library(sf) nc <- system.file("shape/nc.shp", package = "sf") %>% st_read() %>% st_transform(4326) %>% highlight_key() map <- leaflet(nc) %>% addTiles() %>% addPolygons( opacity = 1, color = 'white', weight = .25, fillOpacity = .5, fillColor = 'blue', smoothFactor = 0 ) p <- plot_ly(nc) %>% add_markers(x = ~BIR74, y = ~SID79) %>% layout(dragmode = "lasso") %>% highlight("plotly_selected") crosstalk::bscols(map, p)
Any feedback/input is greatly appreciated :)
I was originally thinking polygon brushing would be really hard to implement, because it'd either have to work by 1) any intersection between the brushing rectangle and the polygon, or 2) complete coverage of the polygon by the brushing rectangle.
But a nice easier-to-implement alternative would be 3) the brushing rectangle includes the center-of-mass of the polygon (is that the right term for it?). I believe there are fast routines to do this in R?
Also fwiw this is what I was going after here: https://twitter.com/mdsumner/status/830380049815597056