···
On Wed, Nov 30, 2016 at 10:25 AM, rootsumsquared@gmail.com wrote:
I’m using the following, but you have to agree this is hacky. There’s got to be a better way to locate the data source object?
var source = Bokeh.index[Bokeh._.keys(Bokeh.index)[0]].model.document._roots[0].attributes.renderers[6].attributes.data_source
source.trigger(“change”);
it would be useful to know the context in which you want to use this code, because it’s likely you can get the data source either directly or indirectly from the context, e.g. a custom js handler. Also, knowing how things were laid out would be helpful (is the top-level model a plot or a layout, etc.). Otherwise, the above line may be shortened to:
var source = Bokeh._.values(Bokeh.index)[0].model.renderers[6].data_source
or
var DataSource = require(“models/sources/data_source”).DataSource
var source = Bokeh._.values(Bokeh.index)[0].model.select_one(DataSource)
You can also select by name, etc. Don’t use attributes member directly as this is an internal implementation detail.
To modify a data source’s data, you can use either:
source.data = new_data;
or
source.data[“column_name”] = column
source.trigger(“change”)
Replacing entire data triggers change events automatically. It’s not possible with partial updates (in Python it’s possible with some magic).
Mateusz
–
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/f12d1397-f247-4a0c-a97e-e838e8e6cbd1%40continuum.io.
For more options, visit https://groups.google.com/a/continuum.io/d/optout.