Skip to content Skip to sidebar Skip to footer

Bokeh Callback For Image Update

I have a Bokeh plot that can display an image, which can be changed by a slider (and also should update regularly) (similar to this question Sliding through images with Bokeh Slide

Solution 1:

As of Bokeh 1.4.0 there is no callback on the image load. The ImageURL glyph is not one that is much used by the core developers, AFAIK, and we can't always anticipate every use case that every user might want. For this reason, we have made Bokeh itself extensible, so the best I can suggest at the moment is to extend Bokeh with a custom extension. The documentation for creating custom extensions is here:

http://docs.bokeh.org/en/latest/docs/user_guide/extensions.html

In abbreviated forms, you'd create a class like this that adds a callback property, and supplies the JavaScript implementation for your custom ImageURL glyph:

classMyImageURL(ImageURL):

     callback =Instance(Callback, help="A callback to run when images load")

    __implementation__ = JAVASCRIPT_CODE_HERE

Then it can be used like any low level glyoh:

my_glyph = MyImageURL(...)
source = ColumnDataSource(...)
plot.add_glyph(source, my_glyph)

Solution 2:

You can subscribe to the change event of the image tag and do whatever you need to. You can do this with JQuery's change method or straight javascript's onchange handler.

Post a Comment for "Bokeh Callback For Image Update"