I am trying to use plot clicks in the context of a brilliant app. After the official demo, I use this bit of code to update the date picker and switch to another tab in my application when I click:
observe({ d <- event_data("plotly_click", source = 'plot') if(!is.null(d) & (input$navPanel == 'overview')) { d %>% filter(curveNumber == 0) %>% select(x) -> selected_date updateDateInput(session, "date", value = lubridate::ymd(selected_date$x)) updateTabsetPanel(session, "navPanel", selected = "details") }
However, when I then try to switch from the details tab to overview , I will immediately return to the details tab. I assume that this happens because the event is never cleared, i.e. d not null when the tab changes, so the condition in if -clause is TRUE .
So how can I clear the click event programmatically? Adding d <- NULL to the end of the conditional expression does not seem to do this.
source share