update growth trends dygraph

This commit is contained in:
2025-10-31 11:32:13 -04:00
parent 16804b72c0
commit 7cf49fec0f
+20 -4
View File
@@ -918,11 +918,27 @@ fillCol(
) )
output$test_dy <- renderDygraph({ output$test_dy <- renderDygraph({
test_ts <- test_query() req(growth_counties)
dygraph(test_ts, main = "Normalized Aggregate Growth") %>% aggregated_growth <- growth_counties() %>%
dySeries("population_index", label = "Population") %>% st_drop_geometry() %>%
dySeries("housing_index", label = "Housing Units") %>% group_by(year) %>%
summarize(
avg_normalized_population = mean(normalized_population, na.rm = TRUE),
avg_normalized_housing = mean(normalized_housing, na.rm = TRUE)
) %>%
mutate(year = as.Date(paste0(year, "-01-01")))
result <- aggregated_growth %>%
select(year, avg_normalized_population, avg_normalized_housing)
result_ts <- result %>%
select(-year) %>%
xts(order.by = result$year)
dygraph(result_ts, main = "Normalized Growth") %>%
dySeries("avg_normalized_population", label = "Population", color = "red") %>%
dySeries("avg_normalized_housing", label = "Housing Units", color = "blue") %>%
dyRangeSelector() dyRangeSelector()
}) })