I used a lot of DT table and plot interaction in my shiny app.
My current app have a DT table 1, a ggplot plot 2.
- When no row in table 1 is selected, plot 2 draw an overview plot.
- When some rows in table 1 are selected, plot 2 update to a subset of data.
Then I met this problem:
- With table 1 and plot 2 showing some data, I moved to some other page in app to update the data behind table 1 and plot 2, then moved back to this page.
- Table 1 and plot 2 will update to new data, but there is a brief period when some error generated.
The error is caused when
- Table 1 underlying data has updated, but the actual rendered DT table has not changed, especially the selected rows vector has not changed, which will be cleared after table 1 update finish (it will not even be cleared previously, the newer DT fixed it by my suggestion).
- Plot 2 is updating in same time, using the previous selected rows vector on the new underlying data, which is wrong.
If we can set some priority on the table and plots when data is updating, this can be solved. However I only found some priority on observe(), not plot rendering.
Maybe we can put the plot rendering code inside
observeEvent and assign some priority?