R 如何防止打印在有光泽的盒子中溢出?
我偶然发现了盒子和情节中折叠的盒子之间的这种wierd交互: 在第一个实例中,在下面的最小工作示例中,在左侧,展开长方体会将绘图推到长方体的边缘上,而在右侧的第二个实例中,则不会。 另外,取消对操作按钮代码的注释也可以解决这个问题。 有人能向我解释为什么会发生这种情况以及如何解决这个问题吗? 我知道我可以使用右边的布局,但我真的很想了解这种行为 提前谢谢R 如何防止打印在有光泽的盒子中溢出?,r,shiny,shinydashboard,R,Shiny,Shinydashboard,我偶然发现了盒子和情节中折叠的盒子之间的这种wierd交互: 在第一个实例中,在下面的最小工作示例中,在左侧,展开长方体会将绘图推到长方体的边缘上,而在右侧的第二个实例中,则不会。 另外,取消对操作按钮代码的注释也可以解决这个问题。 有人能向我解释为什么会发生这种情况以及如何解决这个问题吗? 我知道我可以使用右边的布局,但我真的很想了解这种行为 提前谢谢 library(shiny) library(shinydashboard) ui <- dashboardPage(
library(shiny)
library(shinydashboard)
ui <- dashboardPage(
dashboardHeader(),
dashboardSidebar(),
dashboardBody(
fluidPage(
box(width = 12,
title = "Some Title",
collapsible = TRUE,
solidHeader = TRUE,
status = "danger",
box(widht = 12,
title = "Some Sub Title",
collapsible = TRUE,
solidHeader = TRUE,
box(
width = 12,
title = "Details 1",
collapsible = TRUE,
solidHeader = TRUE,
collapsed = TRUE,
status = "info",
tableOutput("Placeholder_Table_1")
),
#actionButton(inputId = "Action_1",
# label = "Does nothing"
#),
plotOutput("Placeholder_Plot_1")
),
box(widht = 12,
title = "Sub Title 2",
collapsible = TRUE,
solidHeader = TRUE,
plotOutput("Placeholder_Plot_2"),
box(
width = 12,
title = "Details 2",
collapsible = TRUE,
solidHeader = TRUE,
collapsed = TRUE,
status = "info",
tableOutput("Placeholder_Table_2")
)
)
)
)
)
)
server <- function(input, output) {
output$Placeholder_Table_1 <- renderTable(
tibble('Variable 1' = "X",
'Variable 2' = "Y",
'Variable 3' = "Z"
)
)
output$Placeholder_Table_2 <- renderTable(
tibble('Variable 1' = "X",
'Variable 2' = "Y",
'Variable 3' = "Z"
)
)
output$Placeholder_Plot_1 <- renderPlot(
ggplot(data = mtcars) +
labs(title = "Placeholder Plot 1")
)
output$Placeholder_Plot_2 <- renderPlot(
ggplot(data = mtcars) +
labs(title = "Placeholder Plot 2")
)
}
shinyApp(ui, server)
库(闪亮)
图书馆(shinydashboard)
ui问题不在于绘图,而是来自框
首先需要知道的是,box
实际上使用了bootstrap中的.col xxx
类,这些类有一个CSSfloat:left代码>。这将导致其自身的父div高度为0。请阅读以下内容:
但是,您看到的是它在UI上占用了一些空间,因此您看到的高度是box+plot,但在父div高度计算中,它只是plot
要修复此问题,非常简单,请使用fluidrow
,。row
有一个CSS显示:表
,解决了此问题
fluidRow(框(
宽度=12,
title=“详情1”,
可折叠=真,
solidHeader=TRUE,
折叠=真,
status=“info”,
tableOutput(“占位符表1”)
)),
感谢您如此清楚地解释这一点,它的效果非常好!