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

Skip to content

Commit 487623f

Browse files
Reference reorder (plotly#1488)
1 parent 17f37f3 commit 487623f

7 files changed

+65907
-81
lines changed

_data/get_plotschema.py

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
import json
2+
from urllib.request import urlopen
3+
4+
orders = json.load(open("orderings.json", "r"))
5+
6+
schema = json.load(urlopen("https://raw.githubusercontent.com/plotly/plotly.js/master/dist/plot-schema.json"))
7+
del schema["traces"]["area"]
8+
9+
def reorder_keys(parent, target, order):
10+
original = parent[target]
11+
parent[target] = {}
12+
for k in order:
13+
if k in original:
14+
parent[target][k] = original[k]
15+
for k in original.keys():
16+
if k not in parent[target]:
17+
parent[target][k] = original[k]
18+
print("missing key in %s: %s" % (target, k))
19+
20+
reorder_keys(schema, "traces", orders["traces"])
21+
reorder_keys(schema["layout"], "layoutAttributes", orders["layout"])
22+
23+
for trace in schema["traces"].values():
24+
reorder_keys(trace, "attributes", orders["trace_attr_order"])
25+
26+
json.dump(schema, open('plotschema.json', 'w'), indent=2)

0 commit comments

Comments
 (0)