What are JSON prototypes?

I have been trying to learn bokeh recently and in the course I want to clear few confusions as they have not been documented anywhere (or atleast I could not find it)

  1. What is JSON Prototypes for some classes in bokeh.models? What is it’s use? Is it restricted to just bokeh.models? Or more specifically to asubsect of bokeh.models’ classes? is there a exhaustive list of all classes which has a json prototype in the documentation somewhere?
  2. I wanted to write a customJS callback where I had passed my figure object as args dict, but when I try to access the yaxis object of the figure to change its label, i see an error of undefined in my browser console. In the documentation here callbacks — Bokeh 3.0.3 Documentation ,
    how do I interpretate the ’ In particular those can be bokeh’s models. '. Does it means arg in customJS callback can only be python objects of bokeh.model classes? If yes, then why did not my error say wring argument for figure object instead it gave me an error only when I tried doing this ’ figure_obj.yaxis[0].axis_label=“new_lablel” ’ For the workaround I found that if I explicitly get a reference to yaxis[0] axis object and then pass it as argument to custoimJS and access its attribute axis_lable, as ’ my_y_axes.axis_label =“new_label” ’ , this works fine as expected.

I would really appreciate if some one could help in clearing this for me. I have tried my best in explaining my problem/confusion, let me know if you need more details

Bokeh is a cross-runtime (Python<–>Javascript) tool. As such, it has to have a format for serializing data between runtimes. The JSON prototypes show what “complete” serialization of each model would look like. In practice, Bokeh typically only sends the fields that are actually modified, rather than the “complete” version. For the most part, these JSON prototypes are not really of interest to end-users (they would be more useful to someone trying to create an entire new language binding for BokehJS). We provide them for completeness.

I wanted to write a customJS callback where I had passed my figure object as args dict, but when I try to access the yaxis object of the figure to change its label, i see an error of undefined in my browser console.

This is not enough information to help. It is always advised to provide a complete Minimal Reproducible Example.

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.