convertCSSStylesToSVG: Convert a CSS-style attribute to separate SVG attributes

Description Usage Arguments Value Author(s) References See Also Examples

Description

In SVG, one can represent style settings (e.g. stroke, stroke-width, fill and so on) using separate SVG attributes or as a single style attribute with a value that lists all the settings in CSS form, i.e. with ';'-separated name: value pairs. So <g stroke="red" stroke-width="3" fill="blue"> can also be written as <g style="stroke: red; stroke-width: 3; fill: blue">

This function and its methods allow us to convert from the CSS form to the separate-attribute form. This can make processing the document and its elements easier in both R and Javascript. It does mean that we cannot use a CSS file to specify and control the appearances of the nodes.

This function and methods operate on a document, an individual node, a list of nodes, or an XMLNodeSet returned from getNodeSet.

Usage

1

Arguments

nodes

an XML node (XMLInternalNode), a document (XMLInternalDocument), a list of XMLInternalNode objects, or an XMLNodeSet returned from getNodeSet.

...

additional parameters for the methods

Value

The updated object with the modified internal nodes.

Author(s)

Duncan Temple Lang

References

http://www.w3.org/TR/SVG11/styling.html

See Also

svgPlot compressStyles

Examples

1
2
3
4
5
6
7
8
9
doc = svgPlot(plot(1:10, pch = c("red", "blue")), asXML =  TRUE)
nodes = getNodeSet(doc, "//*[@style]")
convertCSSStylesToSVG(nodes[[1]])

nodes = getNodeSet(doc, "//*[@style]")
convertCSSStylesToSVG(nodes)

doc = svgPlot(plot(1:10, pch = c("red", "blue")), asXML = TRUE)
convertCSSStylesToSVG(doc)

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