Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Aligning plots to the center of the box() in R shiny dashboard

the script below creates two plots within two boxes in R shiny dashboard page which are aligned to the right of the box, I wish to align these plots center of the box.These packages are the minimum required packages to create the given plots. Please help.

## app.R ##
library(shiny)
library(shinydashboard)
library(bupaR)
library(edeaR)
library(eventdataR)
library(processmapR)
library(processmonitR)
library(xesreadR)
library(petrinetR)

ui <- dashboardPage(
dashboardHeader(
),
dashboardSidebar(
width = 0
),
dashboardBody(
box(title = "Process Map", status = "primary",height = "575", solidHeader = 
T,patients %>% process_map(),align = "left"),
box(title = "Resource Map", status = "primary",height = "575", solidHeader = 
T,
resource_map(patients, render = T))
)
)

server <- function(input, output) { }

shinyApp(ui, server)

enter image description here

like image 851
Ashmin Kaul Avatar asked Sep 10 '17 10:09

Ashmin Kaul


1 Answers

The problem seems to be that the htmlwidgets are initialized with 960 pixels width or so. Two ways to override this could be:

pmap <- patients %>% process_map()
pmap$width <- "100%"
rmap <- resource_map(patients, render = T)
rmap$width <- "100%"
ui <- dashboardPage(
  dashboardHeader(),
  dashboardSidebar(
    width = 0
  ),
  dashboardBody(
    box(
      title = "Process Map", 
      status = "primary",height = "575", 
      solidHeader = T,
      pmap,
      align = "left"),
    box(
      title = "Resource Map", 
      status = "primary",
      height = "575", 
      solidHeader = T, 
      rmap
    )
  )
)

or

ui <- dashboardPage(
  dashboardHeader(),
  dashboardSidebar(
    width = 0
  ),
  dashboardBody(
    tags$head(tags$style(HTML(".grViz { width:100%!important;}"))),  
    box(
      title = "Process Map", 
      status = "primary",height = "575", 
      solidHeader = T,
      patients %>% process_map(),
      align = "left"),
    box(
      title = "Resource Map", 
      status = "primary",
      height = "575", 
      solidHeader = T, 
      resource_map(patients, render = T)
    )
  )
)
like image 104
lukeA Avatar answered Sep 29 '22 17:09

lukeA