From c314511e2e637a1208998bdf1caec896bf6ce8cd Mon Sep 17 00:00:00 2001 From: TimZ99 Date: Mon, 18 May 2020 18:52:41 +0200 Subject: [PATCH] Added dynamic height to offline bar --- src/psm/Util/Server/HistoryGraph.php | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/psm/Util/Server/HistoryGraph.php b/src/psm/Util/Server/HistoryGraph.php index 8b5b8e38..8434c095 100644 --- a/src/psm/Util/Server/HistoryGraph.php +++ b/src/psm/Util/Server/HistoryGraph.php @@ -252,6 +252,20 @@ class HistoryGraph $prev_downtime = 0; $downtime = 0; + // get highest latency record for offline height + $n = count($records); + $highest_latency = 0.0000; + for ($i = 0; $i < $n; $i++) { + if (!array_key_exists('latency', $records[$i])) { + continue; + } + // Update if latency is higher + $highest_latency = $highest_latency < floatval($records[$i]['latency']) ? + floatval($records[$i]['latency']) : $highest_latency; + } + // to ms + $highest_latency = round($highest_latency * 1000); + // Create the list of points and server down zones foreach ($records as $record) { $time = strtotime($record['date']);