plotly.js
plotly.js copied to clipboard
Reduce size of an HTML file with a lot of plotly graphs in Rmarkdown ( R )
Hello, first of all I want to thank you for this amazing package. I use it daily for my reports and it's great.
I'm trying to create an HTML Rmarkdown that runs many plotly graphs... The issues in the HTML file is too big and can't open it.
I found out that I can use "partial_bundle" function to reduce the size of my file. On my home computer it works great.
I created the following file:
```{r pressure, echo=FALSE, error=TRUE}
dta = data.frame(x= rnorm(1000), y = rnorm(1000))
plot_ly(dta, x=~x,y=~y)
The Rmarkdown HTML file size is ~5Mb and when I add the funtion "partial_bundle" like this:
```{r pressure, echo=FALSE, error=TRUE}
dta = data.frame(x= rnorm(1000), y = rnorm(1000))
plot_ly(dta, x=~x,y=~y) %>%
partial_bundle()
The size of the Rmarkdown HTML file reduces to ~2.5Mb which is great.
The issue is in my work environment the function doesn't work because it seems like it needs to access internet to download the scripts but it's blocked in my work:
Error in curl::curl_download(paste0("https://cdn.plot.ly/",bundle_script), : Could not resolve host https://cdn.plot.ly
It there a way to use it offline? There is a description here of the function but I dont get how to use it offline in Rmarkdown..
I use R version 4.1.2 and plotly_4.10.0
Thanks for you help.