Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Difficulities to run the Shiny example #17

Open
frajuegies opened this issue Jan 5, 2017 · 2 comments
Open

Difficulities to run the Shiny example #17

frajuegies opened this issue Jan 5, 2017 · 2 comments

Comments

@frajuegies
Copy link

Dear all,

I have tried your Shiny sample code ... but I am getting the below mentioned error message.
Have I missed something ?

Thank you very much for your help.... It would be great to have the tool for the interaction with a dendogram.

Best regards,
Jürgen

library(shiny)
library(svglite)
library(svgPanZoom)
library(ggplot2)

ui <- shinyUI(bootstrapPage(
  
  svgPanZoomOutput(outputId = "main_plot")
  
))

server = shinyServer(function(input, output) {
  output$main_plot <- renderSvgPanZoom({
    p <- ggplot() + geom_point(data=data.frame(faithful),aes(x=eruptions,y=waiting)) + stat_density2d(data=data.frame(faithful),aes(x=eruptions,y=waiting, alpha =..level..),geom="polygon") + scale_alpha_continuous(range=c(0.05,0.2))
    svgPanZoom(p, controlIconsEnabled = T)
  })
})

runApp(list(ui=ui,server=server))

Error Message
Listening on http://127.0.0.1:3278
Warning in svgPanZoom(p, controlIconsEnabled = T) :
for best results with ggplot2 and lattice, please install gridSVG
Warning: package ‘gdtools’ was built under R version 3.3.2
Warning: Error in : '' does not exist in current working directory ('C:/Users/u991726/Documents').
Stack trace (innermost first):
84: check_path
83: path_to_connection
82: read_xml.character
81: xml2::read_xml
80: svglite::xmlSVG
79: svgPanZoom
78: func [#4]
77: origRenderFunc
76: output$main_plot
1: runApp

sessionInfo():
R version 3.3.1 (2016-06-21)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 7 x64 (build 7601) Service Pack 1

locale:
[1] LC_COLLATE=German_Germany.1252 LC_CTYPE=German_Germany.1252 LC_MONETARY=German_Germany.1252 LC_NUMERIC=C
[5] LC_TIME=German_Germany.1252

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

other attached packages:
[1] gdtools_0.1.3 ggplot2_2.2.1 svgPanZoom_0.3.3 svglite_1.2.0 shiny_0.14

loaded via a namespace (and not attached):
[1] Rcpp_0.12.6 assertthat_0.1 digest_0.6.10 mime_0.5 plyr_1.8.4 grid_3.3.1 R6_2.1.2 xtable_1.8-2
[9] jsonlite_1.0 gtable_0.2.0 scales_0.4.1 lazyeval_0.2.0 xml2_1.0.0 tools_3.3.1 htmlwidgets_0.8 munsell_0.4.3
[17] httpuv_1.3.3 yaml_2.1.13 colorspace_1.2-6 htmltools_0.3.5 tibble_1.2

@timelyportfolio
Copy link
Owner

timelyportfolio commented Jan 5, 2017

@frajuegies glad you are using. This is likely due to some complication with gridSVG. Try this instead and let me know. Unfortunately, svglite did not exist when I originally wrote svgPanZoom.

library(shiny)
library(svglite)
library(svgPanZoom)
library(ggplot2)

ui <- shinyUI(bootstrapPage(
  
  svgPanZoomOutput(outputId = "main_plot")
  
))

server = shinyServer(function(input, output) {
  output$main_plot <- renderSvgPanZoom({
    p <- ggplot() + geom_point(data=data.frame(faithful),aes(x=eruptions,y=waiting)) + stat_density2d(data=data.frame(faithful),aes(x=eruptions,y=waiting, alpha =..level..),geom="polygon") + scale_alpha_continuous(range=c(0.05,0.2))
    svgPanZoom(
      # key here is using print(p) instead of just p
      svglite::stringSVG(print(p),standalone=F),
      controlIconsEnabled = T
    )
  })
})

runApp(list(ui=ui,server=server))

You also might want to use viewBox = FALSE argument to svgPanZoom if you plan to use a browser other than RStudio Viewer.

@frajuegies
Copy link
Author

Great, the example is working as expected !
Thank you very much for your very fast answer !

Now I will insert this capability in my Shiny app....

Once again, thank you and best regards,

Jürgen

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants