Trying to make a shiny app with these properties.
Default view is aggregate layer. There will be number of columns/bars. On click of a column, the view is updated to show the non-aggregated version of data.
It is something like to know which bar is getting clicked and filtering the data with respect to it.
I have written the below code, which does the aggregate layer. However not sure how to get the "clicked_on_this_bar" details. Here if we get, user clicked on bar of "Area A", then we can just filter orig_df with area A and update the view. How to proceed in this ?
rm( list = ls() )
library( shiny ) ; library( shinydashboard ) ; library( dplyr ) ; library( deckgl )
ui <- basicPage( deckglOutput( 'map', height = '800px' ) )
server <- function(input, output) {
aggregate_df = data.frame( 'area' = LETTERS[1:2], 'count' = 110:111, median_lon = c( 3.39, 3.41 ),
median_lat = c( 49.7, 49.4 ), color = c("#0080FF", "#FF0080") )
orig_df = data.frame( 'area' = rep( c( 'A', 'B' ), c( 3, 2 ) ), count = 10:14, lon = c( 3.45, 3.39, 3.19, 3.41, 3.92 ),
lat = c( 48, 49.7, 52, 49.4, 51.5 ), color = c("#0080FF", "#FF0080", "#FF3030", "#00EE00", '#FF7F24') )
output$map = renderDeckgl({
deckgl( zoom = 7, pitch = 35, latitude = 48.29507, longitude = 4.0731520 ) %>%
add_column_layer(
data = aggregate_df,
getPosition = ~median_lon + median_lat,
getElevation = ~count,
getFillColor = ~color,
getTooltip = "Area: {{area}}, Count: {{count}}",
elevationScale = 100
) %>% add_basemap()
})
# observeEvent({
#
# deckgl_proxy( 'map' ) %>%
#
# add_column_layer(
# data = orig_df %>% filter( area == click[['A']] ),
# getPosition = ~lon + lat,
# getElevation = ~count,
# getFillColor = ~color,
# getTooltip = "Area: {{area}}, Count: {{count}}",
# elevationScale = 50
# ) %>% update_deckgl(it = "works")
#
# })
}
shinyApp(ui, server)