I am working on a dashboard using Flexdashboard and would like to present a map and datatable that filter together using crosstalk. I have been able to do this using standard or circle markers but it doesn't seem to work when using clusters.
I found this issue raised on Github from 2017 which links to a full example in RPubs but haven't been able to find a solution. Here is the code from that example:
library(crosstalk)
library(leaflet)
library(DT)
# Wrap data frame in SharedData
sd <- SharedData$new(quakes[sample(nrow(quakes), 10),])
bscols(
# Create a filter input
filter_slider("mag", "Magnitude", sd, column=~mag, step=0.1, width=250),
leaflet(sd) %>% addTiles() %>% addMarkers( clusterOptions = markerClusterOptions()),
datatable(sd, extensions="Scroller", style="bootstrap", class="compact", width="100%",
options=list(deferRender=TRUE, scrollY=300, scroller=TRUE))
)
The issue is that while the number of rows in the table reduces as the magnitude range is narrowed the clusters do not change. Just using standard markers instead of the clusters does work (again taken from the RPubs example by Matthias Hinz):
# Use SharedData like a dataframe with Crosstalk-enabled widgets
bscols(
# Create a filter input
filter_slider("mag", "Magnitude", sd, column=~mag, step=0.1, width=250),
leaflet(sd) %>% addTiles() %>% addMarkers(),
datatable(sd, extensions="Scroller", style="bootstrap", class="compact", width="100%",
options=list(deferRender=TRUE, scrollY=300, scroller=TRUE))
)
I would like to have the clusters update as the data is filtered. This could either be by creating new clusters or changing the number displayed on the existing ones.
I want this to be a standalone html document that can be shared offline rather than hosted so as I understand it I would not be able to use Shiny.