I'm wondering if my issue is also fixable with the preview release. I'm running plotly using event_data in a shinydashboard and it has been crashing after a few clicks. I'm on RStudio 1.1.456, it happened both on my mac and windows device. I've completely cleared my workspace and restarted. Below is the session info from my windows device. Also I've attached a sample simplified shiny app where it typically crashes after a few clicks, sometimes it won't crash until a second or third run. I'll try updating to the next RStudio version.
R version 3.5.1 (2018-07-02)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows >= 8 x64 (build 9200)
Matrix products: default
locale:
[1] LC_COLLATE=English_United States.1252 LC_CTYPE=English_United States.1252 LC_MONETARY=English_United States.1252
[4] LC_NUMERIC=C LC_TIME=English_United States.1252
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] odbc_1.1.6
loaded via a namespace (and not attached):
[1] bit_1.1-14 compiler_3.5.1 hms_0.4.2 DBI_1.0.0 tools_3.5.1 yaml_2.2.0 Rcpp_0.12.18 bit64_0.9-7
[9] blob_1.1.1 pkgconfig_2.0.1 rlang_0.2.2
library(shiny)
library(shinydashboard)
library(tidyverse)
library(plotly)
library(nycflights13)
library(shinyjs)
library(V8)
ui <- dashboardPage(skin = "black",
dashboardHeader(
title="Test App"
),
dashboardSidebar(sidebarMenu(id = "sidebar",
menuItem("Tab One", tabName = "tabOne", icon = icon("heartbeat")),
menuItem("Tab Two", tabName = "tabTwo", icon = icon("warning"))
)),
dashboardBody(
useShinyjs(),
extendShinyjs(text = "shinyjs.resetClick = function() { Shiny.onInputChange('.clientValue-plotly_click-month_select', 'null'); }"),
tabItems(
tabItem(tabName = "tabOne",
fluidPage(
shiny::column(width = 2,
selectInput("month","Month: ", unique(nycflights13::flights$month))
),
shiny::column(width = 5,
plotlyOutput("plot1")
),
shiny::column(width = 5,
plotlyOutput("plot2")
)
)
),
tabItem(tabName = "tabTwo",
h2("Test")
)
)
)
)
server <- function(input, output, session) {
output$plot1 <- renderPlotly({
result <- nycflights13::flights %>%
group_by(month) %>%
count()
plot <- result %>%
ggplot(aes(x = month, y = n)) +
geom_point(aes(text = paste0("Flight Count: ", n)), size = 1.5) +
geom_line(size = 1) +
labs(x="Month",y="")
plot %>%
ggplotly(tooltip = c("text"), source = "month_select")
})
output$plot2 <- renderPlotly({
# Get month based on click
event_data <- event_data("plotly_click", source = "month_select")
print(event_data)
selected_month <- input$month
if(!is.null(event_data)) {
selected_month <- event_data[[3]]
}
print(selected_month)
result <- nycflights13::flights %>%
filter(month == selected_month) %>%
group_by(carrier) %>%
count()
plot <- result %>%
ggplot(aes(x = carrier, y = n)) +
geom_bar(stat="identity") +
labs(x="Airline",y="Flight Count")
plot %>%
ggplotly()
})
observeEvent(input$month, {
js$resetClick()
})
}
# Run the application
shinyApp(ui = ui, server = server)