从此页面上的代码开始:enter link description here,我希望能够控制第一个tabBox的选项卡1上的方框图的大小。在下面的代码中黑客攻击几个滑块和uiOuput调用,我现在可以轻松控制箱线图的高度和宽度。但是,虽然tabBox在高度上很好地扩展以包含绘图,但它的宽度不会扩展。在高宽度值时,绘图在框的边界上延伸。我看到类似的结果使用一个简单的Box来包含该图。
有没有办法改变Box / tabBox的宽度以获得所需的效果?
library(shiny)
library(shinydashboard)
body <- dashboardBody(
fluidRow(
tabBox(
title = "First tabBox",
# The id lets us use input$tabset1 on the server to find the current tab
id = "tabset1",
tabPanel("Tab1", "First tab content", uiOutput('UI_test')),
tabPanel("Tab2", "Tab content 2")
),
tabBox(
side = "right",
selected = "Tab3",
tabPanel("Tab1", "Tab content 1"),
tabPanel("Tab2", "Tab content 2"),
tabPanel("Tab3", "Note that when side=right, the tab order is reversed.",
sliderInput('sldHt', 'Height', min=100, max=500,
value=200, step=10),
sliderInput('sldWd', 'Width', min=100, max = 500,
value=200, step=10)
)
)
),
fluidRow(
tabBox(
# Title can include an icon
title = tagList(shiny::icon("gear"), "tabBox status"),
tabPanel("Tab1",
"Currently selected tab from first box:",
verbatimTextOutput("tabset1Selected")
),
tabPanel("Tab2", "Tab content 2")
)
)
)
shinyApp(
ui = dashboardPage(
dashboardHeader(title = "tabBoxes"),
dashboardSidebar(),
body
),
server = function(input, output) {
# The currently selected tab from the first box
output$tabset1Selected <- renderText({
input$tabset1
})
output$UI_test = renderUI({
plotOutput('test',
height = input$sldHt,
width = input$sldWd)
})
output$test = renderPlot(
boxplot(len ~ dose, data = ToothGrowth,
boxwex = 0.25, at = 1:3 - 0.2,
subset = supp == "VC", col = "yellow",
main = "Guinea Pigs' Tooth Growth",
xlab = "Vitamin C dose mg",
ylab = "tooth length",
xlim = c(0.5, 3.5), ylim = c(0, 35), yaxs = "i"))
}
)