changeText | R Documentation |
Changes the text entry of XML element of type 'text'. The XML element may be found by its name (XML attribute 'id') or based on its current text entry.
changeText(
svg,
element_name,
text,
alignment = NULL,
in_group = NULL,
hide_blank = FALSE
)
svg |
XML document with SVG content |
element_name |
Name (attribute 'id') of text (XML element 'text') or current text entry of text (XML element 'text'). |
text |
New text entry. |
alignment |
Character value for text alignment. Accepts 'start', 'middle', and 'end' (default NULL = no change). |
in_group |
Name (attribute 'id') of group (XML element 'g') that contains the text element (default NULL = no group, search the entire SVG). |
hide_blank |
Should text elements with empty strings be hidden (set attribute 'display' to 'none')? (default FALSE) |
XML document with SVG content
#read SVG file
fpath <- system.file("extdata", "fig1.svg", package="svgtools")
svg <- read_svg(file = fpath)
#change a text
svg <- changeText(svg = svg, element_name = "Category A", text = "low")
svg <- changeText(svg = svg, element_name = "Category B", text = "medium")
svg <- changeText(svg = svg, element_name = "Category C", text = "high")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.