This documentation may lag behind the latest version, use the documentation provided with the package for up to date information.
grid.garnish() allows a user to add arbitrary attributes to grid
graphics objects. These attributes are then applied to the SVG element that the
attributes to grid graphics objects. Examples of such attributes are
onmouseout. The values of these
event is triggered. These functions can be defined and included with the use of
The usage of the function is defined as follows (further parameters are
available to be viewed via
The key argument here is in fact
..., which allows us to provide any named
argument and have it applied to the
path. By providing an argument with any
name or value we like, we are essentially adding attributes to the SVG that
will be generated.
The application of this function is going to be demonstrated with the use of
onclick event attribute on a graphics object.
When gridSVG processes
GRID.rect.1, it will now attach an additional
attribute to it,
onclick, holding the value of
alert(...);. The resulting
SVG image can then be loaded into a browser. Although it appears identical to
what is shown in R’s plotting window, upon clicking the rectangle we are shown
a dialog box with some text. By using
is possible to produce complex interactive graphics with gridSVG. The resulting
image produced from the above example is shown below (try clicking on the
An example where
grid.garnish() is demonstrated is in the
Tooltips example where the SVG elements
produced from a graphics object cause the name of the graphics object to appear
as text in a tooltip.