Problem with legend when updating (bokeh server)

Hello,
I try to update a figure by adding a new plot by setting the old one’s data source columns to be empty lists via callback.
Without using a legend, everything works. Otherwise the new plots resize weird. What is bokeh’s problem ?

Example:

from bokeh.plotting import figure, curdoc
from bokeh.layouts import column
from bokeh.models import Button, ColumnDataSource

i = 0
plot_sources = []

source = ColumnDataSource(data=dict(x=[1, 2], y=[2, 3]))
plot_sources.append(source)

p = figure(width=400, height=400)
p.circle("x", "y", source=source, legend="text")

def callback():
    global i, plot_sources
    i += 1

    for source in plot_sources:
        source.data = dict(x=[], y=[])

    source = ColumnDataSource(data=dict(x=[1, 3], y=[i, 5]))
    plot_sources.append(source)

    p.circle("x", "y", source=source, legend="text %d" % i)

button = Button(label="Press Me")
button.on_click(callback)

curdoc().add_root(column(p, button))

``

starting with:
bokeh serve --show app.py

Hi,

Bokeh is a large project and like any large projects, it has its share of bugs. There have been several recent fixes for both layout issues some specialized server synchronization issues recently. I can't reproduce any problem with your code in the latest version off GitHub master, so perhaps you might have luck with the latest "dev build" which can be obtained with conda or pip:

  <no title> — Bokeh 3.3.2 Documentation

Or else wait for the next full release 0.12.6 which should be out in about two weeks.

Thanks,

Bryan

···

On May 16, 2017, at 03:56, [email protected] wrote:

Hello,
I try to update a figure by adding a new plot by setting the old one's data source columns to be empty lists via callback.
Without using a legend, everything works. Otherwise the new plots resize weird. What is bokeh's problem ?

Example:
from bokeh.plotting import figure, curdoc
from bokeh.layouts import column
from bokeh.models import Button, ColumnDataSource

i = 0
plot_sources =

source = ColumnDataSource(data=dict(x=[1, 2], y=[2, 3]))
plot_sources.append(source)

p = figure(width=400, height=400)
p.circle("x", "y", source=source, legend="text")

def callback():
    global i, plot_sources
    i += 1

    for source in plot_sources:
        source.data = dict(x=, y=)

    source = ColumnDataSource(data=dict(x=[1, 3], y=[i, 5]))
    plot_sources.append(source)

    p.circle("x", "y", source=source, legend="text %d" % i)

button = Button(label="Press Me")
button.on_click(callback)

curdoc().add_root(column(p, button))

starting with:
bokeh serve --show app.py

--
You received this message because you are subscribed to the Google Groups "Bokeh Discussion - Public" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit https://groups.google.com/a/continuum.io/d/msgid/bokeh/fbf7616f-42f1-4f0c-8d32-a635656c0585%40continuum.io\.
For more options, visit https://groups.google.com/a/continuum.io/d/optout\.