daattali / timevis

📅 Create interactive timeline visualizations in R
http://daattali.com/shiny/timevis-demo/
Other
652 stars 157 forks source link

input$mytimevis_selected #83

Closed balintba closed 4 years ago

balintba commented 4 years ago

Hello,

I have opened an issue regarding the automatic update of this variable in case of using the SetSelection(...) function. I have however noticed another thing, that is somewhat inconvenient. In case the user selects the elements on the timeline, the observeEvent(input$mytimevis_selected, {.....}) Event controll gets triggered. However, when clicking on the timeline anywhere, not selecting new elements, aka deselecting the previously selected ones, the above observeEvent does not get triggered. It would be nice if it got triggered, also be deselecting the element, in order to clean up some temporary variables. I do not know if it is an issue in the timevis package or in shiny general.

I have implemented a button, which prints the input$mytimevis_selected variables on the screen. Upon selecting an element, the element ID gets returned, upon deselecting the previously selected element NULL gets printed on the console.

Therefore it is really strange that the observeEvent(input$mytimevis, {.....}) method does not gets triggered, since the value of the variable clearly gets changed.

Anyway, many thanks for your effort! Best regards, Balazs

p.s.: the automatic update of the variable upon programatic selection issue was closed, but by installing the package from cran, the issue persists. Your comments will be highly appriciated. Thanks again!

daattali commented 4 years ago

observeEvent by default does not get triggered on NULL values. This is not specific to timevis. You can use a regular observe() or use the ignoreNULL = FALSE parameter to force it to trigger when the input value is empty.

By the way, for any future issues, please include a minimal reproducible example, so that I would have exact code to run to show the issue.

balintba commented 4 years ago

Huge thanks again! Understood and will do in the future! Real great package you created. Thanks a lot!