Skip to content
Open
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
37 changes: 26 additions & 11 deletions R/colour_choices.R
Original file line number Diff line number Diff line change
Expand Up @@ -103,15 +103,17 @@ colour_choices <- function(input, output, session, verif_data) {
shiny::req(verif_data())
fcst_models <- unique(unlist(lapply(verif_data(), function(x) unique(x[["mname"]]))))
colour_table_modal(
data.frame(mname = fcst_models, colour = palette_colours()[1:length(fcst_models)], stringsAsFactors = FALSE)
data.frame(mname = fcst_models, colour = palette_colours()[1:length(fcst_models)], new_legend = fcst_models, stringsAsFactors = FALSE)
)
colour_table(colour_table_modal())
lapply(
seq_along(fcst_models),
function(i) shiny::observeEvent(input[[paste0("colour_", i)]], {
function(i) shiny::observeEvent(c(input[[paste0("colour_", i)]], input[[paste0("legend_", i)]]), {
modified_colours <- colour_table_modal()
new_colour <- input[[paste0("colour_", i)]]
modified_colours$colour[modified_colours$mname == fcst_models[i]] <- new_colour
new_legend <- input[[paste0("legend_", i)]]
modified_colours$new_legend[modified_colours$mname == fcst_models[i]] <- new_legend
colour_table_modal(modified_colours)
})
)
Expand All @@ -136,21 +138,34 @@ colour_choices <- function(input, output, session, verif_data) {
c(RColorBrewer:::quallist, "harp2", "Custom"),
selected_palette()
),
lapply(seq_along(fcst_models), function(i)
colourpicker::colourInput(
ns(paste0("colour_", i)),
fcst_models[i],
value = colour_table()$colour[i],
showColour = "background",
palette = palette,
allowedCols = allowed_cols
shiny::fluidRow(
column(6,
lapply(seq_along(fcst_models), function(i)
colourpicker::colourInput(
ns(paste0("colour_", i)),
fcst_models[i],
value = colour_table()$colour[i],
showColour = "background",
palette = palette,
allowedCols = allowed_cols
)
)
),
column(6,
lapply(seq_along(fcst_models), function(i)
shiny::textInput(
ns(paste0("legend_", i)),
paste("Legend",fcst_models[i]),
colour_table()$new_legend[i]
)
)
)
),
footer = shiny::tagList(
shiny::actionButton(ns("colours_modal_cancel"), "Cancel"),
customActionButton(ns("colours_modal_ok"), "OK", btn_class = "primary")
),
size = "s"
size = "m"
)

}
Expand Down
20 changes: 19 additions & 1 deletion R/options_bar.R
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ options_barUI <- function(id) {
#' @export
#'
#' @examples
options_bar <- function(input, output, session) {
options_bar <- function(input, output, session, colour_table) {

app_start_dir <- shiny::getShinyOption("app_start_dir")
volumes <- c(Home = fs::path_home(), harp_getVolumes()())
Expand Down Expand Up @@ -205,6 +205,24 @@ options_bar <- function(input, output, session) {
}
})

# Update mname from text input to create new legends
new_verif_data <- reactiveVal(NULL)
shiny::observeEvent(colour_table(), {
shiny::req(colour_table())
fcst_models <- unique(unlist(lapply(verif_data(), function(x) unique(x[["mname"]]))))

new_verif_data <- verif_data()
new_verif_data <- mutate_list(
new_verif_data,
mname = msub(
mname,
fcst_models,
colour_table()$new_legend
)
)
verif_data(new_verif_data)
})

return(verif_data)

}
Expand Down
2 changes: 1 addition & 1 deletion inst/shiny_apps/plot_point_verif/server.R
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ server <- function(input, output, session) {
# LOAD DATA #
############################################################

verif_data <- shiny::callModule(harpVis::options_bar, "options_bar")
verif_data <- shiny::callModule(harpVis::options_bar, "options_bar", colour_table)

############################################################
# FILTER DATA #
Expand Down