css - 删除shinydashboardPlus中的左侧边栏(仅保留右侧)

标签 css r shiny shinydashboard

是否可以完全删除 shinydashboardPlus 中的左侧侧边栏,但保留右侧?

我尝试省略对参数 sidebar 的调用,但此参数是必需的,因此我收到错误。我想要的是实现这一目标(没有左侧边栏,只有右侧边栏)。

enter image description here

示例代码

library(shiny)
library(shinydashboard)
library(shinydashboardPlus)
data(iris)

header <- dashboardHeaderPlus(
  enable_rightsidebar = TRUE,
  rightSidebarIcon = "filter"
)

sidebar <- dashboardSidebar(selectInput(inputId = "slect",
                                        label = "Selection Menu", 
                                        selected = "a",
                                        choices = LETTERS[1:3])
)

body <- dashboardBody(fluidPage(plotOutput( "scatter", 
                                  height = "700px", 
                                  width = "700px")))

rightsidebar <- rightSidebar()

ui <- dashboardPagePlus(header, 
                        sidebar, 
                        body, 
                        rightsidebar)

server <- function(input, output) {
    output$scatter <- renderPlot({
    plot(iris$Petal.Length, iris$Petal.Width, pch=21)
      cats <- levels(iris$Species)
      cols <- c("red", "blue", "yellow2")
      ind <- lapply(cats, function(z) which(iris$Species == z))
      for (i in seq(cats)) {
        points(iris$Petal.Length[ind[[i]]], iris$Petal.Width[ind[[i]]], 
               pch = 19, col = cols[i])
      }
    })
}

shinyApp(ui, server)

session 信息:

> sessionInfo()
R version 4.0.0 (2020-04-24)
Platform: x86_64-apple-darwin17.0 (64-bit)
Running under: macOS Catalina 10.15.6

Matrix products: default
BLAS:   /System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/libBLAS.dylib
LAPACK: /Library/Frameworks/R.framework/Versions/4.0/Resources/lib/libRlapack.dylib

locale:
[1] en_GB.UTF-8/en_GB.UTF-8/en_GB.UTF-8/C/en_GB.UTF-8/en_GB.UTF-8

attached base packages:
[1] stats4    parallel  stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
 [1] shinydashboardPlus_0.7.5 shinydashboard_0.7.1     shinyWidgets_0.5.3       dendextend_1.13.4       
 [5] tidyr_1.1.0              patchwork_1.0.1          ggplot2_3.3.1            shinyhelper_0.3.2       
 [9] colorspace_1.4-1         colourpicker_1.0         shinythemes_1.1.2        DT_0.13                 
[13] shiny_1.4.0.2            dplyr_1.0.0              MSnbase_2.14.2           ProtGenerics_1.20.0     
[17] S4Vectors_0.26.1         mzR_2.22.0               Rcpp_1.0.4.6             Biobase_2.48.0          
[21] BiocGenerics_0.34.0 

最佳答案

抱歉,现在时间有限,但请检查您的第一个问题:

library(shiny)
library(shinyjs)
library(shinydashboard)
library(shinydashboardPlus)
data(iris)

header <- dashboardHeaderPlus(
  titleWidth = "0px",
  enable_rightsidebar = TRUE,
  rightSidebarIcon = "filter"
)

sidebar <- dashboardSidebar(
  width = "0px"
)

body <- dashboardBody(
  useShinyjs(),
  fluidPage(plotOutput( "scatter",
                        height = "700px", 
                        width = "700px")))

rightsidebar <- rightSidebar()

ui <- tags$body(class="skin-blue sidebar-mini control-sidebar-open", dashboardPagePlus(header, 
                        sidebar, 
                        body, 
                        rightsidebar))

server <- function(input, output) {
  hide(selector = "body > div > header > nav > a")
  output$scatter <- renderPlot({
    plot(iris$Petal.Length, iris$Petal.Width, pch=21)
    cats <- levels(iris$Species)
    cols <- c("red", "blue", "yellow2")
    ind <- lapply(cats, function(z) which(iris$Species == z))
    for (i in seq(cats)) {
      points(iris$Petal.Length[ind[[i]]], iris$Petal.Width[ind[[i]]], 
             pch = 19, col = cols[i])
    }
  })
}

shinyApp(ui, server)

关于css - 删除shinydashboardPlus中的左侧边栏(仅保留右侧),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/63830346/

相关文章:

r - dplyr 编译问题,Rcpp.h : no such file or directory

R Shiny 颜色代码表行取决于单元格内容

r - 如何区分应用程序崩溃和用户关闭

css - 带 CSS 的梯形跨度

r - 按顺序匹配向量

r - 使用 ggplot() 在同一图上绘制多个时间序列

css - 更改 Shiny 应用程序的 selectizeInput 中边框阴影的颜色

python - 清除 HTML 中的非正文文本

javascript - 如何在 JsPlumb 中建立与边缘的连接?

javascript - 动态调整元素后,jQuery Isotope 无法正确重新排列