R

时间:2017-12-12 07:37:05

标签: html css r shiny shinydashboard

请运行下面的R闪亮脚本,我将附上两个屏幕,需要一些帮助来定位小部件:

屏幕1:

  1. 我想增加selectInput小部件的宽度,使得选项清晰可见,与KPI框的间距相等。
  2. 我希望这两个大盒子的宽度和高度相同,以便从左到右完全覆盖屏幕。
  3. 注意:框的左边框应与selectInput小部件的左边框重合。 image1

    屏幕2: 1.请帮助移动第一个和第二个selectInput小部件以及上面的kpi框,以便可以像上面屏幕中的要求那样增加框图宽度。请帮忙。

    enter image description here

    ## app.R ##
    library(shiny)
    library(shinydashboard)
    ui <- dashboardPage(
    dashboardHeader(title = "Iris Chart"),
    dashboardSidebar(
    width = 0
    ),
    dashboardBody(
    tags$head(tags$style(HTML('.info-box {min-height: 45px;} .info-box-icon 
    {height: 45px; line-height: 45px;} .info-box-content {padding-top: 0px; 
    padding-bottom: 0px;} 
                              '))),
    fluidRow(
      column(1,
      selectInput("Position", "", 
      c("User_Analyses","User_Activity_Analyses"),selected = "Median", width = 
      "400"),
      conditionalPanel(
      condition = "input.Position == 'User_Analyses'",
      selectInput("stats", "", c("Time","Cases"),selected = "Median", width = 
      "400"))),
      tags$br(),
      column(10,
      infoBox("User1", paste0(10), icon = icon("credit-card"), width = "3"),
             infoBox("User2",paste0(10), icon = icon("credit-card"), width = 
      "3"),
    
             infoBox("User3",paste0(10), icon = icon("credit-card"), width = 
      "3"),
             infoBox("User4",paste0(16), icon = icon("credit-card"), width = 
      "3")),
    
    
      column(10,
             conditionalPanel(
               condition = "input.Position == 'User_Analyses'",
    
               box(title = "Plot1", status = "primary",height = "537" ,solidHeader = T,
                   plotOutput("case_hist",height = "466")),
               box(title = "Plot2", status = "primary",height = "537" ,solidHeader = T,
                   plotOutput("trace_hist",height = "466"))
    
    
             ),
             conditionalPanel(
               condition = "input.Position == 'User_Activity_Analyses'",
               box(title = "Plot3",status = "primary",solidHeader = T,height = "537",width = "6",
                   plotOutput("sankey_plot")),
               box(title = "Plot4",status = "primary",solidHeader = T,height = "537",width = "6",
                   plotOutput("sankey_table"))
    
               )
    
    
    
    
    
      )
    
    )
    
    
    
    )
    )
    server <- function(input, output) 
    {
    output$case_hist <- renderPlot(
    plot(iris$Sepal.Length)
    
    )
    
    output$trace_hist <- renderPlot(
    plot(mtcars$mpg)
    
    )
    output$sankey_plot <- renderPlot({
    plot(diamonds$carat)
    })
    #Plot for Sankey Data table 
    output$sankey_table <- renderPlot({
    plot(iris$Petal.Length)
    })
    }
    shinyApp(ui, server)
    

1 个答案:

答案 0 :(得分:0)

这有点像你想要的。

library(shiny)
library(shinydashboard)
ui <- dashboardPage(
  dashboardHeader(title = "Iris Chart"),
  dashboardSidebar(
    width = 0
  ),
  dashboardBody(
    tags$head(tags$style(HTML('.info-box {min-height: 45px;} .info-box-icon 
                              {height: 45px; line-height: 45px;} .info-box-content {padding-top: 0px; 
                              padding-bottom: 0px;} 
                              '))),
    fluidRow(
      column(
        width = 12,
        column(
          width = 2,
          selectInput("Position", "", 
                      c("User_Analyses","User_Activity_Analyses"),selected = "Median", width = 
                        "400"),
          conditionalPanel(
            condition = "input.Position == 'User_Analyses'",
            style = "margin-top:-22px;",
            selectInput("stats", "", c("Time","Cases"),selected = "Median", width = "400"))
        ),
        column(
          style = "padding-top:20px;",
          width = 10,
          infoBox("User1", paste0(10), icon = icon("credit-card"), width = "3"),
          infoBox("User2",paste0(10), icon = icon("credit-card"), width ="3"),

          infoBox("User3",paste0(10), icon = icon("credit-card"), width ="3"),
          infoBox("User4",paste0(16), icon = icon("credit-card"), width ="3"))
        ),
      column(
        width = 12,
        conditionalPanel(
          condition = "input.Position == 'User_Analyses'",
          box(title = "Plot1", status = "primary",height = "537" ,solidHeader = T,
              plotOutput("case_hist",height = "466")),
          box(title = "Plot2", status = "primary",height = "537" ,solidHeader = T,
              plotOutput("trace_hist",height = "466"))
        ),
        conditionalPanel(
          condition = "input.Position == 'User_Activity_Analyses'",
          box(title = "Plot3",status = "primary",solidHeader = T,height = "537",width = "6",
              plotOutput("sankey_plot")),
          box(title = "Plot4",status = "primary",solidHeader = T,height = "537",width = "6",
              plotOutput("sankey_table"))
        )      
      )
    )
    )
    )
server <- function(input, output) 
{
  output$case_hist <- renderPlot(
    plot(iris$Sepal.Length)

  )

  output$trace_hist <- renderPlot(
    plot(mtcars$mpg)

  )
  output$sankey_plot <- renderPlot({
    plot(diamonds$carat)
  })
  #Plot for Sankey Data table 
  output$sankey_table <- renderPlot({
    plot(iris$Petal.Length)
  })
}
shinyApp(ui, server)