deckgl icon indicating copy to clipboard operation
deckgl copied to clipboard

removing old add_legend in shiny app

Open todd-james opened this issue 2 years ago • 3 comments

Hi @crazycapivara,

I was wondering whether you would be able to help me with a few issues I am facing when implementing deckgl in a shiny application. I have detailed the issues on a couple of stackoverflow posts here and here, which also contain working examples of the issues.

The primary difficulty I am facing is the persistent of old legends on outputs of deckglOutput, where changing/updating add_legend parameters to include new variables that are representative of the new data that are being displayed just add an additional legend that clutters the plot view, as opposed to replacing the old legend.

This is also an issue when I have multiple deckglOutput with different data, where the legend are plot on the incorrect output.

Any guidance or assistance resolving these issues would be greatly appreciated!

Thanks, James

todd-james avatar Dec 06 '22 18:12 todd-james

Hi @todd-james, unfortunately you are right, there is no function yet to remove a legend, so you would need to pass some javascript to do so.

crazycapivara avatar Dec 09 '22 18:12 crazycapivara

Hi @crazycapivara,

Thank you for the clarification! Unfortunately I haven't got any experience with javascript. Please may you send some sample code that can be implemented in R or point me in the direction of how I might attempt this myself. Thanks.

todd-james avatar Dec 09 '22 20:12 todd-james

you can add script as a tag in the ui.r

tags$head(tags$script(" Your JS Code ")) or tags$head(HTML("<script type='text/javascript'> Your JS Code </script>"))

sbmkvp avatar Apr 25 '23 22:04 sbmkvp