FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
graphing-library-docs/_data/get_plotschema.py at master · plotly/graphing-library-docs · GitHub
Uh oh!
There was an error while loading.
Please reload this page
.
plotly
/
graphing-library-docs
Public
Uh oh!
There was an error while loading.
Please reload this page
.
Notifications
You must be signed in to change notification settings
Fork
71
Star
59
Code
Issues
29
Pull requests
23
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Issues
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
graphing-library-docs
/
_data
/
get_plotschema.py
Copy path
More file actions
More file actions
Latest commit
History
History
History
117 lines (102 loc) · 3.74 KB
Breadcrumbs
graphing-library-docs
/
_data
/
get_plotschema.py
Copy path
File metadata and controls
117 lines (102 loc) · 3.74 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
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
import
json
from
urllib
.
request
import
urlopen
import
sys
version
=
sys
.
argv
[
1
]
orders
=
json
.
load
(
open
(
"orderings.json"
,
"r"
))
schema
=
json
.
load
(
urlopen
(
"https://raw.githubusercontent.com/plotly/plotly.js/v%s/dist/plot-schema.json"
%
version
)
)
# schema = json.load(open("plot-schema.json", "r"))
def
reorder_keys
(
parent
,
target
,
order
):
original
=
parent
[
target
]
parent
[
target
]
=
{}
for
k
in
order
:
if
k
in
original
:
parent
[
target
][
k
]
=
original
[
k
]
for
k
in
original
.
keys
():
if
k
not
in
parent
[
target
]:
parent
[
target
][
k
]
=
original
[
k
]
print
(
"missing key in %s: %s"
%
(
target
,
k
))
reorder_keys
(
schema
,
"traces"
,
orders
[
"traces"
])
reorder_keys
(
schema
[
"layout"
],
"layoutAttributes"
,
orders
[
"layout"
])
for
trace
in
schema
[
"traces"
].
values
():
reorder_keys
(
trace
,
"attributes"
,
orders
[
"trace_attr_order"
])
def
make_underscore
(
path
,
section
,
value
):
if
section
==
"layout"
:
patterns
=
dict
(
xaxis
=
"xaxes"
,
yaxis
=
"yaxes"
,
scene
=
"scenes"
,
coloraxis
=
"coloraxes"
,
geo
=
"geos"
,
mapbox
=
"mapboxes"
,
ternary
=
"ternaries"
,
polar
=
"polars"
,
smith
=
"smiths"
,
)
item_patterns
=
dict
(
shapes
=
"shapes"
,
images
=
"layout_images"
,
annotations
=
"annotations"
,
)
if
len
(
path
)
>
0
and
path
[
0
]
in
patterns
:
if
len
(
path
)
>
1
:
return
(
"fig.update_"
+
patterns
[
path
[
0
]]
+
"("
+
"_"
.
join
(
path
[
1
:])
+
"="
+
value
+
")"
)
return
"fig.update_"
+
patterns
[
path
[
0
]]
+
"(...)"
elif
len
(
path
)
>
0
and
path
[
0
]
in
item_patterns
:
if
len
(
path
)
>
3
:
return
(
"fig.update_"
+
item_patterns
[
path
[
0
]]
+
"("
+
"_"
.
join
(
path
[
3
:])
+
"="
+
value
+
")"
)
return
"fig.update_"
+
item_patterns
[
path
[
0
]]
+
"(...)"
elif
len
(
path
)
>
0
:
return
"fig.update_layout("
+
"_"
.
join
(
path
)
+
"="
+
value
+
")"
return
"fig.update_layout(...)"
else
:
if
len
(
path
)
>
0
:
return
(
"fig.update_traces("
+
"_"
.
join
(
path
)
+
"="
+
value
+
", selector=dict(type='"
+
section
+
"'))"
)
return
"fig.update_traces(..., selector=dict(type='"
+
section
+
"'))"
def
underscores
(
attr
,
path
,
section
):
if
"items"
not
in
attr
or
(
len
(
path
)
>
0
and
path
[
0
]
in
[
"shapes"
,
"annotations"
,
"images"
]
):
if
"_deprecated"
in
attr
:
del
attr
[
"_deprecated"
]
for
k
in
attr
:
if
type
(
attr
[
k
])
==
dict
and
not
k
.
endswith
(
"src"
):
underscores
(
attr
[
k
],
path
+
[
k
],
section
)
if
len
(
path
)
==
0
or
path
[
-
1
]
!=
"items"
:
if
attr
.
get
(
"role"
)
==
"object"
:
attr
[
"magic_underscores"
]
=
make_underscore
(
path
,
section
,
"dict(...)"
)
else
:
attr
[
"magic_underscores"
]
=
make_underscore
(
path
,
section
,
"<VALUE>"
)
elif
len
(
path
)
==
0
or
path
[
-
1
]
!=
"items"
:
attr
[
"magic_underscores"
]
=
make_underscore
(
path
,
section
,
"list(...)"
)
underscores
(
schema
[
"layout"
][
"layoutAttributes"
], [],
"layout"
)
for
trace_type
in
schema
[
"traces"
]:
underscores
(
schema
[
"traces"
][
trace_type
][
"attributes"
], [],
trace_type
)
json
.
dump
(
schema
,
open
(
"plotschema.json"
,
"w"
),
indent
=
2
)
json
.
dump
(
dict
(
version
=
version
),
open
(
"jsversion.json"
,
"w"
),
indent
=
2
)
Back
|
FazBrowse Home
|
New Git URL