In bokeh, custom callbacks can be set using a CustomJS object and passing it as the callback argument to an object. I am using “from_py_func” to write those callbacks in Python.This works well.
However, all those callbacks are only executed when the user interacts with the object, such as doing select or range update.
What I need is a way to trigger a callback upon page load, such that it starts without the need
of the user doing anything.
How can this be done? I like to keep things simple for now and achieve this with a standalone bokeh file: no server, no html/javascript hacking.
There's not currently any hook for this. It could probably be a reasonable feature, but there are questions/discussion warranted. E.g. is page load really appropriate? that probably won't work in the notebook, so maybe on some plot initialization step. But then we should try to think of a reasonably simple scheme instead of adding another ad-hoc hook. I'd encourage you to make a feature request issue at Issues · bokeh/bokeh · GitHub
For now, I'd probably recommend replacing the standard FILE template with one that has a little extra JS added to do whatever you want to happen on page load. Otehrwise, it's probably possible to make a custom user model that subclasses Plot and calls a callback on init, but AFAIK this has not been demonstrated.
Bryan
···
On May 3, 2016, at 10:10 AM, Artur Scholz <[email protected]> wrote:
Hi,
In bokeh, custom callbacks can be set using a CustomJS object and passing it as the callback argument to an object. I am using "from_py_func" to write those callbacks in Python.This works well.
However, all those callbacks are only executed when the user interacts with the object, such as doing select or range update.
What I need is a way to trigger a callback upon page load, such that it starts without the need
of the user doing anything.
How can this be done? I like to keep things simple for now and achieve this with a standalone bokeh file: no server, no html/javascript hacking.
Thanks for the hint. Actually a number of use cases come to mind for having a hook at page load. In my case its a 2d world map onto which I want to draw markers for satellite ground tracks, and update their location. But basically any kind of animation would need that.
Your suggestion sounds like the way forward. Unfortunately I have no clue on how to do that. Could you please elaborate more on how to do this.
I am going to post my results when done.
···
On Tuesday, May 3, 2016 at 5:18:24 PM UTC+2, Bryan Van de ven wrote:
There’s not currently any hook for this. It could probably be a reasonable feature, but there are questions/discussion warranted. E.g. is page load really appropriate? that probably won’t work in the notebook, so maybe on some plot initialization step. But then we should try to think of a reasonably simple scheme instead of adding another ad-hoc hook. I’d encourage you to make a feature request issue at https://github.com/bokeh/bokeh/issues
For now, I’d probably recommend replacing the standard FILE template with one that has a little extra JS added to do whatever you want to happen on page load. Otehrwise, it’s probably possible to make a custom user model that subclasses Plot and calls a callback on init, but AFAIK this has not been demonstrated.
In bokeh, custom callbacks can be set using a CustomJS object and passing it as the callback argument to an object. I am using “from_py_func” to write those callbacks in Python.This works well.
However, all those callbacks are only executed when the user interacts with the object, such as doing select or range update.
What I need is a way to trigger a callback upon page load, such that it starts without the need
of the user doing anything.
How can this be done? I like to keep things simple for now and achieve this with a standalone bokeh file: no server, no html/javascript hacking.
Thanks
Artur
–
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].
Adding more/better docs about the (new) JS API is on my (long) to-do before the next release. In the mean time I am afraid I can only offer examples, and answer questions. Here is an example of a custom user model:
Some things to know. On the python side, you'd subclass an existing Bokeh Model, and provide a JS __implementation__ that defines the JS implementation of the Model. BokehJS models are Backbone models, and the code is actually written in coffeescript. I think a custom user extension that makes a subclass that calls a callback on init would look something like this (completely untested):
Thanks for the hint. Actually a number of use cases come to mind for having a hook at page load. In my case its a 2d world map onto which I want to draw markers for satellite ground tracks, and update their location. But basically any kind of *animation* would need that.
Your suggestion sounds like the way forward. Unfortunately I have no clue on how to do that. Could you please elaborate more on how to do this.
I am going to post my results when done.
On Tuesday, May 3, 2016 at 5:18:24 PM UTC+2, Bryan Van de ven wrote:
There's not currently any hook for this. It could probably be a reasonable feature, but there are questions/discussion warranted. E.g. is page load really appropriate? that probably won't work in the notebook, so maybe on some plot initialization step. But then we should try to think of a reasonably simple scheme instead of adding another ad-hoc hook. I'd encourage you to make a feature request issue at Issues · bokeh/bokeh · GitHub
For now, I'd probably recommend replacing the standard FILE template with one that has a little extra JS added to do whatever you want to happen on page load. Otehrwise, it's probably possible to make a custom user model that subclasses Plot and calls a callback on init, but AFAIK this has not been demonstrated.
Bryan
> On May 3, 2016, at 10:10 AM, Artur Scholz <[email protected]> wrote:
>
> Hi,
>
> In bokeh, custom callbacks can be set using a CustomJS object and passing it as the callback argument to an object. I am using "from_py_func" to write those callbacks in Python.This works well.
>
> However, all those callbacks are only executed when the user interacts with the object, such as doing select or range update.
>
> What I need is a way to trigger a callback upon page load, such that it starts without the need
> of the user doing anything.
>
> How can this be done? I like to keep things simple for now and achieve this with a standalone bokeh file: no server, no html/javascript hacking.
>
> Thanks
> Artur
>
>
>
>
>
> --
> You received this message because you are subscribed to the Google Groups "Bokeh Discussion - Public" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to bokeh+un...@continuum.io.
> To post to this group, send email to bo...@continuum.io.
> To view this discussion on the web visit https://groups.google.com/a/continuum.io/d/msgid/bokeh/CALqfExaWuAKV9oh2-2AZ10TCZPSOLVeP4OtzbGAdgcS-2Nm3WQ%40mail.gmail.com\.
> For more options, visit https://groups.google.com/a/continuum.io/d/optout\.
On Wed, May 4, 2016 at 7:24 PM, Bryan Van de Ven [email protected] wrote:
Hi Artur,
Adding more/better docs about the (new) JS API is on my (long) to-do before the next release. In the mean time I am afraid I can only offer examples, and answer questions. Here is an example of a custom user model:
Some things to know. On the python side, you’d subclass an existing Bokeh Model, and provide a JS implementation that defines the JS implementation of the Model. BokehJS models are Backbone models, and the code is actually written in coffeescript. I think a custom user extension that makes a subclass that calls a callback on init would look something like this (completely untested):
Thanks for the hint. Actually a number of use cases come to mind for having a hook at page load. In my case its a 2d world map onto which I want to draw markers for satellite ground tracks, and update their location. But basically any kind of animation would need that.
Your suggestion sounds like the way forward. Unfortunately I have no clue on how to do that. Could you please elaborate more on how to do this.
I am going to post my results when done.
On Tuesday, May 3, 2016 at 5:18:24 PM UTC+2, Bryan Van de ven wrote:
There’s not currently any hook for this. It could probably be a reasonable feature, but there are questions/discussion warranted. E.g. is page load really appropriate? that probably won’t work in the notebook, so maybe on some plot initialization step. But then we should try to think of a reasonably simple scheme instead of adding another ad-hoc hook. I’d encourage you to make a feature request issue at https://github.com/bokeh/bokeh/issues
For now, I’d probably recommend replacing the standard FILE template with one that has a little extra JS added to do whatever you want to happen on page load. Otehrwise, it’s probably possible to make a custom user model that subclasses Plot and calls a callback on init, but AFAIK this has not been demonstrated.
In bokeh, custom callbacks can be set using a CustomJS object and passing it as the callback argument to an object. I am using “from_py_func” to write those callbacks in Python.This works well.
However, all those callbacks are only executed when the user interacts with the object, such as doing select or range update.
What I need is a way to trigger a callback upon page load, such that it starts without the need
of the user doing anything.
How can this be done? I like to keep things simple for now and achieve this with a standalone bokeh file: no server, no html/javascript hacking.
Thanks
Artur
–
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].