Skip to content

Commit

Permalink
change area in region, add download button for graphs
Browse files Browse the repository at this point in the history
  • Loading branch information
costavale committed Jan 14, 2023
1 parent 2d812a1 commit 6b2a578
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 11 deletions.
48 changes: 40 additions & 8 deletions app.R
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ ui <- fluidPage(

selectInput(
"area",
"Select an Area",
"Select a Region",
choices = levels(factor(data$area)),
selected = NULL,
multiple = TRUE
Expand Down Expand Up @@ -146,10 +146,10 @@ ui <- fluidPage(
htmlOutput("area_1"),
htmlOutput("site_name_1"),
htmlOutput("site_type_1")),
column(3, selectInput("var1", "Choose a variable to visualize:",
column(3, selectInput("var1", "Graph 1: Variable to visualize",
choices = c("", names(data)[c(3, 4, 10:12, 15:25)]),
selected = "")),
column(3, selectInput("var2", "Choose a variable to visualize:",
column(3, selectInput("var2", "Graph 2: Variable to visualize:",
choices = c("", names(data)[c(3, 4, 10:12, 15:25)]),
selected = ""))
),
Expand All @@ -158,7 +158,11 @@ ui <- fluidPage(
fluidRow(
column(9, reactableOutput("table01", height = "auto"),
downloadButton("download_filtered",
label = "Download the selected data")),
label = "Download the selected data"),
downloadButton("SaveGraph01",
label = "Download Graph 01"),
downloadButton("SaveGraph02",
label = "Download Graph 02")),
column(3, shinycssloaders::withSpinner(plotOutput("graph_01", height = "45vh")),
shinycssloaders::withSpinner(plotOutput("graph_02", height = "45vh")))
)
Expand Down Expand Up @@ -345,7 +349,7 @@ server <- function(input, output, session) {

renderPrint({
HTML(paste(
"<b>", "Area: ",
"<b>", "Region: ",
"</b>",
input$area
))
Expand Down Expand Up @@ -437,10 +441,30 @@ server <- function(input, output, session) {
write.csv(s[c(1:4, 6)], file)
}
)


## download the Graph 01 ----
output$SaveGraph01 <- downloadHandler(
filename = function(file) {
"graph_01.png"
},
content = function(file) {
ggsave(file, plot = graph_01(), device = "png")
}
)

## download the Graph 02 ----
output$SaveGraph02 <- downloadHandler(
filename = function(file) {
"graph_02.png"
},
content = function(file) {
ggsave(file, plot = graph_02(), device = "png")
}
)

## render graph-01 ----

output$graph_01 <- renderPlot({
graph_01 <- reactive({

req(input$var1)
req(data_selected)
Expand All @@ -464,9 +488,13 @@ server <- function(input, output, session) {

})

output$graph_01 <- renderPlot({
graph_01()
})

## render graph-02 ----

output$graph_02 <- renderPlot({
graph_02 <- reactive({

req(input$var2)
req(data_selected)
Expand All @@ -489,6 +517,10 @@ server <- function(input, output, session) {

})

output$graph_02 <- renderPlot({
graph_02()
})

## create the tidy_words dataset ----

tidy_words <- reactive({
Expand Down
6 changes: 3 additions & 3 deletions rsconnect/shinyapps.io/costavale/MH-shiny.dcf
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ account: costavale
server: shinyapps.io
hostUrl: https://api.shinyapps.io/v1
appId: 5683000
bundleId: 5682940
bundleId: 5986122
url: https://costavale.shinyapps.io/MH-shiny/
when: 1647279344.70289
lastSyncTime: 1647279344.70289
when: 1654617868.98301
lastSyncTime: 1654617868.98305
asMultiple: FALSE
asStatic: FALSE

0 comments on commit 6b2a578

Please sign in to comment.