diff --git a/h2/components/modules/mod_graph.R b/h2/components/modules/mod_graph.R index 2dafd88..f0e2080 100644 --- a/h2/components/modules/mod_graph.R +++ b/h2/components/modules/mod_graph.R @@ -5,7 +5,10 @@ graph_ui <- function(id) { ns <- NS(id) - fluidRow(actionButton(ns("plot"), "Plot"), + fluidRow(selectInput(ns("variable"), "Select a variable to plot:", + c("Global Temperature at Surface" = "global_tas", + "CO2 Concentration" = "CO2_concentration")), + actionButton(ns("plot"), "Plot"), plotlyOutput(ns("graph"))) } @@ -14,7 +17,7 @@ graph_server <- function(id, r6, i) { observe({ if (r6$save == TRUE) { filtered_output <- - filter(r6$output[[r6$i()]], variable == "global_tas") + filter(r6$output[[r6$i()]], variable == input$variable) output$graph <- renderPlotly({ plot_ly( @@ -38,7 +41,7 @@ graph_server <- function(id, r6, i) { } if (r6$save == FALSE) { filtered_output <- - filter(r6$no_save, variable == "global_tas") + filter(r6$no_save, variable == input$variable) output$graph <- renderPlotly({ plot_ly( @@ -55,12 +58,12 @@ graph_server <- function(id, r6, i) { ) %>% layout( xaxis = list(title = "Year"), - yaxis = list(title = "Global Temperature (C)"), - title = "Global Temperature at Surface" + yaxis = list(title = input$variable), + title = input$variable ) }) } }) %>% - bindEvent(input$plot) + bindEvent(input$plot, ignoreNULL = FALSE, ignoreInit = FALSE) }) } \ No newline at end of file diff --git a/h2/components/modules/mod_run.R b/h2/components/modules/mod_run.R index d4570ef..62d77a1 100644 --- a/h2/components/modules/mod_run.R +++ b/h2/components/modules/mod_run.R @@ -18,7 +18,7 @@ run_ui <- function(id) { selected = "input/hector_ssp245.ini", inline=TRUE, shape = "square", width = "80%"), sliderInput(ns("start"), label="Select dates:", - min = 1750, max = 2300, value = c(2000,2300), sep="", width = "90%", step=5), + min = 1750, max = 2300, value = c(1900,2100), sep="", width = "90%", step=5), # sliderInput(ns("end"), "Select end date:", # min = 1750, max = 2300, value = 2300, sep="", width = "90%"), br(), @@ -108,6 +108,6 @@ run_server <- function(id, r6, i) { #updateMaterialSwitch(session = i, inputId = "savetoggle", value = FALSE) #not working right now }) %>% - bindEvent(input$run, ignoreInit = TRUE) + bindEvent(input$run, ignoreNULL = FALSE, ignoreInit = FALSE) # runs when app opens }) }