New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add new child to existing column #5518
Comments
That error is unexpected. Failing on layout is something that would normally happen. Layout, as currently implemented, doesn't like changes. |
I'm also fine with a "this is not supported" answer. I can find ways around this if necessary. |
It should be supported, we've always intended to have a second pass to shore up some rough edges around layout there just have not been resources to do it yet. |
No, |
Yes, the protocol is supposed to afford adding new models, not just patching existing ones. |
Encountered similar issue, although was not adding a new figure but instead adding a new completely unrelated DOM element. This apparently causes the constraint solver to fail, but only when certain other models like figures are in the document. Here's a minimal reproducible example: from bokeh.layouts import column
from bokeh.models.widgets import (Button, Div)
from bokeh.models.sources import ColumnDataSource
from bokeh.plotting import curdoc, figure
source = ColumnDataSource(data={"x": [0], "y": [0]})
fig = figure(plot_width=500, plot_height=300)
fig.circle(x="x", y="y", source=source)
button = Button(label="Add point")
column1 = column([fig,
button])
column2 = column([])
counter = 0
def on_click():
global counter
counter += 1
source.stream({"x": [counter], "y": [counter]})
column2.children = [Div(text=str(counter))] # new, completely unrelated, element
button.on_click(on_click)
curdoc().add_root(column([column1, column2])) When you click on the button, it gives a JS error: Uncaught Error: unknown constraint
at Solver.removeConstraint (bokeh.js:46936)
at Solver.exports.Solver.Solver.remove_constraint (bokeh.js:2324)
at Object.exports.update_constraints (bokeh.js:2158)
at PlotCanvasView.exports.PlotCanvasView.PlotCanvasView.update_constraints (bokeh.js:18141)
at PlotCanvasView.exports.PlotCanvasView.PlotCanvasView.render (bokeh.js:18079)
at later (bokeh.js:4381) Note that no error arises however if either
I recall reading a related issue which suggested that there could be issues with changing the children of a layout, unfortunately I can't find that issue ticket right now. I forget though if its a todo or a won't-do; if the latter it would not be possible to say have a dynamic number of plots, which would be a blocking issue for me. |
Thanks for the test case, just FYI resolving this is one of my top two priorities for |
Thanks, good to know. (also figured it'd be helpful to have the JS error pasted above so that it could be searched for in the issue tracker.) |
I tried to reproduce the original issue on top of |
@azjps' issue is something different and easily reproducible. Also, replacing widgets with plots gives you different kinds of errors (e.g. unknown edit variable). |
Came across a similar issue, so am chiming in here with another toy example in case it proves useful. Clicking 'Replace Plot', then 'Expand Range', will trigger the same 'unknown constraint' error reported above: from bokeh.layouts import row, column
from bokeh.models.sources import ColumnDataSource
from bokeh.models.widgets import Button
from bokeh.plotting import figure, curdoc
x = range(0,13)
y = range(2,15)
circ = ColumnDataSource(dict(x=[0,1],y=[0,1]))
fig = figure(y_axis_type='log')
fig.line(x,y)
fig2 = figure()
fig2.circle(x='x',y='y',source=circ)
but = Button(label="Replace Plot")
but2 = Button(label="Expand Range")
c = column(but, but2, fig, fig2)
def replace_plot():
fig3 = figure(y_axis_type='linear')
fig3.line(x,y)
c.children[2] = fig3
def expand_range():
circ.data['y'] = [0, 5001]
but.on_click(replace_plot)
but2.on_click(expand_range)
curdoc().add_root(c) Differences to the previous example:
Similarly to the previous example, the error also occurs if |
@mattpap just FYI I think some things I'm recording in #4875 might have some (at least tnagential) bearing here. You should merge in the array intersection fix at the very least, since caused problems when new models were added. But see also the comments about |
Seeing the same issue in a condition similar to @pstoeckl's example using bokeh 0.12.6dev4, it all seems to work despite the errors though. |
@philippjfr, because those errors come from views that aren't relevant anymore, but weren't destroyed yet. |
I think this might also be related to #4810 (same Also, confirming still an issue as of 0.12.6dev7 |
Has this issue been resolved? I am encountering the same error when trying to replace a row in my layout with some new widgets. |
I'm also experiencing this issue. My version of python and bokeh:
This is a simplified version of the from bokeh.io import curdoc
from bokeh.layouts import row, column, widgetbox
from bokeh.models.widgets import Slider, TextInput, Button
from bokeh.plotting import figure
from bokeh.models.widgets import Panel, Tabs
def query_prop_data():
# Query data goes in here
tab1_plots.children[0] = figure(plot_height=500,
plot_width=1000,
title='QUERY PLOT DONE')
tab2_plots.children[0] = figure(plot_height=500,
plot_width=1000,
title='QUERY PLOT DONE')
return
def refresh_plots():
# Refresh Plot goes in here
tab1_plots.children[0] = figure(plot_height=500,
plot_width=1000,
title='PLOT REFRESHED')
return
def update(attr, old, new):
refresh_plots()
return
# Setup Widgets
window = Slider(title="Change only tab 1", value=0, start=0, end=35, step=7)
prop_txt = TextInput(placeholder='enter prop code', title='PROPERTY CODE:')
run_button = Button(label='Query', button_type='success')
for widget in [window]:
widget.on_change('value', update)
for widget in [run_button]:
widget.on_click(query_prop_data)
inputs = widgetbox(prop_txt, run_button, window)
tab1_plots = row(column())
tab2_plots = row(column())
tab1_plots.children[0] = figure(plot_height=500,
plot_width=1000,
title='QUERY A PROPERTY TO GENERATE PLOT')
tab2_plots.children[0] = figure(plot_height=500,
plot_width=1000,
title='QUERY A PROPERTY TO GENERATE PLOT')
tab1 = Panel(child=tab1_plots, title="Tab1")
tab2 = Panel(child=tab2_plots, title="Tab2")
tabs = Tabs(tabs=[tab1, tab2], width=1000)
page_layout = row(children=[inputs, tabs], sizing_mode='fixed')
curdoc().add_root(page_layout)
curdoc().title = "Forecast Analysis" Only occurs when I start up my server with Each time the query button is clicked I get four lines like this:
Not sure if this is a code issue on my part or a bug. Hope that helps! |
When adding a child plot to an existing column and then updating the plot appears but then I get the following error:
And my figures come out wonky:
The text was updated successfully, but these errors were encountered: