Code Monkey home page Code Monkey logo

Comments (14)

lionel- avatar lionel- commented on June 12, 2024 1

Are the SVGs included inline? We had problems with inline SVGs in vdiffr before this fix: r-lib/vdiffr#51

I'm not knowledgeable in the matter unfortunately.

from slickr.

yonicd avatar yonicd commented on June 12, 2024 1

@osker130 this should work for you. I'll update the html link that is with the package.

library(svglite)
library(ggplot2)
library(slickR)

plotsToSVG=list(
  #Standard Plot
  xmlSVG({plot(1:10)},standalone=TRUE),
  #ggplot
  xmlSVG({show(ggplot(iris,aes(x=Sepal.Length,y=Sepal.Width,colour=Species))+
                 geom_point())},standalone=TRUE) 
)

hash_encode_url <- function(url){
  gsub("#", "%23", url)
}

#make the plot self contained SVG to pass into slickR 
s.in=sapply(plotsToSVG,function(sv){
  hash_encode_url(paste0("data:image/svg+xml;utf8,",as.character(sv)))
  })

slickR(s.in,slideId = 'ex4',slickOpts = list(dots=T), height = 200,width = '100%')

from slickr.

yonicd avatar yonicd commented on June 12, 2024

Thank you for pointing that out. I didnt notice that those examples broke.

from slickr.

yonicd avatar yonicd commented on June 12, 2024

can you paste the sessioninfo::session_info() into the issue.

I can render the sliders in the rstudio IDE the plots, there seems to be a problem with the standalone output for the xmlSVG and how it is rendered in the browser (in my case chrome).

from slickr.

osker130 avatar osker130 commented on June 12, 2024

I tried to run with regular plots and a ggplot. Neither one renders.

library(svglite)
library(ggplot2)
library(dplyr)
library(slickR)

plotsToSVG=list(
  #Standard Plot
  xmlSVG({plot(1:10)},standalone=TRUE),
  #ggplot
  xmlSVG({show(ggplot(iris,aes(x=Sepal.Length,y=Sepal.Width,colour=Species))+
                 geom_point())},standalone=TRUE) 
)

#make the plot self contained SVG to pass into slickR 
s.in=sapply(plotsToSVG,function(sv){paste0("data:image/svg+xml;utf8,",as.character(sv))})

slickR(s.in,slideId = 'ex4',slickOpts = list(dots=T), height = 200,width = '100%')`
sessionInfo()
R version 3.5.2 (2018-12-20)
Platform: x86_64-redhat-linux-gnu (64-bit)
Running under: Red Hat Enterprise Linux

Matrix products: default
BLAS/LAPACK: /usr/lib64/R/lib/libRblas.so

locale:
 [1] LC_CTYPE=en_US.UTF-8       LC_NUMERIC=C              
 [3] LC_TIME=en_US.UTF-8        LC_COLLATE=en_US.UTF-8    
 [5] LC_MONETARY=en_US.UTF-8    LC_MESSAGES=en_US.UTF-8   
 [7] LC_PAPER=en_US.UTF-8       LC_NAME=C                 
 [9] LC_ADDRESS=C               LC_TELEPHONE=C            
[11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C       

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
[1] gdtools_0.1.7 slickR_0.2.4  dplyr_0.7.8   ggplot2_3.1.0 svglite_1.2.1

loaded via a namespace (and not attached):
 [1] Rcpp_1.0.1       rstudioapi_0.9.0 xml2_1.2.0       bindr_0.1.1     
 [5] magrittr_1.5     tidyselect_0.2.5 munsell_0.5.0    cowplot_0.9.4   
 [9] colorspace_1.4-0 R6_2.4.0         rlang_0.3.1      plyr_1.8.4      
[13] tools_3.5.2      grid_3.5.2       gtable_0.2.0     withr_2.1.2     
[17] htmltools_0.3.6  digest_0.6.18    yaml_2.2.0       lazyeval_0.2.1  
[21] assertthat_0.2.0 tibble_2.0.1     crayon_1.3.4     bindrcpp_0.2.2  
[25] purrr_0.2.5      base64enc_0.1-3  htmlwidgets_1.3  glue_1.3.0      
[29] labeling_0.3     compiler_3.5.2   pillar_1.3.1     scales_1.0.0    
[33] jsonlite_1.6     pkgconfig_2.0.2 

from slickr.

yonicd avatar yonicd commented on June 12, 2024

Hi

You are running slickr v0.2.4, can you update to the GH master (slickR v0.4) and try again please.

remotes::install_github('metrumresearchgroup/slickR')

Thanks

from slickr.

yonicd avatar yonicd commented on June 12, 2024

Also what browser/version are you using to open the rendered file on?

I see that there is a problem on

  • chrome 75.0.3745.4 (Official Build) dev (64-bit)
  • firefox 6.0.1 (64-bit)

but not on

  • safari 12.0.3 (14606.4.5)

from slickr.

yonicd avatar yonicd commented on June 12, 2024

cc @timelyportfolio @lionel- any ideas why the standalone svg+xml from {svglite} would be having problems on those browsers?

from slickr.

yonicd avatar yonicd commented on June 12, 2024

Yes they are inline. thanks for the link

from slickr.

osker130 avatar osker130 commented on June 12, 2024

@yonicd @lionel- thank you both! @yonicd your solution works well. The svgs now render fine. Any thoughts on the HTML widgets? I tried the slickR v0.4 update yesterday when I was having problems and then reverted after concluding that the update wasn't the solution. My goal is to use these in an Rshiny application. Most users will be accessing with google chrome as their default browser.

from slickr.

yonicd avatar yonicd commented on June 12, 2024

which html widget didn't work? i have those examples working on my side.

from slickr.

osker130 avatar osker130 commented on June 12, 2024

This one wont render in RStudio. I'm left with grey boxes for leaflet and white boxes for plottly. The widgets work fine as standalones.

suppressMessages({
  library(leaflet)
  library(plotly)
})

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

p <- iris%>%ggplot(aes(x=Sepal.Length,y=Sepal.Width))+geom_point()
pL= ggplotly(p)
htmlwidgets::saveWidget(pL,'ggplotly.html')

slickR(c(rep(paste0(readLines('leaflet.html'),collapse='\n'),4),
         rep(paste0(readLines('ggplotly.html'),collapse='\n'),4)),
       slideId = c('leaf','plot'),
       slideIdx = list(1:4,5:8),
       slideType = rep('iframe',2),
       slickOpts = list(list(dots=T,slidesToShow=2,slidesToScroll=2),
                        list(dots=T,slidesToShow=2,slidesToScroll=2)),
       height='400px',width='100%')

from slickr.

yonicd avatar yonicd commented on June 12, 2024

It’s a known problem that Iframes don’t in render in the rstudio viewer, only in the browser

from slickr.

osker130 avatar osker130 commented on June 12, 2024

from slickr.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.