svg_group {omsvg} | R Documentation |
Addition of a group element
Description
The svg_group()
function allows for grouping of several SVG elements. This
is useful if we'd like to pass presentation attributes to several elements
at once.
Usage
svg_group(
svg,
...,
.list = list2(...),
attrs = list(),
anims = list(),
filters = list(),
id = NULL
)
Arguments
svg |
The |
... |
a collection of named arguments that consist of presentation
attributes (e.g., |
.list |
Allows for the use of a list as an input alternative to |
attrs |
A presentation attribute list. The helper function
|
anims |
An animation directive list for the element. This should be
structured using the |
filters |
A filter directive list for the element. This is easily
created by using a list of |
id |
An optional ID value to give to the built tag. This is useful for modifying this element in a later function call or for interacting with CSS. |
Value
An svg
object.
Examples
if (interactive()) {
# Create an SVG with two rectangles
# contained within a group
SVG(width = 300, height = 300) %>%
svg_group(
fill = "steelblue", stroke = "red", opacity = 0.5,
~ svg_rect(., x = 20, y = 20, width = 50, height = 50),
~ svg_rect(., x = 40, y = 40, width = 50, height = 50, fill = "red")
)
# Create an SVG with two rectangles
# that are nested within two
# different groups
SVG(width = 300, height = 300) %>%
svg_group(
fill = "green", stroke = "red",
~ svg_rect(., x = 30, y = 30, width = 40, height = 50),
~ svg_group(.,
fill = "steelblue", opacity = 0.5,
~ svg_rect(., x = 60, y = 60, width = 50, height = 50)
)
)
}