Description Usage Arguments Value Author(s) See Also Examples
This function associates the Cascading Style Sheet with the specified (parsed) SVG document. It can either insert a link or (h)reference to the CSS file (or URL) or can insert its contents directly into the SVG. Inserting the contents is useful if one wants to make the SVG independent of the location of the CSS file, e.g. if the CSS file is a local file and we want the SVG file to be distributed elsewhere. On the other hand, using a reference to the file allows us to have a single copy shared by multiple SVG files, and also facilitates updating the CSS file and having the changes be used by these SVG files without requiring additional processing.
The CSS to be used is determined from the R option "SVGCSS"
.
If this is not set, we look at the environment variable SVGCSS
.
If that is not set, then we use the default which is in the
installed SVGAnnotation
package directories.
1 2 3 |
doc |
the parsed SVG document |
css |
the name of the CSS file/URL. By default, we use the CSS file that comes with this
package. The R user can specify a different one directly in the call to this function,
or by setting the R option named SVGCSS, e.g. |
insert |
a logical value indicating whether to insert the contents of the CSS document into the XML document or add a reference to it. |
silent |
a logical value that controls whether a warning is
emitted if one attempts to insert an already present CSS file.
If this is |
The updated XML document.
Duncan Temple Lang
compressStyles
and
convertCSSStylesToSVG
1 2 3 4 5 6 7 8 9 10 11 12 13 14 | doc = svgPlot(plot(1:10))
addCSS(doc)
addCSS(doc) # get a warning since it is already there.
# add a reference
addCSS(doc, "http://www.omegahat.org/OmegaTech.css", FALSE)
# put the content in directly
addCSS(doc, insert = TRUE)
#
addCSS(doc, I("class {\n fill: red;\n stroke: blue;}"))
saveXML(doc, tempfile())
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.