getStyle: Manipulate the style attribute of an SVG node

Description Usage Arguments Value Author(s) See Also Examples

Description

These functions allow us to query and set and reorganize the value of a style attribute of an SVG node. We use these to determine the vector of CSS-based style settings and to set a new value.

modifyStyle is used to merge new values for particular characteristics in an existing style.

These functions are provided for use in building higher-level functionality such as tooltips, animation, and other effects in SVG plots.

Usage

1
2
3
4
getStyle(node)
setStyle(node, ..., .style = structure(unlist(list(...)),
          names = names(list(...))))
modifyStyle(style, ..., .vals = list(...))

Arguments

node

the SVG node whose style is to be manipulated

style

the style to be modified. This can be a character vector or an XML node.

...

name = value pairs giving the attributes and their values for the style

.style

a named vector containing the name - value pairs as if they were typed via ....

.vals

the name-value settings for the styles given as a single list rather than individually via the ....

Value

getStyle returns a named character vector. setStyle returns the updated node. modifyStyle returns the updated object it was given.

Author(s)

Duncan Temple Lang

See Also

convertCSSStylesToSVG

Examples

1
2
3
4
5
6
7
 doc = svgPlot(plot(1:10, col = c("red", "blue")))

 pts = getPlotPoints(doc)

 sty = getStyle(pts[[1]])
 sty1 = modifyStyle(sty, fill = "green", 'stroke-width' = 2)
 

duncantl/SVGAnnotation documentation built on May 15, 2019, 5:57 p.m.