plotly / plotly/plotly.R

Feature request: Coordinates of mouse clicks when used with Shiny

Open
#1,194 4 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

shiny
Dominant language
R
Stars
2.7k
Forks
641
PR merge metrics
No merged PRs in 30d

Description

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.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

The request centers on plotly::plotlyOutput() and the Shiny plotOutput(..., click=...) behavior shown in the example. First trace how plotly outputs integrate with Shiny, then verify that mouse clicks expose exact x and y coordinates through the requested input; done means a working equivalent API demonstrated with those coordinate values.

Written by the indexing model from the issue text.

Assessment

Tech stack
r
Domain
data-visualization
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.