radioShowHide: Add toggle buttons to hide/display elements of an R SVG plot

Description Usage Arguments Value Author(s) References See Also

Description

This is a high-level, reasonably specialized function for adding interactive controls to an SVG document that dynamically (i.e. at viewing time) control the visiblity/invisibility of elements on the plot. It was developed to toggle the appearance of curves (time series) in a matplot and also across panels in a lattice plot.

This uses the SVG widgets from Andreas Neumann to allow the viewer to toggle the elements displayed in the viewing region of the plot.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
radioShowHide(doc, insertScripts = TRUE, within = FALSE,
              group = FALSE, 
              labels = paste("Series", seq(length = numSeries)), 
              extraWidth = 15 * (max(nchar(labels)) + 1),
              save = if(!is(doc, "XMLInternalDocument")) doc, 
              id.prefix = "series",
              checkboxCallback = if (is.na(within))
                                   "togglePanel"
                                 else
                                    "toggle",
              jscripts = c("helper_functions.js",
                           "timer.js",
                           "checkbox_and_radiobutton.js",
                           "hideSVGElements.js"), 
              numPanels = 1)

Arguments

doc

the SVG plot, given as either a file name or the XML tree returned from svgPlot.

insertScripts

a logical value indicating whether to insert the specified JavaScript code or merely use a reference to the files in the SVG document.

within

a logical value that indicates whether the plot was created with a call to matplot (TRUE) or a call to a regular plotting function (FALSE). This helps the function to identify the different elements in the plot.

group

unused!

labels

a character vector giving the labels to display beside the checkboxes. There should be one for each series/element in the plot.

extraWidth

the amount of horizontal space (in pixels?) that we add to the SVG viewbox to accomodate the check boxes.

save

a logical value that

id.prefix

a character string giving a value that is used as a prefix for the id attribute in the different SVG elements that correspond to the series/elements whose visibility we want to toggle.

checkboxCallback

the name of the JavaScript function which is to be invoked at viewing time when the state of a check box is changed/toggled.

jscripts

a character vector giving the names of the JavaScript files needed to provide the viewing time functionality.

numPanels

the number of panels in the plot. This is relevant for lattice plots.

Value

Either the updated SVG document or the name of the file to which it was written. The function is called for its side effect on the SVG document.

Author(s)

Duncan Temple Lang

References

http://www.carto.net/papers/svg

See Also

addSlider illustrates adding a different GUI component.


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