/
styles.py
142 lines (131 loc) · 2.74 KB
/
styles.py
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
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
"""
Possible properies
* background-color
* axes
* color
* visible
* label
* color
* ticklabel
* color
* x/y/z
* color
* visible
* label
* color
* ticklabel
* color
Run:
python -m ipyvolume.style
to update the json style (needed for the js side)
"""
from . import utils
import copy
styles = {}
_defaults = {
'axes': {
'visible': True,
'label' : {
'color': 'black'
},
'ticklabel': {
'color': 'black'
}
},
'box': {
'visible': True,
},
}
def create(name, properties):
styles[name] = properties
return properties
light = create("light", \
{
'background-color': 'white',
'axes': {
'color': 'black',
}
})
default = {}
utils.dict_deep_update(default, _defaults)
utils.dict_deep_update(default, light)
dark = create("dark", \
{
'background-color': '#000001', # for some reason we cannot set it to black!?!
'axes': {
'color': 'white',
'label': {
'color': 'white'
},
'ticklabel': {
'color': 'white'
},
}
})
demo = create("demo", \
{
'background-color': 'white',
'box' : {
'color': 'pink',
'visible': True,
},
'axes': {
'color': 'black',
'visible': True,
'x': {
'color': '#f00',
'label': {
'color': '#0f0'
},
'ticklabel': {
'color': '#00f'
},
},
'y': {
'color': '#0f0',
'label': {
'color': '#00f'
},
'ticklabel': {
'color': '#f00'
}
},
'z': {
'color': '#00f',
'label': {
'color': '#f00'
},
'ticklabel': {
'color': '#0f0'
}
}
}
})
minimal = {
'box' : {
'visible': False,
},
'axes': {
'visible': False,
}
}
nobox = create("nobox", {
'box' : {
'visible': False,
},
'axes': {
'visible': True,
}
})
if __name__ == "__main__":
import os
source = __file__
dest = os.path.join(os.path.dirname(source), "../js/data/style.json")
print(source, dest)
need_update = (not os.path.exists(dest)) or (os.path.getmtime(source) > os.path.getmtime(dest))
if need_update:
import json
print(styles)
with open(dest, "w") as f:
json.dump(styles, f, indent=2)
print("wrote json")