gpt4 book ai didi

r - 将绘图与 R Shiny 仪表板中的 box() 中心对齐

转载 作者:行者123 更新时间:2023-12-04 11:35:16 25 4
gpt4 key购买 nike

下面的脚本在 R Shiny 仪表板页面中的两个框中创建两个图,它们与框的右侧对齐,我希望将这些图对齐框的中心。这些包是创建给定图所需的最少包。请帮忙。

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

最佳答案

问题似乎是 htmlwidget 被初始化为 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)
)
)
)

关于r - 将绘图与 R Shiny 仪表板中的 box() 中心对齐,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46139901/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com