[英]Shiny: How to increase the width of tabsetPanel to cover the whole area to the right of the sidebarPanel?
[英]TabsetPanel not filling whole page in Shiny
我正在嘗試創建一個使用tabsetPanel的閃亮應用程序,但是,當我創建選項卡時,應用程序中的內容不再填充窗口的整個空間,並在輸出的右側和下方留下了很大的白色間隙。 下面是一個非常基本的示例。 沒有選項卡,該應用程序可以完美地作為流暢的頁面運行,但是對於我正在做的工作,我需要將其拆分為多個選項卡。
一個簡單的例子:
`library(shiny)
# Define UI for application that draws a histogram
ui <- fluidPage(
# Application title
titlePanel("Old Faithful Geyser Data"),
mainPanel(
tabsetPanel(
tabPanel("Test",
# Sidebar with a slider input for number of bins
sidebarLayout(
sidebarPanel(
sliderInput("bins",
"Number of bins:",
min = 1,
max = 50,
value = 30)
),
# Show a plot of the generated distribution
mainPanel(
plotOutput("distPlot")
)
)),
#Create second tab just for demonstration
tabPanel("Second Test", h3("Test")
))))
# Define server logic required to draw a histogram
server <- function(input, output) {
output$distPlot <- renderPlot({
# generate bins based on input$bins from ui.R
x <- faithful[, 2]
bins <- seq(min(x), max(x), length.out = input$bins + 1)
# draw the histogram with the specified number of bins
hist(x, breaks = bins, col = 'darkgray', border = 'white')
})
{ "example second tab" }
}
# Run the application
shinyApp(ui = ui, server = server) `
我試圖擺弄fillPage和fluidPage,但是由於將對象移到錯誤的位置而使情況變得更糟,或者什么也沒有發生。 這只是發生在我身上嗎? 有誰知道這樣做的原因是什么,如果可以的話,如何解決?
這是橫跨整個寬度的一個:
library(shiny)
ui <- fluidPage(
titlePanel("Title"),
tabsetPanel(
tabPanel(
"Test",
sidebarLayout(
sidebarPanel(
sliderInput("bins", "Number of bins:", min = 1, max = 50, value = 30)
),
mainPanel(
plotOutput("distPlot")
)
)
),
tabPanel("Second Test", h3("Test"))
)
)
server <- function(input, output) {
output$distPlot <- renderPlot({
x <- faithful[, 2]
bins <- seq(min(x), max(x), length.out = input$bins + 1)
hist(x, breaks = bins, col = 'darkgray', border = 'white')
})
{ "example second tab" }
}
shinyApp(ui = ui, server = server)
基本上,您有一個mainPanel
包裹在tabsetPanel
周圍。 沒有它,一切看起來都會很好。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.