addSlider: Add slider to an SVG display

Description Usage Arguments Value Author(s) References See Also

Description

This function arranges to add an interactive slider to the SVG graphic described in doc. The slider is implemented via the Carto.net SVG and ECMAScript/ECMAScript library. This function endeavors to do most of the generic setup within the SVG document to be able to use the slider.

The creator of the SVG document with the slider must ensure that there is enough space to display the slider (using enlargeSVGViewBox, for example). But often, this function provides the necessary functionality to get the slider into the document and SVG display and functional as most of the work is in the JavaScript.

Usage

1
2
3
4
5
6
addSlider(doc, onload, javascript, id = "slider",
          svg = NULL,
          defaultJavascripts = c("mapApp.js",
                                 "helper_functions.js",
                                 "slider.js"), 
          side = "bottom", ...)

Arguments

doc

the parsed XML/SVG document into which the relevant nodes will be inserted

onload

a JavaScript command which is invoked when the SVG document is loaded. This is expected to create the slider object.

javascript

any JavaScript code that is needed to support the onload computations or any other aspect of the view/run-time behavior of the SVG document. This is separate from the defaultJavascripts parameter as the files specified there are the standard/default ones that are needed to use the Carto.net slider generally. This javascript parameter is for the caller to specify code that is specific to the SVG document and the particular slider.

id

an identifying string/name for the slider. This should be unique within the SVG document.

svg

the SVG root node of the XML document. This can be specified to allow a caller who has already accessed this for other purposes to provide it so the function doesn't have to do the small amount of work to retrieve it.

defaultJavascripts

the names of the JavaScript code files that should also be included to make the slider function. These are passed to addECMAScripts.

side

where to place the slider

...

name = value pairs of JavaScript variable names and R objects that are also added to the JavaScript code. See addECMAScripts.

Value

The updated XML document, returned invisibly.

Author(s)

Duncan Temple Lang

References

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

See Also

addECMAScripts


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