Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit c005784

Browse files
committed
add bokeh example
1 parent a54c66c commit c005784

File tree

1 file changed

+54
-0
lines changed

1 file changed

+54
-0
lines changed

pyscriptjs/public/bokeh.html

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
<html><head>
2+
<title>Bokeh Example</title>
3+
<meta charset="iso-8859-1">
4+
<script type="text/javascript" src="https://cdn.bokeh.org/bokeh/release/bokeh-2.4.2.min.js"></script>
5+
<script type="text/javascript" src="https://cdn.bokeh.org/bokeh/release/bokeh-gl-2.4.2.min.js"></script>
6+
<script type="text/javascript" src="https://cdn.bokeh.org/bokeh/release/bokeh-widgets-2.4.2.min.js"></script>
7+
<script type="text/javascript" src="https://cdn.bokeh.org/bokeh/release/bokeh-tables-2.4.2.min.js"></script>
8+
<script type="text/javascript" src="https://cdn.bokeh.org/bokeh/release/bokeh-mathjax-2.4.2.min.js"></script>
9+
10+
<script type="text/javascript">
11+
Bokeh.set_log_level("info");
12+
</script>
13+
<link rel="stylesheet" href="build/pyscript.css" />
14+
15+
<script defer src="build/pyscript.js"></script>
16+
17+
</head>
18+
<body>
19+
<h1>Bokeh Example</h1>
20+
<div id="myplot"></div>
21+
<py-repl></py-repl>
22+
23+
<py-script>
24+
from bokeh.plotting import figure
25+
from bokeh.resources import CDN
26+
import json
27+
from bokeh.embed import json_item
28+
from js import Bokeh
29+
30+
31+
from bokeh.io import output_notebook, show
32+
from bokeh.plotting import figure
33+
import bokeh.sampledata
34+
35+
# create a new plot with default tools, using figure
36+
p = figure(plot_width=400, plot_height=400)
37+
38+
# add a circle renderer with x and y coordinates, size, color, and alpha
39+
p.circle([1, 2, 3, 4, 5], [6, 7, 2, 4, 5], size=15, line_color="navy", fill_color="orange", fill_alpha=0.5)
40+
p_json = json.dumps(json_item(p, "myplot"))
41+
print(p_json)
42+
43+
async def show(item):
44+
print("about to embed")
45+
Bokeh.embed.embed_item(item)
46+
print ("Done embedding...")
47+
48+
pyscript.run_until_complete(show(p_json))
49+
#show(p) # show the results
50+
51+
</py-script>
52+
53+
</body>
54+
</html>

0 commit comments

Comments
 (0)