C-Dash: set x-range max value to utc.now 66/41566/1
authorTibor Frank <[email protected]>
Thu, 12 Sep 2024 11:39:42 +0000 (11:39 +0000)
committerTibor Frank <[email protected]>
Thu, 12 Sep 2024 11:39:42 +0000 (11:39 +0000)
- trending and statistics

Change-Id: I05350c7834072d7bac101b018682ca0e051e4fef
Signed-off-by: Tibor Frank <[email protected]>
csit.infra.dash/app/cdash/stats/graphs.py
csit.infra.dash/app/cdash/stats/layout.yaml
csit.infra.dash/app/cdash/trending/graphs.py
csit.infra.dash/app/cdash/trending/layout.yaml

index 4b25396..61eef41 100644 (file)
@@ -17,6 +17,9 @@
 import plotly.graph_objects as go
 import pandas as pd
 
+from datetime import datetime
+from pytz import UTC
+
 from ..utils.constants import Constants as C
 
 
@@ -86,6 +89,7 @@ def graph_statistics(df: pd.DataFrame, job: str, layout: dict) -> tuple:
         )
     )
 
+    x_range = [data["start_time"][0], datetime.now(tz=UTC).strftime("%Y-%m-%d")]
     tickvals = [0, ]
     step = max(data["duration"]) / 5
     for i in range(5):
@@ -97,6 +101,7 @@ def graph_statistics(df: pd.DataFrame, job: str, layout: dict) -> tuple:
             f"{(val // 3600):02d}:{((val % 3600) // 60):02d}" \
                 for val in tickvals
         ]
+        layout_duration["xaxis"]["range"] = x_range
         fig_duration.update_layout(layout_duration)
 
     # Passed / failed:
@@ -124,6 +129,7 @@ def graph_statistics(df: pd.DataFrame, job: str, layout: dict) -> tuple:
     )
     layout_pf = layout.get("plot-stats-passed", dict())
     if layout_pf:
+        layout_pf["xaxis"]["range"] = x_range
         fig_passed.update_layout(layout_pf)
 
     return fig_passed, fig_duration
index 4886546..70ba940 100644 (file)
@@ -15,7 +15,7 @@ plot-stats-passed:
   xaxis:
     title: 'Date [MMDD]'
     type: "date"
-    autorange: True
+    autorange: False
     fixedrange: False
     showgrid: True
     gridcolor: "rgb(238, 238, 238)"
@@ -56,7 +56,7 @@ plot-stats-duration:
   xaxis:
     title: 'Date [MMDD]'
     type: "date"
-    autorange: True
+    autorange: False
     fixedrange: False
     showgrid: True
     gridcolor: "rgb(238, 238, 238)"
index 816b28e..512a9d8 100644 (file)
@@ -19,6 +19,8 @@ import plotly.graph_objects as go
 import pandas as pd
 
 from numpy import nan
+from datetime import datetime
+from pytz import UTC
 
 from ..utils.constants import Constants as C
 from ..utils.utils import get_color, get_hdrh_latencies
@@ -453,11 +455,13 @@ def graph_trending(
     fig_tput = None
     fig_lat = None
     fig_band = None
+    start_times = list()
     y_units = set()
     for idx, itm in enumerate(sel):
         df = select_trending_data(data, itm)
         if df is None or df.empty:
             continue
+        start_times.append(df["start_time"][0])
 
         if normalize:
             phy = itm["phy"].rsplit("-", maxsplit=2)
@@ -528,15 +532,21 @@ def graph_trending(
 
         y_units.update(units)
 
+    x_range = [min(start_times), datetime.now(tz=UTC).strftime("%Y-%m-%d")]
     if fig_tput:
-        fig_layout = layout.get("plot-trending-tput", dict())
-        fig_layout["yaxis"]["title"] = \
+        layout_tput = layout.get("plot-trending-tput", dict())
+        layout_tput["yaxis"]["title"] = \
             f"Throughput [{'|'.join(sorted(y_units))}]"
-        fig_tput.update_layout(fig_layout)
+        layout_tput["xaxis"]["range"] = x_range
+        fig_tput.update_layout(layout_tput)
     if fig_band:
-        fig_band.update_layout(layout.get("plot-trending-bandwidth", dict()))
+        layout_band = layout.get("plot-trending-bandwidth", dict())
+        layout_band["xaxis"]["range"] = x_range
+        fig_band.update_layout(layout_band)
     if fig_lat:
-        fig_lat.update_layout(layout.get("plot-trending-lat", dict()))
+        layout_lat = layout.get("plot-trending-lat", dict())
+        layout_lat["xaxis"]["range"] = x_range
+        fig_lat.update_layout(layout_lat)
 
     return fig_tput, fig_band, fig_lat
 
index e4fcd29..948ca93 100644 (file)
@@ -16,7 +16,7 @@ plot-trending-tput:
   xaxis:
     title: 'Date [MMDD]'
     type: "date"
-    autorange: True
+    autorange: False
     fixedrange: False
     showgrid: True
     gridcolor: "rgb(238, 238, 238)"
@@ -56,7 +56,7 @@ plot-trending-bandwidth:
   xaxis:
     title: 'Date [MMDD]'
     type: "date"
-    autorange: True
+    autorange: False
     fixedrange: False
     showgrid: True
     gridcolor: "rgb(238, 238, 238)"
@@ -96,7 +96,7 @@ plot-trending-lat:
   xaxis:
     title: 'Date [MMDD]'
     type: "date"
-    autorange: True
+    autorange: False
     fixedrange: False
     showgrid: True
     gridcolor: "rgb(238, 238, 238)"