微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

R ShinydashboardPlus 2.0.0 相当于 sidebar_fullCollapse或 css

如何解决R ShinydashboardPlus 2.0.0 相当于 sidebar_fullCollapse或 css

有人可以帮助我使用正确的 css 代码以允许我

(1) 让 dashboardControlbar 即右侧边栏(在早期版本的 rightSidebar shinydashboardplus)在启动时打开

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

enter image description here

(点击右侧的齿轮不允许右侧控制栏折叠,左侧工作正常)

这篇文章是从 this one which addresses the above scenario but is only valid for the earlier versions of shinydashboardPlus < 2.0.0 开始的,已经有 major breaking changed in the latest version of the package and internal functions have been changed

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

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

我曾尝试将 css 检查器工具与包中的新示例一起使用(版本 2 运行 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 

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。