闪亮的仪表板主板高度问题 [英] shiny dashboard mainpanel height issue

查看:28
本文介绍了闪亮的仪表板主板高度问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是我

---------更新-------------

不确定这是否有帮助,当我不使用 mainpanel() 时这不是问题

图书馆(闪亮)图书馆(闪亮的仪表板)图书馆(DT)ui <- 仪表板页面(仪表板标题(标题=动态框"),仪表板侧边栏(条件面板(条件=input.tabselected==3",textInput("text", "输入 ID:"),框(宽度= 1,背景= '紫色'),actionButton("确定", "按确定",style='padding:8px; font-size:100%'))),仪表板主体(流体行(valueBoxOutput("vbox1", width = 2),valueBoxOutput("vbox2", width = 2),valueBoxOutput("vbox3", width = 2),valueBoxOutput("vbox4", width = 2),valueBoxOutput("vbox5", width = 2),valueBoxOutput("vbox6", width = 2)),流体行(column(width = 4, box(title = "Iris", width = NULL,solidHeader = FALSE, dataTableOutput("dat1"))),column(width = 4, box(title = "MT Cars", width = NULL,solidHeader = FALSE, dataTableOutput("dat2"))),column(width = 4, box(title = "Old Faithful Gyser", width = NULL,solidHeader = FALSE, dataTableOutput("dat3")))),流体行(column(width = 4, box(title = "Plot1 ", width = NULL,solidHeader = FALSE, plotOutput("plot1", height = "600px"))),column(width = 4, box(title = "Plot2", width = NULL,solidHeader = FALSE, plotOutput("plot2", height = "600px"))),column(width = 4, box(title = "Plot3", width = NULL,solidHeader = FALSE, plotOutput("plot3", height = "600px"))))))服务器 <- 功能(输入,输出){output$vbox1 <- renderValueBox({ valueBox("One","Yes",icon = icon("听诊器"))})output$vbox2 <- renderValueBox({ valueBox("Two","Yes",icon = icon("听诊器"))})output$vbox3 <- renderValueBox({ valueBox("三","是",icon = icon("听诊器"))})output$vbox4 <- renderValueBox({ valueBox("四","是",icon = icon("听诊器"))})output$vbox5 <- renderValueBox({ valueBox("Five","Yes",icon = icon("stethoscope"))})output$vbox6 <- renderValueBox({ valueBox("Six","Yes",icon = icon("听诊器"))})output$dat1 <- renderDataTable({datatable(iris)})output$dat2 <- renderDataTable({datatable(mtcars,extensions = 'Responsive')})output$dat3 <- renderDataTable({datatable(faithful,rownames = FALSE, options = list(autoWidth = TRUE))})#output$dat4 <- renderDataTable({datatable(data.frame(HairEyeColor),extensions = 'Responsive')})}闪亮应用程序(用户界面,服务器)

解决方案

你没有使用 shinydashboard 中的函数,而是使用标准的 shiny 包,你需要包装tabBoxfluidRow 中.

图书馆(闪亮)图书馆(闪亮的仪表板)图书馆(闪亮的BS)图书馆(DT)ui <- 仪表板页面(仪表板头(),仪表板侧边栏(侧边栏面板(textInput("text", "输入 ID:"),框(宽度= 1,背景= '紫色'),actionButton("确定", "按确定",style='padding:8px; font-size:100%'))),仪表板主体(流体行(tabBox(宽度= 12,高度= NULL,tabPanel("About", value=1, h6("目的是测试tabPanel设计中ShinyApp的宽度", br(),br(),分发原型")),tabPanel("数据", value=2,流体行(valueBoxOutput("vbox1", width = 2),valueBoxOutput("vbox2", width = 2),valueBoxOutput("vbox3", width = 2),valueBoxOutput("vbox4", width = 2),valueBoxOutput("vbox5", width = 2),valueBoxOutput("vbox6", width = 2)),流体行(column(width = 4, box(title = "Iris", width = NULL,solidHeader = FALSE, dataTableOutput("dat1"))),column(width = 4, box(title = "MT Cars", width = NULL,solidHeader = FALSE, dataTableOutput("dat2"))),column(width = 4, box(title = "Old Faithful Gyser", width = NULL,solidHeader = FALSE, dataTableOutput("dat3")))),流体行(column(width = 4, box(title = "Plot1", width = NULL,solidHeader = FALSE, plotOutput("plot1"))),column(width = 4, box(title = "Plot2", width = NULL,solidHeader = FALSE, plotOutput("plot2"))),列(宽度= 4,框(标题=Plot3",宽度= NULL,solidHeader = FALSE,plotOutput(plot3")))))))))服务器 <- 功能(输入,输出){output$vbox1 <- renderValueBox({ valueBox("One","Yes",icon = icon("听诊器"))})output$vbox2 <- renderValueBox({ valueBox("Two","Yes",icon = icon("听诊器"))})output$vbox3 <- renderValueBox({ valueBox("三","是",icon = icon("听诊器"))})output$vbox4 <- renderValueBox({ valueBox("四","是",icon = icon("听诊器"))})output$vbox5 <- renderValueBox({ valueBox("Five","Yes",icon = icon("stethoscope"))})output$vbox6 <- renderValueBox({ valueBox("Six","Yes",icon = icon("听诊器"))})output$dat1 <- renderDataTable({datatable(iris)})output$dat2 <- renderDataTable({datatable(mtcars,extensions = 'Responsive')})output$dat3 <- renderDataTable({datatable(faithful,rownames = FALSE, options = list(autoWidth = TRUE))})}闪亮应用程序(用户界面,服务器)

This is an extension of my previous question. Now I am not able to extend the height of my main panel.

This is my code below

library(shiny)
library(shinydashboard)
library(shinyBS)
library(DT)

ui <- dashboardPage(
  dashboardHeader(),
  dashboardSidebar(
    sidebarPanel(
      textInput("text", "Enter Id:"),
      box(width = 1, background  = 'purple'),
      actionButton("Ok", "Press Ok",style='padding:8px; font-size:100%')
    )

  ),
  dashboardBody(

    mainPanel(width = 12, 

      tabsetPanel(

        tabPanel("About", value=1, h6("The objective is to test width of ShinyApp in tabPanel design", br(),
                                      br(),

                                      "Distribution Prototype"

                                     )
                 ),


        tabPanel("Data", value=2,

                 fluidRow(

                   valueBoxOutput("vbox1", width = 2),
                   valueBoxOutput("vbox2", width = 2),
                   valueBoxOutput("vbox3", width = 2),
                   valueBoxOutput("vbox4", width = 2),
                   valueBoxOutput("vbox5", width = 2),
                   valueBoxOutput("vbox6", width = 2)


                 ),

                 fluidRow(

                   column(width = 4,  box(title = "Iris", width = NULL, solidHeader = FALSE, dataTableOutput("dat1"))),
                   column(width = 4,  box(title = "MT Cars", width = NULL, solidHeader = FALSE, dataTableOutput("dat2"))),
                   column(width = 4,  box(title = "Old Faithful Gyser", width = NULL, solidHeader = FALSE, dataTableOutput("dat3")))),

                 fluidRow(


                   column(width = 4,  box(title = "Plot1", width = NULL, solidHeader = FALSE, plotOutput("plot1", height = "600px"))),
                   column(width = 4,  box(title = "Plot2", width = NULL, solidHeader = FALSE, plotOutput("plot2", height = "600px"))),
                   column(width = 4,  box(title = "Plot3", width = NULL, solidHeader = FALSE, plotOutput("plot3", height = "600px")))


                 )

        )
      )
    )
  ))

server <- function(input, output) {

  output$vbox1 <- renderValueBox({ valueBox( "One","Yes",icon = icon("stethoscope"))})
  output$vbox2 <- renderValueBox({ valueBox( "Two","Yes",icon = icon("stethoscope"))})
  output$vbox3 <- renderValueBox({ valueBox( "Three","Yes",icon = icon("stethoscope"))})
  output$vbox4 <- renderValueBox({ valueBox( "Four","Yes",icon = icon("stethoscope"))})
  output$vbox5 <- renderValueBox({ valueBox( "Five","Yes",icon = icon("stethoscope"))})
  output$vbox6 <- renderValueBox({ valueBox( "Six","Yes",icon = icon("stethoscope"))})

  output$dat1 <- renderDataTable({datatable(iris)})
  output$dat2 <- renderDataTable({datatable(mtcars,extensions = 'Responsive' )})
  output$dat3 <- renderDataTable({datatable(faithful,rownames = FALSE, options = list(autoWidth = TRUE)  )})

}

shinyApp(ui, server)

The plots are sticking out of the default layout space and I am not finding any options in the mainPanel() to increase the height. I attempted forcing the height value within the mainPanel(), like this mainPanel(width = 12, height, 20 ....) and that did not work. Any suggestion is much appreciated.

+

---------Updated-------------

Not sure if this helps, this is not an issue when I dont use mainpanel()

library(shiny)
library(shinydashboard)
library(DT)

ui <- dashboardPage(
  dashboardHeader(title = "Dynamic boxes"),


  dashboardSidebar(
    conditionalPanel(condition="input.tabselected==3",
                     textInput("text", "Enter Id:"),
                     box(width = 1, background  = 'purple'),
                     actionButton("Ok", "Press Ok",style='padding:8px; font-size:100%')
    )
  ),
  dashboardBody(
    fluidRow(

      valueBoxOutput("vbox1", width = 2),
      valueBoxOutput("vbox2", width = 2),
      valueBoxOutput("vbox3", width = 2),
      valueBoxOutput("vbox4", width = 2),
      valueBoxOutput("vbox5", width = 2),
      valueBoxOutput("vbox6", width = 2)


    ),

    fluidRow(

      column(width = 4,  box(title = "Iris", width = NULL, solidHeader = FALSE, dataTableOutput("dat1"))),

      column(width = 4,  box(title = "MT Cars", width = NULL, solidHeader = FALSE, dataTableOutput("dat2"))),

      column(width = 4,  box(title = "Old Faithful Gyser", width = NULL, solidHeader = FALSE, dataTableOutput("dat3")))


  ),

  fluidRow(


    column(width = 4,  box(title = "Plot1 ", width = NULL, solidHeader = FALSE, plotOutput("plot1", height = "600px"))),
    column(width = 4,  box(title = "Plot2", width = NULL, solidHeader = FALSE, plotOutput("plot2", height = "600px"))),
    column(width = 4,  box(title = "Plot3", width = NULL, solidHeader = FALSE, plotOutput("plot3", height = "600px")))


  )



  )
  )


server <- function(input, output) {

  output$vbox1 <- renderValueBox({ valueBox( "One","Yes",icon = icon("stethoscope"))})
  output$vbox2 <- renderValueBox({ valueBox( "Two","Yes",icon = icon("stethoscope"))})
  output$vbox3 <- renderValueBox({ valueBox( "Three","Yes",icon = icon("stethoscope"))})
  output$vbox4 <- renderValueBox({ valueBox( "Four","Yes",icon = icon("stethoscope"))})
  output$vbox5 <- renderValueBox({ valueBox( "Five","Yes",icon = icon("stethoscope"))})
  output$vbox6 <- renderValueBox({ valueBox( "Six","Yes",icon = icon("stethoscope"))})

  output$dat1 <- renderDataTable({datatable(iris)})
  output$dat2 <- renderDataTable({datatable(mtcars,extensions = 'Responsive' )})
  output$dat3 <- renderDataTable({datatable(faithful,rownames = FALSE, options = list(autoWidth = TRUE)  )})
  #output$dat4 <- renderDataTable({datatable(data.frame(HairEyeColor),extensions = 'Responsive' )})
}

shinyApp(ui, server)

解决方案

You are not using the functions from shinydashboard but rather the standard shiny package and you need to wrap your tabBox inside a fluidRow.

library(shiny)
library(shinydashboard)
library(shinyBS)
library(DT)

ui <- dashboardPage(
  dashboardHeader(),
  dashboardSidebar(
    sidebarPanel(
      textInput("text", "Enter Id:"),
      box(width = 1, background  = 'purple'),
      actionButton("Ok", "Press Ok",style='padding:8px; font-size:100%')
    )

  ),
  dashboardBody(

              fluidRow(
              tabBox(width = 12, height = NULL,

                tabPanel("About", value=1, h6("The objective is to test width of ShinyApp in tabPanel design", br(),
                                              br(),

                                              "Distribution Prototype"

                )
                ),


                tabPanel("Data", value=2,

                         fluidRow(

                           valueBoxOutput("vbox1", width = 2),
                           valueBoxOutput("vbox2", width = 2),
                           valueBoxOutput("vbox3", width = 2),
                           valueBoxOutput("vbox4", width = 2),
                           valueBoxOutput("vbox5", width = 2),
                           valueBoxOutput("vbox6", width = 2)


                         ),

                         fluidRow(

                           column(width = 4,  box(title = "Iris", width = NULL, solidHeader = FALSE, dataTableOutput("dat1"))),
                           column(width = 4,  box(title = "MT Cars", width = NULL, solidHeader = FALSE, dataTableOutput("dat2"))),
                           column(width = 4,  box(title = "Old Faithful Gyser", width = NULL, solidHeader = FALSE, dataTableOutput("dat3")))),

                         fluidRow(


                           column(width = 4,  box(title = "Plot1", width = NULL, solidHeader = FALSE, plotOutput("plot1"))),
                           column(width = 4,  box(title = "Plot2", width = NULL, solidHeader = FALSE, plotOutput("plot2"))),
                           column(width = 4,  box(title = "Plot3", width = NULL, solidHeader = FALSE, plotOutput("plot3")))


                         )

                )
              )
    )
  ))

server <- function(input, output) {

  output$vbox1 <- renderValueBox({ valueBox( "One","Yes",icon = icon("stethoscope"))})
  output$vbox2 <- renderValueBox({ valueBox( "Two","Yes",icon = icon("stethoscope"))})
  output$vbox3 <- renderValueBox({ valueBox( "Three","Yes",icon = icon("stethoscope"))})
  output$vbox4 <- renderValueBox({ valueBox( "Four","Yes",icon = icon("stethoscope"))})
  output$vbox5 <- renderValueBox({ valueBox( "Five","Yes",icon = icon("stethoscope"))})
  output$vbox6 <- renderValueBox({ valueBox( "Six","Yes",icon = icon("stethoscope"))})

  output$dat1 <- renderDataTable({datatable(iris)})
  output$dat2 <- renderDataTable({datatable(mtcars,extensions = 'Responsive' )})
  output$dat3 <- renderDataTable({datatable(faithful,rownames = FALSE, options = list(autoWidth = TRUE)  )})

}

shinyApp(ui, server)

这篇关于闪亮的仪表板主板高度问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆