4
votes

I have to add more sliders in sidebarPanel but when i scroll the page down, the entire page scrolls down along with mainPanel. What exactly i need is, mainPanel where the graph or output is displayed has to be locked or freezed in such a way when i scroll down the input slider and change the slider to observe the corresponding output on the mainPanel in Shiny.

Below is the part of the code of ui.R. Here I have shown only 7 sliders but actually I have 31 sliders.

library(shiny)  
shinyServer(fluidPage(  
  titlePanel("Regression"),  
  sidebarLayout(    
    sidebarPanel(   
      sliderInput("slide1","Select a value:",
                  min=min(unidf$X.17,na.rm = T),max=max(unidf$X.17,na.rm = T), value = median(unidf$X.17,na.rm = T)),  
      sliderInput("slide2","Head HIC-15:",
                  min=min(unidf$X.18,na.rm = T),max=max(unidf$X.18,na.rm = T), value = median(unidf$X.18,na.rm = T)),  
      sliderInput("slide3","Select a value:",
                  min=min(unidf$X.19,na.rm = T),max=max(unidf$X.19,na.rm = T), value = median(unidf$X.19,na.rm = T)),  
      sliderInput("slide4","Select a value:",
                  min=min(unidf$X.20,na.rm = T),max=max(unidf$X.20,na.rm = T), value = median(unidf$X.20,na.rm = T)),  
      sliderInput("slide5","Lateral force (kN):",
                  min=min(unidf$X.21,na.rm = T),max=max(unidf$X.21,na.rm = T), value = median(unidf$X.21,na.rm = T)),  
      sliderInput("slide6","Select a value:",
                  min=min(unidf$X.22,na.rm = T),max=max(unidf$X.22,na.rm = T), value = median(unidf$X.22,na.rm = T)),  
      sliderInput("slide7","Average deflection (mm):",
                  min=min(unidf$X.23,na.rm = T),max=max(unidf$X.23,na.rm = T), value = median(unidf$X.23,na.rm = T))  

    ),  
    mainPanel(...  
1
Good question but strange for me. In my cases I needed to fix a sidebar and a header panel because in a main panel is where I have many objects. Anyway it is a good practice to try that all controls could be visible without scrolling. You could put some of them into a main panel, for exampleAndriy T.

1 Answers

2
votes

I had similar situation. Here is my solution:

dashboardSidebar(
    tags$head(
      tags$style(HTML("
                      .sidebar { height: 90vh; overflow-y: auto; }
                      " )
      )
    ),
... ...

I hope it can help you.