Below, I am trying to make a dash reactive to changes in user inputs. There date range values, a dropdown menu and checkbox. When any of the default feature is changed, there should be a new graphs ans correspomding result due to the changes.
The below code uses the eventReactive() function to create a reactive component - "" bike_orderlines_data_filtered_tbl().
bike_orderlines_data_filtered_tbl <- eventReactive(
eventExpr = input$apply,
valueExpr = {
bike_orderlines_tbl %>%
filter(order_date %>% between(left = input$date_range[1],
right = input$date_range[2])) %>%
filter(category_1 %in% input$checkbox_category_1) %>%
filter(category_2 %in% input$picker_category_2)
# Filtering code goes here
},
ignoreNULL = FALSE
)
However, When I call the the reactive componebt in the below codes
renderPlotly(expr = {
geo_plot_tbl <- reactive({
bike_orderlines_data_filtered_tbl() %>%
group_by(state) %>%
summarise(total_revenue = sum(total_price)) %>%
ungroup() %>%
right_join(germany_sf, by = c("state" = "VARNAME_1")) %>%
mutate(total_revenue = ifelse(is.na(total_revenue), 0, total_revenue)) %>%
mutate(label_text = str_glue("State: {state}
Revenue: {format_to_euro(total_revenue)}")) %>%
st_as_sf()
})
plot_ly(geo_plot_tbl(),
split = ~NAME_1,
color = ~total_revenue,
colors = "Blues",
stroke = I("black"),
hoverinfo = 'text',
text = ~label_text,
hoveron = "fills",
showlegend = FALSE)
})
there is some kind of reactivity going on but now new result is produce when the checkbox, datte range and dropdown menu is change.
Thanks in advance
When I try apply the normal dplyr function with usung shiny reactive component - ie an ordinary dataframe, the is a dynamic resulkl produce which is note reactive.