mirror of
https://github.com/gradio-app/gradio.git
synced 2025-02-17 11:29:58 +08:00
Fix bug multiple bokeh plots (#3896)
* Fix bug multiple bokeh plots * CHANGELOG
This commit is contained in:
parent
73ec7fb0a8
commit
f81b8235c7
@ -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:
|
||||
|
||||
|
@ -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} />
|
||||
|
Loading…
Reference in New Issue
Block a user