R Shiny布局 [英] R Shiny Layouts

查看:161
本文介绍了R Shiny布局的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在闪亮的仪表板上,我目前正在绘制1个条形图,并在下面绘制4个饼图,如下所示:

In my shiny dashboard, I am currently plotting 1 bar graph above, and 4 pie charts below, as follows:

fluidRow(
  column(12, plotOutput("bar1"))),
  fluidRow(
    column(3, plotOutput("pie")),
    column(3, plotOutput("pie2")),
    column(3, plotOutput("pie3")),
    column(3, plotOutput("pie4")))

如何将条形图与4个饼图并排成正方形?

How would I go about plotting the bar chart alongside the 4 pie charts, with the pie charts arranged in a square?

有效地,条形图将是column(6,...,所有饼图将是column(3,...,但是我需要条形图扩展到两行,以便将饼形图直接绘制在其旁边.

Effectively the bar chart would be column(6,... and all of the pie charts would be column(3,... but I would need the bar chart to extend to 2 rows so the pie charts are plotted directly beside it.

推荐答案

标准plotOutput的高度为400px

plotOutput(outputId,width ="100%",height ="400px",单击= NULL,
dblclick = NULL,悬停= NULL,hoverDelay = NULL,hoverDelayType = NULL,brush = NULL,clickId = NULL,hoverId = NULL,内联= FALSE)

plotOutput(outputId, width = "100%", height = "400px", click = NULL,
dblclick = NULL, hover = NULL, hoverDelay = NULL, hoverDelayType = NULL, brush = NULL, clickId = NULL, hoverId = NULL, inline = FALSE)

因此您可以执行以下操作:

So you can do the following:

library(shiny)

ui <- fluidPage(
  fluidRow(
    column(6, plotOutput("bar1",height = "800px")),
    column(6,
           column(6, plotOutput("pie")),
           column(6, plotOutput("pie2")),
           column(6, plotOutput("pie3")),
           column(6, plotOutput("pie4"))

    ))
)

server <- function(input, output) {

  output$bar1 <- renderPlot({
    hist(rnorm(1:100));box();grid()
  })
  output$pie <- renderPlot({
    plot(rnorm(1:100));box();grid()
  })
  output$pie2 <- renderPlot({
    plot(rnorm(1:100));box();grid()
  })
  output$pie3 <- renderPlot({
    plot(rnorm(1:100));box();grid()
  })
  output$pie4 <- renderPlot({
    plot(rnorm(1:100));box();grid()
  })
}

shinyApp(ui,server)

这篇关于R Shiny布局的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆