@@ -129,8 +129,9 @@ server <- function(input, output, session) {
129
129
CASES_DEATHS_CURRENT <- resolveCurrentCasesDeathDay()
130
130
HOSP_CURRENT <- resolveCurrentHospDay()
131
131
132
- # Set the "previous" target to be the same as the starting target variable
132
+ # Set the "previous" target and score type to be the same as the starting values
133
133
PREV_TARGET <- INIT_TARGET
134
+ PREV_SCORE_TYPE <- INIT_SCORE_TYPE
134
135
135
136
PREV_AS_OF_DATA <- reactiveVal(NULL )
136
137
AS_OF_CHOICES <- reactiveVal(HOSP_CURRENT )
@@ -264,7 +265,7 @@ server <- function(input, output, session) {
264
265
output [[paste0(" renderWarningText" , DASH_SUFFIX )]] <- renderText(" " )
265
266
showElement(paste0(" truthPlot" , DASH_SUFFIX ))
266
267
}
267
- # Not totaling over all locations
268
+ # Not totaling over all locations (single states and "US")
268
269
} else {
269
270
if (! is.null(asOfData )) {
270
271
filteredScoreDf <- filteredScoreDf %> %
@@ -788,14 +789,28 @@ server <- function(input, output, session) {
788
789
# Only show forecasters that have data for the score chosen
789
790
updateForecasterChoices(session , df , input $ forecasters , input $ scoreType )
790
791
791
- # If we are switching between coverage and other score types we need to
792
- # update the as of data we have so it matches the correct locations shown
793
- if (input $ location == " US" ) {
792
+ showScoreExplanation(session , input $ scoreType , DASH_SUFFIX )
793
+ USE_CURR_TRUTH <<- TRUE
794
+
795
+ # Normally when score type selection changes, we reuse the existing truth
796
+ # plot (behavior is toggled by `USE_CURR_TRUTH`). This is valid as long
797
+ # as the locations reported by each score type are the same.
798
+ #
799
+ # However, regardless of which location is selected, coverage aggregates
800
+ # scores over states that have forecasts reported by all selected
801
+ # forecasters. This means that when changing to or from "coverage" and
802
+ # any single state or "US" is selected as the location (that is, we are
803
+ # not aggregating over shared locations), we need to regenerate the truth
804
+ # plot with updated truth data.
805
+ if ((input $ scoreType == " coverage" || PREV_SCORE_TYPE == " coverage" ) && input $ location != TOTAL_LOCATIONS ) {
794
806
updateAsOfData()
807
+ # Don't ONLY create a new truth plot, make a new main plot, too.
808
+ RE_RENDER_TRUTH <<- FALSE
809
+ # Need to create new truth plot.
810
+ USE_CURR_TRUTH <<- FALSE
795
811
}
796
812
797
- showScoreExplanation(session , input $ scoreType , DASH_SUFFIX )
798
- USE_CURR_TRUTH <<- TRUE
813
+ PREV_SCORE_TYPE <<- input $ scoreType
799
814
})
800
815
801
816
# When forecaster selections change, update available aheads, locations, and CIs to choose from
0 commit comments