Skip to content

Feature request: Coordinates of mouse clicks when used with Shiny #1194

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

Open
KasperSkytte opened this issue Feb 9, 2018 · 3 comments
Open
Labels

Comments

@KasperSkytte
Copy link

When using plotly with Shiny, would it be possible to implement a feature in plotly::plotlyOutput() similar to plotOutput("plot", click = "plot_click") to capture the exact coordinates of a mouse click like in the example below?

library(shiny)

ui <- basicPage(
  plotOutput("plot1", click = "plot_click"),
  verbatimTextOutput("info")
)

server <- function(input, output) {
  output$plot1 <- renderPlot({
    plot(mtcars$wt, mtcars$mpg)
  })

  output$info <- renderText({
    paste0("x=", input$plot_click$x, "\ny=", input$plot_click$y)
  })
}

shinyApp(ui, server)

I am hoping to be able to reproduce the exact mouse click positions during a data analysis and reuse them in a different analysis.

@cpsievert
Copy link
Collaborator

It's only currently possible to get the coordinates of clicks on actual data/marks. Doing something like this properly should be done at the plotly.js level... I've started an issue here -- plotly/plotly.js#2696

@KasperSkytte
Copy link
Author

Great, thanks a lot!

@ismirsehregal
Copy link

For those interested: I posted a workaround here.

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

No branches or pull requests

3 participants