相关疑难解决方法(0)

R Shiny:如何在 NULL 时不显示绘图

如果您在 R 工作室中运行此代码,您会发现 NULL 数据的绘图仍然是一大块白色。

数据为NULL时怎么不显示呢?

在其他图表中,大白板看起来不太好。

library(shiny)

server <- function(input, output) {
  output$x = renderPlot(NULL)
}

ui <- fluidPage(
  br(),
  plotOutput("x"),
  tags$head(tags$style(HTML("
                            body {
                            margin: 0;
                            font-family: helvetica, sans-serif;
                            background: #F2F0F0;
                            }

                            .shiny-plot-output{
                            max-width: 100%;
                            box-shadow: 0px 0px 6px #888;
                            margin-left: auto;
                            margin-right: auto;
                            }
                            ")))  
  )

shinyApp(ui = ui, server = server)
Run Code Online (Sandbox Code Playgroud)

r shiny

4
推荐指数
1
解决办法
9113
查看次数

标签 统计

r ×1

shiny ×1