Lou
Lou

Reputation: 41

Retrieving HTML Element Linked to Bokeh JS Object from Bokeh.documents in JavaScript

Question:

Is it possible to retrieve the HTML element linked to a Bokeh JS object from the Bokeh.documents? I would like to access the HTML button created with a Bokeh widget in Python in order to trigger a click event over it using JavaScript.

Details:

I'm working with Bokeh to create interactive visualizations in Python. I have created a Bokeh widget, specifically a button, which generates corresponding HTML elements when rendered in a web browser. Now, I want to manipulate this button using JavaScript, but I'm unsure how to access the HTML element that corresponds to the Bokeh JS object from the Bokeh.documents array in JavaScript.

Additional Context:

I have explored the Bokeh.documents array in the browser's console and can see the structure of the document, but I'm struggling to understand how to map the Bokeh JS object to its corresponding HTML element. Any guidance or code snippets demonstrating how to achieve this would be greatly appreciated.

Current Approach:

Here's what I've tried so far:

const bokehDocs = Bokeh.documents;
const myWidget = bokehDocs[0].get_model_by_name("myButtonWidget"); // Example name of my button widget
// Now, how can I get the corresponding HTML element linked to this Bokeh JS object (myWidget)?

Expected Outcome:

I expect to be able to retrieve the HTML element linked to the Bokeh JS object, such as a button, so that I can manipulate it using JavaScript. This could involve triggering events like clicks or updating its properties dynamically.

Any help or insights into how to achieve this would be greatly appreciated. Thank you in advance!

Upvotes: 0

Views: 42

Answers (0)

Related Questions