Bokeh custom tool with Bokeh.embed

I'm trying to create a custom save tool and embed the plot using Bokeh.embed . However, the plot will not render. The JavaScript console throws an error that the model has not been registered. I appreciate any advice the bokeh community has to offer.

Here is the code

@seanoughton do you mean you are using json_items? If so, then including custom extensions is not yet supported. You would need to use the components or autoload_static APIs instead for now.

If that’s not what you mean, them more information is needed. Really, a complete minimal reproducing example (which always advised when asking for help).

Hi Bryan
Thanks so much for responding. Yes I am using json_items, so this information was really helpful.

I was having difficulty in including code in my post, which is why I embedded the screenshot. When I added the code, I got an error saying that I could only tag up to 2 users in my post.

Again, thanks for the speedy response.

Best!

@seanoughton that might be a Discourse “new user” thing, we probably need to visit the Discourse trust levels since the defaults may be a bit restrictive for our community.

Just out of curiosity, is there a way to manually register the custom tool in javascript on the front end before the plot is embedded when using json_items and Bokeh.embed

Thanks in advance!

Should work in principle, but I’ve never tried to do it manually like that. You might look at the output of autoload_static, there should be a call to register (or something similar) for your custom model. Perhaps that can just be lifted into your template (before the embed call).

Awesome! Thanks so much!

Hi @Bryan
I just wanted to let you know that I got this working with registering the custom model in javascript before the embed.
So thanks very much for the advice.
One thing I wanted to note was that I could not get it to work with version 1.4.0 .
With that version it threw this error in the js console:

Uncaught TypeError: name.slice is not a function
    at normalize (bokeh-1.4.0.min.js:50)
    at require (bokeh-1.4.0.min.js:68)
    at Object.main.register_plugin (bokeh-1.4.0.min.js:115)
    at outer (tool.html:38)
    at tool.html:43
    at tool.html:33
    at tool.html:34

It works fine in version 1.3.4.

Once again thanks for your help and thanks for being part of a great project like Bokeh!

@seanoughton We look forward to the day where we can make firmer guarantees about some stable subset of BokehJS API between versions. We are not quite there yet, but getting closer.

@Bryan You are all doing a great job. Thanks!