use*_*203 7 javascript python bokeh
我在散景中有一个多线图,我想使用套索工具选择一些多线.默认情况下这不起作用:套索工具不会选择任何行.
from bokeh.io import output_file, show
from bokeh.plotting import figure
from bokeh.models import MultiLine
plot = figure(plot_width=400, plot_height=400, tools="lasso_select")
renderer = plot.multi_line([[1, 2, 3, 4, 5], [0,1]], [[2, 5, 8, 2, 7], [1,0]])
selected_circle = MultiLine(line_alpha=0.5, line_color='firebrick')
nonselected_circle = MultiLine(line_alpha=1, line_color='red')
renderer.selection_glyph = selected_circle
renderer.nonselection_glyph = nonselected_circle
show(plot)
Run Code Online (Sandbox Code Playgroud)
当然,问题是如何将一条线视为选中:如果该线的一个点位于套索区域中或者所有点都位于套索区域中,是否选择该线?
我试图添加一些javascript代码来改变套索工具的行为,但显然多线不能像简单数据点那样工作:
这段代码......
on_lasso = CustomJS(args=dict(), code='''
console.log(cb_obj.selected);
''')
lasso = LassoSelectTool(callback=on_lasso)
plot = figure(plot_width=800, plot_height=600, tools=[lasso])
Run Code Online (Sandbox Code Playgroud)
...告诉我cb_obj.selected由于某种原因未定义.
任何帮助将不胜感激!
PS:我使用散景v0.13.0
小智 1
不幸的是,除了 之外的选择方法tap似乎不可用MultiLine。为了让您了解一些历史,bokeh 中实现了tap对 bokeh 的支持;请参阅GitHub 中的散景问题 #3110。MultiLinev0.12.2
但是,lasso在调试模式 ( export BOKEH_DEV=1) 中使用您的 CustomJs 代码,我在控制台日志中收到以下内容:
[bokeh] 'poly' selection not available for MultiLine bokeh.js:13478
Run Code Online (Sandbox Code Playgroud)
此警告仅记录一次,请参阅代码,并且很容易错过。
我建议在 Bokeh GitHub 中打开功能请求。
| 归档时间: |
|
| 查看次数: |
187 次 |
| 最近记录: |