How to identify the Backbone model of a Bokeh plot object?

Broadening this question, for mixed Python+JS development it might be useful to understand where to access the Backbone model of the various objects in a page

Two example of reasons to do this:

  • re-rendering objects: for example, if I change the value of a Slider through the callback of another bokeh widget, the slider does not render to the new value and (I presume) I need to access its renderer and give it a nudge

  • modifying data (columndatasources) from JS scripts that take place outside of a Bokeh Callback

By starting at bokeh.index, where should one look for the data sources and the models? [el, model, model.attributes, model.collections,…?]

Hi Giuseppe,

Yes, I forgot the index only contains Plot objects. But each of these has a "renderers" backbone attribute, so you can use

  plot.get('renderers')

to get the list of renderers. One (or more) of these will be a GlyphRenderer, and these are the objects that have a "data_source" backbone attribute:

  renderer.get('data_source')

You can update and trigger this object just as is done in the User Guide examples.

Adding some JS object graph search functions (like the python side has) is on our long TODO list.

Bryan

···

On Aug 17, 2015, at 1:31 AM, Pythonic <[email protected]> wrote:

Broadening this question, for mixed Python+JS development it might be useful to understand where to access the Backbone model of the various objects in a page

Two example of reasons to do this:

- re-rendering objects: for example, if I change the value of a Slider through the callback of another bokeh widget, the slider does not render to the new value and (I presume) I need to access its renderer and give it a nudge

- modifying data (columndatasources) from JS scripts that take place outside of a Bokeh Callback

By starting at bokeh.index, where should one look for the data sources and the models? [el, model, model.attributes, model.collections,...?]

--
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/2ac5d5dc-a2f8-4f88-b842-2958e310448c%40continuum.io\.
For more options, visit https://groups.google.com/a/continuum.io/d/optout\.

Priceless, many thanks

···

On Monday, 17 August 2015 15:23:30 UTC+1, Bryan Van de ven wrote:

Hi Giuseppe,

Yes, I forgot the index only contains Plot objects. But each of these has a “renderers” backbone attribute, so you can use

    plot.get('renderers')

to get the list of renderers. One (or more) of these will be a GlyphRenderer, and these are the objects that have a “data_source” backbone attribute:

    renderer.get('data_source')

You can update and trigger this object just as is done in the User Guide examples.

Adding some JS object graph search functions (like the python side has) is on our long TODO list.

Bryan

On Aug 17, 2015, at 1:31 AM, Pythonic [email protected] wrote:

Broadening this question, for mixed Python+JS development it might be useful to understand where to access the Backbone model of the various objects in a page

Two example of reasons to do this:

  • re-rendering objects: for example, if I change the value of a Slider through the callback of another bokeh widget, the slider does not render to the new value and (I presume) I need to access its renderer and give it a nudge
  • modifying data (columndatasources) from JS scripts that take place outside of a Bokeh Callback

By starting at bokeh.index, where should one look for the data sources and the models? [el, model, model.attributes, model.collections,…?]


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/2ac5d5dc-a2f8-4f88-b842-2958e310448c%40continuum.io.

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

Here is where I am:

_ = Bokeh._

index = window.Bokeh.index

keys = _.keys(index)

plot = Bokeh.index[keys[0]] // index only has 1 key

renderers = plot.model.get(‘renderers’)

console.log(renderers) // this results in “undefined”

Manually exploring the plot object in the log, I find renderers in plot.views.attributes.renderers**,** but none respond to get(‘data_source’) or show any data_source attribute in the console log

I am sure I must be doing some silly error along the line, any suggestion? Many thanks

···

On Monday, 17 August 2015 15:27:53 UTC+1, Pythonic wrote:

Priceless, many thanks

On Monday, 17 August 2015 15:23:30 UTC+1, Bryan Van de ven wrote:

Hi Giuseppe,

Yes, I forgot the index only contains Plot objects. But each of these has a “renderers” backbone attribute, so you can use

    plot.get('renderers')

to get the list of renderers. One (or more) of these will be a GlyphRenderer, and these are the objects that have a “data_source” backbone attribute:

    renderer.get('data_source')

You can update and trigger this object just as is done in the User Guide examples.

Adding some JS object graph search functions (like the python side has) is on our long TODO list.

Bryan

On Aug 17, 2015, at 1:31 AM, Pythonic [email protected] wrote:

Broadening this question, for mixed Python+JS development it might be useful to understand where to access the Backbone model of the various objects in a page

Two example of reasons to do this:

  • re-rendering objects: for example, if I change the value of a Slider through the callback of another bokeh widget, the slider does not render to the new value and (I presume) I need to access its renderer and give it a nudge
  • modifying data (columndatasources) from JS scripts that take place outside of a Bokeh Callback

By starting at bokeh.index, where should one look for the data sources and the models? [el, model, model.attributes, model.collections,…?]


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/2ac5d5dc-a2f8-4f88-b842-2958e310448c%40continuum.io.

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

Solved:

In summary

The columndatasource is in window.Bokeh.ColumnDataSource.Collection.models[k].attributes.data, with [k] being the key to the datasource you want

The code

This shows how to access it, presuming you provided a name to the ColumnDataSource when you created it in Python (e.g. source = models.ColumnDataSource(data_dict, name=‘mycolumndatasource’) )

console.log(Bokeh);

var my_source_name = 'mycolumndatasource';

var sources = Bokeh.ColumnDataSource.Collection.models;

var source_keys = Bokeh._.keys(sources)

console.log(source_keys)

for (i = 0; i < source_keys.length; i++) {

var k = source_keys[i];

var source_name = sources[k].attributes.name

if (source_name == my_source_name) {

   var my_data = sources[k].attributes.data

}

}

console.log(my_data);

Comment

  • Being able to access the data sources from external js is extremely useful to do hybrid Python / Javascript development, as one can rely on Bokeh’s interconnection while using external functionalities

  • Exploring window.Bokeh, I thought all the objects with capital first letter like ColumnDataSource were constructors, did not expect them to contain active collections and models

···

On Monday, 17 August 2015 16:06:26 UTC+1, Pythonic wrote:

Here is where I am:

_ = Bokeh._

index = window.Bokeh.index

keys = _.keys(index)

plot = Bokeh.index[keys[0]] // index only has 1 key

renderers = plot.model.get(‘renderers’)

console.log(renderers) // this results in “undefined”

Manually exploring the plot object in the log, I find renderers in plot.views.attributes.renderers**,** but none respond to get(‘data_source’) or show any data_source attribute in the console log

I am sure I must be doing some silly error along the line, any suggestion? Many thanks

On Monday, 17 August 2015 15:27:53 UTC+1, Pythonic wrote:

Priceless, many thanks

On Monday, 17 August 2015 15:23:30 UTC+1, Bryan Van de ven wrote:

Hi Giuseppe,

Yes, I forgot the index only contains Plot objects. But each of these has a “renderers” backbone attribute, so you can use

    plot.get('renderers')

to get the list of renderers. One (or more) of these will be a GlyphRenderer, and these are the objects that have a “data_source” backbone attribute:

    renderer.get('data_source')

You can update and trigger this object just as is done in the User Guide examples.

Adding some JS object graph search functions (like the python side has) is on our long TODO list.

Bryan

On Aug 17, 2015, at 1:31 AM, Pythonic [email protected] wrote:

Broadening this question, for mixed Python+JS development it might be useful to understand where to access the Backbone model of the various objects in a page

Two example of reasons to do this:

  • re-rendering objects: for example, if I change the value of a Slider through the callback of another bokeh widget, the slider does not render to the new value and (I presume) I need to access its renderer and give it a nudge
  • modifying data (columndatasources) from JS scripts that take place outside of a Bokeh Callback

By starting at bokeh.index, where should one look for the data sources and the models? [el, model, model.attributes, model.collections,…?]


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/2ac5d5dc-a2f8-4f88-b842-2958e310448c%40continuum.io.

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

I am trying to do something similar where I would like to change the data in a ColumnDataSource using javascript, but I’m having a hard time locating the ColumnDataSource. I generated the attached html file from the attached .py file. When I follow the steps below looking in the html file, I find Bokeh.ColumnDataSource.Collection.models, but it has nothing in it, i.e.

console.log(Bokeh.ColumnDataSource.Collection.models);

returns an empty list:

[] 

Has something changed since August? If so, where can I find documentation or examples?

Thanks,
Greg

sinusoidal_tline_voltages_test.html (27.9 KB)

sinusoidal_tline_voltages.py (1.43 KB)

···

On Sunday, August 23, 2015 at 4:16:35 AM UTC-6, Pythonic wrote:

Solved:

In summary

The columndatasource is in window.Bokeh.ColumnDataSource.Collection.models[k].attributes.data, with [k] being the key to the datasource you want

The code

This shows how to access it, presuming you provided a name to the ColumnDataSource when you created it in Python (e.g. source = models.ColumnDataSource(data_dict, name=‘mycolumndatasource’) )

console.log(Bokeh);

var my_source_name = 'mycolumndatasource';
var sources = Bokeh.ColumnDataSource.Collection.models;
var source_keys = Bokeh._.keys(sources)
console.log(source_keys)
for (i = 0; i < source_keys.length; i++) {
var k = source_keys[i];
var source_name = sources[k].[attributes.name](http://attributes.name)
if (source_name == my_source_name) {
   var my_data = sources[k].attributes.data
}

}

console.log(my_data);

Comment

  • Being able to access the data sources from external js is extremely useful to do hybrid Python / Javascript development, as one can rely on Bokeh’s interconnection while using external functionalities
  • Exploring window.Bokeh, I thought all the objects with capital first letter like ColumnDataSource were constructors, did not expect them to contain active collections and models

On Monday, 17 August 2015 16:06:26 UTC+1, Pythonic wrote:

Here is where I am:

_ = Bokeh._

index = window.Bokeh.index

keys = _.keys(index)

plot = Bokeh.index[keys[0]] // index only has 1 key

renderers = plot.model.get(‘renderers’)

console.log(renderers) // this results in “undefined”

Manually exploring the plot object in the log, I find renderers in plot.views.attributes.renderers**,** but none respond to get(‘data_source’) or show any data_source attribute in the console log

I am sure I must be doing some silly error along the line, any suggestion? Many thanks

On Monday, 17 August 2015 15:27:53 UTC+1, Pythonic wrote:

Priceless, many thanks

On Monday, 17 August 2015 15:23:30 UTC+1, Bryan Van de ven wrote:

Hi Giuseppe,

Yes, I forgot the index only contains Plot objects. But each of these has a “renderers” backbone attribute, so you can use

    plot.get('renderers')

to get the list of renderers. One (or more) of these will be a GlyphRenderer, and these are the objects that have a “data_source” backbone attribute:

    renderer.get('data_source')

You can update and trigger this object just as is done in the User Guide examples.

Adding some JS object graph search functions (like the python side has) is on our long TODO list.

Bryan

On Aug 17, 2015, at 1:31 AM, Pythonic [email protected] wrote:

Broadening this question, for mixed Python+JS development it might be useful to understand where to access the Backbone model of the various objects in a page

Two example of reasons to do this:

  • re-rendering objects: for example, if I change the value of a Slider through the callback of another bokeh widget, the slider does not render to the new value and (I presume) I need to access its renderer and give it a nudge
  • modifying data (columndatasources) from JS scripts that take place outside of a Bokeh Callback

By starting at bokeh.index, where should one look for the data sources and the models? [el, model, model.attributes, model.collections,…?]


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/2ac5d5dc-a2f8-4f88-b842-2958e310448c%40continuum.io.

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

Collection is no longer used that way in 0.11 as you discovered … I’m not sure what coverage the docs or examples have here, others will know better.

A use of Bokeh.index to get models I know of is

https://github.com/bokeh/bokeh/blob/master/examples/embed/spectrogram/spectrogram.coffee

In 0.11, ideally you would start by finding the bokeh Document instance you care about. It’s reachable from any model in the document as model.document - if you’re in a JS callback, pass any model to the callback then get model.document. If you’re in an arbitrary tag, I don’t remember a clean, supported way to do this (or even to get the Bokeh object, which may load later than your JS in some situations). I’ll suggest some hacks later though.

Once you have the document, the best approach is on the Python side set mydatasource.name=“something”, then in JS do doc.get_model_by_name(“something”). If you instead have the model id there is a get_model_by_id(). Or if you know the document structure you could dig through the document starting from doc.roots().

Hacks to get a document -

There isn’t a global var containing all documents or models anymore, but there is still a Bokeh.index which contains views for all document roots I think, plus I think models that were explicitly passed to show() or file_html()… The views have a model field and models have a document field so as a hack you can get the document that way. Pick any key from Bokeh.index, get its value, get its model field, get the model’s document field.

Another possible hack is to trigger a client-side callback that doesn’t do anything except get passed a model, and then in the callback set a global like window.bokeh_doc to model.document. Then other code can get the document from there. I’m not sure of the easiest way to do a fake self-triggered callback though. Maybe an invisible button. Very bad hack.

Either way I’d suggest use the hack to get Document and then use the Document API to get all the specific models.

The BEST hack of course is to make a PR for a future release adding things like Bokeh.get_document_by_session_id() or Bokeh.get_document_by_title() or Bokeh.get_rendered_documents(). :wink: Tricky bits might include:

  • if a document is no longer rendered or used in an open session, be sure to forget it to avoid a leak

  • multiple document instances can have the same session id if multiple websockets are open

  • document.title can change at any time

There may be other better PR ideas others have. A very simple one could be to be able to add a “Document created” callback, perhaps, and you could set global vars from that callback.

Anyway apologies for the rough edge.

Havoc

···

On Jan 20, 2016, at 3:48 PM, Greg Nordin [email protected] wrote:

I am trying to do something similar where I would like to change the data in a ColumnDataSource using javascript, but I’m having a hard time locating the ColumnDataSource. I generated the attached html file from the attached .py file. When I follow the steps below looking in the html file, I find Bokeh.ColumnDataSource.Collection.models, but it has nothing in it, i.e.

console.log(Bokeh.ColumnDataSource.Collection.models);

returns an empty list:

[] 

Has something changed since August? If so, where can I find documentation or examples?

Thanks,
Greg

On Sunday, August 23, 2015 at 4:16:35 AM UTC-6, Pythonic wrote:

Solved:

In summary

The columndatasource is in window.Bokeh.ColumnDataSource.Collection.models[k].attributes.data, with [k] being the key to the datasource you want

The code

This shows how to access it, presuming you provided a name to the ColumnDataSource when you created it in Python (e.g. source = models.ColumnDataSource(data_dict, name=‘mycolumndatasource’) )

console.log(Bokeh);

var my_source_name = 'mycolumndatasource';
var sources = Bokeh.ColumnDataSource.Collection.models;
var source_keys = Bokeh._.keys(sources)
console.log(source_keys)
for (i = 0; i < source_keys.length; i++) {
var k = source_keys[i];
var source_name = sources[k].[attributes.name](http://attributes.name)
if (source_name == my_source_name) {
   var my_data = sources[k].attributes.data
}

}

console.log(my_data);

Comment

  • Being able to access the data sources from external js is extremely useful to do hybrid Python / Javascript development, as one can rely on Bokeh’s interconnection while using external functionalities
  • Exploring window.Bokeh, I thought all the objects with capital first letter like ColumnDataSource were constructors, did not expect them to contain active collections and models

On Monday, 17 August 2015 16:06:26 UTC+1, Pythonic wrote:

Here is where I am:

_ = Bokeh._

index = window.Bokeh.index

keys = _.keys(index)

plot = Bokeh.index[keys[0]] // index only has 1 key

renderers = plot.model.get(‘renderers’)

console.log(renderers) // this results in “undefined”

Manually exploring the plot object in the log, I find renderers in plot.views.attributes.renderers**,** but none respond to get(‘data_source’) or show any data_source attribute in the console log

I am sure I must be doing some silly error along the line, any suggestion? Many thanks

On Monday, 17 August 2015 15:27:53 UTC+1, Pythonic wrote:

Priceless, many thanks

On Monday, 17 August 2015 15:23:30 UTC+1, Bryan Van de ven wrote:

Hi Giuseppe,

Yes, I forgot the index only contains Plot objects. But each of these has a “renderers” backbone attribute, so you can use

    plot.get('renderers')

to get the list of renderers. One (or more) of these will be a GlyphRenderer, and these are the objects that have a “data_source” backbone attribute:

    renderer.get('data_source')

You can update and trigger this object just as is done in the User Guide examples.

Adding some JS object graph search functions (like the python side has) is on our long TODO list.

Bryan

On Aug 17, 2015, at 1:31 AM, Pythonic [email protected] wrote:

Broadening this question, for mixed Python+JS development it might be useful to understand where to access the Backbone model of the various objects in a page

Two example of reasons to do this:

  • re-rendering objects: for example, if I change the value of a Slider through the callback of another bokeh widget, the slider does not render to the new value and (I presume) I need to access its renderer and give it a nudge
  • modifying data (columndatasources) from JS scripts that take place outside of a Bokeh Callback

By starting at bokeh.index, where should one look for the data sources and the models? [el, model, model.attributes, model.collections,…?]


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/2ac5d5dc-a2f8-4f88-b842-2958e310448c%40continuum.io.

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

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/75bba408-73bf-45a5-bac6-4bba998b8f99%40continuum.io.

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

<sinusoidal_tline_voltages_test.html>

<sinusoidal_tline_voltages.py>

Thanks, Havoc. I really appreciate the information.

I saw the spectrogram.coffee file earlier and went through it, but I don’t know coffeescript yet and decided to look for other approaches rather than doing a crash course in coffeescript. I’m still a noob to javascript so I was thinking I ought to get that nailed down first.

What I am trying to do is avoid needing a server so that the final html file can be run only client side. I need to animate several lines on a graph so I am looking at finding the line data and updating it through javascript callbacks. My main motivation is to create single page html instructional visualizations & animations for a university class I am teaching. I tried using Bokeh server to do the animation and it works fine on my laptop. However, I’m finding the students largely unwilling to try to set up python & bokeh on their own machines (most of which are Windows-based) and running “bokeh serve --show <filename.py>” from the command line. One of my teaching assistants did this and when he showed it to me there was a noticeable lag (seconds) between hitting a button or changing a slider and having the plot respond. I think his laptop is a bit underpowered. When I run it on my laptop I notice that the (internal) network traffic is ~5-7 MBps when I run bokeh serve with the same file. In any case, I’m now looking for a way to put a given interactive visualization/animation into a single html file on a static server that students can point their browser at such that the html file runs on their machines.

I wish I was in a position to make a PR for a future release. However, I think I still have a lot to learn before I can get to that point :-).

Again, I really appreciate your help and suggestions!

···

On Wednesday, January 20, 2016 at 9:46:32 PM UTC-7, Havoc Pennington wrote:

Collection is no longer used that way in 0.11 as you discovered … I’m not sure what coverage the docs or examples have here, others will know better.

A use of Bokeh.index to get models I know of is

https://github.com/bokeh/bokeh/blob/master/examples/embed/spectrogram/spectrogram.coffee

In 0.11, ideally you would start by finding the bokeh Document instance you care about. It’s reachable from any model in the document as model.document - if you’re in a JS callback, pass any model to the callback then get model.document. If you’re in an arbitrary tag, I don’t remember a clean, supported way to do this (or even to get the Bokeh object, which may load later than your JS in some situations). I’ll suggest some hacks later though.

Once you have the document, the best approach is on the Python side set mydatasource.name=“something”, then in JS do doc.get_model_by_name(“something”). If you instead have the model id there is a get_model_by_id(). Or if you know the document structure you could dig through the document starting from doc.roots().

Hacks to get a document -

There isn’t a global var containing all documents or models anymore, but there is still a Bokeh.index which contains views for all document roots I think, plus I think models that were explicitly passed to show() or file_html()… The views have a model field and models have a document field so as a hack you can get the document that way. Pick any key from Bokeh.index, get its value, get its model field, get the model’s document field.

Another possible hack is to trigger a client-side callback that doesn’t do anything except get passed a model, and then in the callback set a global like window.bokeh_doc to model.document. Then other code can get the document from there. I’m not sure of the easiest way to do a fake self-triggered callback though. Maybe an invisible button. Very bad hack.

Either way I’d suggest use the hack to get Document and then use the Document API to get all the specific models.

The BEST hack of course is to make a PR for a future release adding things like Bokeh.get_document_by_session_id() or Bokeh.get_document_by_title() or Bokeh.get_rendered_documents(). :wink: Tricky bits might include:

  • if a document is no longer rendered or used in an open session, be sure to forget it to avoid a leak
  • multiple document instances can have the same session id if multiple websockets are open
  • document.title can change at any time

There may be other better PR ideas others have. A very simple one could be to be able to add a “Document created” callback, perhaps, and you could set global vars from that callback.

Anyway apologies for the rough edge.

Havoc

On Jan 20, 2016, at 3:48 PM, Greg Nordin [email protected] wrote:

Solved:

In summary

The columndatasource is in window.Bokeh.ColumnDataSource.Collection.models[k].attributes.data, with [k] being the key to the datasource you want

The code

This shows how to access it, presuming you provided a name to the ColumnDataSource when you created it in Python (e.g. source = models.ColumnDataSource(data_dict, name=‘mycolumndatasource’) )

console.log(Bokeh);

var my_source_name = 'mycolumndatasource';
var sources = Bokeh.ColumnDataSource.Collection.models;
var source_keys = Bokeh._.keys(sources)
console.log(source_keys)
for (i = 0; i < source_keys.length; i++) {
var k = source_keys[i];
var source_name = sources[k].[attributes.name](http://attributes.name)
if (source_name == my_source_name) {
   var my_data = sources[k].attributes.data
}

}

console.log(my_data);

Comment

  • Being able to access the data sources from external js is extremely useful to do hybrid Python / Javascript development, as one can rely on Bokeh’s interconnection while using external functionalities
  • Exploring window.Bokeh, I thought all the objects with capital first letter like ColumnDataSource were constructors, did not expect them to contain active collections and models

On Monday, 17 August 2015 16:06:26 UTC+1, Pythonic wrote:

Here is where I am:

_ = Bokeh._

index = window.Bokeh.index

keys = _.keys(index)

plot = Bokeh.index[keys[0]] // index only has 1 key

renderers = plot.model.get(‘renderers’)

console.log(renderers) // this results in “undefined”

Manually exploring the plot object in the log, I find renderers in plot.views.attributes.renderers**,** but none respond to get(‘data_source’) or show any data_source attribute in the console log

I am sure I must be doing some silly error along the line, any suggestion? Many thanks

On Monday, 17 August 2015 15:27:53 UTC+1, Pythonic wrote:

Priceless, many thanks

On Monday, 17 August 2015 15:23:30 UTC+1, Bryan Van de ven wrote:

Hi Giuseppe,

Yes, I forgot the index only contains Plot objects. But each of these has a “renderers” backbone attribute, so you can use

    plot.get('renderers')

to get the list of renderers. One (or more) of these will be a GlyphRenderer, and these are the objects that have a “data_source” backbone attribute:

    renderer.get('data_source')

You can update and trigger this object just as is done in the User Guide examples.

Adding some JS object graph search functions (like the python side has) is on our long TODO list.

Bryan

On Aug 17, 2015, at 1:31 AM, Pythonic [email protected] wrote:

Broadening this question, for mixed Python+JS development it might be useful to understand where to access the Backbone model of the various objects in a page

Two example of reasons to do this:

  • re-rendering objects: for example, if I change the value of a Slider through the callback of another bokeh widget, the slider does not render to the new value and (I presume) I need to access its renderer and give it a nudge
  • modifying data (columndatasources) from JS scripts that take place outside of a Bokeh Callback

By starting at bokeh.index, where should one look for the data sources and the models? [el, model, model.attributes, model.collections,…?]


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/2ac5d5dc-a2f8-4f88-b842-2958e310448c%40continuum.io.

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

I am trying to do something similar where I would like to change the data in a ColumnDataSource using javascript, but I’m having a hard time locating the ColumnDataSource. I generated the attached html file from the attached .py file. When I follow the steps below looking in the html file, I find Bokeh.ColumnDataSource.Collection.models, but it has nothing in it, i.e.

console.log(Bokeh.ColumnDataSource.Collection.models);

returns an empty list:

[] 

Has something changed since August? If so, where can I find documentation or examples?

Thanks,
Greg

On Sunday, August 23, 2015 at 4:16:35 AM UTC-6, Pythonic wrote:

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/75bba408-73bf-45a5-bac6-4bba998b8f99%40continuum.io.

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

<sinusoidal_tline_voltages_test.html>

<sinusoidal_tline_voltages.py>

Greg,

Working on a similar issue (browser-side update of data). I’ve gotten this Javascript to works on 0.11 for a page with a single ColumnDataSource. Walk the id hierarchy until a model with a ‘data’ attribute is found.

    var ids = Bokeh._.keys(Bokeh.index)
    for (var i = 0; i < ids.length; i++) {
        var plot = Bokeh.index[ids[i]]
       
        for( k in plot.model.document._all_models) {
            var m = plot.model.document.get_model_by_id(k)
            var d = m.attributes.data
            if( d != undefined ) {
                var my_data = d
                break;
            }
        }
        if( my_data != undefined) {
            break;
        }
    }

   // Do updates to my_data
   
   // update plot
   m.trigger('change')

``

I get an error using Havoc’s recommendation of named ColumnDataSources (‘on the Python side set mydatasource.name=“something”, then in JS do doc.get_model_by_name(“something”).’ If I have a plot with 2 or more glyphs, I get “Error: Multiple models are named ‘something’”.

Jeff

···

On Thursday, January 21, 2016 at 5:10:12 AM UTC, Greg Nordin wrote:

Thanks, Havoc. I really appreciate the information.

I saw the spectrogram.coffee file earlier and went through it, but I don’t know coffeescript yet and decided to look for other approaches rather than doing a crash course in coffeescript. I’m still a noob to javascript so I was thinking I ought to get that nailed down first.

What I am trying to do is avoid needing a server so that the final html file can be run only client side. I need to animate several lines on a graph so I am looking at finding the line data and updating it through javascript callbacks. My main motivation is to create single page html instructional visualizations & animations for a university class I am teaching. I tried using Bokeh server to do the animation and it works fine on my laptop. However, I’m finding the students largely unwilling to try to set up python & bokeh on their own machines (most of which are Windows-based) and running “bokeh serve --show <filename.py>” from the command line. One of my teaching assistants did this and when he showed it to me there was a noticeable lag (seconds) between hitting a button or changing a slider and having the plot respond. I think his laptop is a bit underpowered. When I run it on my laptop I notice that the (internal) network traffic is ~5-7 MBps when I run bokeh serve with the same file. In any case, I’m now looking for a way to put a given interactive visualization/animation into a single html file on a static server that students can point their browser at such that the html file runs on their machines.

I wish I was in a position to make a PR for a future release. However, I think I still have a lot to learn before I can get to that point :-).

Again, I really appreciate your help and suggestions!

On Wednesday, January 20, 2016 at 9:46:32 PM UTC-7, Havoc Pennington wrote:

Collection is no longer used that way in 0.11 as you discovered … I’m not sure what coverage the docs or examples have here, others will know better.

A use of Bokeh.index to get models I know of is

https://github.com/bokeh/bokeh/blob/master/examples/embed/spectrogram/spectrogram.coffee

In 0.11, ideally you would start by finding the bokeh Document instance you care about. It’s reachable from any model in the document as model.document - if you’re in a JS callback, pass any model to the callback then get model.document. If you’re in an arbitrary tag, I don’t remember a clean, supported way to do this (or even to get the Bokeh object, which may load later than your JS in some situations). I’ll suggest some hacks later though.

Once you have the document, the best approach is on the Python side set mydatasource.name=“something”, then in JS do doc.get_model_by_name(“something”). If you instead have the model id there is a get_model_by_id(). Or if you know the document structure you could dig through the document starting from doc.roots().

Hacks to get a document -

There isn’t a global var containing all documents or models anymore, but there is still a Bokeh.index which contains views for all document roots I think, plus I think models that were explicitly passed to show() or file_html()… The views have a model field and models have a document field so as a hack you can get the document that way. Pick any key from Bokeh.index, get its value, get its model field, get the model’s document field.

Another possible hack is to trigger a client-side callback that doesn’t do anything except get passed a model, and then in the callback set a global like window.bokeh_doc to model.document. Then other code can get the document from there. I’m not sure of the easiest way to do a fake self-triggered callback though. Maybe an invisible button. Very bad hack.

Either way I’d suggest use the hack to get Document and then use the Document API to get all the specific models.

The BEST hack of course is to make a PR for a future release adding things like Bokeh.get_document_by_session_id() or Bokeh.get_document_by_title() or Bokeh.get_rendered_documents(). :wink: Tricky bits might include:

  • if a document is no longer rendered or used in an open session, be sure to forget it to avoid a leak
  • multiple document instances can have the same session id if multiple websockets are open
  • document.title can change at any time

There may be other better PR ideas others have. A very simple one could be to be able to add a “Document created” callback, perhaps, and you could set global vars from that callback.

Anyway apologies for the rough edge.

Havoc

On Jan 20, 2016, at 3:48 PM, Greg Nordin [email protected] wrote:

Solved:

In summary

The columndatasource is in window.Bokeh.ColumnDataSource.Collection.models[k].attributes.data, with [k] being the key to the datasource you want

The code

This shows how to access it, presuming you provided a name to the ColumnDataSource when you created it in Python (e.g. source = models.ColumnDataSource(data_dict, name=‘mycolumndatasource’) )

console.log(Bokeh);

var my_source_name = 'mycolumndatasource';
var sources = Bokeh.ColumnDataSource.Collection.models;
var source_keys = Bokeh._.keys(sources)
console.log(source_keys)
for (i = 0; i < source_keys.length; i++) {
var k = source_keys[i];
var source_name = sources[k].[attributes.name](http://attributes.name)
if (source_name == my_source_name) {
   var my_data = sources[k].attributes.data
}

}

console.log(my_data);

Comment

  • Being able to access the data sources from external js is extremely useful to do hybrid Python / Javascript development, as one can rely on Bokeh’s interconnection while using external functionalities
  • Exploring window.Bokeh, I thought all the objects with capital first letter like ColumnDataSource were constructors, did not expect them to contain active collections and models

On Monday, 17 August 2015 16:06:26 UTC+1, Pythonic wrote:

Here is where I am:

_ = Bokeh._

index = window.Bokeh.index

keys = _.keys(index)

plot = Bokeh.index[keys[0]] // index only has 1 key

renderers = plot.model.get(‘renderers’)

console.log(renderers) // this results in “undefined”

Manually exploring the plot object in the log, I find renderers in plot.views.attributes.renderers**,** but none respond to get(‘data_source’) or show any data_source attribute in the console log

I am sure I must be doing some silly error along the line, any suggestion? Many thanks

On Monday, 17 August 2015 15:27:53 UTC+1, Pythonic wrote:

Priceless, many thanks

On Monday, 17 August 2015 15:23:30 UTC+1, Bryan Van de ven wrote:

Hi Giuseppe,

Yes, I forgot the index only contains Plot objects. But each of these has a “renderers” backbone attribute, so you can use

    plot.get('renderers')

to get the list of renderers. One (or more) of these will be a GlyphRenderer, and these are the objects that have a “data_source” backbone attribute:

    renderer.get('data_source')

You can update and trigger this object just as is done in the User Guide examples.

Adding some JS object graph search functions (like the python side has) is on our long TODO list.

Bryan

On Aug 17, 2015, at 1:31 AM, Pythonic [email protected] wrote:

Broadening this question, for mixed Python+JS development it might be useful to understand where to access the Backbone model of the various objects in a page

Two example of reasons to do this:

  • re-rendering objects: for example, if I change the value of a Slider through the callback of another bokeh widget, the slider does not render to the new value and (I presume) I need to access its renderer and give it a nudge
  • modifying data (columndatasources) from JS scripts that take place outside of a Bokeh Callback

By starting at bokeh.index, where should one look for the data sources and the models? [el, model, model.attributes, model.collections,…?]


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/2ac5d5dc-a2f8-4f88-b842-2958e310448c%40continuum.io.

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

I am trying to do something similar where I would like to change the data in a ColumnDataSource using javascript, but I’m having a hard time locating the ColumnDataSource. I generated the attached html file from the attached .py file. When I follow the steps below looking in the html file, I find Bokeh.ColumnDataSource.Collection.models, but it has nothing in it, i.e.

console.log(Bokeh.ColumnDataSource.Collection.models);

returns an empty list:

[] 

Has something changed since August? If so, where can I find documentation or examples?

Thanks,
Greg

On Sunday, August 23, 2015 at 4:16:35 AM UTC-6, Pythonic wrote:

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/75bba408-73bf-45a5-bac6-4bba998b8f99%40continuum.io.

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

<sinusoidal_tline_voltages_test.html>

<sinusoidal_tline_voltages.py>

I get an error using Havoc’s recommendation of named ColumnDataSources (‘on the Python side set mydatasource.name=“something”, then in JS do doc.get_model_by_name(“something”).’ If I have a plot with 2 or more glyphs, I get “Error: Multiple models are named ‘something’”.

You need a different name for each thing you want to pull out - name each model something meaningful.

There’s also an _all_models_by_name._dict private dict where the values can be lists so you can get multiple same-name models. It’s an oversight that there’s no public API to get multiple. In Python the Document.select method exists and can return multiple matches.

Be aware that _all_models and _all_models_by_name are private (leading underscore = implementation detail) so may change in a future release. The public API way to do that would be with names, or to start from roots() and walk through the tree. Though adding a public API to get all models could make sense too, right now there isn’t one.

(simple PR to get started with though!)

And there should be public API to get multiple same-name models. Both needed APIs would be good issues to file.

Havoc

···

On Jan 22, 2016, at 8:10 AM, Jeff Harris [email protected] wrote:

Jeff

On Thursday, January 21, 2016 at 5:10:12 AM UTC, Greg Nordin wrote:

Thanks, Havoc. I really appreciate the information.

I saw the spectrogram.coffee file earlier and went through it, but I don’t know coffeescript yet and decided to look for other approaches rather than doing a crash course in coffeescript. I’m still a noob to javascript so I was thinking I ought to get that nailed down first.

What I am trying to do is avoid needing a server so that the final html file can be run only client side. I need to animate several lines on a graph so I am looking at finding the line data and updating it through javascript callbacks. My main motivation is to create single page html instructional visualizations & animations for a university class I am teaching. I tried using Bokeh server to do the animation and it works fine on my laptop. However, I’m finding the students largely unwilling to try to set up python & bokeh on their own machines (most of which are Windows-based) and running “bokeh serve --show <filename.py>” from the command line. One of my teaching assistants did this and when he showed it to me there was a noticeable lag (seconds) between hitting a button or changing a slider and having the plot respond. I think his laptop is a bit underpowered. When I run it on my laptop I notice that the (internal) network traffic is ~5-7 MBps when I run bokeh serve with the same file. In any case, I’m now looking for a way to put a given interactive visualization/animation into a single html file on a static server that students can point their browser at such that the html file runs on their machines.

I wish I was in a position to make a PR for a future release. However, I think I still have a lot to learn before I can get to that point :-).

Again, I really appreciate your help and suggestions!

On Wednesday, January 20, 2016 at 9:46:32 PM UTC-7, Havoc Pennington wrote:

Collection is no longer used that way in 0.11 as you discovered … I’m not sure what coverage the docs or examples have here, others will know better.

A use of Bokeh.index to get models I know of is

https://github.com/bokeh/bokeh/blob/master/examples/embed/spectrogram/spectrogram.coffee

In 0.11, ideally you would start by finding the bokeh Document instance you care about. It’s reachable from any model in the document as model.document - if you’re in a JS callback, pass any model to the callback then get model.document. If you’re in an arbitrary tag, I don’t remember a clean, supported way to do this (or even to get the Bokeh object, which may load later than your JS in some situations). I’ll suggest some hacks later though.

Once you have the document, the best approach is on the Python side set mydatasource.name=“something”, then in JS do doc.get_model_by_name(“something”). If you instead have the model id there is a get_model_by_id(). Or if you know the document structure you could dig through the document starting from doc.roots().

Hacks to get a document -

There isn’t a global var containing all documents or models anymore, but there is still a Bokeh.index which contains views for all document roots I think, plus I think models that were explicitly passed to show() or file_html()… The views have a model field and models have a document field so as a hack you can get the document that way. Pick any key from Bokeh.index, get its value, get its model field, get the model’s document field.

Another possible hack is to trigger a client-side callback that doesn’t do anything except get passed a model, and then in the callback set a global like window.bokeh_doc to model.document. Then other code can get the document from there. I’m not sure of the easiest way to do a fake self-triggered callback though. Maybe an invisible button. Very bad hack.

Either way I’d suggest use the hack to get Document and then use the Document API to get all the specific models.

The BEST hack of course is to make a PR for a future release adding things like Bokeh.get_document_by_session_id() or Bokeh.get_document_by_title() or Bokeh.get_rendered_documents(). :wink: Tricky bits might include:

  • if a document is no longer rendered or used in an open session, be sure to forget it to avoid a leak
  • multiple document instances can have the same session id if multiple websockets are open
  • document.title can change at any time

There may be other better PR ideas others have. A very simple one could be to be able to add a “Document created” callback, perhaps, and you could set global vars from that callback.

Anyway apologies for the rough edge.

Havoc

On Jan 20, 2016, at 3:48 PM, Greg Nordin [email protected] wrote:

Solved:

In summary

The columndatasource is in window.Bokeh.ColumnDataSource.Collection.models[k].attributes.data, with [k] being the key to the datasource you want

The code

This shows how to access it, presuming you provided a name to the ColumnDataSource when you created it in Python (e.g. source = models.ColumnDataSource(data_dict, name=‘mycolumndatasource’) )

console.log(Bokeh);

var my_source_name = 'mycolumndatasource';
var sources = Bokeh.ColumnDataSource.Collection.models;
var source_keys = Bokeh._.keys(sources)
console.log(source_keys)
for (i = 0; i < source_keys.length; i++) {
var k = source_keys[i];
var source_name = sources[k].[attributes.name](http://attributes.name)
if (source_name == my_source_name) {
   var my_data = sources[k].attributes.data
}

}

console.log(my_data);

Comment

  • Being able to access the data sources from external js is extremely useful to do hybrid Python / Javascript development, as one can rely on Bokeh’s interconnection while using external functionalities
  • Exploring window.Bokeh, I thought all the objects with capital first letter like ColumnDataSource were constructors, did not expect them to contain active collections and models

On Monday, 17 August 2015 16:06:26 UTC+1, Pythonic wrote:

Here is where I am:

_ = Bokeh._

index = window.Bokeh.index

keys = _.keys(index)

plot = Bokeh.index[keys[0]] // index only has 1 key

renderers = plot.model.get(‘renderers’)

console.log(renderers) // this results in “undefined”

Manually exploring the plot object in the log, I find renderers in plot.views.attributes.renderers**,** but none respond to get(‘data_source’) or show any data_source attribute in the console log

I am sure I must be doing some silly error along the line, any suggestion? Many thanks

On Monday, 17 August 2015 15:27:53 UTC+1, Pythonic wrote:

Priceless, many thanks

On Monday, 17 August 2015 15:23:30 UTC+1, Bryan Van de ven wrote:

Hi Giuseppe,

Yes, I forgot the index only contains Plot objects. But each of these has a “renderers” backbone attribute, so you can use

    plot.get('renderers')

to get the list of renderers. One (or more) of these will be a GlyphRenderer, and these are the objects that have a “data_source” backbone attribute:

    renderer.get('data_source')

You can update and trigger this object just as is done in the User Guide examples.

Adding some JS object graph search functions (like the python side has) is on our long TODO list.

Bryan

On Aug 17, 2015, at 1:31 AM, Pythonic [email protected] wrote:

Broadening this question, for mixed Python+JS development it might be useful to understand where to access the Backbone model of the various objects in a page

Two example of reasons to do this:

  • re-rendering objects: for example, if I change the value of a Slider through the callback of another bokeh widget, the slider does not render to the new value and (I presume) I need to access its renderer and give it a nudge
  • modifying data (columndatasources) from JS scripts that take place outside of a Bokeh Callback

By starting at bokeh.index, where should one look for the data sources and the models? [el, model, model.attributes, model.collections,…?]


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/2ac5d5dc-a2f8-4f88-b842-2958e310448c%40continuum.io.

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

I am trying to do something similar where I would like to change the data in a ColumnDataSource using javascript, but I’m having a hard time locating the ColumnDataSource. I generated the attached html file from the attached .py file. When I follow the steps below looking in the html file, I find Bokeh.ColumnDataSource.Collection.models, but it has nothing in it, i.e.

console.log(Bokeh.ColumnDataSource.Collection.models);

returns an empty list:

[] 

Has something changed since August? If so, where can I find documentation or examples?

Thanks,
Greg

On Sunday, August 23, 2015 at 4:16:35 AM UTC-6, Pythonic wrote:

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/75bba408-73bf-45a5-bac6-4bba998b8f99%40continuum.io.

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

<sinusoidal_tline_voltages_test.html>

<sinusoidal_tline_voltages.py>

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/77a3e54f-1473-422a-89ee-232cfdb9592d%40continuum.io.

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

I was contemplating making it so that names had to be unique. Thoughts?

Bryan

···

On Jan 22, 2016, at 09:20, Havoc Pennington [email protected] wrote:

On Jan 22, 2016, at 8:10 AM, Jeff Harris [email protected] wrote:

I get an error using Havoc’s recommendation of named ColumnDataSources (‘on the Python side set mydatasource.name=“something”, then in JS do doc.get_model_by_name(“something”).’ If I have a plot with 2 or more glyphs, I get “Error: Multiple models are named ‘something’”.

You need a different name for each thing you want to pull out - name each model something meaningful.

There’s also an _all_models_by_name._dict private dict where the values can be lists so you can get multiple same-name models. It’s an oversight that there’s no public API to get multiple. In Python the Document.select method exists and can return multiple matches.

Be aware that _all_models and _all_models_by_name are private (leading underscore = implementation detail) so may change in a future release. The public API way to do that would be with names, or to start from roots() and walk through the tree. Though adding a public API to get all models could make sense too, right now there isn’t one.

(simple PR to get started with though!)

And there should be public API to get multiple same-name models. Both needed APIs would be good issues to file.

Havoc

Jeff

On Thursday, January 21, 2016 at 5:10:12 AM UTC, Greg Nordin wrote:

Thanks, Havoc. I really appreciate the information.

I saw the spectrogram.coffee file earlier and went through it, but I don’t know coffeescript yet and decided to look for other approaches rather than doing a crash course in coffeescript. I’m still a noob to javascript so I was thinking I ought to get that nailed down first.

What I am trying to do is avoid needing a server so that the final html file can be run only client side. I need to animate several lines on a graph so I am looking at finding the line data and updating it through javascript callbacks. My main motivation is to create single page html instructional visualizations & animations for a university class I am teaching. I tried using Bokeh server to do the animation and it works fine on my laptop. However, I’m finding the students largely unwilling to try to set up python & bokeh on their own machines (most of which are Windows-based) and running “bokeh serve --show <filename.py>” from the command line. One of my teaching assistants did this and when he showed it to me there was a noticeable lag (seconds) between hitting a button or changing a slider and having the plot respond. I think his laptop is a bit underpowered. When I run it on my laptop I notice that the (internal) network traffic is ~5-7 MBps when I run bokeh serve with the same file. In any case, I’m now looking for a way to put a given interactive visualization/animation into a single html file on a static server that students can point their browser at such that the html file runs on their machines.

I wish I was in a position to make a PR for a future release. However, I think I still have a lot to learn before I can get to that point :-).

Again, I really appreciate your help and suggestions!

On Wednesday, January 20, 2016 at 9:46:32 PM UTC-7, Havoc Pennington wrote:

Collection is no longer used that way in 0.11 as you discovered … I’m not sure what coverage the docs or examples have here, others will know better.

A use of Bokeh.index to get models I know of is

https://github.com/bokeh/bokeh/blob/master/examples/embed/spectrogram/spectrogram.coffee

In 0.11, ideally you would start by finding the bokeh Document instance you care about. It’s reachable from any model in the document as model.document - if you’re in a JS callback, pass any model to the callback then get model.document. If you’re in an arbitrary tag, I don’t remember a clean, supported way to do this (or even to get the Bokeh object, which may load later than your JS in some situations). I’ll suggest some hacks later though.

Once you have the document, the best approach is on the Python side set mydatasource.name=“something”, then in JS do doc.get_model_by_name(“something”). If you instead have the model id there is a get_model_by_id(). Or if you know the document structure you could dig through the document starting from doc.roots().

Hacks to get a document -

There isn’t a global var containing all documents or models anymore, but there is still a Bokeh.index which contains views for all document roots I think, plus I think models that were explicitly passed to show() or file_html()… The views have a model field and models have a document field so as a hack you can get the document that way. Pick any key from Bokeh.index, get its value, get its model field, get the model’s document field.

Another possible hack is to trigger a client-side callback that doesn’t do anything except get passed a model, and then in the callback set a global like window.bokeh_doc to model.document. Then other code can get the document from there. I’m not sure of the easiest way to do a fake self-triggered callback though. Maybe an invisible button. Very bad hack.

Either way I’d suggest use the hack to get Document and then use the Document API to get all the specific models.

The BEST hack of course is to make a PR for a future release adding things like Bokeh.get_document_by_session_id() or Bokeh.get_document_by_title() or Bokeh.get_rendered_documents(). :wink: Tricky bits might include:

  • if a document is no longer rendered or used in an open session, be sure to forget it to avoid a leak
  • multiple document instances can have the same session id if multiple websockets are open
  • document.title can change at any time

There may be other better PR ideas others have. A very simple one could be to be able to add a “Document created” callback, perhaps, and you could set global vars from that callback.

Anyway apologies for the rough edge.

Havoc

On Jan 20, 2016, at 3:48 PM, Greg Nordin [email protected] wrote:

Solved:

In summary

The columndatasource is in window.Bokeh.ColumnDataSource.Collection.models[k].attributes.data, with [k] being the key to the datasource you want

The code

This shows how to access it, presuming you provided a name to the ColumnDataSource when you created it in Python (e.g. source = models.ColumnDataSource(data_dict, name=‘mycolumndatasource’) )

console.log(Bokeh);

var my_source_name = 'mycolumndatasource';
var sources = Bokeh.ColumnDataSource.Collection.models;
var source_keys = Bokeh._.keys(sources)
console.log(source_keys)
for (i = 0; i < source_keys.length; i++) {
var k = source_keys[i];
var source_name = sources[k].[attributes.name](http://attributes.name)
if (source_name == my_source_name) {
   var my_data = sources[k].attributes.data
}

}

console.log(my_data);

Comment

  • Being able to access the data sources from external js is extremely useful to do hybrid Python / Javascript development, as one can rely on Bokeh’s interconnection while using external functionalities
  • Exploring window.Bokeh, I thought all the objects with capital first letter like ColumnDataSource were constructors, did not expect them to contain active collections and models

On Monday, 17 August 2015 16:06:26 UTC+1, Pythonic wrote:

Here is where I am:

_ = Bokeh._

index = window.Bokeh.index

keys = _.keys(index)

plot = Bokeh.index[keys[0]] // index only has 1 key

renderers = plot.model.get(‘renderers’)

console.log(renderers) // this results in “undefined”

Manually exploring the plot object in the log, I find renderers in plot.views.attributes.renderers**,** but none respond to get(‘data_source’) or show any data_source attribute in the console log

I am sure I must be doing some silly error along the line, any suggestion? Many thanks

On Monday, 17 August 2015 15:27:53 UTC+1, Pythonic wrote:

Priceless, many thanks

On Monday, 17 August 2015 15:23:30 UTC+1, Bryan Van de ven wrote:

Hi Giuseppe,

Yes, I forgot the index only contains Plot objects. But each of these has a “renderers” backbone attribute, so you can use

    plot.get('renderers')

to get the list of renderers. One (or more) of these will be a GlyphRenderer, and these are the objects that have a “data_source” backbone attribute:

    renderer.get('data_source')

You can update and trigger this object just as is done in the User Guide examples.

Adding some JS object graph search functions (like the python side has) is on our long TODO list.

Bryan

On Aug 17, 2015, at 1:31 AM, Pythonic [email protected] wrote:

Broadening this question, for mixed Python+JS development it might be useful to understand where to access the Backbone model of the various objects in a page

Two example of reasons to do this:

  • re-rendering objects: for example, if I change the value of a Slider through the callback of another bokeh widget, the slider does not render to the new value and (I presume) I need to access its renderer and give it a nudge
  • modifying data (columndatasources) from JS scripts that take place outside of a Bokeh Callback

By starting at bokeh.index, where should one look for the data sources and the models? [el, model, model.attributes, model.collections,…?]


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/2ac5d5dc-a2f8-4f88-b842-2958e310448c%40continuum.io.

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

I am trying to do something similar where I would like to change the data in a ColumnDataSource using javascript, but I’m having a hard time locating the ColumnDataSource. I generated the attached html file from the attached .py file. When I follow the steps below looking in the html file, I find Bokeh.ColumnDataSource.Collection.models, but it has nothing in it, i.e.

console.log(Bokeh.ColumnDataSource.Collection.models);

returns an empty list:

[] 

Has something changed since August? If so, where can I find documentation or examples?

Thanks,
Greg

On Sunday, August 23, 2015 at 4:16:35 AM UTC-6, Pythonic wrote:

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/75bba408-73bf-45a5-bac6-4bba998b8f99%40continuum.io.

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

<sinusoidal_tline_voltages_test.html>

<sinusoidal_tline_voltages.py>

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/77a3e54f-1473-422a-89ee-232cfdb9592d%40continuum.io.

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

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/06532E36-5A94-4C2D-A23A-D949009F9770%40continuum.io.

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

I already implemented then un-implemented that :slight_smile: https://github.com/bokeh/bokeh/pull/3112#issuecomment-156885135

If you wanted to require uniqueness the commits where I added that error are simple to restore. But I think you were probably right before, it’s fine to require names to be unique only at the point where someone does a get_model_by_name (because then they’ve assumed uniqueness by asking for a single model). So it’s good as is to me.

Havoc

···

On Jan 22, 2016, at 10:38 AM, Bryan Van de Ven [email protected] wrote:

I was contemplating making it so that names had to be unique. Thoughts?

Bryan

On Jan 22, 2016, at 09:20, Havoc Pennington [email protected] wrote:

On Jan 22, 2016, at 8:10 AM, Jeff Harris [email protected] wrote:

I get an error using Havoc’s recommendation of named ColumnDataSources (‘on the Python side set mydatasource.name=“something”, then in JS do doc.get_model_by_name(“something”).’ If I have a plot with 2 or more glyphs, I get “Error: Multiple models are named ‘something’”.

You need a different name for each thing you want to pull out - name each model something meaningful.

There’s also an _all_models_by_name._dict private dict where the values can be lists so you can get multiple same-name models. It’s an oversight that there’s no public API to get multiple. In Python the Document.select method exists and can return multiple matches.

Be aware that _all_models and _all_models_by_name are private (leading underscore = implementation detail) so may change in a future release. The public API way to do that would be with names, or to start from roots() and walk through the tree. Though adding a public API to get all models could make sense too, right now there isn’t one.

(simple PR to get started with though!)

And there should be public API to get multiple same-name models. Both needed APIs would be good issues to file.

Havoc

Jeff

On Thursday, January 21, 2016 at 5:10:12 AM UTC, Greg Nordin wrote:

Thanks, Havoc. I really appreciate the information.

I saw the spectrogram.coffee file earlier and went through it, but I don’t know coffeescript yet and decided to look for other approaches rather than doing a crash course in coffeescript. I’m still a noob to javascript so I was thinking I ought to get that nailed down first.

What I am trying to do is avoid needing a server so that the final html file can be run only client side. I need to animate several lines on a graph so I am looking at finding the line data and updating it through javascript callbacks. My main motivation is to create single page html instructional visualizations & animations for a university class I am teaching. I tried using Bokeh server to do the animation and it works fine on my laptop. However, I’m finding the students largely unwilling to try to set up python & bokeh on their own machines (most of which are Windows-based) and running “bokeh serve --show <filename.py>” from the command line. One of my teaching assistants did this and when he showed it to me there was a noticeable lag (seconds) between hitting a button or changing a slider and having the plot respond. I think his laptop is a bit underpowered. When I run it on my laptop I notice that the (internal) network traffic is ~5-7 MBps when I run bokeh serve with the same file. In any case, I’m now looking for a way to put a given interactive visualization/animation into a single html file on a static server that students can point their browser at such that the html file runs on their machines.

I wish I was in a position to make a PR for a future release. However, I think I still have a lot to learn before I can get to that point :-).

Again, I really appreciate your help and suggestions!

On Wednesday, January 20, 2016 at 9:46:32 PM UTC-7, Havoc Pennington wrote:

Collection is no longer used that way in 0.11 as you discovered … I’m not sure what coverage the docs or examples have here, others will know better.

A use of Bokeh.index to get models I know of is

https://github.com/bokeh/bokeh/blob/master/examples/embed/spectrogram/spectrogram.coffee

In 0.11, ideally you would start by finding the bokeh Document instance you care about. It’s reachable from any model in the document as model.document - if you’re in a JS callback, pass any model to the callback then get model.document. If you’re in an arbitrary tag, I don’t remember a clean, supported way to do this (or even to get the Bokeh object, which may load later than your JS in some situations). I’ll suggest some hacks later though.

Once you have the document, the best approach is on the Python side set mydatasource.name=“something”, then in JS do doc.get_model_by_name(“something”). If you instead have the model id there is a get_model_by_id(). Or if you know the document structure you could dig through the document starting from doc.roots().

Hacks to get a document -

There isn’t a global var containing all documents or models anymore, but there is still a Bokeh.index which contains views for all document roots I think, plus I think models that were explicitly passed to show() or file_html()… The views have a model field and models have a document field so as a hack you can get the document that way. Pick any key from Bokeh.index, get its value, get its model field, get the model’s document field.

Another possible hack is to trigger a client-side callback that doesn’t do anything except get passed a model, and then in the callback set a global like window.bokeh_doc to model.document. Then other code can get the document from there. I’m not sure of the easiest way to do a fake self-triggered callback though. Maybe an invisible button. Very bad hack.

Either way I’d suggest use the hack to get Document and then use the Document API to get all the specific models.

The BEST hack of course is to make a PR for a future release adding things like Bokeh.get_document_by_session_id() or Bokeh.get_document_by_title() or Bokeh.get_rendered_documents(). :wink: Tricky bits might include:

  • if a document is no longer rendered or used in an open session, be sure to forget it to avoid a leak
  • multiple document instances can have the same session id if multiple websockets are open
  • document.title can change at any time

There may be other better PR ideas others have. A very simple one could be to be able to add a “Document created” callback, perhaps, and you could set global vars from that callback.

Anyway apologies for the rough edge.

Havoc

On Jan 20, 2016, at 3:48 PM, Greg Nordin [email protected] wrote:

Solved:

In summary

The columndatasource is in window.Bokeh.ColumnDataSource.Collection.models[k].attributes.data, with [k] being the key to the datasource you want

The code

This shows how to access it, presuming you provided a name to the ColumnDataSource when you created it in Python (e.g. source = models.ColumnDataSource(data_dict, name=‘mycolumndatasource’) )

console.log(Bokeh);

var my_source_name = 'mycolumndatasource';
var sources = Bokeh.ColumnDataSource.Collection.models;
var source_keys = Bokeh._.keys(sources)
console.log(source_keys)
for (i = 0; i < source_keys.length; i++) {
var k = source_keys[i];
var source_name = sources[k].[attributes.name](http://attributes.name)
if (source_name == my_source_name) {
   var my_data = sources[k].attributes.data
}

}

console.log(my_data);

Comment

  • Being able to access the data sources from external js is extremely useful to do hybrid Python / Javascript development, as one can rely on Bokeh’s interconnection while using external functionalities
  • Exploring window.Bokeh, I thought all the objects with capital first letter like ColumnDataSource were constructors, did not expect them to contain active collections and models

On Monday, 17 August 2015 16:06:26 UTC+1, Pythonic wrote:

Here is where I am:

_ = Bokeh._

index = window.Bokeh.index

keys = _.keys(index)

plot = Bokeh.index[keys[0]] // index only has 1 key

renderers = plot.model.get(‘renderers’)

console.log(renderers) // this results in “undefined”

Manually exploring the plot object in the log, I find renderers in plot.views.attributes.renderers**,** but none respond to get(‘data_source’) or show any data_source attribute in the console log

I am sure I must be doing some silly error along the line, any suggestion? Many thanks

On Monday, 17 August 2015 15:27:53 UTC+1, Pythonic wrote:

Priceless, many thanks

On Monday, 17 August 2015 15:23:30 UTC+1, Bryan Van de ven wrote:

Hi Giuseppe,

Yes, I forgot the index only contains Plot objects. But each of these has a “renderers” backbone attribute, so you can use

    plot.get('renderers')

to get the list of renderers. One (or more) of these will be a GlyphRenderer, and these are the objects that have a “data_source” backbone attribute:

    renderer.get('data_source')

You can update and trigger this object just as is done in the User Guide examples.

Adding some JS object graph search functions (like the python side has) is on our long TODO list.

Bryan

On Aug 17, 2015, at 1:31 AM, Pythonic [email protected] wrote:

Broadening this question, for mixed Python+JS development it might be useful to understand where to access the Backbone model of the various objects in a page

Two example of reasons to do this:

  • re-rendering objects: for example, if I change the value of a Slider through the callback of another bokeh widget, the slider does not render to the new value and (I presume) I need to access its renderer and give it a nudge
  • modifying data (columndatasources) from JS scripts that take place outside of a Bokeh Callback

By starting at bokeh.index, where should one look for the data sources and the models? [el, model, model.attributes, model.collections,…?]


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/2ac5d5dc-a2f8-4f88-b842-2958e310448c%40continuum.io.

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

I am trying to do something similar where I would like to change the data in a ColumnDataSource using javascript, but I’m having a hard time locating the ColumnDataSource. I generated the attached html file from the attached .py file. When I follow the steps below looking in the html file, I find Bokeh.ColumnDataSource.Collection.models, but it has nothing in it, i.e.

console.log(Bokeh.ColumnDataSource.Collection.models);

returns an empty list:

[] 

Has something changed since August? If so, where can I find documentation or examples?

Thanks,
Greg

On Sunday, August 23, 2015 at 4:16:35 AM UTC-6, Pythonic wrote:

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/75bba408-73bf-45a5-bac6-4bba998b8f99%40continuum.io.

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

<sinusoidal_tline_voltages_test.html>

<sinusoidal_tline_voltages.py>

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/77a3e54f-1473-422a-89ee-232cfdb9592d%40continuum.io.

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

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/06532E36-5A94-4C2D-A23A-D949009F9770%40continuum.io.

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

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/45BC4982-6741-44C6-888D-C6F075018D96%40continuum.io.

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

I might not be explaining this correctly, understand the feedback, or am doing this wrong.

In Python I have a single ColumnDataSource defined that’s used as the source for 2 glyphs:

x = list(range(-20, 21))
y = [abs(xx) for xx in x]
source = ColumnDataSource(data=dict(x=x, y=y),name=‘something’)
p = figure(tools=TOOLS, width=300, height=300)
p.circle(‘x’, ‘y0’, source=source)
p.line(‘x’, ‘y0’, source=source)
show(p)

``

In Javascript I am unable to get the single ColumnDataSource by name as it appears multiple times:

var source_name = ‘something’;

var plot_ids = Bokeh._.keys(Bokeh.index)

for (i = 0; i < plot_ids.length; i++) {

var plot = Bokeh.index[plot_ids[i]]

var d = plot.model.document.get_model_by_name(source_name) // error here.

if( d != null ) {

	my_data = d.attributes.data

}

}

Bokeh 0.11.0; Safari browser; generating plot from spyder 2.3.8; python 3.5 environment.

If there is only a single glyph on the plot the above works, but fails with 2 or more glyphs referencing the same ColumnDataSource.

···

On Friday, January 22, 2016 at 3:38:12 PM UTC, Bryan Van de ven wrote:

I was contemplating making it so that names had to be unique. Thoughts?

Bryan

On Jan 22, 2016, at 09:20, Havoc Pennington [email protected] wrote:

On Jan 22, 2016, at 8:10 AM, Jeff Harris [email protected] wrote:

I get an error using Havoc’s recommendation of named ColumnDataSources (‘on the Python side set mydatasource.name=“something”, then in JS do doc.get_model_by_name(“something”).’ If I have a plot with 2 or more glyphs, I get “Error: Multiple models are named ‘something’”.

You need a different name for each thing you want to pull out - name each model something meaningful.

There’s also an _all_models_by_name._dict private dict where the values can be lists so you can get multiple same-name models. It’s an oversight that there’s no public API to get multiple. In Python the Document.select method exists and can return multiple matches.

Be aware that _all_models and _all_models_by_name are private (leading underscore = implementation detail) so may change in a future release. The public API way to do that would be with names, or to start from roots() and walk through the tree. Though adding a public API to get all models could make sense too, right now there isn’t one.

(simple PR to get started with though!)

And there should be public API to get multiple same-name models. Both needed APIs would be good issues to file.

Havoc

Jeff

On Thursday, January 21, 2016 at 5:10:12 AM UTC, Greg Nordin wrote:

Thanks, Havoc. I really appreciate the information.

I saw the spectrogram.coffee file earlier and went through it, but I don’t know coffeescript yet and decided to look for other approaches rather than doing a crash course in coffeescript. I’m still a noob to javascript so I was thinking I ought to get that nailed down first.

What I am trying to do is avoid needing a server so that the final html file can be run only client side. I need to animate several lines on a graph so I am looking at finding the line data and updating it through javascript callbacks. My main motivation is to create single page html instructional visualizations & animations for a university class I am teaching. I tried using Bokeh server to do the animation and it works fine on my laptop. However, I’m finding the students largely unwilling to try to set up python & bokeh on their own machines (most of which are Windows-based) and running “bokeh serve --show <filename.py>” from the command line. One of my teaching assistants did this and when he showed it to me there was a noticeable lag (seconds) between hitting a button or changing a slider and having the plot respond. I think his laptop is a bit underpowered. When I run it on my laptop I notice that the (internal) network traffic is ~5-7 MBps when I run bokeh serve with the same file. In any case, I’m now looking for a way to put a given interactive visualization/animation into a single html file on a static server that students can point their browser at such that the html file runs on their machines.

I wish I was in a position to make a PR for a future release. However, I think I still have a lot to learn before I can get to that point :-).

Again, I really appreciate your help and suggestions!

On Wednesday, January 20, 2016 at 9:46:32 PM UTC-7, Havoc Pennington wrote:

Collection is no longer used that way in 0.11 as you discovered … I’m not sure what coverage the docs or examples have here, others will know better.

A use of Bokeh.index to get models I know of is

https://github.com/bokeh/bokeh/blob/master/examples/embed/spectrogram/spectrogram.coffee

In 0.11, ideally you would start by finding the bokeh Document instance you care about. It’s reachable from any model in the document as model.document - if you’re in a JS callback, pass any model to the callback then get model.document. If you’re in an arbitrary tag, I don’t remember a clean, supported way to do this (or even to get the Bokeh object, which may load later than your JS in some situations). I’ll suggest some hacks later though.

Once you have the document, the best approach is on the Python side set mydatasource.name=“something”, then in JS do doc.get_model_by_name(“something”). If you instead have the model id there is a get_model_by_id(). Or if you know the document structure you could dig through the document starting from doc.roots().

Hacks to get a document -

There isn’t a global var containing all documents or models anymore, but there is still a Bokeh.index which contains views for all document roots I think, plus I think models that were explicitly passed to show() or file_html()… The views have a model field and models have a document field so as a hack you can get the document that way. Pick any key from Bokeh.index, get its value, get its model field, get the model’s document field.

Another possible hack is to trigger a client-side callback that doesn’t do anything except get passed a model, and then in the callback set a global like window.bokeh_doc to model.document. Then other code can get the document from there. I’m not sure of the easiest way to do a fake self-triggered callback though. Maybe an invisible button. Very bad hack.

Either way I’d suggest use the hack to get Document and then use the Document API to get all the specific models.

The BEST hack of course is to make a PR for a future release adding things like Bokeh.get_document_by_session_id() or Bokeh.get_document_by_title() or Bokeh.get_rendered_documents(). :wink: Tricky bits might include:

  • if a document is no longer rendered or used in an open session, be sure to forget it to avoid a leak
  • multiple document instances can have the same session id if multiple websockets are open
  • document.title can change at any time

There may be other better PR ideas others have. A very simple one could be to be able to add a “Document created” callback, perhaps, and you could set global vars from that callback.

Anyway apologies for the rough edge.

Havoc

On Jan 20, 2016, at 3:48 PM, Greg Nordin [email protected] wrote:

Solved:

In summary

The columndatasource is in window.Bokeh.ColumnDataSource.Collection.models[k].attributes.data, with [k] being the key to the datasource you want

The code

This shows how to access it, presuming you provided a name to the ColumnDataSource when you created it in Python (e.g. source = models.ColumnDataSource(data_dict, name=‘mycolumndatasource’) )

console.log(Bokeh);

var my_source_name = 'mycolumndatasource';
var sources = Bokeh.ColumnDataSource.Collection.models;
var source_keys = Bokeh._.keys(sources)
console.log(source_keys)
for (i = 0; i < source_keys.length; i++) {
var k = source_keys[i];
var source_name = sources[k].[attributes.name](http://attributes.name)
if (source_name == my_source_name) {
   var my_data = sources[k].attributes.data
}

}

console.log(my_data);

Comment

  • Being able to access the data sources from external js is extremely useful to do hybrid Python / Javascript development, as one can rely on Bokeh’s interconnection while using external functionalities
  • Exploring window.Bokeh, I thought all the objects with capital first letter like ColumnDataSource were constructors, did not expect them to contain active collections and models

On Monday, 17 August 2015 16:06:26 UTC+1, Pythonic wrote:

Here is where I am:

_ = Bokeh._

index = window.Bokeh.index

keys = _.keys(index)

plot = Bokeh.index[keys[0]] // index only has 1 key

renderers = plot.model.get(‘renderers’)

console.log(renderers) // this results in “undefined”

Manually exploring the plot object in the log, I find renderers in plot.views.attributes.renderers**,** but none respond to get(‘data_source’) or show any data_source attribute in the console log

I am sure I must be doing some silly error along the line, any suggestion? Many thanks

On Monday, 17 August 2015 15:27:53 UTC+1, Pythonic wrote:

Priceless, many thanks

On Monday, 17 August 2015 15:23:30 UTC+1, Bryan Van de ven wrote:

Hi Giuseppe,

Yes, I forgot the index only contains Plot objects. But each of these has a “renderers” backbone attribute, so you can use

    plot.get('renderers')

to get the list of renderers. One (or more) of these will be a GlyphRenderer, and these are the objects that have a “data_source” backbone attribute:

    renderer.get('data_source')

You can update and trigger this object just as is done in the User Guide examples.

Adding some JS object graph search functions (like the python side has) is on our long TODO list.

Bryan

On Aug 17, 2015, at 1:31 AM, Pythonic [email protected] wrote:

Broadening this question, for mixed Python+JS development it might be useful to understand where to access the Backbone model of the various objects in a page

Two example of reasons to do this:

  • re-rendering objects: for example, if I change the value of a Slider through the callback of another bokeh widget, the slider does not render to the new value and (I presume) I need to access its renderer and give it a nudge
  • modifying data (columndatasources) from JS scripts that take place outside of a Bokeh Callback

By starting at bokeh.index, where should one look for the data sources and the models? [el, model, model.attributes, model.collections,…?]


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/2ac5d5dc-a2f8-4f88-b842-2958e310448c%40continuum.io.

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

I am trying to do something similar where I would like to change the data in a ColumnDataSource using javascript, but I’m having a hard time locating the ColumnDataSource. I generated the attached html file from the attached .py file. When I follow the steps below looking in the html file, I find Bokeh.ColumnDataSource.Collection.models, but it has nothing in it, i.e.

console.log(Bokeh.ColumnDataSource.Collection.models);

returns an empty list:

[] 

Has something changed since August? If so, where can I find documentation or examples?

Thanks,
Greg

On Sunday, August 23, 2015 at 4:16:35 AM UTC-6, Pythonic wrote:

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/75bba408-73bf-45a5-bac6-4bba998b8f99%40continuum.io.

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

<sinusoidal_tline_voltages_test.html>

<sinusoidal_tline_voltages.py>

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/77a3e54f-1473-422a-89ee-232cfdb9592d%40continuum.io.

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

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/06532E36-5A94-4C2D-A23A-D949009F9770%40continuum.io.

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

Oh - that looks like a bug, we must add the same model to _all_models_by_name twice. Are you willing to file an issue on GitHub?

Workaround would be to access _all_models_by_name directly.

Havoc

···

On Jan 22, 2016, at 12:55 PM, Jeff Harris [email protected] wrote:

I might not be explaining this correctly, understand the feedback, or am doing this wrong.

In Python I have a single ColumnDataSource defined that’s used as the source for 2 glyphs:

x = list(range(-20, 21))
y = [abs(xx) for xx in x]
source = ColumnDataSource(data=dict(x=x, y=y),name=‘something’)
p = figure(tools=TOOLS, width=300, height=300)
p.circle(‘x’, ‘y0’, source=source)
p.line(‘x’, ‘y0’, source=source)
show(p)

``

In Javascript I am unable to get the single ColumnDataSource by name as it appears multiple times:

var source_name = ‘something’;

var plot_ids = Bokeh._.keys(Bokeh.index)

for (i = 0; i < plot_ids.length; i++) {

var plot = Bokeh.index[plot_ids[i]]

var d = plot.model.document.get_model_by_name(source_name) // error here.

if( d != null ) {

  my_data = d.attributes.data

}

}

Bokeh 0.11.0; Safari browser; generating plot from spyder 2.3.8; python 3.5 environment.

If there is only a single glyph on the plot the above works, but fails with 2 or more glyphs referencing the same ColumnDataSource.

On Friday, January 22, 2016 at 3:38:12 PM UTC, Bryan Van de ven wrote:

I was contemplating making it so that names had to be unique. Thoughts?

Bryan

On Jan 22, 2016, at 09:20, Havoc Pennington [email protected] wrote:

On Jan 22, 2016, at 8:10 AM, Jeff Harris [email protected] wrote:

I get an error using Havoc’s recommendation of named ColumnDataSources (‘on the Python side set mydatasource.name=“something”, then in JS do doc.get_model_by_name(“something”).’ If I have a plot with 2 or more glyphs, I get “Error: Multiple models are named ‘something’”.

You need a different name for each thing you want to pull out - name each model something meaningful.

There’s also an _all_models_by_name._dict private dict where the values can be lists so you can get multiple same-name models. It’s an oversight that there’s no public API to get multiple. In Python the Document.select method exists and can return multiple matches.

Be aware that _all_models and _all_models_by_name are private (leading underscore = implementation detail) so may change in a future release. The public API way to do that would be with names, or to start from roots() and walk through the tree. Though adding a public API to get all models could make sense too, right now there isn’t one.

(simple PR to get started with though!)

And there should be public API to get multiple same-name models. Both needed APIs would be good issues to file.

Havoc

Jeff

On Thursday, January 21, 2016 at 5:10:12 AM UTC, Greg Nordin wrote:

Thanks, Havoc. I really appreciate the information.

I saw the spectrogram.coffee file earlier and went through it, but I don’t know coffeescript yet and decided to look for other approaches rather than doing a crash course in coffeescript. I’m still a noob to javascript so I was thinking I ought to get that nailed down first.

What I am trying to do is avoid needing a server so that the final html file can be run only client side. I need to animate several lines on a graph so I am looking at finding the line data and updating it through javascript callbacks. My main motivation is to create single page html instructional visualizations & animations for a university class I am teaching. I tried using Bokeh server to do the animation and it works fine on my laptop. However, I’m finding the students largely unwilling to try to set up python & bokeh on their own machines (most of which are Windows-based) and running “bokeh serve --show <filename.py>” from the command line. One of my teaching assistants did this and when he showed it to me there was a noticeable lag (seconds) between hitting a button or changing a slider and having the plot respond. I think his laptop is a bit underpowered. When I run it on my laptop I notice that the (internal) network traffic is ~5-7 MBps when I run bokeh serve with the same file. In any case, I’m now looking for a way to put a given interactive visualization/animation into a single html file on a static server that students can point their browser at such that the html file runs on their machines.

I wish I was in a position to make a PR for a future release. However, I think I still have a lot to learn before I can get to that point :-).

Again, I really appreciate your help and suggestions!

On Wednesday, January 20, 2016 at 9:46:32 PM UTC-7, Havoc Pennington wrote:

Collection is no longer used that way in 0.11 as you discovered … I’m not sure what coverage the docs or examples have here, others will know better.

A use of Bokeh.index to get models I know of is

https://github.com/bokeh/bokeh/blob/master/examples/embed/spectrogram/spectrogram.coffee

In 0.11, ideally you would start by finding the bokeh Document instance you care about. It’s reachable from any model in the document as model.document - if you’re in a JS callback, pass any model to the callback then get model.document. If you’re in an arbitrary tag, I don’t remember a clean, supported way to do this (or even to get the Bokeh object, which may load later than your JS in some situations). I’ll suggest some hacks later though.

Once you have the document, the best approach is on the Python side set mydatasource.name=“something”, then in JS do doc.get_model_by_name(“something”). If you instead have the model id there is a get_model_by_id(). Or if you know the document structure you could dig through the document starting from doc.roots().

Hacks to get a document -

There isn’t a global var containing all documents or models anymore, but there is still a Bokeh.index which contains views for all document roots I think, plus I think models that were explicitly passed to show() or file_html()… The views have a model field and models have a document field so as a hack you can get the document that way. Pick any key from Bokeh.index, get its value, get its model field, get the model’s document field.

Another possible hack is to trigger a client-side callback that doesn’t do anything except get passed a model, and then in the callback set a global like window.bokeh_doc to model.document. Then other code can get the document from there. I’m not sure of the easiest way to do a fake self-triggered callback though. Maybe an invisible button. Very bad hack.

Either way I’d suggest use the hack to get Document and then use the Document API to get all the specific models.

The BEST hack of course is to make a PR for a future release adding things like Bokeh.get_document_by_session_id() or Bokeh.get_document_by_title() or Bokeh.get_rendered_documents(). :wink: Tricky bits might include:

  • if a document is no longer rendered or used in an open session, be sure to forget it to avoid a leak
  • multiple document instances can have the same session id if multiple websockets are open
  • document.title can change at any time

There may be other better PR ideas others have. A very simple one could be to be able to add a “Document created” callback, perhaps, and you could set global vars from that callback.

Anyway apologies for the rough edge.

Havoc

On Jan 20, 2016, at 3:48 PM, Greg Nordin [email protected] wrote:

Solved:

In summary

The columndatasource is in window.Bokeh.ColumnDataSource.Collection.models[k].attributes.data, with [k] being the key to the datasource you want

The code

This shows how to access it, presuming you provided a name to the ColumnDataSource when you created it in Python (e.g. source = models.ColumnDataSource(data_dict, name=‘mycolumndatasource’) )

console.log(Bokeh);

var my_source_name = 'mycolumndatasource';
var sources = Bokeh.ColumnDataSource.Collection.models;
var source_keys = Bokeh._.keys(sources)
console.log(source_keys)
for (i = 0; i < source_keys.length; i++) {
var k = source_keys[i];
var source_name = sources[k].[attributes.name](http://attributes.name)
if (source_name == my_source_name) {
   var my_data = sources[k].attributes.data
}

}

console.log(my_data);

Comment

  • Being able to access the data sources from external js is extremely useful to do hybrid Python / Javascript development, as one can rely on Bokeh’s interconnection while using external functionalities
  • Exploring window.Bokeh, I thought all the objects with capital first letter like ColumnDataSource were constructors, did not expect them to contain active collections and models

On Monday, 17 August 2015 16:06:26 UTC+1, Pythonic wrote:

Here is where I am:

_ = Bokeh._

index = window.Bokeh.index

keys = _.keys(index)

plot = Bokeh.index[keys[0]] // index only has 1 key

renderers = plot.model.get(‘renderers’)

console.log(renderers) // this results in “undefined”

Manually exploring the plot object in the log, I find renderers in plot.views.attributes.renderers**,** but none respond to get(‘data_source’) or show any data_source attribute in the console log

I am sure I must be doing some silly error along the line, any suggestion? Many thanks

On Monday, 17 August 2015 15:27:53 UTC+1, Pythonic wrote:

Priceless, many thanks

On Monday, 17 August 2015 15:23:30 UTC+1, Bryan Van de ven wrote:

Hi Giuseppe,

Yes, I forgot the index only contains Plot objects. But each of these has a “renderers” backbone attribute, so you can use

    plot.get('renderers')

to get the list of renderers. One (or more) of these will be a GlyphRenderer, and these are the objects that have a “data_source” backbone attribute:

    renderer.get('data_source')

You can update and trigger this object just as is done in the User Guide examples.

Adding some JS object graph search functions (like the python side has) is on our long TODO list.

Bryan

On Aug 17, 2015, at 1:31 AM, Pythonic [email protected] wrote:

Broadening this question, for mixed Python+JS development it might be useful to understand where to access the Backbone model of the various objects in a page

Two example of reasons to do this:

  • re-rendering objects: for example, if I change the value of a Slider through the callback of another bokeh widget, the slider does not render to the new value and (I presume) I need to access its renderer and give it a nudge
  • modifying data (columndatasources) from JS scripts that take place outside of a Bokeh Callback

By starting at bokeh.index, where should one look for the data sources and the models? [el, model, model.attributes, model.collections,…?]


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/2ac5d5dc-a2f8-4f88-b842-2958e310448c%40continuum.io.

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

I am trying to do something similar where I would like to change the data in a ColumnDataSource using javascript, but I’m having a hard time locating the ColumnDataSource. I generated the attached html file from the attached .py file. When I follow the steps below looking in the html file, I find Bokeh.ColumnDataSource.Collection.models, but it has nothing in it, i.e.

console.log(Bokeh.ColumnDataSource.Collection.models);

returns an empty list:

[] 

Has something changed since August? If so, where can I find documentation or examples?

Thanks,
Greg

On Sunday, August 23, 2015 at 4:16:35 AM UTC-6, Pythonic wrote:

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/75bba408-73bf-45a5-bac6-4bba998b8f99%40continuum.io.

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

<sinusoidal_tline_voltages_test.html>

<sinusoidal_tline_voltages.py>

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/77a3e54f-1473-422a-89ee-232cfdb9592d%40continuum.io.

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

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/06532E36-5A94-4C2D-A23A-D949009F9770%40continuum.io.

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

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/00e14bad-ffbc-49bf-bbde-cd28d6b852d9%40continuum.io.

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

Yes, but not at computer at the moment.

···

On Jan 22, 2016, at 6:03 PM, Havoc Pennington [email protected] wrote:

Oh - that looks like a bug, we must add the same model to _all_models_by_name twice. Are you willing to file an issue on GitHub?

Workaround would be to access _all_models_by_name directly.

Havoc

On Jan 22, 2016, at 12:55 PM, Jeff Harris [email protected] wrote:

I might not be explaining this correctly, understand the feedback, or am doing this wrong.

In Python I have a single ColumnDataSource defined that’s used as the source for 2 glyphs:

x = list(range(-20, 21))
y = [abs(xx) for xx in x]
source = ColumnDataSource(data=dict(x=x, y=y),name=‘something’)
p = figure(tools=TOOLS, width=300, height=300)
p.circle(‘x’, ‘y0’, source=source)
p.line(‘x’, ‘y0’, source=source)
show(p)

``

In Javascript I am unable to get the single ColumnDataSource by name as it appears multiple times:

var source_name = ‘something’;

var plot_ids = Bokeh._.keys(Bokeh.index)

for (i = 0; i < plot_ids.length; i++) {

var plot = Bokeh.index[plot_ids[i]]

var d = plot.model.document.get_model_by_name(source_name) // error here.

if( d != null ) {

  my_data = d.attributes.data

}

}

Bokeh 0.11.0; Safari browser; generating plot from spyder 2.3.8; python 3.5 environment.

If there is only a single glyph on the plot the above works, but fails with 2 or more glyphs referencing the same ColumnDataSource.

On Friday, January 22, 2016 at 3:38:12 PM UTC, Bryan Van de ven wrote:

I was contemplating making it so that names had to be unique. Thoughts?

Bryan

On Jan 22, 2016, at 09:20, Havoc Pennington [email protected] wrote:

On Jan 22, 2016, at 8:10 AM, Jeff Harris [email protected] wrote:

I get an error using Havoc’s recommendation of named ColumnDataSources (‘on the Python side set mydatasource.name=“something”, then in JS do doc.get_model_by_name(“something”).’ If I have a plot with 2 or more glyphs, I get “Error: Multiple models are named ‘something’”.

You need a different name for each thing you want to pull out - name each model something meaningful.

There’s also an _all_models_by_name._dict private dict where the values can be lists so you can get multiple same-name models. It’s an oversight that there’s no public API to get multiple. In Python the Document.select method exists and can return multiple matches.

Be aware that _all_models and _all_models_by_name are private (leading underscore = implementation detail) so may change in a future release. The public API way to do that would be with names, or to start from roots() and walk through the tree. Though adding a public API to get all models could make sense too, right now there isn’t one.

(simple PR to get started with though!)

And there should be public API to get multiple same-name models. Both needed APIs would be good issues to file.

Havoc

Jeff

On Thursday, January 21, 2016 at 5:10:12 AM UTC, Greg Nordin wrote:

Thanks, Havoc. I really appreciate the information.

I saw the spectrogram.coffee file earlier and went through it, but I don’t know coffeescript yet and decided to look for other approaches rather than doing a crash course in coffeescript. I’m still a noob to javascript so I was thinking I ought to get that nailed down first.

What I am trying to do is avoid needing a server so that the final html file can be run only client side. I need to animate several lines on a graph so I am looking at finding the line data and updating it through javascript callbacks. My main motivation is to create single page html instructional visualizations & animations for a university class I am teaching. I tried using Bokeh server to do the animation and it works fine on my laptop. However, I’m finding the students largely unwilling to try to set up python & bokeh on their own machines (most of which are Windows-based) and running “bokeh serve --show <filename.py>” from the command line. One of my teaching assistants did this and when he showed it to me there was a noticeable lag (seconds) between hitting a button or changing a slider and having the plot respond. I think his laptop is a bit underpowered. When I run it on my laptop I notice that the (internal) network traffic is ~5-7 MBps when I run bokeh serve with the same file. In any case, I’m now looking for a way to put a given interactive visualization/animation into a single html file on a static server that students can point their browser at such that the html file runs on their machines.

I wish I was in a position to make a PR for a future release. However, I think I still have a lot to learn before I can get to that point :-).

Again, I really appreciate your help and suggestions!

On Wednesday, January 20, 2016 at 9:46:32 PM UTC-7, Havoc Pennington wrote:

Collection is no longer used that way in 0.11 as you discovered … I’m not sure what coverage the docs or examples have here, others will know better.

A use of Bokeh.index to get models I know of is

https://github.com/bokeh/bokeh/blob/master/examples/embed/spectrogram/spectrogram.coffee

In 0.11, ideally you would start by finding the bokeh Document instance you care about. It’s reachable from any model in the document as model.document - if you’re in a JS callback, pass any model to the callback then get model.document. If you’re in an arbitrary tag, I don’t remember a clean, supported way to do this (or even to get the Bokeh object, which may load later than your JS in some situations). I’ll suggest some hacks later though.

Once you have the document, the best approach is on the Python side set mydatasource.name=“something”, then in JS do doc.get_model_by_name(“something”). If you instead have the model id there is a get_model_by_id(). Or if you know the document structure you could dig through the document starting from doc.roots().

Hacks to get a document -

There isn’t a global var containing all documents or models anymore, but there is still a Bokeh.index which contains views for all document roots I think, plus I think models that were explicitly passed to show() or file_html()… The views have a model field and models have a document field so as a hack you can get the document that way. Pick any key from Bokeh.index, get its value, get its model field, get the model’s document field.

Another possible hack is to trigger a client-side callback that doesn’t do anything except get passed a model, and then in the callback set a global like window.bokeh_doc to model.document. Then other code can get the document from there. I’m not sure of the easiest way to do a fake self-triggered callback though. Maybe an invisible button. Very bad hack.

Either way I’d suggest use the hack to get Document and then use the Document API to get all the specific models.

The BEST hack of course is to make a PR for a future release adding things like Bokeh.get_document_by_session_id() or Bokeh.get_document_by_title() or Bokeh.get_rendered_documents(). :wink: Tricky bits might include:

  • if a document is no longer rendered or used in an open session, be sure to forget it to avoid a leak
  • multiple document instances can have the same session id if multiple websockets are open
  • document.title can change at any time

There may be other better PR ideas others have. A very simple one could be to be able to add a “Document created” callback, perhaps, and you could set global vars from that callback.

Anyway apologies for the rough edge.

Havoc

On Jan 20, 2016, at 3:48 PM, Greg Nordin [email protected] wrote:

Solved:

In summary

The columndatasource is in window.Bokeh.ColumnDataSource.Collection.models[k].attributes.data, with [k] being the key to the datasource you want

The code

This shows how to access it, presuming you provided a name to the ColumnDataSource when you created it in Python (e.g. source = models.ColumnDataSource(data_dict, name=‘mycolumndatasource’) )

console.log(Bokeh);

var my_source_name = 'mycolumndatasource';
var sources = Bokeh.ColumnDataSource.Collection.models;
var source_keys = Bokeh._.keys(sources)
console.log(source_keys)
for (i = 0; i < source_keys.length; i++) {
var k = source_keys[i];
var source_name = sources[k].[attributes.name](http://attributes.name)
if (source_name == my_source_name) {
   var my_data = sources[k].attributes.data
}

}

console.log(my_data);

Comment

  • Being able to access the data sources from external js is extremely useful to do hybrid Python / Javascript development, as one can rely on Bokeh’s interconnection while using external functionalities
  • Exploring window.Bokeh, I thought all the objects with capital first letter like ColumnDataSource were constructors, did not expect them to contain active collections and models

On Monday, 17 August 2015 16:06:26 UTC+1, Pythonic wrote:

Here is where I am:

_ = Bokeh._

index = window.Bokeh.index

keys = _.keys(index)

plot = Bokeh.index[keys[0]] // index only has 1 key

renderers = plot.model.get(‘renderers’)

console.log(renderers) // this results in “undefined”

Manually exploring the plot object in the log, I find renderers in plot.views.attributes.renderers**,** but none respond to get(‘data_source’) or show any data_source attribute in the console log

I am sure I must be doing some silly error along the line, any suggestion? Many thanks

On Monday, 17 August 2015 15:27:53 UTC+1, Pythonic wrote:

Priceless, many thanks

On Monday, 17 August 2015 15:23:30 UTC+1, Bryan Van de ven wrote:

Hi Giuseppe,

Yes, I forgot the index only contains Plot objects. But each of these has a “renderers” backbone attribute, so you can use

    plot.get('renderers')

to get the list of renderers. One (or more) of these will be a GlyphRenderer, and these are the objects that have a “data_source” backbone attribute:

    renderer.get('data_source')

You can update and trigger this object just as is done in the User Guide examples.

Adding some JS object graph search functions (like the python side has) is on our long TODO list.

Bryan

On Aug 17, 2015, at 1:31 AM, Pythonic [email protected] wrote:

Broadening this question, for mixed Python+JS development it might be useful to understand where to access the Backbone model of the various objects in a page

Two example of reasons to do this:

  • re-rendering objects: for example, if I change the value of a Slider through the callback of another bokeh widget, the slider does not render to the new value and (I presume) I need to access its renderer and give it a nudge
  • modifying data (columndatasources) from JS scripts that take place outside of a Bokeh Callback

By starting at bokeh.index, where should one look for the data sources and the models? [el, model, model.attributes, model.collections,…?]


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/2ac5d5dc-a2f8-4f88-b842-2958e310448c%40continuum.io.

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

I am trying to do something similar where I would like to change the data in a ColumnDataSource using javascript, but I’m having a hard time locating the ColumnDataSource. I generated the attached html file from the attached .py file. When I follow the steps below looking in the html file, I find Bokeh.ColumnDataSource.Collection.models, but it has nothing in it, i.e.

console.log(Bokeh.ColumnDataSource.Collection.models);

returns an empty list:

[] 

Has something changed since August? If so, where can I find documentation or examples?

Thanks,
Greg

On Sunday, August 23, 2015 at 4:16:35 AM UTC-6, Pythonic wrote:

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/75bba408-73bf-45a5-bac6-4bba998b8f99%40continuum.io.

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

<sinusoidal_tline_voltages_test.html>

<sinusoidal_tline_voltages.py>

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/77a3e54f-1473-422a-89ee-232cfdb9592d%40continuum.io.

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

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/06532E36-5A94-4C2D-A23A-D949009F9770%40continuum.io.

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

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/00e14bad-ffbc-49bf-bbde-cd28d6b852d9%40continuum.io.

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

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/C468157E-4562-4EA4-B8B3-F096F00B312B%40continuum.io.

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