问题
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?
回答1:
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())
来源:https://stackoverflow.com/questions/47921757/how-to-resize-html-widget-using-savewidget-in-htmlwidgets-r