getCSS: Query the SVG document for information

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

Description

These functions allow us to query the SVG plot for information such as the dimensions of the SVG canvas/view-box, the CSS or JavaScript code it currently contains or refers to, the lattice/trellis object that was used to create the plot, the high-level description of the elements in the SVG corresponding to lattice plot componets (getSVGNodeTypes).

getUSR returns the value of the usr attribute on the r:display element. This value was retrieved from the device after the expression in cmd is evaluated. This only makes sense when there is a single plot.

getRCommand returns the R command that were used to create the initial plot with svgPlot.

Usage

1
2
3
4
5
6
7
8
getCSS(doc, asNodes = FALSE)
getECMAScript(doc, asNodes = FALSE)
getJavaScript(doc, asNodes = FALSE)
## S3 method for class 'SVGDocument'
dim(x)
getLatticeObject(doc, asNodes = FALSE)
getSVGNodeTypes(doc)
getRCommand(doc)

Arguments

doc,x

the XML/SVG document as a tree

asNodes

a logical value indicating whether to return the XML/SVG nodes corresponding to the content rather than the content itself. This can be useful if we want to modify the nodes or even remove them.

Value

getCSS and getECMAScript return a character vector containing the content in the SVG document of that type.

The dim method returns a numeric vector (not an integer vector as dim normally would for, e.g., a matrix or data frame or array). The names of the elements give the units. (In the future This might be made an explicit attribute rather than using the names attribute.)

The getSVGNodeTypes function returns a character vector.

Author(s)

Duncan Temple Lang

References

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

See Also

svgPlot addECMAScripts addCSS

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
  doc = svgPlot(plot(1:10))
  dim(doc)

  addCSS(doc)
  addCSS(doc, I("class {\n  fill: red;\n  stroke: blue;}"))
  addCSS(doc, "http://www.omegahat.org/OmegaTech.css", FALSE)

  f = system.file("JavaScript", "link.js", package = "SVGAnnotation")
  addECMAScripts(doc, f)
  addECMAScripts(doc, f, insert = TRUE)


  getCSS(doc)
  getECMAScript(doc)

  data(mtcars)
  library(lattice)
  pp = svgPlot(xyplot( mpg ~ wt | am + cyl, mtcars,
                      group = carb,
                      auto.key = list(columns = 4, space ="right")))
  getSVGNodeTypes(pp)

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