Suppose I have
TOOLS = "box_select,tap,poly_select"
PC_fig = figure(tools=TOOLS, width=700, height=500, title=None)
Merck_source = ColumnDataSource(Merck_PC)
Merck_pt = PC_fig.circle("PC1","PC2",source=Merck_source)
``
I can select points by mouse using selection tools such as box_select, tap and poly_select. Suppose I have a button
Merck_toogle = Toggle(label="Toggle Merck individuals", button_type="success")
``
When clicked, a given set of points in Merck_source will be selected just like they will be if a selection tool is used through mouse, and a source selection event will be triggered.
Is there a way by which what I said above can be implemented?
Assume that 3, 4, 15 are the
indices of your data source to be selected I do something like this.
Define a callback function:
``
Merck_toggle.on_click(on_merck_toggle)
``
In the callback on_merck_toggle updated selected:
Merck_source.selected = {u'2d': {}, u'1d': {u'indices': [3, 4, 15]}, u'0d': {u'indices': [], u'get_view': {}, u'glyph': None}}
``
or just the ‘1d’ sub-dict:
`Merck_source`.selected[u'1d'] = {u'indices': [3, 4, 15]}
``
Note, that just setting the indices
in the sub-sub-dict did not work for me:
`Merck_source`.selected[u'1d'][u'indices'] = [3, 4, 15]
``
Thanks! This is exactly what I want!
···
On Tuesday, May 9, 2017 at 9:08:51 PM UTC+8, christoph wrote:
Assume that 3, 4, 15 are the
indices of your data source to be selected I do something like this.
Define a callback function:
``
Merck_toggle.on_click(on_merck_toggle)
``
In the callback on_merck_toggle updated selected:
Merck_source.selected = {u’2d’: {}, u’1d’: {u’indices’: [3, 4, 15]}, u’0d’: {u’indices’: , u’get_view’: {}, u’glyph’: None}}
``
or just the ‘1d’ sub-dict:
Merck_source
.selected[u’1d’] = {u’indices’: [3, 4, 15]}
``
Note, that just setting the indices
in the sub-sub-dict did not work for me:
Merck_source
.selected[u’1d’][u’indices’] = [3, 4, 15]
``