From: Dominik Csapak <d.csapak@proxmox.com>
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 [thread overview]
Message-ID: <20261126145410.3011676-7-d.csapak@proxmox.com> (raw)
In-Reply-To: <20261126145410.3011676-1-d.csapak@proxmox.com>
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 <d.csapak@proxmox.com>
---
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<f64>], 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<f64>], 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<f64>], 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
next prev parent reply other threads:[~2026-11-26 14:54 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-26 14:49 [PATCH datacenter-manager 00/10] dashborad: add widget settings and leaderboard graph types Dominik Csapak
2026-11-26 14:49 ` [PATCH datacenter-manager 01/10] ui: dashboard: use plural for the container panel Dominik Csapak
2026-11-26 14:49 ` [PATCH datacenter-manager 02/10] ui: views: keep the icon for custom widget titles Dominik Csapak
2026-11-26 14:49 ` [PATCH datacenter-manager 03/10] ui: views: add options panel for editing widgets Dominik Csapak
2026-11-26 14:49 ` [PATCH datacenter-manager 04/10] ui: views: add only one menu entry per widget type Dominik Csapak
2026-11-26 14:49 ` [PATCH datacenter-manager 05/10] ui: dashboard: top entities: only build graph gradients on change Dominik Csapak
2026-11-26 14:49 ` Dominik Csapak [this message]
2026-11-26 14:49 ` [PATCH datacenter-manager 07/10] ui: dashboard: top entities: limit color stops by graph width Dominik Csapak
2026-11-26 14:49 ` [PATCH datacenter-manager 08/10] ui: dashboard: top entities: add line, area and bar graph types Dominik Csapak
2026-11-26 14:49 ` [PATCH datacenter-manager 09/10] ui: dashboard: top entities: show indicator line for tooltip point Dominik Csapak
2026-11-26 14:49 ` [PATCH datacenter-manager 10/10] docs: custom views: mention the graph types of the leaderboard widget Dominik Csapak
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261126145410.3011676-7-d.csapak@proxmox.com \
--to=d.csapak@proxmox.com \
--cc=pdm-devel@lists.proxmox.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox