Shiny dashboard multiple charts - overlapping

泄露秘密 提交于 2019-12-23 22:27:41

问题


I am using shiny dashboard package for my app. while trying to display 2 plots on the same page (each one in a box) they are overlapping. Also tried to use fluidRow for each plot - but still it seems both plot are connected to the same box (and overlapping)

This is my code:

 mainPanel(
  fluidRow( 
     box(showOutput("MeasuresPlot","morris"),width=6,title="Graph"),
     box(showOutput("ImportPlot","morris"),width=6,title="Graph2")
   )      
  )

回答1:


Your almost there, inside your fluid row you can use columns like this:

library(shiny)
library(shinydashboard)


ui <-dashboardPage(
    dashboardHeader(),
    dashboardSidebar(),
    dashboardBody(
      fluidRow(
        column(6,box(plotOutput("plt1"),width=12,title="Graph",background ="green") ),
        column(6,box(plotOutput("plt2"),width=12,title="Graph2",background="yellow") )
      ),
      fluidRow( actionButton("plot","plot") )
    )
)

server <- shinyServer(function(input, output, session) {
  observeEvent(input$plot,{
    output$plt1 <- renderPlot({plot(runif(100),runif(100))})
    output$plt2 <- renderPlot({plot(runif(100),runif(100))})
  })
})

shinyApp(ui = ui, server = server)

The maximum width of a fluidRow is 12 so setting each column to have width 6 gives 2 equal width plots.



来源:https://stackoverflow.com/questions/33105539/shiny-dashboard-multiple-charts-overlapping

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!