Fix bug multiple bokeh plots (#3896)

* Fix bug multiple bokeh plots

* CHANGELOG
This commit is contained in:
Freddy Boulton 2023-04-17 22:09:51 -04:00 committed by GitHub
parent 73ec7fb0a8
commit f81b8235c7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 4 deletions

View File

@ -8,6 +8,7 @@ No changes to highlight.
## Bug Fixes:
- Fixed issue with old_value check in File. by [@tomchang25](https://github.com/tomchang25) in [PR 3859](https://github.com/gradio-app/gradio/pull/3859).
- Fixed bug where all bokeh plots appeared in the same div by [@freddyaboulton](https://github.com/freddyaboulton) in [PR 3896](https://github.com/gradio-app/gradio/pull/3896)
## Documentation Changes:

View File

@ -16,6 +16,7 @@
export let theme: string;
export let caption: string;
export let bokeh_version: string | null;
const divId = `bokehDiv-${Math.random().toString(5).substring(2)}`
function get_color(index: number) {
let current_color = colors[index % colors.length];
@ -43,8 +44,8 @@
function embed_bokeh(plot, type, bokeh_loaded){
if (document){
if (document.getElementById("bokehDiv")) {
document.getElementById("bokehDiv").innerHTML = "";
if (document.getElementById(divId)) {
document.getElementById(divId).innerHTML = "";
}
}
if (type == "bokeh" && window.Bokeh) {
@ -53,7 +54,7 @@
bokeh_loaded = true;
}
let plotObj = JSON.parse(plot);
window.Bokeh.embed.embed_item(plotObj, "bokehDiv");
window.Bokeh.embed.embed_item(plotObj, divId);
}
}
@ -192,7 +193,7 @@
{#if value && type == "plotly"}
<div bind:this={plotDiv} />
{:else if type == "bokeh"}
<div id="bokehDiv" class="gradio-bokeh"/>
<div id={divId} class="gradio-bokeh"/>
{:else if type == "altair"}
<div class="altair layout">
<Vega {spec} />