UTI: PoC - Make detailed hover information copyable 35/35835/4
authorTibor Frank <tifrank@cisco.com>
Thu, 31 Mar 2022 06:43:15 +0000 (08:43 +0200)
committerTibor Frank <tifrank@cisco.com>
Fri, 1 Apr 2022 06:02:37 +0000 (06:02 +0000)
Change-Id: Ib313d6289412b921caa528c3984a640c3e4862eb
Signed-off-by: Tibor Frank <tifrank@cisco.com>
resources/tools/dash/app/pal/trending/graphs.py
resources/tools/dash/app/pal/trending/layout.py
resources/tools/dash/app/pal/trending/layout.yaml

index da528a9..8cb96ea 100644 (file)
@@ -218,7 +218,7 @@ def trending_tput(data: pd.DataFrame, sel:dict, layout: dict, start: datetime,
                     anomaly_x.append(x_axis[idx])
                     anomaly_y.append(trend_avg[idx])
                     anomaly_color.append(_ANOMALY_COLOR[anomaly])
                     anomaly_x.append(x_axis[idx])
                     anomaly_y.append(trend_avg[idx])
                     anomaly_color.append(_ANOMALY_COLOR[anomaly])
-            anomaly_color.append([0.0, 1.0])
+            anomaly_color.append([0.0, 0.5, 1.0])
             traces.append(
                 go.Scatter(
                     x=anomaly_x,
             traces.append(
                 go.Scatter(
                     x=anomaly_x,
index 6369a02..6be71ac 100644 (file)
@@ -15,6 +15,7 @@
 """
 
 
 """
 
 
+import json
 import pandas as pd
 
 from dash import dcc
 import pandas as pd
 
 from dash import dcc
@@ -173,6 +174,18 @@ class Layout:
                         )
                     ],
                     type="circle"
                         )
                     ],
                     type="circle"
+                ),
+                html.Div(
+                    children=[
+                        dcc.Markdown("""
+                        **Metadata**
+
+                        Click on data points in the graph.
+                        """),
+                        html.Pre(
+                            id="hover-metadata"
+                        )
+                    ]
                 )
             ],
             style={
                 )
             ],
             style={
@@ -569,3 +582,12 @@ class Layout:
                     }
                     return (no_update, store_sel, _list_tests(),
                         no_update, no_update, no_update, style)
                     }
                     return (no_update, store_sel, _list_tests(),
                         no_update, no_update, no_update, style)
+
+        @app.callback(
+            Output("hover-metadata", "children"),
+            Input("graph", "clickData")
+        )
+        def _show_metadata(hover_data):
+            if not hover_data:
+                raise PreventUpdate
+            return json.dumps(hover_data, indent=2)
index be69d83..143ade1 100644 (file)
@@ -5,7 +5,7 @@ plot-trending:
   autosize: True
   showlegend: True
   # width: 1100
   autosize: True
   showlegend: True
   # width: 1100
-  height: 800
+  height: 600
   yaxis:
     showticklabels: True
     tickformat: ".3s"
   yaxis:
     showticklabels: True
     tickformat: ".3s"
@@ -67,7 +67,7 @@ plot-trending:
     l: 70
   legend:
     orientation: "h"
     l: 70
   legend:
     orientation: "h"
-    y: -0.2
+    y: -0.18
     xanchor: "auto"
     traceorder: "normal"
     bordercolor: "rgb(238, 238, 238)"
     xanchor: "auto"
     traceorder: "normal"
     bordercolor: "rgb(238, 238, 238)"