这应该可以完成这项工作:
library(shiny)
library(shinydashboard)
library(dashboardthemes)
library(ggplot2)
ui <- dashboardPage(
dashboardHeader(title = "FullscreenDashboard", titleWidth = 450),
dashboardSidebar(disable = T),
dashboardBody(
### change theme
shinyDashboardThemes(
theme = "grey_dark"
),
fillPage(
tags$style(type = "text/css", "#plot1 {height: calc(100vh - 80px) !important;}"),
plotOutput("plot1", width = "100%",height = "100%")
)
)
)
server <- function(input, output, session){
output$plot1 <- renderPlot({ #reactivePlot
dat <- data.frame(
time = factor(c("Lunch","Dinner"), levels=c("Lunch","Dinner")),
total_bill = c(14.89, 17.23)
)
#Plot
p<-ggplot(data=dat, aes(x=time, y=total_bill, fill=time)) +
geom_bar(stat="identity")
p
})
}
shinyApp(ui, server)
EDIT:如何填写navbarPage
with tabPanel
library(shiny)
library(ggplot2)
ui <- navbarPage("Navbar!",
tabPanel("Plot",
fillPage(
tags$style(type = "text/css", "#plot1 {height: calc(100vh - 80px) !important;}"),
plotOutput("plot1", width = "100%",height = "100%")
)
),
tabPanel("Summary",
fillPage(
tags$style(type = "text/css", "#plot2 {height: calc(100vh - 80px) !important;}"),
plotOutput("plot2", width = "100%",height = "100%")
)
)
)
server <- function(input, output, session){
data <- reactive({
dat <- data.frame(
time = factor(c("Lunch","Dinner"), levels=c("Lunch","Dinner")),
total_bill = c(14.89, 17.23)
)
#Plot
p<-ggplot(data=dat, aes(x=time, y=total_bill, fill=time)) +
geom_bar(stat="identity")
p
})
output$plot1 <- renderPlot({
data()
})
output$plot2 <- renderPlot({
data()
})
}
shinyApp(ui, server)
整个应用程序的背景图片:你们中的一些人可能希望您的应用程序有一个漂亮的背景,在这种情况下,我建议您看看setBackgroundImage
内的函数shinyWidgets
包装按照here
library(shiny)
library(shinyWidgets)
ui <- fluidPage(
tags$h2("Add a shiny app background image"),
setBackgroundImage(
src = "https://www.fillmurray.com/1920/1080"
)
)
server <- function(input, output, session) {
}
shinyApp(ui, server)