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):
__implementation__ = """
Plot = require "models/Plot"
p = require "core/properties"
class PlotWithCallback extends Plot
initialize: (attrs, options) ->
callback: [ p.Any ]
callback = Instance(Callback)
Then you would use it:
p = PlotWithCallback(...)
p.callback = CustomJS(...)
Alternatively you might rather have a FigureWithCallback subclass.
On May 3, 2016, at 2:20 PM, Artur Scholz <[email protected]> wrote:
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.
> On May 3, 2016, at 10:10 AM, Artur Scholz <[email protected]> wrote:
> 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.
> 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/CALqfExaWuAKV9oh2-2AZ10TCZPSOLVeP4OtzbGAdgcS-2Nm3WQ%40mail.gmail.com.
> 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/d6fc9f0e-4bbd-41e4-8a32-f2a9aef98879%40continuum.io.
For more options, visit https://groups.google.com/a/continuum.io/d/optout.