R Shinyd仪表板布局柱布局

R Shinyd仪表板布局柱布局,r,shiny,shinydashboard,R,Shiny,Shinydashboard,我的R闪亮仪表板主体中有以下代码: dashboardBody( tabBox(width = 12, tabPanel("US County Detail", fluidRow(width=12, column(width=6, tableOutput("County_tbl")), column(width=3, uiOutput(

我的R闪亮仪表板主体中有以下代码:

dashboardBody(
    tabBox(width = 12,
           tabPanel("US County Detail",
                fluidRow(width=12,
                         column(width=6, tableOutput("County_tbl")),
                         column(width=3, uiOutput("States_List")),
                         column(width=3, sliderInput("slider", "Threshold:", 0, 100, post = " %", 50))),
                fluidRow(width=12,
                         column(width=7, ''),
                         column(width=4, plotlyOutput("County_Map"))),
                fluidRow(width=12,
                         column(width=6, ''),
                         column(width=6, plotlyOutput("County_Chart")))
              )
            )
          )
基本上,通过上面的代码,我试图在第一列中生成一个长数据表,在第2列和第3列中它旁边有一个下拉框和滑块。然后,在数据表旁边,我想显示一张下面有条形图的地图

然而,地图和条形图目前正位于我的长数据表的底部。这意味着除非向下滚动,否则无法看到它们。有没有办法把地图和图表强制放在下拉框和滑块下面

谢谢

目前正在这样做:

事实上,我想把它放在这里:


这是因为地图和条形图被设置为位于表格下方的行中,因此它们位于表格下方是有意义的

您希望嵌套列,以便地图和图表与表位于同一行中

我不确定下面的代码是否完全正确-如果您提供一个可复制的示例,我很乐意检查如何应用它。但希望你能看到这个想法

fluidRow(
# This column is the total width of the app
  column(width = 12,
         fluidRow(
# This column is half the width of the app and contains the table
           column(width = 6,
                  tableOutput("County_tbl")),
# This column is half the width of the app and contains everything else
           column(width = 6,
# This row contains the dropdown box and slider (each set to half width)
                  fluidRow(
                    column(width = 6, 
                           uiOutput("States_List")),
                    column(width = 6,
                           sliderInput("slider", "Threshold:", 0, 100, post = " %", 50))), 
# This row contains the outputs
                  fluidRow(
                    plotlyOutput("County_Map"), 
                    plotlyOutput("County_Chart")
                  )
           )
         )
  )
)

这是因为地图和条形图被设置为位于表格下方的行中,因此它们位于表格下方是有意义的

您希望嵌套列,以便地图和图表与表位于同一行中

我不确定下面的代码是否完全正确-如果您提供一个可复制的示例,我很乐意检查如何应用它。但希望你能看到这个想法

fluidRow(
# This column is the total width of the app
  column(width = 12,
         fluidRow(
# This column is half the width of the app and contains the table
           column(width = 6,
                  tableOutput("County_tbl")),
# This column is half the width of the app and contains everything else
           column(width = 6,
# This row contains the dropdown box and slider (each set to half width)
                  fluidRow(
                    column(width = 6, 
                           uiOutput("States_List")),
                    column(width = 6,
                           sliderInput("slider", "Threshold:", 0, 100, post = " %", 50))), 
# This row contains the outputs
                  fluidRow(
                    plotlyOutput("County_Map"), 
                    plotlyOutput("County_Chart")
                  )
           )
         )
  )
)

嗨,请提供一个最小的可复制代码,以便有助于复制问题。 这是如何安排UI的问题,即fluidrow和column。我尝试了同样的方法,并在此基础上构建了一个示例代码

[![library(shiny)
library(shinydashboard)
library(plotly)

ui <- dashboardPage(
  dashboardHeader(
    title = "Dashboard"),


  #sidebar content
  dashboardSidebar(
    sidebarMenu(
      menuItem("Dashboard", tabName = "dashboard", icon = icon("dashboard"))
    )
  ),



dashboardBody(
  tabItems(
    tabItem(tabName='dashboard',
            tabBox(width = 12,
                   tabPanel("US County Detail",
                            fluidRow(
                              column(5,
                                     fluidRow(
                                       tableOutput("County_tbl")
                                     )
                                     ),
                              column(7,
                                     fluidRow(
                                       column(6,
                                              uiOutput("States_List")
                                              ),
                                       column(6,
                                              sliderInput("slider", "Threshold:", 0, 100, post = " %", 50)
                                              )
                                              ),
                                     fluidRow(
                                       column(12,
                                              plotlyOutput("County_Map")
                                              )
                                            ),
                                     fluidRow(
                                       column(12,
                                              plotlyOutput("County_Chart")
                                              )

                                     )

                                     )
                            )
                   )
            )    

    )

  )

)
)



server <- function(input, output,session) {

  output$County_tbl<-renderTable({
    head(mtcars)
  })

  output$States_List<-renderUI({
    list_data<-unique(names(mtcars))
    selectInput("cars","Select Car",choices = list_data)
  })

  output$County_Map<-renderPlotly({
    plot_ly(
      x = c("giraffes", "orangutans", "monkeys"),
      y = c(20, 14, 23),
      name = "SF Zoo",
      type = "bar"
    )
  })

  output$County_Chart<-renderPlotly({
    Animals <- c("giraffes", "orangutans", "monkeys")
    SF_Zoo <- c(20, 14, 23)
    LA_Zoo <- c(12, 18, 29)
    data <- data.frame(Animals, SF_Zoo, LA_Zoo)

  plot_ly(data, x = ~Animals, y = ~SF_Zoo, type = 'bar', name = 'SF Zoo') %>%
      add_trace(y = ~LA_Zoo, name = 'LA Zoo') %>%
      layout(yaxis = list(title = 'Count'), barmode = 'group')

  })


}  
shinyApp(ui = ui, server = server)
[![library(闪亮)
图书馆(shinydashboard)
图书馆(绘本)

uiHI请提供最小的可复制代码,以便有助于复制问题。 这是如何安排UI的问题,即fluidrow和column。我尝试了同样的方法,并在此基础上构建了一个示例代码

[![library(shiny)
library(shinydashboard)
library(plotly)

ui <- dashboardPage(
  dashboardHeader(
    title = "Dashboard"),


  #sidebar content
  dashboardSidebar(
    sidebarMenu(
      menuItem("Dashboard", tabName = "dashboard", icon = icon("dashboard"))
    )
  ),



dashboardBody(
  tabItems(
    tabItem(tabName='dashboard',
            tabBox(width = 12,
                   tabPanel("US County Detail",
                            fluidRow(
                              column(5,
                                     fluidRow(
                                       tableOutput("County_tbl")
                                     )
                                     ),
                              column(7,
                                     fluidRow(
                                       column(6,
                                              uiOutput("States_List")
                                              ),
                                       column(6,
                                              sliderInput("slider", "Threshold:", 0, 100, post = " %", 50)
                                              )
                                              ),
                                     fluidRow(
                                       column(12,
                                              plotlyOutput("County_Map")
                                              )
                                            ),
                                     fluidRow(
                                       column(12,
                                              plotlyOutput("County_Chart")
                                              )

                                     )

                                     )
                            )
                   )
            )    

    )

  )

)
)



server <- function(input, output,session) {

  output$County_tbl<-renderTable({
    head(mtcars)
  })

  output$States_List<-renderUI({
    list_data<-unique(names(mtcars))
    selectInput("cars","Select Car",choices = list_data)
  })

  output$County_Map<-renderPlotly({
    plot_ly(
      x = c("giraffes", "orangutans", "monkeys"),
      y = c(20, 14, 23),
      name = "SF Zoo",
      type = "bar"
    )
  })

  output$County_Chart<-renderPlotly({
    Animals <- c("giraffes", "orangutans", "monkeys")
    SF_Zoo <- c(20, 14, 23)
    LA_Zoo <- c(12, 18, 29)
    data <- data.frame(Animals, SF_Zoo, LA_Zoo)

  plot_ly(data, x = ~Animals, y = ~SF_Zoo, type = 'bar', name = 'SF Zoo') %>%
      add_trace(y = ~LA_Zoo, name = 'LA Zoo') %>%
      layout(yaxis = list(title = 'Count'), barmode = 'group')

  })


}  
shinyApp(ui = ui, server = server)
[![library(闪亮)
图书馆(shinydashboard)
图书馆(绘本)
用户界面