diff --git a/app/dashboard.Rmd b/app/dashboard.Rmd index f128af9..6181779 100644 --- a/app/dashboard.Rmd +++ b/app/dashboard.Rmd @@ -177,7 +177,7 @@ observeEvent(input$selectStorm, { storm_selection$storm_basin <- input$stormBasin storm_selection$storm_year <- input$stormYear storm_selection$storm_name <- input$stormName - storm_selection$is_selected <- TRUE + #storm_selection$is_selected <- TRUE showNotification("Storm selection updated!", type = "message") }) @@ -218,7 +218,7 @@ Storm Overview {data-navmenu="Storm Details"} # Storm Overview - Setup observe({ - req(storm_selection$is_selected) + req(storm_selection$storm_basin, storm_selection$storm_year, storm_selection$storm_name) unique_lfs <- get_unique_lf_ids(storm_selection) @@ -247,7 +247,7 @@ Col {data-width=500} # TODO: implement hurricane category status storm_track <- reactive({ - req(storm_selection, storm_selection$is_selected) + req(storm_selection$storm_basin, storm_selection$storm_year, storm_selection$storm_name) result <- get_hurdat_track(storm_selection) # HURDAT storm status @@ -363,7 +363,8 @@ storm_track <- reactive({ arrange(datetime) return(result) -}) +}) %>% + bindCache(storm_selection$storm_year, storm_selection$storm_name, storm_selection$storm_basin) output$track_map <- renderLeaflet({ track_data <- storm_track() @@ -550,16 +551,17 @@ Col {data-width=500 .tabset} # Overview - Normalization and Landfalls storm_yearly_normalization <- reactive({ - req(storm_selection$is_selected) + req(storm_selection$storm_basin, storm_selection$storm_year, storm_selection$storm_name) result <- get_all_normalized_cost_index(storm_selection) return(result) -}) +}) %>% + bindCache(storm_selection$storm_year, storm_selection$storm_name, storm_selection$storm_basin) output$cost_index_chart <- renderDygraph({ req( - storm_yearly_normalization, + storm_yearly_normalization(), input$storm_overview_cost_index_lf_select, input$storm_overview_cost_index_mmh_mmp, input$storm_overview_cost_index_scale, @@ -632,15 +634,18 @@ output$cost_index_chart <- renderDygraph({ ) %>% dyAxis("x", drawGrid = F) %>% dyRangeSelector() -}) +}) %>% + bindCache(storm_selection$storm_year, storm_selection$storm_name, storm_selection$storm_basin) + +hurdat_landfalls <- reactive({ + req(storm_selection$storm_basin, storm_selection$storm_year, storm_selection$storm_name) + get_hurdat_landfalls(storm_selection) +}) %>% + bindCache(storm_selection$storm_year, storm_selection$storm_name, storm_selection$storm_basin) output$landfalls_table <- renderDT({ - req(storm_selection$is_selected) - - hurdat_landfalls <- get_hurdat_landfalls(storm_selection) - datatable( - hurdat_landfalls, + hurdat_landfalls(), rownames = F, colnames = c( "Date", @@ -763,7 +768,7 @@ Column {data-width=550} ```{r} observe({ - req(storm_selection$is_selected) + req(storm_selection$storm_basin, storm_selection$storm_year, storm_selection$storm_name) updateSliderInput( session, @@ -797,10 +802,7 @@ sliderInput( # TODO: implement data loading growth_counties <- reactive({ - req( - storm_selection$is_selected, - input$growth_trend_lf_select - ) + req(storm_selection$storm_basin, storm_selection$storm_year, storm_selection$storm_name, input$growth_trend_lf_select) selected_lf <- input$growth_trend_lf_select @@ -823,7 +825,8 @@ growth_counties <- reactive({ st_as_sf(wkt = "geom_wkt") return(result) -}) +}) %>% + bindCache(storm_selection$storm_year, storm_selection$storm_name, storm_selection$storm_basin, input$growth_trend_lf_select) output$growth_map <- renderLeaflet({ req(growth_counties(), input$growth_trend_map_slider, input$growth_map_metric) @@ -867,12 +870,12 @@ output$growth_map <- renderLeaflet({ ) } - map + return(map) }) observe({ req( - growth_counties, + growth_counties(), input$growth_trend_map_slider, input$growth_map_metric ) @@ -941,7 +944,7 @@ Column {data-width=450} dygraphOutput("test_dy") output$test_dy <- renderDygraph({ - req(growth_counties) + req(growth_counties()) aggregated_growth <- growth_counties() %>% st_drop_geometry() %>% @@ -973,11 +976,11 @@ output$test_dy <- renderDygraph({ #3}) ``` -```{r include=FALSE} +```{r include=FALSE, execute=FALSE} # Growth - County Table output$county_growth_dt <- renderDT({ - req(growth_counties, input$growth_trend_map_slider, storm_selection$is_selected) + req(growth_counties(), input$growth_trend_map_slider, torm_selection$storm_basin, storm_selection$storm_year, storm_selection$storm_name) base_year <- storm_selection$storm_year current_year <- input$growth_trend_map_slider