R shiny Dashboard:如何将垂直滚动条添加到仪表板侧边栏?

问题描述 投票:0回答:2

我有几个关于 R shiny Dashboard 的问题。

ui.R

library(shinydashboard)
library(shiny)

dashboardPage(
dashboardHeader(title = 'Test Interface'),
dashboardSidebar(width = 600,

               h3('-------Input Data-------'),
               fluidRow(
                 column(6, div(style = "height:10px"), fileInput(inputId = 'FileInput', label = 'Upload Input:', accept = c('csv','tsv','txt'))),
                 column(2, div(style = "height:3px"), checkboxInput(inputId = 'header', label = 'Header', value = FALSE)),
                 column(2, div(style = "height:12px"), radioButtons(inputId = 'sep', label = 'Separator', choices = c(comma=',',tab="\t",space=' '), selected = ","),offset = 1)
               ),
               fluidRow(column(6, div(style = "height:1px"), fileInput(inputId = 'FileInput1', label = 'Upload Second Input:'))),
               br(),
               h3('-------Select Foreground-------'),
               fluidRow(
                 column(5, div(style = "height:17px"), radioButtons(inputId = 'cutoff', label = 'Selection', choices = c('Up'='pos','Down'='neg','Both'='both'))),
                 br(),
                 column(3, div(style = "height:1px"), textInput(inputId = 'fc', label = "Fold Change", value = '0')),
                 column(3, div(style = "height:1px; margin-left:10cm"), height = 6,textInput(inputId = 'pvalue', label = "Adj. Pvalue",value = '0.05'))
               ),
               fluidRow(column(2, h1(" "), actionButton(inputId = 'select', label = "Select Data"))),
               fluidRow(column(5, div(style = "height:25px;font-color:blue"), downloadButton('download', 'Download Plot')))),
               dashboardBody(
                 tabsetPanel(type="tabs", id = "tabvalue",
                             tabPanel(title = "Input Table", value = 'tab1', DT::dataTableOutput('table')),
                             tabPanel(title = "Plot", value = 'tab7', plotOutput('plot',width = 800,height = 800)))))

服务器.R

library(shiny)

shinyServer(function(input, output, session){
})

我不知道如何将垂直滚动条添加到 dashboardSidebar。在我实际的应用程序中,当我运行应用程序时,最后的元素是不可见的。

谢谢!

r shiny shinydashboard
2个回答
15
投票

我遇到了这个并提出了以下 hack(我的意思是 hack)。

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

90vh
将侧边栏高度设置为视口高度的 90%。您可能需要根据口味调整它。百分比太大,一些侧边栏仍然低于地平线;百分比太小,侧边栏明显在主体之前结束(滚动条过早出现)。


0
投票

这也适用于使用

.control-sidebar
i.o 的控制栏。
.sidebar

© www.soinside.com 2019 - 2024. All rights reserved.