]> git.proxmox.com Git - flutter/pve_flutter_frontend.git/commitdiff
widget/line chart: clamp maxima to 0.001 as lower limit
authorThomas Lamprecht <t.lamprecht@proxmox.com>
Tue, 14 Dec 2021 18:39:45 +0000 (19:39 +0100)
committerThomas Lamprecht <t.lamprecht@proxmox.com>
Tue, 14 Dec 2021 18:39:47 +0000 (19:39 +0100)
this is used for scaling the graph, and if we do not clamp then a
idleing guest that produces cpu load noise < 0.001 looks like there's
a lot going on, as its scaled the same as when there's intertia
changes going on with an actual relevant load level.

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
lib/widgets/proxmox_line_chart.dart

index 625e759cd117c4f151c1c1753c676679c21da9b9..5352a47dc07918119f30b0f61e9a22ceb39078d8 100644 (file)
@@ -32,7 +32,10 @@ class ProxmoxLineChart extends CustomPainter {
     paint.strokeWidth = 1;
 
     var path = Path();
-    final globalMaxima = data!.map((e) => e.y).reduce((a, b) => max(a, b));
+    final globalMaxima = max(
+      data!.map((e) => e.y).reduce((a, b) => max(a, b)),
+      0.001, // avoid that almost zero usage looks like a high load
+    );
     final points = convertDataToPoints(data!, size, staticMax ?? globalMaxima);
     points.asMap().forEach((i, el) {
       if (i == 0) {