【发布时间】:2023-04-08 07:15:01
【问题描述】:
我已经构建了一个图,我想填充闪亮仪表板的整个页面。基本上下面的代码对我有用,除了图表总是页面高度的一半,我希望它填满整个高度。我已经尝试在这个论坛上使用 fillPage() 函数和其他解决方案,但似乎没有一个适合我的特定情况。
下面是一些可重现的代码及其生成的图像。谢谢。
library(shiny)
library(shinydashboard)
ui <- dashboardPage(
dashboardHeader(title = "Header"),
sidebar <- dashboardSidebar(),
body <- dashboardBody(
fillPage(plotlyOutput("Waterfall", height="100%", width="100%"))
),
dashboardPage(dashboardHeader(title="Title"), sidebar,body)
)
server <- shinyServer(function(input, output, session) {
x= list("Sales", "Consulting", "Net revenue", "Purchases", "Other expenses", "Profit before tax")
measure= c("relative", "relative", "total", "relative", "relative", "total")
text= c("+60", "+80", "", "-40", "-20", "Total")
y= c(60, 80, 0, -40, -20, 0)
data = data.frame(x=factor(x,levels=x),measure,text,y)
output$Waterfall <- renderPlotly({ plot_ly(
data, name = "20", type = "waterfall", measure = ~measure,
x = ~x, textposition = "outside", y= ~y, text =~text,
connector = list(line = list(color= "rgb(63, 63, 63)"))) })
})
shinyApp(ui=ui, server=server)
【问题讨论】:
标签: r shiny shinydashboard