[bokeh] Change in source.selected does not affect table view

Hi,

Seems like a regression, please file an issue on GitHub with this information.

Thanks,

Bryan

···

On May 2, 2018, at 14:10, [email protected] wrote:

Since the introduction of the Selection class, I've not been able to programmatically change which rows of a DataTable are highlighted as I used to be able to do by manually editing the source.selected object. I can verify source.selected is updated, but it doesn't appear to push a visual change anymore?

Am I missing something about how to use the Selection class?

Thanks,

Dan

from __future__ import print_function
from bokeh.layouts import column
from bokeh.models import ColumnDataSource, Selection, Select, CustomJS
from bokeh.io import curdoc
from bokeh.models.widgets import Button, TableColumn, DataTable

source = ColumnDataSource(dict(x=list(range(10))))
source.js_on_change('selected', CustomJS(args=dict(source=source), code="source.change.emit()")) # doesn't help?

def update_table_selection():
    if not source.selected.indices:
        new_index = 0
    else:
        new_index = source.selected.indices[0]+1

    source.selected = Selection(indices=[new_index])
    select.value = str(source.selected.indices[0])

def print_selection(attr, old, new):
    print("old: %s" % old.indices)
    print("new: %s" % new.indices)

button = Button(label="Next", button_type="primary", width=200)
button.on_click(update_table_selection)
select = Select(value=' ', options=[" "]+[str(x) for x in range(10)], width=200, title='Selection Index')
table = DataTable(source=source, columns=[TableColumn(field="x", title="x")])
source.on_change('selected', print_selection)

curdoc().add_root(column(button, select, table))

--
You received this message because you are subscribed to the Google Groups "Bokeh Discussion - Public" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit https://groups.google.com/a/continuum.io/d/msgid/bokeh/369f7733-4036-4e3e-a72d-da117c072d16%40continuum.io\.
For more options, visit https://groups.google.com/a/continuum.io/d/optout\.

Actually there seems to be an old issue, can you add a comment to update with this MRE and note that it's still not working?

  Setting Selected Property of ColumnData does not Change Selected Row. · Issue #5701 · bokeh/bokeh · GitHub

Thanks.

Bryan

···

On May 2, 2018, at 14:16, Bryan Van de ven <[email protected]> wrote:

Hi,

Seems like a regression, please file an issue on GitHub with this information.

Thanks,

Bryan

On May 2, 2018, at 14:10, [email protected] wrote:

Since the introduction of the Selection class, I've not been able to programmatically change which rows of a DataTable are highlighted as I used to be able to do by manually editing the source.selected object. I can verify source.selected is updated, but it doesn't appear to push a visual change anymore?

Am I missing something about how to use the Selection class?

Thanks,

Dan

from __future__ import print_function
from bokeh.layouts import column
from bokeh.models import ColumnDataSource, Selection, Select, CustomJS
from bokeh.io import curdoc
from bokeh.models.widgets import Button, TableColumn, DataTable

source = ColumnDataSource(dict(x=list(range(10))))
source.js_on_change('selected', CustomJS(args=dict(source=source), code="source.change.emit()")) # doesn't help?

def update_table_selection():
   if not source.selected.indices:
       new_index = 0
   else:
       new_index = source.selected.indices[0]+1

   source.selected = Selection(indices=[new_index])
   select.value = str(source.selected.indices[0])

def print_selection(attr, old, new):
   print("old: %s" % old.indices)
   print("new: %s" % new.indices)

button = Button(label="Next", button_type="primary", width=200)
button.on_click(update_table_selection)
select = Select(value=' ', options=[" "]+[str(x) for x in range(10)], width=200, title='Selection Index')
table = DataTable(source=source, columns=[TableColumn(field="x", title="x")])
source.on_change('selected', print_selection)

curdoc().add_root(column(button, select, table))

--
You received this message because you are subscribed to the Google Groups "Bokeh Discussion - Public" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit https://groups.google.com/a/continuum.io/d/msgid/bokeh/369f7733-4036-4e3e-a72d-da117c072d16%40continuum.io\.
For more options, visit https://groups.google.com/a/continuum.io/d/optout\.

Hello there, it seems we found a similar issue (the github issue was closed 10th of may). We are trying to use the tap tool to select multiple glyphs on diferent figures that have some correlation to the one we tap and have achieve what seems to be a solution.

for glyphs in tap.renderers(there is only 3 graphicglyphs):

glyphs.data_source.selected.on_change(‘indices’, lambda attr, old, new : func())

However when we run the bokeh serve --show smth.py

We found erratic behaviour, console shows us (with a print) that at most func() is called once on each glyph and at least its called twice overall (mostrly is called tiwce and sometimes three times). however on different taps there is no response of func.

First we thought we where doing something wrong, however we found this mail and decided to print the indices list with an external button and even though we see no call from func, we see changes in the indices list.

Maybe we are doing something wrong, but we can’t seem to understand what. If there is more info needed please ask. Hopefully it’s something wrong on our side, but in the worst case scenario, how woul anyone recommend to bypass the issue?

Thanks in advance,

Javier

···

El miércoles, 2 de mayo de 2018, 16:19:35 (UTC-3), Bryan Van de ven escribió:

Actually there seems to be an old issue, can you add a comment to update with this MRE and note that it’s still not working?

    [https://github.com/bokeh/bokeh/issues/5701](https://github.com/bokeh/bokeh/issues/5701)

Thanks.

Bryan

On May 2, 2018, at 14:16, Bryan Van de ven [email protected] wrote:

Hi,

Seems like a regression, please file an issue on GitHub with this information.

Thanks,

Bryan

On May 2, 2018, at 14:10, [email protected] wrote:

Since the introduction of the Selection class, I’ve not been able to programmatically change which rows of a DataTable are highlighted as I used to be able to do by manually editing the source.selected object. I can verify source.selected is updated, but it doesn’t appear to push a visual change anymore?

Am I missing something about how to use the Selection class?

Thanks,

Dan

from future import print_function

from bokeh.layouts import column

from bokeh.models import ColumnDataSource, Selection, Select, CustomJS

from bokeh.io import curdoc

from bokeh.models.widgets import Button, TableColumn, DataTable

source = ColumnDataSource(dict(x=list(range(10))))

source.js_on_change(‘selected’, CustomJS(args=dict(source=source), code=“source.change.emit()”)) # doesn’t help?

def update_table_selection():

if not source.selected.indices:

   new_index = 0

else:

   new_index = source.selected.indices[0]+1

source.selected = Selection(indices=[new_index])

select.value = str(source.selected.indices[0])

def print_selection(attr, old, new):

print(“old: %s” % old.indices)

print(“new: %s” % new.indices)

button = Button(label=“Next”, button_type=“primary”, width=200)

button.on_click(update_table_selection)

select = Select(value=’ ', options=[" "]+[str(x) for x in range(10)], width=200, title=‘Selection Index’)

table = DataTable(source=source, columns=[TableColumn(field=“x”, title=“x”)])

source.on_change(‘selected’, print_selection)

curdoc().add_root(column(button, select, table))


You received this message because you are subscribed to the Google Groups “Bokeh Discussion - Public” group.

To unsubscribe from this group and stop receiving emails from it, send an email to [email protected].

To post to this group, send email to [email protected].

To view this discussion on the web visit https://groups.google.com/a/continuum.io/d/msgid/bokeh/369f7733-4036-4e3e-a72d-da117c072d16%40continuum.io.

For more options, visit https://groups.google.com/a/continuum.io/d/optout.