CDU-data-science-team / pxtextminingdashboard

Text mining and visualization of NHS patient feedback.
https://feedbackmatters.uk/rsconnect/text_mining_dashboard/
Other
4 stars 1 forks source link

Fix debounce- cached plot does not render properly #21

Closed ChrisBeeley closed 3 years ago

ChrisBeeley commented 3 years ago

The debounce is fine, but the renderCachePlot does not work properly.

In my commit message I wondered if the req() in the reactive() might be the cause, but now I'm doubtful. It's all pretty new, I think maybe just wait till 1.6 settles down a bit and there are more SO qs and as to look at?

andreassot10 commented 3 years ago

There's something weird going on. The sentiment control in the sentiment module isn't working anymore.

EDIT: It's the renderCachedPlot() in this line that freezes it. Using renderPlot() instead works just fine. I wonder why on earth renderCachedPlot() ignores the sentiment control. This is very annoying. Without caching, a user that alternates between sentiments will wait forever for the plots to be calculated.

andreassot10 commented 3 years ago

I think I found it. It took a look at some examples with renderCachedPlot() and noticed that, when the dataset is reactive, it's included in cacheKeyExpr.

So I replaced this

cacheKeyExpr = 
    {
      list(
        input$label, 
        input$ngramsType
      ) 
    }

with this

cacheKeyExpr = 
    {
      list(
        plot_data(),
        input$label, 
        input$ngramsType
      ) 
    }

here and it seems to be working fine.

Can you please take a look too?