title: Shiny Mouse Click with ggplot2 pie chart
body: <p>I know that I can get xy mouse click coordinates in shiny with this stacked bar chart produced by ggplot2:</p>
  <pre><code>data &lt;- data.frame(pie = c(0.25,0.25,0.25,0.25))
  library(ggplot2)
  ui &lt;- fluidPage(
    plotOutput('pie', click = &quot;plot_click&quot;),
    verbatimTextOutput('mouse')
  )
  
  server &lt;- function(input, output) {
      output$pie &lt;- renderPlot({
          ggplot(data, aes(x = factor(1), y = pie, fill = row.names(data))) 
                + geom_bar(stat = &quot;identity&quot;)
  })
      output$mouse &lt;- renderPrint({
          str(input$plot_click)
      })
  }
  
  shinyApp(ui=ui, server=server) 
  </code></pre>
  <p>Which when I ran and clicked on just now, I get this kind output, specifically a list, which contains the relative xy coordinate that I clicked on in the plot:</p>
  <pre><code>List of 7
  $ x      : num 0.887
  $ y      : num 0.116
  $ mapping:List of 3
   ..$ x   : chr &quot;factor(1)&quot;
   ..$ y   : chr &quot;pie&quot;
   ..$ fill: chr &quot;row.names(data)&quot;
  $ domain :List of 4
   ..$ left  : num 0.5
   ..$ right : num 1.5
   ..$ bottom: num -0.05
   ..$ top   : num 1.05
  $ range  :List of 4
   ..$ left  : num 44.9
   ..$ right : num 818
   ..$ bottom: num 365
   ..$ top   : num 5.48
  $ log    :List of 2
   ..$ x: NULL
   ..$ y: NULL
  $ .nonce : num 0.797
  </code></pre>
  <p>However, when I convert this to a pie chart instead with the following, I don't get a list with int 0 elements for the x and y.  I'm using this code (which simply adds coord_polar(theta = &quot;y&quot;) to the ggplot):</p>
  <pre><code>data &lt;- data.frame(pie = c(0.25,0.25,0.25,0.25))
  library(ggplot2)
  ui &lt;- fluidPage(
    plotOutput('pie', click = &quot;plot_click&quot;),
    verbatimTextOutput('mouse')
  )
  
  server &lt;- function(input, output) {
      output$pie &lt;- renderPlot({
          ggplot(data, aes(x = factor(1), y = pie, fill = row.names(data))) 
              + geom_bar(stat = &quot;identity&quot;) 
              + coord_polar(theta = &quot;y&quot;)
      })
      output$mouse &lt;- renderPrint({
          str(input$plot_click)
      })
   }
  
  shinyApp(ui=ui, server=server) 
  </code></pre>
  <p>Which gives me this kind of result upon clicking on the plot:</p>
  <pre><code>List of 7
  $ x      : int 0
  $ y      : int 0
  $ mapping:List of 3
   ..$ x   : chr &quot;factor(1)&quot;
   ..$ y   : chr &quot;pie&quot;
   ..$ fill: chr &quot;row.names(data)&quot;
  $ domain :List of 4
   ..$ left  : NULL
   ..$ right : NULL
   ..$ bottom: NULL
   ..$ top   : NULL
  $ range  :List of 4
   ..$ left  : num 31.9
   ..$ right : num 818
   ..$ bottom: num 373
   ..$ top   : num 5.48
  $ log    :List of 2
   ..$ x: NULL
   ..$ y: NULL
  $ .nonce : num 0.964
  </code></pre>
  <p>I'm new to using these mouse events for plots.  Is there any way to get the mouse click coordinates for a ggplot pie chart?  If it's not possible, is there a way to use javascript to covert the pixel coordinates of where I click to plot coordinates?  Or, is there a better graphics system that would support this kind of functionality that I could use in shiny?</p>
  <p>Thanks in advance!</p>