yonicd / slickR

slick carousel htmlwidget for R
https://yonicd.github.io/slickR/
Other
158 stars 14 forks source link

reproduce README gif #31

Closed knapply closed 4 years ago

knapply commented 4 years ago

Is there code somewhere to reproduce the GIF in the README? It looks like you have a way to embed widgets in the carousel, but I can't seem to get it to work.

Thanks!

yonicd commented 4 years ago

The master is updated (https://github.com/metrumresearchgroup/slickR/commit/79c2579040c23e07da132c36a60ff4c244c14be7) this example reproduces the gif in the readme.

library(plotly)
library(leaflet)

l <- leaflet() %>% 
  addTiles()%>%
  htmlwidgets::saveWidget('leaflet.html')

ggiris <- qplot(Petal.Width, Sepal.Length, data = iris, color = Species)%>%
  ggplotly()%>%
  htmlwidgets::saveWidget('ggplotly.html')

leaf_chr <- paste0(readLines('leaflet.html'),collapse='\n')

leaf_obj <- rep(leaf_chr,2)

plot_chr <- paste0(readLines('ggplotly.html'),collapse='\n')

plot_obj <- rep(plot_chr,2)

opts <- slickR::settings(slidesToShow = 2)

(slickR::slickR(plot_obj,slideType = 'iframe',height = 500) + opts) %synch% 
(slickR::slickR(leaf_obj,slideType = 'iframe',height = 500) + opts)
knapply commented 4 years ago

Awesome, thanks so much!