2017-11-07 13 views
0

나는이처럼 보이는 보케 서버 코드가를 제거하는 방법보케 레이아웃 :</p> <pre><code>listOfSubLayouts = main_layout.children plotToRemove = curdoc().get_model_by_name(self.plotid_long) logging.warning(plotToRemove.name) listOfSubLayouts.remove(plotToRemove) </code></pre> <p>제거 라인은 다음과 같은 오류를 제공합니다 : 어린이

error handling message Message 'PATCH-DOC' (revision 1): ValueError('list.remove(x): x not in list',) 

는 누군가에 도움이 되거 주실 래요 여기서 무엇이 잘못 될지 모릅니다.

Dynamically add/remove plot using 'bokeh serve' (bokeh 0.12.0)

어쩌면 보케 서버 환경에서 작동하지 : 나는 여기이 해결책인가?

+0

안녕 어쩌면 그 게시물 https://stackoverflow.com/questions/46697867/replacing-figure-and-table-in을 도울 수 ...이 그것을 할 올바른 방법으로 알고 있지만하지 않습니다 -layout-when-using-global-columndatasource/46713283 # 46713283 https://stackoverflow.com/questions/46494811/how-to-replace-curdoc/46498077#46498077 – Seb

답변

0

이 예제가 도움이되는지 확인하여 자녀를 목록으로 처리 할 수 ​​있습니다. 나는

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

fig = figure(
    title='Third figure', 
    width=400, 
    height=400, 
    x_range=[-5, 10], 
    y_range=(0, 5), 
    tools='pan, wheel_zoom, zoom_in, zoom_out, box_select, lasso_select, tap, reset', 
    x_axis_label='x axis', 
    y_axis_label='y axis', 
) 

x = [1, 2, 3, 4] 
y = [4, 3, 2, 1] 

source = ColumnDataSource(data=dict(x=x, y=y)) 

fig.circle(
    x='x', 
    y='y', 
    source=source, 
    radius=0.5,    
    fill_alpha=0.6,   
    fill_color='green', 
    line_color='black', 
) 

def add_button(): 
    print("adding figure") 
    layout.children.append(fig) 

def remove_button(): 
    print("removing figure") 
    layout.children.pop() 


button = Button(label="Click to add the figure", button_type="success") 
button.on_click(add_button) 

button_rmv = Button(label="Click to remove the figure", button_type="success") 
button_rmv.on_click(remove_button) 

layout = layout([[button, button_rmv]]) 
curdoc().add_root(layout)