Shiny Plotly event_data 错误仅与闪亮的服务器

Gop*_*ala 5 r shiny plotly

当 plotly_click 事件发生在绘图上时,我正在使用闪亮的、绘图的和闪亮的BS来生成一个带有新绘图的模式弹出窗口。当我在本地运行以及在本地浏览器中运行时,它可以完美地找到。

但是,当我将它部署在 Shiny 服务器上时,出现此错误,并且不知道它的含义。有什么想法吗?

library(shiny)
library(plotly)
library(shinyBS)

df1 <- data.frame(x = 1:10, y = 1:10)
df2 <- data.frame(x = c(rep('a', 10), rep('b', 10)),
                  y = c(rnorm(10), rnorm(10, 3, 1)))

ui <- fluidPage(
  column(6, plotlyOutput('scatter')),
  bsModal('boxPopUp', '', '', plotlyOutput('box'))
)

server <- function(input, output, session) {
  output$scatter <- renderPlotly({
    plot_ly(df1, x = ~x, y = ~y, mode = 'markers',
            type = 'scatter', source = 'scatter')
  })
  observeEvent(event_data("plotly_click", source = "scatter"), {
    toggleModal(session, "boxPopUp", toggle = "toggle")
  })
  output$box <- renderPlotly({
    eventdata <- event_data('plotly_click', source = 'scatter')
    validate(need(!is.null(eventdata),
                  'Hover over the scatter plot to populate this boxplot'))
    plot_ly(df2, x = ~x, y = ~y, type = 'box')
  })
}

shinyApp(ui = ui, server = server)
Run Code Online (Sandbox Code Playgroud)

错误信息如下(显示在应用程序的 Shiny 服务器日志中):

Warning: Error in event_data: attempt to apply non-function
Stack trace (innermost first):
    59: event_data
    58: observeEventExpr
     1: runApp
Run Code Online (Sandbox Code Playgroud)

Val*_*vić 2

这是使用 Shiny 0.14 中提供的模式对话框的修改版本。在 RStudio、本地浏览器、shinyapps以及我本地安装的shiny 服务器开源版本上进行了测试。

这是代码:

    library(shiny)
    library(plotly)
    library(shinyBS)

    df1 <- data.frame(x = 1:10, y = 1:10)
    df2 <- data.frame(x = c(rep('a', 10), rep('b', 10)),
                      y = c(rnorm(10), rnorm(10, 3, 1)))

    ui <- fluidPage(
            column(6, plotlyOutput('scatter'))
    )

    server <- function(input, output, session) {
            output$scatter <- renderPlotly({
                    plot_ly(df1, x = x, y = y, mode = 'markers',
                            type = 'scatter', source = 'scatter')
            })

            observeEvent(event_data("plotly_click", source = "scatter"), {
                    showModal(modalDialog(
                            renderPlotly({
                                    plot_ly(df2, x = x, y = y, type = 'box')
                            }),
                            easyClose = TRUE
                    ))
            })

    }

    shinyApp(ui = ui, server = server)
Run Code Online (Sandbox Code Playgroud)