2016-06-30 121 views
1

我有一个从rpivotTable库生成的透视表。我使用闪亮的仪表板来显示在一个框中的透视表的输出。该合适似乎并不正确。闪亮的仪表板rpivotTable布局

下面是输出结果的截图。

enter image description here

我试图让箱体尺寸相匹配的数据透视表的大小和有一个滚动条,如果数据透视表的尺寸更。但背景颜色“皮肤蓝色”似乎根据盒子的大小不合适。下面

是一个示例代码:

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")) 

} 

回答

2

尝试在UI

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")) 

这对我有用。