gpt4 book ai didi

r - Shiny 的应用程序仪表板中的页脚对齐

转载 作者:行者123 更新时间:2023-12-02 05:11:14 24 4
gpt4 key购买 nike

我正在尝试将页脚插入页面底部和中心的 Shiny 应用程序仪表板中。但它是来到 body 的中心。我也无法将其放置在页面底部

这是我的代码:

library(shiny)
library(shinydashboard)
library(DT)
library(ggvis)
library(shiny)

ui <- dashboardPage(
dashboardHeader(title = "Dashboard"),
dashboardSidebar(sidebarMenu(
menuItem("Instructions", tabName = "genIns", icon = icon("info-circle")),
menuItem("Data", tabName = "data", icon = icon("table"))

)),
dashboardBody(
tabItems(
# First tab content
tabItem(tabName = "genIns",
fluidPage(
titlePanel("General Instruction will go here"))
),
# Second tab content
tabItem(tabName = "data",
sliderInput("bins",
"Number of bins:",
min = 1,
max = 50,
value = 30),
plotOutput("distPlot")
)

),
tags$footer("My footer", align = "center")
)
)

服务器.ui

shinyServer(function(input, output, session) {

output$distPlot <- renderPlot({
x <- faithful[, 2] # Old Faithful Geyser data
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')
})
})

最佳答案

您可以将 dashbordPage 包装到 tagList 中,然后将 tags$footer 作为 tagList 的第二个参数。您还可以使用 css 进一步修改页脚的样式。

<小时/>

完整示例:

library(shiny)
library(shinydashboard)
library(DT)
library(ggvis)
library(shiny)

ui <- tagList(
dashboardPage(
dashboardHeader(title = "Dashboard"),
dashboardSidebar(sidebarMenu(
menuItem("Instructions", tabName = "genIns", icon = icon("info-circle")),
menuItem("Data", tabName = "data", icon = icon("table"))

)),
dashboardBody(
tabItems(
# First tab content
tabItem(tabName = "genIns",
fluidPage(
titlePanel("General Instruction will go here"))
),
# Second tab content
tabItem(tabName = "data",
sliderInput("bins",
"Number of bins:",
min = 1,
max = 50,
value = 30),
plotOutput("distPlot")
)

)

)

),#end dashboardPage
tags$footer("My footer", align = "center", style = "
position:absolute;
bottom:0;
width:100%;
height:50px; /* Height of the footer */
color: white;
padding: 10px;
background-color: black;
z-index: 1000;")

)#end tagList


server <- shinyServer(function(input, output, session) {

output$distPlot <- renderPlot({
x <- faithful[, 2] # Old Faithful Geyser data
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')
})
})

shinyApp(ui, server)

关于r - Shiny 的应用程序仪表板中的页脚对齐,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38939827/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com