2

有人可以用正确的 CSS 代码帮助我吗?

(1) 让ie右侧边栏(以前在<2.0.0的早期版本中dashboardControlbar称为)在启动时打开rightSidebarshinydashboardPlus

(2) 点击齿轮图标时,可以选择完全折叠右侧控制栏

在此处输入图像描述 (单击右侧的齿轮不允许折叠右侧控制栏,左侧工作正常)

这篇文章是从这篇文章开始的,它解决了上述情况,但仅对shinydashboardPlus< 2.0.0的早期版本有效,在最新版本的包中发生了重大的破坏性更改,并且内部功能已更改

在下面的示例代码中,我可以通过向正文添加一些标签来实现(1),例如tags$body(class="skin-blue sidebar-mini control-sidebar-open", dashboardPagePlus(...).

我无法实现(2)。在以前的版本sidebar_fullCollapse = TRUE中,可以使用dashboardPagePlus(现在称为dashboardPage)调用,这不再是函数的参数。

我尝试使用带有新示例的 css 检查器工具(使用版本 2 run shinydashboardPlusGallery()),但无法弄清楚如何操作或正确的 css 是什么。

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

header <- dashboardHeader(title = "Demo")

sidebar <- dashboardSidebar(
  selectInput(
    inputId = "slect",
    label = "Selection Menu",
    selected = "a",
    choices = LETTERS[1:3]
  ),
  p("Write something here..."),
  minified = FALSE
)

body <- dashboardBody(
  tags$script('
      $(".navbar-custom-menu").on("click",function(){
        $(window).trigger("resize");
      })'
  ),
  fluidPage(
    plotOutput(
      "scatter",
      height = "700px",
      width = "100%"
    )
  )
)

controlbar <- dashboardControlbar()

ui <- tags$body(class="skin-blue right-sidebar-mini control-sidebar-open", 
                dashboardPage(header,
                              sidebar,
                              body,
                              controlbar
                              # sidebar_fullCollapse = TRUE))
                ))
                        

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)
> sessionInfo()
R Under development (unstable) (2020-10-17 r79346)
Platform: x86_64-apple-darwin17.0 (64-bit)
Running under: macOS High Sierra 10.13.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.1/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] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
[1] shinyEffects_0.1.0       styler_1.4.1            
[3] shinyAce_0.4.1           shinyWidgets_0.6.0      
[5] shinyjqui_0.4.0          shiny_1.6.0             
[7] shinydashboardPlus_2.0.0 shinydashboard_0.7.1 
4

0 回答 0