From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from gate001.proxmox.com (gate001.proxmox.com [45.144.208.40]) by lore.proxmox.com (Postfix) with ESMTPS id C723D1FF0B3 for ; Thu, 26 Nov 2026 15:54:17 +0100 (CET) Received: from gate001.proxmox.com (localhost.localdomain [127.0.0.1]) by gate001.proxmox.com (Proxmox) with ESMTP id D093E216ED; Thu, 26 Nov 2026 15:54:16 +0100 (CET) From: Dominik Csapak To: pdm-devel@lists.proxmox.com Subject: [PATCH datacenter-manager 06/10] ui: dashboard: top entities: center data points in their interval Date: Thu, 26 Nov 2026 15:49:19 +0100 Message-ID: <20261126145410.3011676-7-d.csapak@proxmox.com> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20261126145410.3011676-1-d.csapak@proxmox.com> References: <20261126145410.3011676-1-d.csapak@proxmox.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SPAM-LEVEL: Spam detection results: 0 AWL 0.261 Adjusted score from AWL reputation of From: address DMARC_MISSING 0.1 Missing DMARC policy KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment (newer systems) RCVD_IN_DNSWL_MED -2.3 Sender listed at https://www.dnswl.org/, medium trust SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record Message-ID-Hash: FP55GJYKHX34HU6NT3OYX53IP7PNER6G X-Message-ID-Hash: FP55GJYKHX34HU6NT3OYX53IP7PNER6G X-MailFrom: d.csapak@proxmox.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; emergency; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.10 Precedence: list List-Id: Proxmox Datacenter Manager development discussion List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: since every data point covers the time up to the next one, but was drawn at the start of that interval. This shifted the whole graph half a data point to the left, and the gaps for missing data reached into the intervals of the data points around them. Draw the data points at the center of their interval instead, let the gaps cover exactly the interval of the missing data point, and select the data point for the tooltip whose interval contains the pointer. This makes no big difference for the colored usage bar, but graphs that draw the data points directly, e.g. as bars, would otherwise be cut off at the left edge. Signed-off-by: Dominik Csapak --- ui/src/dashboard/top_entities.rs | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/ui/src/dashboard/top_entities.rs b/ui/src/dashboard/top_entities.rs index 8985ebbc..b96240f5 100644 --- a/ui/src/dashboard/top_entities.rs +++ b/ui/src/dashboard/top_entities.rs @@ -104,8 +104,9 @@ impl Component for TopEntitiesComp { continue; } + // every data point covers the interval up to the next one let idx = (relative_pos * rrd.data.len() as f64) - .round() + .floor() .clamp(0.0, (rrd.data.len() - 1) as f64) as usize; @@ -306,7 +307,7 @@ fn graph_background(data: &[Option], threshold: f64) -> AttrValue { WARN_COLOR, (1.0 - point) * 100.0, GOOD_COLOR, - (i as f64) * 100.0 / data.len() as f64, + (i as f64 + 0.5) * 100.0 / data.len() as f64, ) } else { let point = ((point - threshold) / (1.0 - threshold)).clamp(0.0, 1.0); @@ -315,7 +316,7 @@ fn graph_background(data: &[Option], threshold: f64) -> AttrValue { ERR_COLOR, (1.0 - point) * 100.0, WARN_COLOR, - (i as f64) * 100.0 / data.len() as f64, + (i as f64 + 0.5) * 100.0 / data.len() as f64, ) }; list.push(format!( @@ -326,7 +327,7 @@ fn graph_background(data: &[Option], threshold: f64) -> AttrValue { // data points that were not collected yet. list.push(format!( "{BACKGROUND_COLOR} {:.0}% {:.0}%", - (i as f64 - 1.0) * 100.0 / data.len() as f64, + i as f64 * 100.0 / data.len() as f64, (i as f64 + 1.0) * 100.0 / data.len() as f64, )); }; -- 2.47.3