Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 20 additions & 6 deletions dashboard/app.R
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,10 @@ ui <- fluidPage(padding=0,
tabPanel("Evaluation Plots", value = "evaluations",
fluidRow(column(11, textOutput('renderWarningText'))),
plotlyOutput(outputId = "summaryPlot", height="auto"),
fluidRow(
column(11, offset=1,
div(id="refresh-colors", actionButton(inputId="refreshColors", label= "Shuffle Colors"))
)),
tags$br(),
plotlyOutput(outputId = "truthPlot", height="auto"),
fluidRow(
Expand Down Expand Up @@ -215,9 +219,7 @@ server <- function(input, output, session) {
df <- df %>% rename("10" = cov_10, "20" = cov_20, "30" = cov_30, "40" = cov_40, "50" = cov_50, "60" = cov_60, "70" = cov_70, "80" = cov_80, "90" = cov_90, "95" = cov_95, "98" = cov_98)

# Prepare color palette
set.seed(100)
forecaster_rand <- sample(unique(df$forecaster))
color_palette = setNames(object = viridis(length(unique(df$forecaster))), nm = forecaster_rand)
colorSeed = 100

# Prepare input choices
forecasterChoices = sort(unique(df$forecaster))
Expand All @@ -228,7 +230,7 @@ server <- function(input, output, session) {
# CREATE MAIN PLOT
##################
summaryPlot = function(scoreDf, targetVariable, scoreType, forecasters,
horizon, loc, allLocations, coverageInterval = NULL) {
horizon, loc, allLocations, coverageInterval = NULL, colorSeed) {
signalFilter = CASE_FILTER
if (targetVariable == "Deaths") {
signalFilter = DEATH_FILTER
Expand Down Expand Up @@ -331,6 +333,10 @@ server <- function(input, output, session) {

filteredScoreDf$ahead = factor(filteredScoreDf$ahead, levels = c(1, 2, 3, 4),
labels = c("Horizon: 1 Week", "Horizon: 2 Weeks", "Horizon: 3 Weeks", "Horizon: 4 Weeks"))
set.seed(colorSeed)
forecasterRand <- sample(unique(df$forecaster))
colorPalette = setNames(object = viridis(length(unique(df$forecaster))), nm = forecasterRand)
Comment on lines +336 to +338
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With viridis, the colors sometimes become quite similar after shuffling.
But it usually gets quite distinct within a few more shuffles!
I personally don't know of other qualitative colorblind-friendly palettes that support the number of categories required.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I explored the options a bit and thought this one worked the best of the ones I looked at. Definitely open to using another package though if there is a better one.


p = ggplot(
filteredScoreDf,
aes(x = Week_End_Date, y = Score, color = Forecaster, shape = Forecaster)
Expand All @@ -341,7 +347,7 @@ server <- function(input, output, session) {
scale_x_date(date_labels = "%b %Y") +
scale_y_continuous(limits = c(0,NA), labels = scales::comma) +
facet_wrap(~ahead, ncol=1) +
scale_color_manual(values = color_palette) +
scale_color_manual(values = colorPalette) +
theme_bw() +
theme(panel.spacing=unit(0.5, "lines"))

Expand Down Expand Up @@ -395,13 +401,21 @@ server <- function(input, output, session) {
#############
output$summaryPlot <- renderPlotly({
summaryPlot(df, input$targetVariable, input$scoreType, input$forecasters,
input$aheads, input$location, input$allLocations, input$coverageInterval)
input$aheads, input$location, input$allLocations, input$coverageInterval, colorSeed)
})

###################
# EVENT OBSERVATION
###################

observeEvent(input$refreshColors, {
colorSeed = floor(runif(1, 1, 1000))
output$summaryPlot <- renderPlotly({
summaryPlot(df, input$targetVariable, input$scoreType, input$forecasters,
input$aheads, input$location, input$allLocations, input$coverageInterval, colorSeed)
})
})

# When the target variable changes, update available forecasters, locations, and CIs to choose from
observeEvent(input$targetVariable, {
if (input$targetVariable == 'Deaths') {
Expand Down
4 changes: 4 additions & 0 deletions dashboard/www/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -51,4 +51,8 @@
}
#drag-to-zoom {
font-size:11px;
}
#refreshColors {
height: 26px;
font-size: 12px;
}