1

System details

RStudio Edition : Desktop
RStudio Version : 1.1.463 
OS Version      : Windows 7 Professional
R Version       : 3.5.1

Steps to reproduce the problem

Run the following code in R Studio

library(networkD3)
URL <- paste0(
  "https://cdn.rawgit.com/christophergandrud/networkD3/",
  "master/JSONdata/energy.json"
  )
Energy <- jsonlite::fromJSON(URL)
sankeyNetwork(Links = Energy$links, Nodes = Energy$nodes, Source = "source",
              Target = "target", Value = "value", NodeID = "name",
              units = "TWh", fontSize = 12, nodeWidth = 30)

then on the Viewer tab select either Save as Image or Copy to Clipboard and choose a width of 1,000 and a height of 618. Proceed to save and/or copy the plot and notice that it's cropped all weird. Here's what it looks like. Seems like a bug.

A workaround is to save the html widget as a html file first, then use webshot to save it down as png file. But I don't like workarounds. What's wrong?

htmlwidgets::saveWidget(m, file="m.html")
webshot::webshot("m.html", "m.png")

capture.png

stackinator
  • 5,429
  • 8
  • 43
  • 84
  • I don't see the same problem with RStudio v1.2.1047 Preview on macOS. Maybe give the preview version a shot? https://www.rstudio.com/products/rstudio/download/preview/ – CJ Yetman Oct 30 '18 at 21:18
  • Have you tried opening it instead in a complete browser and then saving from there? – Brandon Bertelsen Oct 30 '18 at 21:57

0 Answers0