assembled with blockbuilder.org and R
htmlwidgets
Last year one of my htmlwidgets exportwidget
for the widget-a-week project tried to fulfill what seems to be a very common need--statically exporting htmlwidgets client side. exportwidget
worked ok but did not seem to be very robust. After the seeing the full suite of svg tests for [fabricjs](https://fabricjs.com), I just had to explore how we might use
fabricjs` instead.
See this bl.ock for an example of exportwidget
+ sankeyNetwork
from networkD3
.
library(htmltools)
#library(sankeyD3)
library(networkD3)
#devtools::install_github("timelyportfolio/exportwidget")
library(exportwidget)
# example from ?networkD3::sankeyNetwork
# make example from sankey
URL <- paste0('https://cdn.rawgit.com/christophergandrud/networkD3/',
'master/JSONdata/energy.json')
energy <- jsonlite::fromJSON(URL)
# Plot
sn<-sankeyNetwork(Links = energy$links, Nodes = energy$nodes, Source = 'source',
Target = 'target', Value = 'value', NodeID = 'name',
units = 'TWh', fontSize = 12, nodeWidth = 30)
browsable(tagList(sn,export_widget()))
The screenshot thumbnail was generated by the exportwidget
and the resized by the magical blockbuilder.