在R闪亮的仪表板中将图形对齐到框的中心()

时间:2017-09-10 10:54:10

标签: r shiny shinydashboard

下面的脚本在R闪亮仪表板页面的两个框内创建了两个图,这些图对齐到框的右侧,我希望对齐这些框的中心。这些包是创建给定图的最小必需包。请帮忙。

## 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

1 个答案:

答案 0 :(得分:4)

问题似乎是htmlwidgets初始化为960像素宽度左右。两种覆盖方法可能是:

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
    )
  )
)

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)
    )
  )
)