add support for colors in plots 88/75388/2
authorDibya Prakash Das <dibyadascool@gmail.com>
Wed, 22 Aug 2018 20:14:14 +0000 (01:44 +0530)
committerLuis Gomez <ecelgp@gmail.com>
Sun, 2 Sep 2018 16:35:07 +0000 (16:35 +0000)
Change-Id: I87be96f0f807109e28e94af8642a40239dc4620f
Signed-off-by: Dibya Prakash Das <dibyadascool@gmail.com>
csit/scripts/generate_uiStateJSON.py [new file with mode: 0644]
csit/scripts/push_to_elk.py
dashboard/dash_config.yaml
dashboard/viz_config.yaml

diff --git a/csit/scripts/generate_uiStateJSON.py b/csit/scripts/generate_uiStateJSON.py
new file mode 100644 (file)
index 0000000..6db4e5f
--- /dev/null
@@ -0,0 +1,54 @@
+UI_STATE_BODY = {
+    "vis": {
+        "colors": None
+    }
+}
+
+
+def generate(dash_config, viz_config):
+
+    colors = {}
+
+    try:
+        series = dash_config['y-axis']['series']
+        for _, value in series.items():
+            try:
+                colors[value['label']] = value['color']
+            except KeyError:
+                continue
+    except KeyError:
+        pass
+
+    try:
+        series = viz_config['series']
+        for _, value in series.items():
+            try:
+                colors[value['label']] = value['color']
+            except KeyError:
+                continue
+    except KeyError:
+        pass
+
+    try:
+        seriesParams = dash_config['y-axis']['seriesParams']
+        for _, value in seriesParams.items():
+            try:
+                colors[value['label']] = value['color']
+            except KeyError:
+                continue
+    except KeyError:
+        pass
+
+    try:
+        seriesParams = viz_config['seriesParams']
+        for _, value in seriesParams.items():
+            try:
+                colors[value['label']] = value['color']
+            except KeyError:
+                continue
+    except KeyError:
+        pass
+
+    UI_STATE_BODY['vis']['colors'] = colors
+
+    return UI_STATE_BODY
index 53cafd8c44f03839363b604c9caad3ec06463cb1..9b67d96f7f25ca8a6068bbec79d2d474dcd799f2 100755 (executable)
@@ -52,7 +52,7 @@ and plot files available in workspace available post-build.
 import json
 import os
 import sys
-
+import glob
 
 # 3rd party lib
 from elasticsearch import Elasticsearch, RequestsHttpConnection, exceptions
@@ -60,6 +60,7 @@ import yaml
 
 # User defined libs
 import generate_visState as vis_gen
+import generate_uiStateJSON as uiStateJSON_gen
 import generate_dashVis as dash_gen
 import data_generate as data_gen
 
@@ -193,6 +194,9 @@ for _, i in dash_config['dashboard']['viz'].items():
     intermediate_format, visState = vis_gen.generate(
         i, viz_config[i['viz-template']])
 
+    uiStateJSON = uiStateJSON_gen.generate(
+        i, viz_config[i['viz-template']])
+
     # p(intermediate_format)
     # p(visState)
 
@@ -213,6 +217,7 @@ for _, i in dash_config['dashboard']['viz'].items():
 
     VIZ_BODY['visualization']['title'] = intermediate_format['title']
     VIZ_BODY['visualization']['visState'] = JSONToString(visState)
+    VIZ_BODY['visualization']['uiStateJSON'] = JSONToString(uiStateJSON)
     VIZ_BODY['visualization']['description'] = intermediate_format['desc']
 
     p(VIZ_BODY)
index 3fc56821c2db5443441420d7c0f1aed556558974..9a9c7c585a58bbcf0faec6aec7e17d174c26dab3 100644 (file)
@@ -31,12 +31,15 @@ dashboard:
           1:
             field: performance.plots.rate.Config DS
             label: Config DS
+            color: red
           2:
             field: performance.plots.rate.OVS Switch
             label: OVS Switch
+            color: yellow
           3:
             field:  performance.plots.rate.Operational DS
             label: Operational DS
+            color: blue
 
       co_ords:
         h: 3
index 7bf87eecf5daeb3d9d41281f4a9c2ba327ec4170..51f29b5d878f95154d49052e6b82479cb08e54c9 100644 (file)
@@ -15,6 +15,7 @@ opendaylight-test-feature:
             label: Pass tests
             schema: metric
             value_axis: 1
+            color: green
         fail:
             data_type: histogram
             mode: stacked
@@ -22,6 +23,7 @@ opendaylight-test-feature:
             label: Fail tests
             schema: metric
             value_axis: 1
+            color: red
         build:
             field: performance.test-run
             label: Build Number