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

retrieving mapping of vars with shiny in ggplot 2.1.0.9000 #1781

Closed
dcangst opened this issue Sep 26, 2016 · 3 comments · Fixed by rstudio/shiny#1392
Closed

retrieving mapping of vars with shiny in ggplot 2.1.0.9000 #1781

dcangst opened this issue Sep 26, 2016 · 3 comments · Fixed by rstudio/shiny#1392

Comments

@dcangst
Copy link

dcangst commented Sep 26, 2016

not sure whether this is the right place to post, but the bug only appears when using ggplot 2.1.0.9000 and not with the CRAN version (2.1.0) in R 3.3.1 (mac, 64bit)

i just noticed that with ggplot 2.1.0.9000 shiny is not able to get coordinates on click the example below reports (in my case at least) this with 2.1.0:

input$click:
List of 7
 $ x      : num 4.91
 $ y      : num 2.51
 $ mapping:List of 2
  ..$ x: chr "Sepal.Length"
  ..$ y: chr "Sepal.Width"
 $ domain :List of 4
  ..$ left  : num 4.12
  ..$ right : num 8.08
  ..$ bottom: num 1.88
  ..$ top   : num 4.52
 $ range  :List of 4
  ..$ left  : num 37.1
  ..$ right : num 1323
  ..$ bottom: num 369
  ..$ top   : num 5.48
 $ log    :List of 2
  ..$ x: NULL
  ..$ y: NULL
 $ .nonce : num 0.665

and this with 2.1.0.9000:

input$click:
List of 6
 $ x      : int 176
 $ y      : int 184
 $ mapping: Named list()
 $ domain :List of 4
  ..$ top   : int 0
  ..$ left  : int 0
  ..$ right : int 1327
  ..$ bottom: int 399
 $ range  :List of 4
  ..$ top   : int 0
  ..$ left  : int 0
  ..$ right : int 1327
  ..$ bottom: int 399
 $ .nonce : num 0.254

with error Warning in seq_len(nrow(layout)) : first element used of 'length.out' argument

Example Script:

library(shiny)
library(ggplot2)

shinyApp(
  ui = pageWithSidebar(
    headerPanel('Iris Data Plot'),
    sidebarPanel(
      selectInput('xcol', 'X Variable', names(iris)),
      selectInput('ycol', 'Y Variable', names(iris), selected=names(iris)[[2]])
    ),
    mainPanel(
      plotOutput('plot1', click = "click"),
      verbatimTextOutput("inputOut")
    )
  ),
  function(input, output, session) {
    output$inputOut  <- renderPrint({
      cat("input$click:\n")
      str(input$click)
    })

    output$plot1 <- renderPlot({
      ggplot(iris, aes_string(x = input$xcol, y = input$ycol)) + 
        geom_point()
    })
  }
)

hope this helps, and thanks for making a great package! (in fact, thanks for making great packages!!)

@hadley
Copy link
Member

hadley commented Sep 26, 2016

One for you @wch

@thomasp85
Copy link
Member

@wch I expect this is due to the internal rewrite of panel and facets. There has been some renaming as the panel class has been removed and a Layout class has been added. The basic layout, scales, and ranges data is unchanged though but is found at different locations e.g. plot$layout$panel_layout for the layout defined by the facetting function...

@wch
Copy link
Member

wch commented Sep 30, 2016

@dcangst We just merged a fix in shiny.

@lock lock bot locked as resolved and limited conversation to collaborators Jun 19, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants