gsvg: Interface to RSVGTipsDevice device

Description Usage Arguments Details Value Author(s) References See Also Examples

View source: R/gsvg.R

Description

This package allows one to show files in a web page produced by the SVG deices in RSVGTipsDevice or SVGAnnotation. The former allows one to easily place tooltips and links to URLs, the latter allows for some very fancy javascripting to make dynamic graphics.

Usage

1
gsvg(f, width=480, height=400, container = NULL, ...)

Arguments

f

optional filename storing file with output

width

width of canvas in pixels

height

height of canvas in pixels

container

parent container for processing object

...

not used

Details

The SVG devices are non-interactive device and requires a file to be written to the file system. These files should have a .svg extension as they are severd from a web page. As such, there are facilities to create a temporary file in a public webspace getStaticTempFile. This function uses the variable gWidgetsWWWStaticDir which must be configured for RApache. The function convertStaticFileToUrl gives the URL for the file on the file system.

The svalue<- method is used to update the graphic.

Unlike the gcanvas widget, only the constructor needs the width and height specified. The SVG graphics "S"cale to fill the allotted space.

Adding a handler to this device is not yet supported. However, the SVGAnnotation package allows one to do very interesting things with svg graphic files.

The gcanvas widget is a similar function for providing graphical output within a browser.

Value

Returns a proto object with class gSvg.

Author(s)

John Verzani

References

The RSVGTipsDevice

See Also

RSVGTipsDevice, gcanvas

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
## Not run: 
  w <- gwindow("svg test")
  g <- ggroup(cont = w)
  sg <- gsvg(cont = g)
  
  makePlot <- function() {
    require(RSVGTipsDevice, quietly=TRUE, warn=FALSE) # must require within callback
    f <- getStaticTmpFile(ext=".svg")  ## use the extension or paste later
    devSVGTips(f)
    plot(rnorm(100))
    dev.off()
    f
  }

  svalue(sg) <- makePlot()
  ## can update
  b <- gbutton("click me", cont = g, handler = function(h,...) {
    svalue(sg) <- makePlot()
  })

  visible(w) <- TRUE
  

## End(Not run)

gWidgetsWWW documentation built on May 31, 2017, 2:08 a.m.