[英]Shiny dashboard rpivotTable layout
我有一个从rpivotTable库生成的数据透视表。我正在使用闪亮的仪表板在框中显示数据透视表的输出。 适合度似乎不正确。
以下是输出外观的屏幕截图。
我尝试使框的大小与数据透视表的大小相匹配,并且如果数据透视表的大小更大,则会有一个滚动条。 但是背景颜色“皮肤蓝色”似乎并不适合盒子的大小。
以下是示例代码:
ui.R
library(shiny)
library(shinydashboard)
library(rpivotTable)
header <- dashboardHeader(title="Dashboard")
sidebar <- dashboardSidebar(
menuItem("Menu1",icon = icon("dashboard"),
menuSubItem("Sub1", icon = icon("dashboard")),
menuSubItem("Sub2", icon = icon("dashboard")),
menuSubItem("Sub3", icon = icon("dashboard"))
),
menuItem("Menu2",icon = icon("dashboard"),
menuSubItem("Sub12", icon = icon("dashboard")),
menuSubItem("Sub22", icon = icon("dashboard")),
menuSubItem("Sub32", icon = icon("dashboard"))))
body <- dashboardBody(
tabItem(tab = "sub1",
box(width = 12,selectInput("testip",label = "Input",choices = c("A","B","C")),
selectInput("testip1",label = "Input",choices = c("A","B","C")),
selectInput("testip2",label = "Input",choices = c("A","B","C")),
actionButton("submit","Submit")),
box(width = 12,height = "800px",
tags$head(tags$style( type = 'text/css', '#myPivot{ overflow-x: scroll; overflow-y: scroll; }')),
rpivotTableOutput("myPivot", height = "780px")))
)
dashboardPage(header, sidebar, body)
server.R
server <- function(input, output) {
output$myPivot <- renderRpivotTable(rpivotTable(data = mtcars, rows = "mpg", cols = "disp"))
}
尝试删除用户界面的高度
tags$head(tags$style(type = 'text/css', '#Alert{ overflow-x: scroll; }')),
rpivotTableOutput("myPivot"))
然后在服务器上定义高度
output$myPivot <- renderRpivotTable(rpivotTable(data = mtcars, rows = "mpg", cols = "disp", height = "780px"))
这对我有用。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.