如何设置尺寸和特定布局的光泽 [英] How to set the sizes and specific layouts in shiny

查看:66
本文介绍了如何设置尺寸和特定布局的光泽的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使以下布局具有光泽:

I am trying to make the following layout in shiny:

到目前为止,这是我借助此 answer的帮助而实现的:

This is what I achieved so far by the help of this answer :

我的ui.R:

library(shiny)
library(ggplot2)
shinyUI(fluidPage(  
# fluidRow(
# title = "My title",
# column(6,plotOutput('plot1', height="200px"))
# #plotOutput('plot1'),
# #plotOutput('plot2'),
# #plotOutput('plot3')
# ),
fluidRow(
  column(6,div(style = "height:200px;background-color: gray;", "Topleft")),
  column(6,div(style = "height:400px;background-color: gray;", "right"))),
fluidRow(
  column(6,div(style = "height:100px;background-color: gray;", "Bottomleft"))
  ),
hr(),  
fluidRow(
  column(7,
       h4("Control Panel"),
       fileInput('file', 'Select an CSV file to read',
                 accept=c('text/csv','text/comma-separated-     values,text/plain','.csv')),
        br(),          
       sliderInput('sampleSize', 'Sample Size', 
                   min=1, max=100, value=min(1, 100), 
                   step=500, round=0),          
       br(),           
       actionButton("readButton", "Read Data!")
    )
    )
  ))

我的服务器.R:

function(input, output) {




}

我不知道如何将plotOutput插入盒子? 如何控制盒子的尺寸使其看起来像上面给出的布局?

I don't know how to plug int he plotOutput into the boxes? How can I control the sizes of the box to look like the layout given above?

推荐答案

不要让事情太复杂,只需处理行,列和图的height属性即可.

Don't make things too complicated, just work with rows, columns and the height attribute of plots:

library(shiny)

ui <- shinyUI(fluidPage(fluidRow(
  column(
    width = 3,
    plotOutput('plot1', height = 200),
    plotOutput('plot2', height = 200)
  ),
  column(width = 8, plotOutput('plot3', height = 400))
),
hr(),
wellPanel(fluidRow(
  column(
    width = 11,
    align = "center",
    h3("Control Panel"),
    column(width = 3, fileInput('file','Select an CSV file to read', accept = c('text/csv', 'text/comma-separated-values,text/plain', '.csv'))),
    column(width = 3, offset = 1, sliderInput('sampleSize','Sample Size', min = 1, max = 100, value = min(1, 100), step = 500,round = 0)),
    column(width = 1, offset = 1, actionButton("readButton", "Read Data!"))
  )
))))


server <- function(input, output) {
  output$plot1 <- renderPlot({
    plot(mtcars$mpg, mtcars$cyl)
  })
  output$plot2 <- renderPlot({
    plot(mtcars$mpg, mtcars$carb)
  })
  output$plot3 <- renderPlot({
    plot(mtcars$mpg, mtcars$disp)
  })
}

shinyApp(ui, server)

这篇关于如何设置尺寸和特定布局的光泽的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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