Remove old plots to embed new ones

Hi,

I’m having an issue removing Bokeh plots.

My web app has a number of buttons. When any button is pressed, I do the following:

  • fetch an API endpoint that returns a JSON Bokeh plot, made with bokeh.embed.json_item()
  • remove all contents of a div with id “plot” where I am going to embed the plot
  • embed it via Bokeh.embed.embed_item() to the div (all buttons embed to the same div)

The second step is where I have the issue. With my limited knowledge I tried to simply document.getElementById("plot").innerHTML = "" so that I can embed new plots there. This does clean the div but when Bokeh.embed.embed_item() is called again, Bokeh embeds all the plots that have been embedded prior to that, and I end up with 10 plots in the same div.

What am I missing / how can I reset this Bokeh ‘memory’ so that I can embed the new plot without the old ones?

Thanks

Any ideas?

HI @sdomingobasora The best way to help others help you is to provide a complete Minimal Reproducible Example. I haven’t seen what you describe but also have not tried what you are trying, so the most efficient way for us to apply our expertise is to experiment on real (toy) code.

Hi @Bryan,

The problem was unrelated to Bokeh and has been solved already. Sorry for the inconvenience.

I was wondering if the thread can be closed/deleted. Haven’t found the way to do it myself.

Cheers

i’ve closed the topic