-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmyapp.py
More file actions
104 lines (90 loc) · 4.6 KB
/
myapp.py
File metadata and controls
104 lines (90 loc) · 4.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
# myapp.py
from random import random
from bokeh.layouts import column
from bokeh.models import Button
from bokeh.palettes import RdYlBu3
from bokeh.plotting import figure, curdoc
# create a plot and style its properties
p = figure(x_range=(0, 100), y_range=(0, 100), toolbar_location=None)
p.border_fill_color = 'black'
p.background_fill_color = 'black'
p.outline_line_color = None
p.grid.grid_line_color = None
# add a text renderer to the plot (no data yet)
r = p.text(x=[], y=[], text=[], text_color=[], text_font_size="26px",
text_baseline="middle", text_align="center")
i = 0
ds = r.data_source
# Valve EJ has flow rate=25; tunnel leads to valve MC
# Valve WC has flow rate=0; tunnels lead to valves OW, RU
# Valve NP has flow rate=0; tunnels lead to valves VR, KL
# Valve AA has flow rate=0; tunnels lead to valves QT, AP, EZ, AK, XV
# Valve VO has flow rate=6; tunnels lead to valves KM, RF, HS, LJ, IA
# Valve CB has flow rate=0; tunnels lead to valves UI, UP
# Valve TE has flow rate=18; tunnel leads to valve JT
# Valve CZ has flow rate=0; tunnels lead to valves UP, OW
# Valve LJ has flow rate=0; tunnels lead to valves DV, VO
# Valve UP has flow rate=7; tunnels lead to valves SK, CB, CZ
# Valve FP has flow rate=0; tunnels lead to valves OW, RE
# Valve KM has flow rate=0; tunnels lead to valves SE, VO
# Valve DV has flow rate=0; tunnels lead to valves LJ, UM
# Valve FL has flow rate=0; tunnels lead to valves AH, TS
# Valve VR has flow rate=24; tunnels lead to valves DM, TF, NP
# Valve IA has flow rate=0; tunnels lead to valves VS, VO
# Valve RF has flow rate=0; tunnels lead to valves VO, JF
# Valve RT has flow rate=0; tunnels lead to valves UM, SE
# Valve RU has flow rate=0; tunnels lead to valves AR, WC
# Valve SE has flow rate=4; tunnels lead to valves GU, KM, CX, RT
# Valve MC has flow rate=0; tunnels lead to valves EJ, AR
# Valve TF has flow rate=0; tunnels lead to valves AH, VR
# Valve CX has flow rate=0; tunnels lead to valves SE, TO
# Valve GL has flow rate=11; tunnels lead to valves UY, KL, CY
# Valve GU has flow rate=0; tunnels lead to valves SE, EZ
# Valve VS has flow rate=0; tunnels lead to valves XN, IA
# Valve EZ has flow rate=0; tunnels lead to valves AA, GU
# Valve GK has flow rate=0; tunnels lead to valves FI, HZ
# Valve JT has flow rate=0; tunnels lead to valves TE, XN
# Valve DM has flow rate=0; tunnels lead to valves VR, HZ
# Valve AR has flow rate=16; tunnels lead to valves UI, RU, MC
# Valve XN has flow rate=9; tunnels lead to valves XP, JT, VS, GT, CY
# Valve CY has flow rate=0; tunnels lead to valves XN, GL
# Valve QT has flow rate=0; tunnels lead to valves UM, AA
# Valve KL has flow rate=0; tunnels lead to valves GL, NP
# Valve SK has flow rate=0; tunnels lead to valves XV, UP
# Valve OW has flow rate=12; tunnels lead to valves CZ, WC, FP
# Valve AK has flow rate=0; tunnels lead to valves AA, HS
# Valve XV has flow rate=0; tunnels lead to valves AA, SK
# Valve GT has flow rate=0; tunnels lead to valves XN, UM
# Valve FI has flow rate=0; tunnels lead to valves JF, GK
# Valve UY has flow rate=0; tunnels lead to valves JF, GL
# Valve UM has flow rate=5; tunnels lead to valves DV, GT, RT, QT
# Valve IQ has flow rate=0; tunnels lead to valves HZ, AH
# Valve JF has flow rate=10; tunnels lead to valves RF, FI, UY, RE, TS
# Valve TS has flow rate=0; tunnels lead to valves JF, FL
# Valve AH has flow rate=23; tunnels lead to valves IQ, FL, TF
# Valve HS has flow rate=0; tunnels lead to valves AK, VO
# Valve HZ has flow rate=20; tunnels lead to valves IQ, DM, GK
# Valve TO has flow rate=15; tunnel leads to valve CX
# Valve XP has flow rate=0; tunnels lead to valves AP, XN
# Valve AP has flow rate=0; tunnels lead to valves XP, AA
# Valve RE has flow rate=0; tunnels lead to valves JF, FP
# Valve UI has flow rate=0; tunnels lead to valves AR, CB
open_nodes = {WC, NP, AA, CB, CZ, LJ, FP, KM, DV, FL, IA, RF, RT, RU, MC, TF, CX, GU,
VS, EZ, GK, JT, DM, CY, QT, KL, SK, AK, XV, GT, FI, IQ, UY, TS, HS, XP, AP, RE, UI}
# 2372 - too high
# create a callback that adds a number in a random location
def callback():
global i
# BEST PRACTICE --- update .data in one step with a new dict
new_data = dict()
new_data['x'] = ds.data['x'] + [random()*70 + 15]
new_data['y'] = ds.data['y'] + [random()*70 + 15]
new_data['text_color'] = ds.data['text_color'] + [RdYlBu3[i%3]]
new_data['text'] = ds.data['text'] + [str(i)]
ds.data = new_data
i = i + 1
# add a button widget and configure with the call back
button = Button(label="Press Me")
button.on_click(callback)
# put the button and plot in a layout and add to the document
curdoc().add_root(column(button, p))