add support for colors in plots
[integration/test.git] / csit / scripts / generate_uiStateJSON.py
1 UI_STATE_BODY = {
2     "vis": {
3         "colors": None
4     }
5 }
6
7
8 def generate(dash_config, viz_config):
9
10     colors = {}
11
12     try:
13         series = dash_config['y-axis']['series']
14         for _, value in series.items():
15             try:
16                 colors[value['label']] = value['color']
17             except KeyError:
18                 continue
19     except KeyError:
20         pass
21
22     try:
23         series = viz_config['series']
24         for _, value in series.items():
25             try:
26                 colors[value['label']] = value['color']
27             except KeyError:
28                 continue
29     except KeyError:
30         pass
31
32     try:
33         seriesParams = dash_config['y-axis']['seriesParams']
34         for _, value in seriesParams.items():
35             try:
36                 colors[value['label']] = value['color']
37             except KeyError:
38                 continue
39     except KeyError:
40         pass
41
42     try:
43         seriesParams = viz_config['seriesParams']
44         for _, value in seriesParams.items():
45             try:
46                 colors[value['label']] = value['color']
47             except KeyError:
48                 continue
49     except KeyError:
50         pass
51
52     UI_STATE_BODY['vis']['colors'] = colors
53
54     return UI_STATE_BODY