Using autoload_static with a Holoviews figure?

146 views Asked by At

Bokeh offers a way to embed interactive plots:

https://docs.bokeh.org/en/latest/docs/user_guide/embed.html

Especially, if one uses the autoload_static function, it is possible to export a self-contained javascript file of the results.

However, most recent versions of Bokeh have removed charts API. Instead, one now has to use Holowviews.

I want to be able to export a self-contained javascript file, just as with Bokeh's autoload_static function, with a Holowiews graph.

Is this possible? How can one do that? The actual autoload_static takes a Bokeh figure as input, which is different that a Holoviews figure.

Thanks

1

There are 1 answers

0
philippjfr On BEST ANSWER

Any HoloViews object can be rendered to a bokeh figure very easily. From there you can use autoload_static as usual. Here is a simple example:

import holoviews as hv
from bokeh.embed import autoload_static
from bokeh.resources import CDN

renderer = hv.renderer('bokeh')
curve = hv.Curve([1, 2, 3, 4, 5])
figure = renderer.get_plot(curve).state
js, tag = autoload_static(figure, CDN, 'test.js')