我在散景中有一个多线图,我想使用套索工具选择一些多线.默认情况下这不起作用:套索工具不会选择任何行.
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