☰Read-only archive⌕
Looking for help with Bokeh?

This is a read-only archive. Ask questions and join the conversation on GitHub.

Visit Community Support on GitHub →
Archived discussions · Captured October 28, 2026

JS Callback: Bokeh.Charts

Community Support
Georg_Polzlbauer
Georg_Polzlbauer

Hi,
I am trying to create pie charts within a JS callback once a user clicks somewhere in a standalone html file.
However, I can not access the Bokeh.Charts object (module? I am kind of noobish at JS…), the following piece of code fails on the Browser:

source.callback = CustomJS(args=dict(source=source), code="""
       data = ....
       var pie = Bokeh.Charts.pie(data)
    """)

… with error (Firefox):
TypeError: Bokeh.Charts is undefined[Learn More]

Bokeh.Charts.pie should be available according to the docs:

Any help appreciated…
Thanks,
Georg

⌁   Link to post
Bryan
Bryan

Hi,

The BokehJS JavaScript APIs are in a separate JS module, and it is *not* automatically included by default. The vast majority of documents created from Python would never use this code at all, so it would be wasteful in terms of payload size to force the JS API to be included on every document.

To load the JS APIs you'd need to add something like this to your HTML template:

  <script src="http://cdn.pydata.org/bokeh/release/bokeh-api-0.12.3.min.js&quot;&gt;&lt;/script&gt;

That will cause Bokeh.Charts to be available, once the script is loaded.

Thanks,

Bryan

···

On Nov 30, 2016, at 8:47 AM, Georg Pölzlbauer <georg.poelzlbauer@gmail.com> wrote:

Hi,
I am trying to create pie charts within a JS callback once a user clicks somewhere in a standalone html file.
However, I can not access the Bokeh.Charts object (module? I am kind of noobish at JS...), the following piece of code fails on the Browser:

source.callback = CustomJS(args=dict(source=source), code="""
       data = ....
       var pie = Bokeh.Charts.pie(data)
    """)

... with error (Firefox):
TypeError: Bokeh.Charts is undefined[Learn More]

Bokeh.Charts.pie should be available according to the docs:
http://bokeh.pydata.org/en/latest/docs/user_guide/bokehjs.html#bokeh-charts

Any help appreciated...
Thanks,
Georg

--
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+unsubscribe@continuum.io.
To post to this group, send email to bokeh@continuum.io.
To view this discussion on the web visit https://groups.google.com/a/continuum.io/d/msgid/bokeh/1425a3d2-bc1d-48df-ac20-bc934e4694e2%40continuum.io\.
For more options, visit https://groups.google.com/a/continuum.io/d/optout\.

⌁   Link to post
Bryan
Bryan

Another option: you could also try adding "bokeh-api" to the .components attribute of a Resources object:

  from bokeh.resources import CDN
  CDN.components.append("bokeh-api")

Now if you explicitly use this CDN resources object when you generate your output, it should also automatically include bokeh-api.js as well.

Thanks,

Bryan

···

On Nov 30, 2016, at 9:20 AM, Bryan Van de Ven <bryan@bokeh.org> wrote:

Hi,

The BokehJS JavaScript APIs are in a separate JS module, and it is *not* automatically included by default. The vast majority of documents created from Python would never use this code at all, so it would be wasteful in terms of payload size to force the JS API to be included on every document.

To load the JS APIs you'd need to add something like this to your HTML template:

  <script src="http://cdn.pydata.org/bokeh/release/bokeh-api-0.12.3.min.js&quot;&gt;&lt;/script&gt;

That will cause Bokeh.Charts to be available, once the script is loaded.

Thanks,

Bryan

On Nov 30, 2016, at 8:47 AM, Georg Pölzlbauer <georg.poelzlbauer@gmail.com> wrote:

Hi,
I am trying to create pie charts within a JS callback once a user clicks somewhere in a standalone html file.
However, I can not access the Bokeh.Charts object (module? I am kind of noobish at JS...), the following piece of code fails on the Browser:

source.callback = CustomJS(args=dict(source=source), code="""
      data = ....
      var pie = Bokeh.Charts.pie(data)
   """)

... with error (Firefox):
TypeError: Bokeh.Charts is undefined[Learn More]

Bokeh.Charts.pie should be available according to the docs:
http://bokeh.pydata.org/en/latest/docs/user_guide/bokehjs.html#bokeh-charts

Any help appreciated...
Thanks,
Georg

--
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+unsubscribe@continuum.io.
To post to this group, send email to bokeh@continuum.io.
To view this discussion on the web visit https://groups.google.com/a/continuum.io/d/msgid/bokeh/1425a3d2-bc1d-48df-ac20-bc934e4694e2%40continuum.io\.
For more options, visit https://groups.google.com/a/continuum.io/d/optout\.

⌁   Link to post

End of archived discussion · Replies are disabled