릴리스 0.12
현재이 작업은 다소 까다 롭지만 불가능하지는 않습니다. 슬라이더에는 "mouseup"
정책이 있지만 현재는 CustomJS
콜백에만 적용됩니다. 그는 "가짜"데이터 소스와 결합되는 경우에는, 우리는 의사 소통 단지 마지막 값 트리거 할 수
from bokeh.io import curdoc
from bokeh.layouts import column
from bokeh.plotting import figure
from bokeh.models.callbacks import CustomJS
from bokeh.models.sources import ColumnDataSource
from bokeh.models.widgets import Slider
# this is the real callback that we want to happen on slider mouseup
def cb(attr, old, new):
print("UPDATE", source.data['value'])
# This data source is just used to communicate/trigger the real callback
source = ColumnDataSource(data=dict(value=[]))
source.on_change('data', cb)
# a figure, just for example
p = figure(x_range=(0,1), y_range=(0,1))
# add a slider with a CustomJS callback and a mouseup policy to update the source
slider = Slider(start=1, end=10, value=1, step=0.1, callback_policy='mouseup')
slider.callback = CustomJS(args=dict(source=source), code="""
source.data = { value: [cb_obj.value] }
""")
curdoc().add_root(column(slider, p))
# make sure to add the source explicitly
curdoc().add_root(source)
내가 말했듯이,이 이상적이지입니다. 앞으로이 상황을 개선 할 수있는 공개 기능 요청이 있습니다. 그러나 팀이 매우 작기 때문에 기부 할 수있는 능력이 있다면 주저하지 말고 연락하십시오 (새로운 기고자 만 새로운 기능의 개발을 가속화 할 수 있습니다)
감사합니다. 마지막으로보고 된 값에 따라 그래프를 업데이트하는 작업자 스레드를 만드는 것은 어떻습니까? 아니면 스레드 안전 문제를 소개합니까? 이 경우 그래프를 업데이트하는 데 사용할 수있는 반복 타이머를 설정할 수 있습니까? (슬라이더 업데이트로 인한 것뿐만 아니라 장기간에 걸친 작업을 예측할 수 있기 때문에 약간의 생각이 있습니다.) – Emile
이것은 아마도 작동 할 수 있지만 [스레드로부터 업데이트] (http : // bokeh)의 사용자 가이드 섹션을 참조하거나 학습해야합니다. .pydata.org/ko/0.12.0/docs/user_guide/server.html # updating-from-threads) – bigreddot
Bokeh 12.6에서이 문제가 해결 되었습니까? – Thornhale