2

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")
   )      
  )
Cœur
  • 37,241
  • 25
  • 195
  • 267
Tamar
  • 23
  • 1
  • 6

1 Answers1

3

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.

RmIu
  • 4,357
  • 1
  • 21
  • 24