【问题标题】:Shiny dashboard rpivotTable layout闪亮的仪表板 rpivotTable 布局
【发布时间】:2016-11-03 00:43:44
【问题描述】:

我有一个从 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)

服务器.R

server <- function(input, output) {

  output$myPivot <- renderRpivotTable(rpivotTable(data = mtcars, rows = "mpg", cols = "disp"))

}

【问题讨论】:

    标签: r shiny shinydashboard rpivottable


    【解决方案1】:

    尝试在 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"))
    

    这对我有用。

    【讨论】:

      猜你喜欢
      • 2015-04-22
      • 1970-01-01
      • 2019-02-12
      • 1970-01-01
      • 2015-04-07
      • 2020-12-03
      • 2016-05-02
      • 1970-01-01
      • 2019-06-20
      相关资源
      最近更新 更多