Good morning,
I’m experimenting with BokehJS because the static document I built with Bokeh might be easier to maintain if I skipped python altogether. I created a hybrid of ajax_source.py with the ‘Minimal Complete Example’ at the bottom of Developing with JavaScript to test. Here’s my complete rewrite of lines 8-20 and 27 of ajax_source.py in JavaScript. I’m either doing something wrong or the Bokeh.Plotting API doesn’t behave like bokeh.plotting in this case. The BokehJS version only prints the first circle and doesn’t append subsequent ones.
Thanks for taking a look,
Jan
<**html ****lang=****"en"**>
<head>
<meta charset="UTF-8">
<title>Ajax Source</title>
<**link rel="stylesheet" href="css/bokeh.min.css" type="text/css" **/>
<script src="js/bokeh.js"></script>
<script src="js/bokeh-api.js"></script>
</head>
<body>
<script>
**const *****source ***= **new **Bokeh.AjaxDataSource({data_url: “http://localhost:5050/data”, polling_interval: 100, mode: “append”});
**const *****p ***= Bokeh.Plotting.figure({height: 300, width: 800,
background_fill_color: “lightgrey”, title: “Streaming Noisy sin(x) via Ajax”});
p.circle({field: ‘x’}, {field: ‘y’}, {source: source});
p.x_range.**follow **= “end”;
p.x_range.**follow_interval **= 10;
Bokeh.Plotting.show(p, document.currentScript.parentElement)
</script>
</body>
</html>
One difference I observe by setting Bokeh log_level to ‘debug’ is that the python version hits glyph_renderer.js:180 three times at each cycle whereas the JavaScript hits it only once. This presumably indicates that the APIs generated different model graphs but I haven’t found the key difference between bokeh/plotting/helpers.py and bokehjs/src/lib/api/plotting.ts yet.
···
On Saturday, May 19, 2018 at 8:40:17 AM UTC-4, Jan Burgy wrote:
Good morning,
I’m experimenting with BokehJS because the static document I built with Bokeh might be easier to maintain if I skipped python altogether. I created a hybrid of ajax_source.py with the ‘Minimal Complete Example’ at the bottom of Developing with JavaScript to test. Here’s my complete rewrite of lines 8-20 and 27 of ajax_source.py in JavaScript. I’m either doing something wrong or the Bokeh.Plotting API doesn’t behave like bokeh.plotting in this case. The BokehJS version only prints the first circle and doesn’t append subsequent ones.
Thanks for taking a look,
Jan
<**html ****lang=****"en"**>
<head>
<meta charset=“UTF-8”>
<title>Ajax Source</title>
<**link rel=“stylesheet” href=“css/bokeh.min.css” type=“text/css” **/>
<script src=“js/bokeh.js”></script>
<script src=“js/bokeh-api.js”></script>
</head>
<body>
<script>
**const *****source ***= **new **Bokeh.AjaxDataSource({data_url: “http://localhost:5050/data”, polling_interval: 100, mode: “append”});
**const *****p ***= Bokeh.Plotting.figure({height: 300, width: 800,
background_fill_color: “lightgrey”, title: “Streaming Noisy sin(x) via Ajax”});
p.circle({field: ‘x’}, {field: ‘y’}, {source: source});
p.x_range.**follow **= “end”;
p.x_range.**follow_interval **= 10;
Bokeh.Plotting.show(p, document.currentScript.parentElement)
</script>
</body>
</html>
Aha, I got the js version working through painstaking side-by-side debugging! Adding the following two lines "fixes":
const [glyph_renderer] = p.renderers.filter(r => 'GlyphRenderer' === r.type);
glyph_renderer.view.finalize();
This is obviously a broke-around. Where does the proper fix belong?
Issue was that the CDSView.protoype.finalize is called with null source first time around (default instantiation in GlyphRenderer.initClass). The python version calls it again in Document._instantiate_references_on_json.