在 flexdashboard 中使用 plot_click

Using plot_click in flexdashboard

有没有办法使用 flexdashboard 通过鼠标交互绘制图表?

闪亮这并不难。我想保存鼠标点击,在 shiny UI 我会使用:

mainPanel(plotOutput("scatterplot", click = "plot_click"))

在服务器中您将拥有:

df <- reactiveValues(Clicksdf = data.frame(clickx = numeric(), clicky = numeric()))

我可以在 flexdashboard 中执行此操作吗?

编写代码块,就好像它既是 Shiny UI 又是服务器:

---
title: "Untitled"
runtime: shiny
output: 
  flexdashboard::flex_dashboard:
    orientation: columns
    vertical_layout: fill
---

```{r setup, include=FALSE}
library(flexdashboard)
library(shiny)
```

Column {data-width=650}
-----------------------------------------------------------------------

### Chart A

```{r}
plotOutput("plot1", click = "wt")
output$plot1 <- renderPlot({
  plot(mtcars$mpg ~ mtcars$wt)
  })
```

Column {data-width=350}
-----------------------------------------------------------------------

### Chart B

```{r}
renderText({
  unlist(input$wt$x)
})
```