☰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

Json_item for javascript

Community Supportbokehjs
eribean
eribean

I am trying to defer generation of some plots in BokehJS without any python backend. Json_item is exactly what I need but it doesn’t seem to be in the javascript “embed” object. Does this exists? Is it hiding somewhere?

Thanks

⌁   Link to post
Bryan
Bryan

@eribean There’s not a json_item on the BokehJS side at present, maybe there should be. But I think you can just construct the object that embed_item expects. Something like (untested):

const doc_json = doc.to_json()

item = {
   doc: doc_json,
   root_id: doc_json.roots.root_ids[0]
}

embed_item(doc_json, "div_id")
⌁   Link to post
eribean
eribean

Thanks @Bryan, worked like a charm! Weirdly enough the rendering is consistently faster so double win!

Just an FYI, if I use

Bokeh.Plotting.show(somePlot, location)

then location expects a selector

'#div_id'

However, embed_item expects an id per your response

'div_id'

⌁   Link to post
Festus_Yeboah
Festus_Yeboah

Hello! I am trying to achieve a similar result but I find the answer a bit confusing and inconclusive, can you help clarify? I am on Bokeh 2.4.3 Firstly, shouldn’t the solution be:

# Python side
const doc_json = doc.to_json(include_defaults=True)
item = {
   doc: doc_json,
   root_id: doc_json.roots.root_ids[0]
}
// JavaScript side
embed_item(doc_json, "div_id")

instead of the posted answer below:

const doc_json = doc.to_json()
item = {
   doc: doc_json,
   root_id: doc_json.roots.root_ids[0]
}
embed_item(doc_json, "div_id")
⌁   Link to post
Bryan
Bryan

@Festus_Yeboah On the Python side just use json_item as described in the docs. There is generally no need to use the low-level to_json API in Python. This question was about accomplishing something using only JS (where json_item does not exist).

⌁   Link to post

End of archived discussion · Replies are disabled