Skip to content

Commit 5a789d1

Browse files
murrantlaf
andauthored
Fix alert history graph when empty (librenms#19751)
* Fix alert history graph when empty * Update print-graph-alerts.inc.php --------- Co-authored-by: Neil Lathwood <gh+n@laf.io>
1 parent cbb1299 commit 5a789d1

1 file changed

Lines changed: 4 additions & 4 deletions

File tree

includes/html/print-graph-alerts.inc.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -102,10 +102,10 @@
102102
},
103103
zoomMin: 86400, //24hrs
104104
zoomMax: <?php
105-
$first_date = reset($data);
106-
$last_date = end($data);
107-
$milisec_diff = abs(strtotime((string) $first_date['x']) - strtotime((string) $last_date['x'])) * 1000;
108-
echo $milisec_diff;
105+
$firstDate = reset($data)['x'] ?? null;
106+
$lastDate = end($data)['x'] ?? null;
107+
$millisecondDiff = ($firstDate && $lastDate) ? abs(strtotime((string) $firstDate) - strtotime((string) $lastDate)) * 1000 : 0;
108+
echo $millisecondDiff;
109109
?>,
110110
orientation:'top'
111111
};

0 commit comments

Comments
 (0)