首页 > 解决方案 > 无法使用散景 BoxSelectTool 访问选择

问题描述

我可以将 BoxSelectTool 添加到我的绘图中。

plot.add_tools(BoxSelectTool(dimensions="both"))

该工具出现,我做了一个矩形选择。但是记录的方法对所选点没有显示任何内容。

source.selected.indices

[] 返回。怎么了。如何获取选定的索引?

在关注帖子之后,我可以让嵌入式服务器正常工作,并且 source.selected.indices 确实返回了积分,但 call_back 仍然不起作用

def callback(attr, old, new):
    print('select changed')
    # The index of the selected glyph is : new['1d']['indices'][0]
    patch_name =  source.data['name'][new['1d']['indices'][0]]
    print("TapTool callback executed on Patch {}".format(patch_name))

 source.on_change('selected',callback)

请问有什么想法吗?

标签: plotbokeh

解决方案


推荐阅读