11

I use saveWidget function in htmlwidgets to save HTML widgets in R. I got the saved HTML files with width 960 and height 500. I am pretty sure that I can resize the widget within knitrOptions parameters but I can not find out the list of the parameters to resize the widget. I have tried:

library(htmlwidgets)
saveWidget(htmlplot, file, knitrOptions = list(width = 1200, height = 700)

I also have tried using fig.width, defaultWidth, etc. but none of them are worked.

How could I resize the widget?

rasyidstat
  • 585
  • 2
  • 6
  • 17

1 Answers1

8

I had this problem today. Unfortunately, I didn't find a good solution to this. I had to change the attribute width of the widget:

wid <- ggiraph(ggobj=pl,
               zoom_max=1000,
               tooltip_opacity=0.7,
               tooltip_extra_css="width:300px;background-color:black;color:white;font-family:Sans,Arial",
               width_svg=80,
               height_svg=7,
               width=1)
wid$x$width <- "6000px"
temp_output <- tempfile(tmpdir=getwd(), fileext=".html")
saveWidget(widget=wid, file=basename(temp_output), selfcontained=TRUE,
           knitrOptions=list())
  • Can you please take a look at this question? https://stackoverflow.com/questions/65606653/r-saving-multiple-html-widgets-together thanks! – stats_noob Jan 07 '21 at 05:48