How do I hide the side panel

...I have a shiny app

that i can manipulate the display like this via the URL
(got that on another post on here)

http://127.0.0.1:4374/?z=05ND012&y=DischargeDebit

I would like to keep the sidepanel code in the but hid it .... is that possible?

here is my code should wok if you paste it into rstudio

library(ggplot2)
library(scales)
library(shiny)
library(shinyjs)


ui <- fluidPage(

  # Sidebar layout with a input and output definitions
  sidebarLayout(
    
    # Inputs
    sidebarPanel(
      
      # Select variable for y-axis
      selectInput(inputId = "y", 
                  label = "Y-axis:",
                  choices = c("Water Level" = "WaterLevel", 
                              "Discharge Debit" = "DischargeDebit"), 
                  selected = "WaterLevel"),
      
      selectInput(inputId = "z", 
                  label = "station:",
                  choices = c(
                    "SHORT CREEK NEAR ROCHE PERCEE (SK)" = "05NB021",
                    "LONG CREEK NEAR ESTEVAN (SK)" = "05NB001",
                    "SOURIS RIVER BELOW RAFFERTY RESERVOIR (SK)" = "05NB036",
                    "RAFFERTY RESERVOIR NEAR ESTEVAN (SK)" = "05NB032",
                    "MOOSE MOUNTAIN CREEK BELOW GRANT DEVINE LAKE (SK)" = "05ND013",
                    "GRANT DEVINE LAKE NEAR ALAMEDA (SK)" = "05ND012",
                    "MOOSE MOUNTAIN CREEK ABOVE GRANT DEVINE LAKE (SK)" = "05ND010",
                    "NICKLE LAKE NEAR WEYBURN (SK)" = "05NB020",
                    "SWIFT CURRENT CREEK BELOW ROCK CREEK (SK)" = "05HD036",
                    "MOOSE MOUNTAIN LAKE (RESERVOIR= NEAR CORNING (SK)" = "05NC002",
                    "MOOSE JAW RIVER NEAR BURDICK (SK)" = "05JE006",
                    "QU'APPELLE RIVER NEAR WELBY (SK)" = "05JM001",
                    "SWIFT CURRENT CREEK NEAR LEINAN (SK)" = "05HD039",
                    "WASCANA CREEK NEAR LUMSDEN (SK)" = "05JF005",
                    "QU'APPELLE RIVER NEAR LUMSDEN (SK)" = "05JF001",
                    "QU'APPELLE RIVER ABOVE BUFFALO POUND LAKE (SK)" = "05JG004",
                    "QU'APPELLE RIVER BELOW LOON CREEK (SK)" = "05JK007",
                    "ELBOW DIVERSION CANAL AT DROP STRUCTURE (SK)" = "05JG006",
                    "LAST MOUNTAIN LAKE AT ROWAN'S RAVINE (SK)" = "05JH004",
                    "LAKE DIEFENBAKER AT GARDINER DAM (SK)" = "05HF003",
                    "ASSINIBOINE RIVER AT KAMSACK (SK)" = "05MD004",
                    "BIG QUILL LAKE NEAR KANDAHAR (SK)" = "05MA010",
                    "SOUTH SASKATCHEWAN RIVER AT SASKATOON (SK)" = "05HG001",
                    "RED DEER RIVER NEAR ERWOOD (SK)" = "05LC001",
                    "NORTH SASKATCHEWAN RIVER AT PRINCE ALBERT (SK)" = "05GG001",
                    "SASKATCHEWAN RIVER BELOW THE FORKS (SK)" = "05KD007",
                    "NORTH SASKATCHEWAN RIVER NEAR DEER CREEK (SK)" = "05EF001",
                    "CARROT RIVER NEAR TURNBERRY (SK)" = "05KH007",
                    "TOBIN LAKE AT THE SPILLWAY (SK)" = "05KD004",
                    "SASKATCHEWAN RIVER BELOW TOBIN LAKE (SK)" = "05KD003",
                    "WHITE GULL CREEK AT HIGHWAY NO. 106 (SK)" = "05KE010",
                    "COLD RIVER AT OUTLET OF COLD LAKE (SK)" = "06AF001",
                    "DORE RIVER NEAR THE MOUTH (SK)" = "06AG002",
                    "LAC LA RONGE AT LA RONGE (SK)" = "06CB001",
                    "RAPID RIVER AT OUTLET OF LAC LA RONGE (SK)" = "06CB002",
                    "CANOE RIVER NEAR BEAUVAL (SK)" = "06BB005",
                    "CHURCHILL RIVER AT SANDY BAY (SK)" = "06EA002",
                    "CHURCHILL RIVER ABOVE WINTEGO RAPIDS (SK)" = "06EA011",
                    "CHURCHILL RIVER ABOVE OTTER RAPIDS (SK)" = "06CD002",
                    "DILLON RIVER BELOW DILLON LAKE (SK)" = "06BA002",
                    "CHURCHILL RIVER NEAR PATUANAK (SK)" = "06BB003",
                    "WAPISKAU RIVER ABOVE WHITE LAKE (SK)" = "06DD003",
                    "REINDEER RIVER ABOVE DEVIL RAPIDS (SK)" = "06DD002",
                    "HAULTAIN RIVER ABOVE NORBERT RIVER (SK)" = "06BD001",
                    "WATHAMAN RIVER BELOW WATHAMAN LAKE (SK)" = "06DC001",
                    "WHEELER RIVER BELOW RUSSELL LAKE (SK)" = "06DA005",
                    "GEIKIE RIVER BELOW WHEELER RIVER (SK)" = "06DA004",
                    "DOUGLAS RIVER NEAR CLUFF LAKE (SK)" = "07MA003",
                    "WATERFOUND RIVER BELOW THERIAU LAKE (SK)" = "07LB002",
                    "WOLLASTON LAKE AT ROSS CHANNEL (SK)" = "06DA001",
                    "MACFARLANE RIVER AT OUTLET OF DAVY LAKE (SK)" = "07MB001",
                    "FOND DU LAC RIVER AT OUTLET OF BLACK LAKE (SK)" = "07LE002",
                    "LAKE ATHABASCA NEAR CRACKINGSTONE POINT (SK)" = "07MC003",
                    "CHARLOT RIVER AT OUTLET OF WEBB LAKE (SK)" = "07QC008",
                    "TAZIN RIVER ABOVE TAZIN LAKE (SK)" = "07QC006",
                    "TAZIN LAKE NEAR OUTLET (SK)" = "07QC002",
                    "ABITAU RIVER ABOVE CUMING LAKE (SK)" = "07QC005"
), 
selected = "05EF001")
      
    ),
    
    # Output
    mainPanel(
      plotOutput(outputId = "lineplot")
    )
  )
)



server <- function(input, output, session) {
  addClass(selector = "body", class = "sidebar-collapse")
  
  
  
  observe({
    query <- parseQueryString(session$clientData$url_search)
    if (!is.null(query[['z']])) {
      updateSliderInput(session, "z", value = query[['z']])
    }
    
    
    if (!is.null(query[['y']])) {
      updateSliderInput(session, "z", value = query[['z']])
    }
  })  
  
  
  
file = "http://dd.weather.gc.ca/hydrometric/csv/SK/hourly/SK_hourly_hydrometric.csv"
skdat <- read.csv(file, head=T, sep=",", dec=".", stringsAsFactors = F)
colnames(skdat) <- c("ID", "Date", "WaterLevel", "Grade1", "Symbol1",
                     "QAQC-1", "DischargeDebit", "Grade2", "Symbol2",
                     "QAQC-2")

#subds <- subset(skdat, ID=input$z)
#subds$datetime <- as.POSIXct(subds$Date, format = "%Y-%m-%dT%H:%M:%OS")
#output$lineplot <- renderPlot({ 
#  ggplot(subds, aes(x = datetime, y = !!as.name(input$y))) + geom_line() 
#})  


output$lineplot <- renderPlot({
  subds <- subset(skdat, ID == input$z)
  subds$datetime <- as.POSIXct(subds$Date, format = "%Y-%m-%dT%H:%M:%OS")
  ggplot(subds, aes(x = datetime, y = !!as.name(input$y))) +
    geom_line()
})


}

# Create a Shiny app object
shinyApp(ui = ui, server = server)

You can try using https://rstudio.github.io/shinydashboard/ to hide the side panel.

1 Like

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.