How to resize HTML widget using saveWidget in htmlwidgets R?

大城市里の小女人 提交于 2020-01-23 07:06:20

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!