Description Usage Arguments Details Value Author(s) References See Also Examples
Write code to include an SVG image in an HTML document which should work with most modern browsers.
1 2 |
image.url |
A character vector or matrix containing the URL or the file path of the SVG image. |
page |
An optional connection. A character string naming the
file to write to or a page object returned by |
width, height |
An HTML length unit (in pixels) specifiying the width (respectively height) at which the image should be rendered. Must be present if browser being used is Internet Explorer. If missing, Firefox will use the default image width(resp. height). |
id |
Character. A string providing an identifier for the SVG image. |
attributes |
Attributes of the SVG image. See details. |
... |
Optional arguments that will be dispatched to the
underlying |
Inserting workable SVG code into an HTML document is difficult because
the attributes of the <object>
tag required depend on
the browser used to view the document. hwriteSVG
uses syntax
taken from support documentation for the SVG Web project. The example
given in the sample helloworld.html
is
1 2 3 4 5 6 7 8 9 10 | <!--[if !IE]>-->
<object data="../svg-files/helloworld.svg" type="image/svg+xml"
width="200" height="200" id="mySVGObject"> <!--<![endif]-->
<!--[if lt IE 9]>
<object src="../svg-files/helloworld.svg" classid="image/svg+xml"
width="200" height="200" id="mySVGObject"> <![endif]-->
<!--[if gte IE 9]>
<object data="../svg-files/helloworld.svg" type="image/svg+xml"
width="200" height="200" id="mySVGObject"> <![endif]-->
</object>
|
Note that recent versions of Firefox should display SVG images without problems, and should not require the specification of height and width. Internet Explorer is far less foregiving and both height and width values must be given or no image will be displayed. Experimentation with appropriate values for the arguments may be necessary.
For attributes which may be included in an <object>
tag, see
the reference for this tag on the website
http://www.w3schools.com.
A character vector containing the output HTML code.
David Scott d.scott@auckland.ac.nz
http://www.w3schools.com/tags/tag_object.asp http://codinginparadise.org/projects/svgweb/docs/QuickStart.html
1 2 3 4 5 6 7 8 9 10 | examplesDir <- file.path(system.file(package = 'hwriterPlus'),
'examples')
catsSVG <- file.path(examplesDir, "cats.svg")
### Raw html produced
hwriteSVG(catsSVG, page = NULL, height = 600, width = 600,
center = FALSE, br = TRUE)
### Formatted a little more nicely
svgHTML <- hwriteSVG(catsSVG, page = NULL, height = 600, width = 600,
center = FALSE, br = TRUE)
unlist(strsplit(svgHTML, "\n"))
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.