View source: R/boxGrobs_boxHeaderGrob.R
| boxHeaderGrob | R Documentation |
Creates a grob box with a centered header and
left-justified body text. Useful for flowchart elements that combine a title
with bullet points or multi-line descriptions.
boxHeaderGrob(
header,
body,
y = unit(0.5, "npc"),
x = unit(0.5, "npc"),
width,
height,
bjust = "center",
header_gp = getOption("boxHeaderGrobTxt", default = gpar(color = "black", cex = 1)),
body_gp = getOption("boxBodyGrobTxt", default = gpar(color = "black", cex = 0.9)),
box_gp = getOption("boxGrob", default = gpar(fill = "white")),
box_fn = roundrectGrob,
name = NULL
)
header |
The header text (centered, typically bold). |
body |
The body text (left-justified, typically with bullets or multiple lines). |
y |
The y position to put the box at. Can be either in |
x |
The x position to put the box at. Can be either in |
width |
The box automatically adapts the size but you can force by specifying the width |
height |
The box automatically adapts the size but you can force by specifying the height |
bjust |
The justification for the box: left, center, right, top or bottom.
See the |
header_gp |
The |
body_gp |
The |
box_gp |
The |
box_fn |
Function to create box for the text. Parameters of 'x=0.5', 'y=0.5' and 'box_gp' will
be passed to this function and return a |
name |
a character identifier for the |
A grob with class "box" compatible with all Gmisc flowchart helpers
(coords, distance, connectGrob,
spreadVertical, alignHorizontal, etc.)
Other flowchart components:
align(),
append(),
boxGrob(),
boxPropGrob(),
boxShapes,
connectGrob(),
coords(),
distance(),
flowchart(),
insert(),
move(),
moveBox(),
spread()
library(grid)
grid.newpage()
# Simple example with header and bullets
box1 <- boxHeaderGrob(
header = "Early rehabilitation",
body = paste("0-1 weeks", "• Instruction", "• Pendulum + assisted ROM", sep = "\n"),
header_gp = gpar(fontsize = 11, fontface = "bold"),
body_gp = gpar(fontsize = 9),
box_gp = gpar(fill = "#E8F5E9", col = "#2E7D32")
)
grid.draw(box1)
# Works with all helpers
box2 <- boxHeaderGrob(
header = "Delayed rehabilitation",
body = "0-3 weeks\n• Sling immobilisation",
y = 0.3,
box_gp = gpar(fill = "#FFF8E1", col = "#EF6C00")
)
# Distance calculation works
d <- distance(box1, box2, type = "v")
# Connect boxes
grid.draw(box2)
connectGrob(box1, box2, type = "vertical")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.