From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from gate001.proxmox.com (gate001.proxmox.com [IPv6:2a0f:8001:1:32::40]) by lore.proxmox.com (Postfix) with ESMTPS id 909881FF0B4 for ; Fri, 27 Nov 2026 17:13:34 +0100 (CET) Received: from gate001.proxmox.com (localhost.localdomain [127.0.0.1]) by gate001.proxmox.com (Proxmox) with ESMTP id 8CC0521769; Fri, 27 Nov 2026 17:13:11 +0100 (CET) From: Dominik Csapak To: pdm-devel@lists.proxmox.com Subject: [PATCH yew-widget-toolkit 20/38] widget: charts: map: keep the tooltip on its points when clustering anew Date: Fri, 27 Nov 2026 17:12:17 +0100 Message-ID: <20261127161241.3713494-21-d.csapak@proxmox.com> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20261127161241.3713494-1-d.csapak@proxmox.com> References: <20261127161241.3713494-1-d.csapak@proxmox.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SPAM-LEVEL: Spam detection results: 0 AWL 0.253 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: GUCXFJQQTI32EDL6A2CE4ASF75UPA6SP X-Message-ID-Hash: GUCXFJQQTI32EDL6A2CE4ASF75UPA6SP 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: The tooltip remembers the index of the cluster it is shown for. When zooming changes the clusters, that index can belong to another cluster, so the tooltip suddenly showed other points than the hovered ones. Look up the cluster with the same points instead, like we already do for the info card, and hide the tooltip if there is none. Signed-off-by: Dominik Csapak --- src/widget/charts/map/mod.rs | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/src/widget/charts/map/mod.rs b/src/widget/charts/map/mod.rs index d75ea73..37a595a 100644 --- a/src/widget/charts/map/mod.rs +++ b/src/widget/charts/map/mod.rs @@ -204,14 +204,18 @@ impl MapComp { }); } - if let Some(index) = self.info_visible { - // keep the open card on the same set of points across re-clustering (the center - // shifts with zoom, so match on membership), or reset it if that cluster is gone - let open_indices = &self.clusters[index].indices; - self.info_visible = clusters + // Keep the open card and the tooltip on the same set of points across re-clustering (the + // center shifts with zoom, so match on membership), or reset them if a cluster is gone. + let remap = |index: usize| { + let indices = &self.clusters.get(index)?.indices; + clusters .iter() - .position(|cluster| &cluster.indices == open_indices); - } + .position(|cluster| &cluster.indices == indices) + }; + self.info_visible = self.info_visible.and_then(remap); + self.tooltip = self + .tooltip + .and_then(|(index, x, y)| Some((remap(index)?, x, y))); self.clusters = clusters; } -- 2.47.3