Migrate Get Requests invocations(libraries)
[integration/test.git] / csit / scripts / generate_uiStateJSON.py
1 # Template for UIState (Currently supports only colors)
2 UI_STATE_BODY = {"vis": {"colors": None}}
3
4
5 def generate(dash_config, viz_config):
6
7     colors = {}
8
9     # Check for 'color' key in 'series' or 'seriesParams' in
10     # either viz_config and dash_config
11
12     # Note:- 'series' simplifies 'seriesParams' and 'aggs'
13     # and avoids duplication
14
15     try:
16         series = dash_config["y-axis"]["series"]
17         for _, value in series.items():
18             try:
19                 colors[value["label"]] = value["color"]
20             except KeyError:
21                 continue
22     except KeyError:
23         pass
24
25     try:
26         series = viz_config["series"]
27         for _, value in series.items():
28             try:
29                 colors[value["label"]] = value["color"]
30             except KeyError:
31                 continue
32     except KeyError:
33         pass
34
35     try:
36         seriesParams = dash_config["y-axis"]["seriesParams"]
37         for _, value in seriesParams.items():
38             try:
39                 colors[value["label"]] = value["color"]
40             except KeyError:
41                 continue
42     except KeyError:
43         pass
44
45     try:
46         seriesParams = viz_config["seriesParams"]
47         for _, value in seriesParams.items():
48             try:
49                 colors[value["label"]] = value["color"]
50             except KeyError:
51                 continue
52     except KeyError:
53         pass
54
55     UI_STATE_BODY["vis"]["colors"] = colors
56
57     return UI_STATE_BODY