☰Read-only archive⌕
Looking for help with Bokeh?

This is a read-only archive. Ask questions and join the conversation on GitHub.

Visit Community Support on GitHub →
Archived discussions · Captured October 28, 2026

Changing selection using js

Community Support
sggaffney
sggaffney

Hello,

I have a Bokeh scatter plot (embedded in a web app) in which I’d like to be able to highlight particular data indices.

I know that I can get the current selection indices using:

Bokeh.ColumnDataSource.Collection.models[0].attributes.selected

But is there a setter that I can use to update these indices, so that the corresponding points are highlighted?

Thanks for your help,

Stephen

⌁   Link to post
Bryan
Bryan

These are backbone models, you should be able to update the selected indices with something like:

  source.set('selected', [10, 27, 52])

It's possible that merely setting the selection won't trigger a re-render request (I can't recall offhand). To make sure a re-render happens, you can also trigger the 'change' event on the source:

  source.trigger('change')

Thanks,

Bryan

···

On Apr 21, 2015, at 3:52 PM, sggaffney@gmail.com wrote:

Hello,

I have a Bokeh scatter plot (embedded in a web app) in which I'd like to be able to highlight particular data indices.

I know that I can get the current selection indices using:
Bokeh.ColumnDataSource.Collection.models[0].attributes.selected
But is there a setter that I can use to update these indices, so that the corresponding points are highlighted?

Thanks for your help,
Stephen

--
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 bokeh+unsubscribe@continuum.io.
To post to this group, send email to bokeh@continuum.io.
To view this discussion on the web visit https://groups.google.com/a/continuum.io/d/msgid/bokeh/4f1b67b2-7f93-4993-bdb8-92b48e573acc%40continuum.io\.
For more options, visit https://groups.google.com/a/continuum.io/d/optout\.

⌁   Link to post

End of archived discussion · Replies are disabled