css - 如何在 Shiny Dashboard 中使用 fillPage
问题描述
我无法在 R 中使用 Shiny 使地图显示为全屏。任何帮助将不胜感激,谢谢。
我在 ui 和服务器端都玩过各种 height = "100%" 和 height = "auto"。这些已经在 fillPage、fillCol、fillRow、outputPlot 和 renderPlot 函数中进行了尝试。
如果我使用 height = "400px" 等,我可以强制执行某些操作,但是当将仪表板从笔记本电脑屏幕移动到更大的东西等时,这通常不会提供任何东西。
我提供了简化版本的代码。它包含我在“真实”版本中的 css 样式,因为我的理解是 css 也可能影响 R 代码。
library(shiny)
library(shinydashboard)
library(ggplot2)
ui <- dashboardPage(
dashboardHeader(title = "SOS"),
dashboardSidebar(
br()
),
dashboardBody(tags$body(tags$style(HTML('
/* logo */
.skin-blue .main-header .logo {
background-color: #0a22d8;
}
/* logo when hovered */
.skin-blue .main-header .logo:hover {
background-color: #8390ef;
}
/* navbar (rest of the header) */
.skin-blue .main-header .navbar {
background-color: #0a22d8;
}
/* main sidebar */
.skin-blue .main-sidebar {
background-color: #0a22d8;
}
/* active selected tab in the sidebarmenu */
.skin-blue .main-sidebar .sidebar .sidebar-menu .active a{
background-color: #ff0000;
}
/* other links in the sidebarmenu */
.skin-blue .main-sidebar .sidebar .sidebar-menu a{
background-color: #00ff00;
color: #000000;
}
/* other links in the sidebarmenu when hovered */
.skin-blue .main-sidebar .sidebar .sidebar-menu a:hover{
background-color: #ff69b4;
}
/* toggle button when hovered */
.skin-blue .main-header .navbar .sidebar-toggle:hover{
background-color: #8390ef;
}
/* my atmpt background */
.skin-blue .content {background-color: #8390ef;}'))),
tabsetPanel(type = "tabs",
tabPanel("Help",
br(),
fillPage(
fillRow(plotOutput("my_map"))
)))))
server <- function(input, output, session){
output$my_map <- renderPlot({
wrld <- map_data("world")
ggplot(wrld, color = "white") +
geom_polygon(aes(x = long, y = lat, group = group)) +
coord_fixed(1.3) +
guides(fill = F)
})
}
shinyApp(ui, server)
解决方案
您能否提供以下属性(您可以使用您的课程而不是 div)
div{
width:100%;
height:100%;
}
推荐阅读
- reactjs - How to import React in TypeScript (.tsx) the right way™?
- oracle - 如何用最新记录消除oracle中的价值
- abap - How To Use Serial Port Monitor
- javascript - How to add jQuery append function dom?
- jquery - Return AJAX message after view has been performed
- c# - PostAsJsonAsync 将前导字符添加到请求正文
- xaml - 如何解决 Xamarin.Forms 中的“属性 'FontSize':'Large' 的无效值”警告
- php - 在 Laravel 应用程序中从 PHP 数组中提取数据时得到零
- c++ - 我想在 cuda 源代码中将浮点数改为双倍
- laravel-5 - 我应该如何使用 HasManyThrough 通过 Laravel 中的 2 个数据透视表连接 3 个表?