Skip to content

Commit

Permalink
Select variable tab
Browse files Browse the repository at this point in the history
added tab to select variable plotted. only global temperature and CO2 concentration right now
  • Loading branch information
ciara-donegan committed Nov 20, 2023
1 parent 1fe5797 commit 799a309
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 8 deletions.
15 changes: 9 additions & 6 deletions h2/components/modules/mod_graph.R
Original file line number Diff line number Diff line change
Expand Up @@ -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")))
}

Expand All @@ -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(
Expand All @@ -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(
Expand All @@ -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)
})
}
4 changes: 2 additions & 2 deletions h2/components/modules/mod_run.R
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
Expand Down Expand Up @@ -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
})
}

0 comments on commit 799a309

Please sign in to comment.