Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error when exporting HTML-plot #99

Open
kapsner opened this issue May 6, 2020 · 0 comments
Open

Error when exporting HTML-plot #99

kapsner opened this issue May 6, 2020 · 0 comments

Comments

@kapsner
Copy link

kapsner commented May 6, 2020

Hello @timelyportfolio,

first of all thanks for this great R package and your well documented vignette, which makes it really easy to figure out for new users how to create nice sunburst-plots (once figured out, how data needs to be structured).

My use-case was to export a self-contained HTML-version of the plot using the R package htmlwidgets.

Although the error only occurs using the htmlwidgets R package, I think the error is related to your sunburstR package due to the different behaviour of exporting HTML pages of the both functions sunburst and sund2b.

Here is a minimal reproducible example:

dat <- data.frame(
  level1 = rep(c("a", "b"), each=3),
  level2 = paste0(rep(c("a", "b"), each=3), 1:3),
  size = c(10,5,2,3,8,6),
  stringsAsFactors = FALSE
)
tree <- d3r::d3_nest(dat, value_cols = "size")

sb1 <- sunburstR::sunburst(
  tree,
  legend = FALSE,
  width = "100%",
  height = 400
)

htmlwidgets::saveWidget(
  widget = sb1,
  file = "sunburst.html",
  selfcontained = T
)

htmlwidgets::saveWidget creates an HTML-page not displaying the plot but some JS/HTML code.

Instead, using the sund2b function to create the plot and exporting it with the same htmlwidgets::saveWidget command produces the desired result:

sb2 <- sunburstR::sund2b(
  tree,
  width = "100%",
  height = 400
)

htmlwidgets::saveWidget(
  widget = sb2,
  file = "sund2b.html",
  selfcontained = T
)

So I think, the issue is somehow related to the sunburst function and how it stores the information to produce its HTML view.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant