我正在使用闪亮,情节和闪亮的BS,如下所示,当在情节上发生plotly_click事件时,生成一个带有新情节的模态弹出窗口。当我在本地运行时,以及在本地浏览器中运行时,它可以很好地找到。
然而,当我在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)
错误消息如下(显示在应用程序的Shiny服务器日志中):
Warning: Error in event_data: attempt to apply non-function
Stack trace (innermost first):
59: event_data
58: observeEventExpr
1: runApp
答案 0 :(得分:2)
这是使用Shiny 0.14中提供的模态对话框的修改版本。 测试了RStudio,本地浏览器shinyapps以及我本地安装的闪亮服务器开源版本。
这是代码:
answer = inputData.nextLine().toLowerCase();
switch (answer) {
case "y":
case "yes":
Some_Operation();
break;
case "n":
case "no":
System.out.println("Good Bye !");
break;
default:
System.out.println("Not a valid reponse");
}