mirror of
https://github.com/dylanbenzi/hurricane_normalization_app.git
synced 2026-07-29 21:01:27 +00:00
add additional caching
This commit is contained in:
+27
-24
@@ -177,7 +177,7 @@ observeEvent(input$selectStorm, {
|
|||||||
storm_selection$storm_basin <- input$stormBasin
|
storm_selection$storm_basin <- input$stormBasin
|
||||||
storm_selection$storm_year <- input$stormYear
|
storm_selection$storm_year <- input$stormYear
|
||||||
storm_selection$storm_name <- input$stormName
|
storm_selection$storm_name <- input$stormName
|
||||||
storm_selection$is_selected <- TRUE
|
#storm_selection$is_selected <- TRUE
|
||||||
|
|
||||||
showNotification("Storm selection updated!", type = "message")
|
showNotification("Storm selection updated!", type = "message")
|
||||||
})
|
})
|
||||||
@@ -218,7 +218,7 @@ Storm Overview {data-navmenu="Storm Details"}
|
|||||||
# Storm Overview - Setup
|
# Storm Overview - Setup
|
||||||
|
|
||||||
observe({
|
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)
|
unique_lfs <- get_unique_lf_ids(storm_selection)
|
||||||
|
|
||||||
@@ -247,7 +247,7 @@ Col {data-width=500}
|
|||||||
# TODO: implement hurricane category status
|
# TODO: implement hurricane category status
|
||||||
|
|
||||||
storm_track <- reactive({
|
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)
|
result <- get_hurdat_track(storm_selection)
|
||||||
|
|
||||||
# HURDAT storm status
|
# HURDAT storm status
|
||||||
@@ -363,7 +363,8 @@ storm_track <- reactive({
|
|||||||
arrange(datetime)
|
arrange(datetime)
|
||||||
|
|
||||||
return(result)
|
return(result)
|
||||||
})
|
}) %>%
|
||||||
|
bindCache(storm_selection$storm_year, storm_selection$storm_name, storm_selection$storm_basin)
|
||||||
|
|
||||||
output$track_map <- renderLeaflet({
|
output$track_map <- renderLeaflet({
|
||||||
track_data <- storm_track()
|
track_data <- storm_track()
|
||||||
@@ -550,16 +551,17 @@ Col {data-width=500 .tabset}
|
|||||||
# Overview - Normalization and Landfalls
|
# Overview - Normalization and Landfalls
|
||||||
|
|
||||||
storm_yearly_normalization <- reactive({
|
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)
|
result <- get_all_normalized_cost_index(storm_selection)
|
||||||
|
|
||||||
return(result)
|
return(result)
|
||||||
})
|
}) %>%
|
||||||
|
bindCache(storm_selection$storm_year, storm_selection$storm_name, storm_selection$storm_basin)
|
||||||
|
|
||||||
output$cost_index_chart <- renderDygraph({
|
output$cost_index_chart <- renderDygraph({
|
||||||
req(
|
req(
|
||||||
storm_yearly_normalization,
|
storm_yearly_normalization(),
|
||||||
input$storm_overview_cost_index_lf_select,
|
input$storm_overview_cost_index_lf_select,
|
||||||
input$storm_overview_cost_index_mmh_mmp,
|
input$storm_overview_cost_index_mmh_mmp,
|
||||||
input$storm_overview_cost_index_scale,
|
input$storm_overview_cost_index_scale,
|
||||||
@@ -632,15 +634,18 @@ output$cost_index_chart <- renderDygraph({
|
|||||||
) %>%
|
) %>%
|
||||||
dyAxis("x", drawGrid = F) %>%
|
dyAxis("x", drawGrid = F) %>%
|
||||||
dyRangeSelector()
|
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({
|
output$landfalls_table <- renderDT({
|
||||||
req(storm_selection$is_selected)
|
|
||||||
|
|
||||||
hurdat_landfalls <- get_hurdat_landfalls(storm_selection)
|
|
||||||
|
|
||||||
datatable(
|
datatable(
|
||||||
hurdat_landfalls,
|
hurdat_landfalls(),
|
||||||
rownames = F,
|
rownames = F,
|
||||||
colnames = c(
|
colnames = c(
|
||||||
"Date",
|
"Date",
|
||||||
@@ -763,7 +768,7 @@ Column {data-width=550}
|
|||||||
```{r}
|
```{r}
|
||||||
|
|
||||||
observe({
|
observe({
|
||||||
req(storm_selection$is_selected)
|
req(storm_selection$storm_basin, storm_selection$storm_year, storm_selection$storm_name)
|
||||||
|
|
||||||
updateSliderInput(
|
updateSliderInput(
|
||||||
session,
|
session,
|
||||||
@@ -797,10 +802,7 @@ sliderInput(
|
|||||||
# TODO: implement data loading
|
# TODO: implement data loading
|
||||||
|
|
||||||
growth_counties <- reactive({
|
growth_counties <- reactive({
|
||||||
req(
|
req(storm_selection$storm_basin, storm_selection$storm_year, storm_selection$storm_name, input$growth_trend_lf_select)
|
||||||
storm_selection$is_selected,
|
|
||||||
input$growth_trend_lf_select
|
|
||||||
)
|
|
||||||
|
|
||||||
selected_lf <- 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")
|
st_as_sf(wkt = "geom_wkt")
|
||||||
|
|
||||||
return(result)
|
return(result)
|
||||||
})
|
}) %>%
|
||||||
|
bindCache(storm_selection$storm_year, storm_selection$storm_name, storm_selection$storm_basin, input$growth_trend_lf_select)
|
||||||
|
|
||||||
output$growth_map <- renderLeaflet({
|
output$growth_map <- renderLeaflet({
|
||||||
req(growth_counties(), input$growth_trend_map_slider, input$growth_map_metric)
|
req(growth_counties(), input$growth_trend_map_slider, input$growth_map_metric)
|
||||||
@@ -867,12 +870,12 @@ output$growth_map <- renderLeaflet({
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
map
|
return(map)
|
||||||
})
|
})
|
||||||
|
|
||||||
observe({
|
observe({
|
||||||
req(
|
req(
|
||||||
growth_counties,
|
growth_counties(),
|
||||||
input$growth_trend_map_slider,
|
input$growth_trend_map_slider,
|
||||||
input$growth_map_metric
|
input$growth_map_metric
|
||||||
)
|
)
|
||||||
@@ -941,7 +944,7 @@ Column {data-width=450}
|
|||||||
dygraphOutput("test_dy")
|
dygraphOutput("test_dy")
|
||||||
|
|
||||||
output$test_dy <- renderDygraph({
|
output$test_dy <- renderDygraph({
|
||||||
req(growth_counties)
|
req(growth_counties())
|
||||||
|
|
||||||
aggregated_growth <- growth_counties() %>%
|
aggregated_growth <- growth_counties() %>%
|
||||||
st_drop_geometry() %>%
|
st_drop_geometry() %>%
|
||||||
@@ -973,11 +976,11 @@ output$test_dy <- renderDygraph({
|
|||||||
#3})
|
#3})
|
||||||
```
|
```
|
||||||
|
|
||||||
```{r include=FALSE}
|
```{r include=FALSE, execute=FALSE}
|
||||||
# Growth - County Table
|
# Growth - County Table
|
||||||
|
|
||||||
output$county_growth_dt <- renderDT({
|
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
|
base_year <- storm_selection$storm_year
|
||||||
current_year <- input$growth_trend_map_slider
|
current_year <- input$growth_trend_map_slider
|
||||||
|
|||||||
Reference in New Issue
Block a user