The design of this driver is that it can be used with ordinary R plotting commands. The extra information needed for tooltips and hyperlinks is supplied by a call to a separate function call before the call to the plotting function that generates the shape. Extra information for only one shape can be supplied this way, so shapes that have tooltips or hyperlinks must be drawn one at a time.
It appears that preferred SVG coding styles have changed over time. The defaults in this driver are those suggested at http://jwatt.org/svg/authoring/.
The driver output by default does NOT include a DOCTYPE DTD (it is recommended at http://jwatt.org/svg/authoring/ to NOT include a DOCTYPE declaration.)
Use shape properties directly rather than specifying them via
style property, e.g., prefer this:
<circle fill="red" stroke="blue" ... /> over this:
<circle style="fill:red; stroke:blue;" ... />.
Use "Namespace" aware functions, e.g.,
getElementsByTagNameNS instead of
(see also "SVG: Namespace Crash Course" in the references).
This driver currently does not have any font metric information,
so the use of
plotmath is not supported.
This device will not record tool tips and hyperlinks if
it is called by
dev.copy - the functions to add tool tips and
hyperlinks are ignored by other devices.
Clean up the SVG code that defines the layout of a tool tip
src/devSVG.c) - currently the vertical
spacing (the 'height' and 'y' attributes) is somewhat ad-hoc (coded
by trial and error, and may not work for all font sizes).
Add font metric information to support the use of
Note that SVG uses Unicode characters encoded like
The symbols for Unicode are described here:
SVG allows for definitions of fonts - maybe the right approach is to include a symbol font in the doc when plotmath is used.
Clean up the two-line tooltip SVG code: The two-line tooltip mode displays OK in the default SVG renderers in Firefox (under Windows 2000/XP and Linux) but does not display in the Batik standalone SVG viewer. It probably needs declarations to extend XML elements: http://www.w3.org/TR/SVG/extend.html 23.5 Adding private elements and attributes to the DTD.
Provide post-processing to use CSS (cascading style sheets) to make SVG files with lots of elements more compact.
The design of how tooltip and URL information is passed to the device is somewhat ugly – it would be nicer if the basic graphics commands allowed additional optional arguments. However, they don't, and the scheme implemented here at least works. It has the advantage that the graphics commands that specify tooltips and URLs will be ignored when other devices are used. One disadvantage is graphics recording will not record tooltips and URLs.
www Consortum W3C Scalable Vector Graphics (SVG) http://www.w3.org/Graphics/SVG/Overview.htm8
SVG authoring guidelines http://jwatt.org/svg/authoring
SVG: Namespaces Crash Course https://developer.mozilla.org/en/docs/SVG_Namespace_Tips_(external)
"SVG Essentials", J. David Eisenberg, O'Reilly and Associates, 2002.
Overview of the RSVGTips device.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.