Last active
August 29, 2015 14:15
-
-
Save jeroen/d0d03c7e58443f5a4438 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(V8) | |
stopifnot(packageVersion("V8") >= "0.5") | |
# Create V8 context and load viz.js | |
ct <- new_context("window") | |
invisible(ct$source('http://mdaines.github.io/viz.js/viz.js')) | |
# This runs: Viz("digraph { a -> b; }", "svg") | |
svg <- ct$call("Viz", "digraph { a -> b; }", "svg") | |
cat(svg) | |
# View SVG in Rstudio: | |
tmp <- tempfile(fileext=".svg") | |
writeLines(svg, tmp) | |
rstudio::viewer(tmp) |
Yes within a package you should preferably ship the js files in your inst
dir (if copyright permits) and load them with system.file
.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thanks for putting this up. Since
DiagrammeR
is installed, we could actually just use the local version of viz.js, sosystem.file(...)
.