From mboxrd@z Thu Jan  1 00:00:00 1970
Return-Path: <yew-devel-bounces@lists.proxmox.com>
Received: from firstgate.proxmox.com (firstgate.proxmox.com [IPv6:2a01:7e0:0:424::9])
	by lore.proxmox.com (Postfix) with ESMTPS id 8E3FA1FF195
	for <inbox@lore.proxmox.com>; Fri, 30 May 2025 14:22:19 +0200 (CEST)
Received: from firstgate.proxmox.com (localhost [127.0.0.1])
	by firstgate.proxmox.com (Proxmox) with ESMTP id 8BF3B2E6DF;
	Fri, 30 May 2025 14:22:35 +0200 (CEST)
From: Dominik Csapak <d.csapak@proxmox.com>
To: yew-devel@lists.proxmox.com
Date: Fri, 30 May 2025 14:21:52 +0200
Message-Id: <20250530122202.2779300-11-d.csapak@proxmox.com>
X-Mailer: git-send-email 2.39.5
In-Reply-To: <20250530122202.2779300-1-d.csapak@proxmox.com>
References: <20250530122202.2779300-1-d.csapak@proxmox.com>
MIME-Version: 1.0
X-SPAM-LEVEL: Spam detection results:  0
 AWL 0.022 Adjusted score from AWL reputation of From: address
 BAYES_00                 -1.9 Bayes spam probability is 0 to 1%
 DMARC_MISSING             0.1 Missing DMARC policy
 KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment
 SPF_HELO_NONE           0.001 SPF: HELO does not publish an SPF Record
 SPF_PASS               -0.001 SPF: sender matches SPF record
Subject: [yew-devel] [PATCH yew-comp 10/20] rrd: give all elements in svg
 keys
X-BeenThere: yew-devel@lists.proxmox.com
X-Mailman-Version: 2.1.29
Precedence: list
List-Id: Yew framework devel list at Proxmox <yew-devel.lists.proxmox.com>
List-Unsubscribe: <https://lists.proxmox.com/cgi-bin/mailman/options/yew-devel>, 
 <mailto:yew-devel-request@lists.proxmox.com?subject=unsubscribe>
List-Archive: <http://lists.proxmox.com/pipermail/yew-devel/>
List-Post: <mailto:yew-devel@lists.proxmox.com>
List-Help: <mailto:yew-devel-request@lists.proxmox.com?subject=help>
List-Subscribe: <https://lists.proxmox.com/cgi-bin/mailman/listinfo/yew-devel>, 
 <mailto:yew-devel-request@lists.proxmox.com?subject=subscribe>
Reply-To: Yew framework devel list at Proxmox <yew-devel@lists.proxmox.com>
Content-Type: text/plain; charset="us-ascii"
Content-Transfer-Encoding: 7bit
Errors-To: yew-devel-bounces@lists.proxmox.com
Sender: "yew-devel" <yew-devel-bounces@lists.proxmox.com>

otherwise adding the selection rectangle (or others in the future)
redraws the whole svg, which messes up the events, for example we then
get a pointerenter event for the svg but no pointerleave, even though
the mouse did not move

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
---
 src/rrd/graph.rs | 42 ++++++++++++++++++++++++++++++++----------
 1 file changed, 32 insertions(+), 10 deletions(-)

diff --git a/src/rrd/graph.rs b/src/rrd/graph.rs
index e2ac767..7f02274 100644
--- a/src/rrd/graph.rs
+++ b/src/rrd/graph.rs
@@ -480,14 +480,22 @@ impl PwtRRDGraph {
         }
         let mut children: Vec<Html> = Vec::new();
 
-        children.push(Path::new().class("pwt-rrd-grid").d(grid_path).into());
-        children.extend(time_labels);
-
-        let y_label_group = Group::new()
-            .node_ref(self.y_label_ref.clone())
-            .children(value_labels);
-
-        children.push(y_label_group.into());
+        children.push(
+            Path::new()
+                .key("grid")
+                .class("pwt-rrd-grid")
+                .d(grid_path)
+                .into(),
+        );
+        children.push(Group::new().key("time-labels").children(time_labels).into());
+
+        children.push(
+            Group::new()
+                .key("value-labels")
+                .node_ref(self.y_label_ref.clone())
+                .children(value_labels)
+                .into(),
+        );
 
         if self.serie0_visible && props.serie0.is_some() {
             let path = compute_outline_path(data0, data1, compute_x, compute_y);
@@ -495,8 +503,13 @@ impl PwtRRDGraph {
                 compute_fill_path(data0, data1, min_data, max_data, compute_x, compute_y);
 
             children.extend(vec![
-                Path::new().class("pwt-rrd-outline-path1").d(path).into(),
                 Path::new()
+                    .key("series0-path")
+                    .class("pwt-rrd-outline-path1")
+                    .d(path)
+                    .into(),
+                Path::new()
+                    .key("series0-fill")
                     .class("pwt-rrd-fill-path1")
                     .d(pos_fill_path)
                     .into(),
@@ -509,8 +522,13 @@ impl PwtRRDGraph {
                 compute_fill_path(data0, data2, min_data, max_data, compute_x, compute_y);
 
             children.extend(vec![
-                Path::new().class("pwt-rrd-outline-path2").d(path).into(),
                 Path::new()
+                    .key("series1-path")
+                    .class("pwt-rrd-outline-path2")
+                    .d(path)
+                    .into(),
+                Path::new()
+                    .key("series1-fill")
                     .class("pwt-rrd-fill-path2")
                     .d(pos_fill_path)
                     .into(),
@@ -535,6 +553,7 @@ impl PwtRRDGraph {
 
                     children.push(
                         Rect::new()
+                            .key("selection-rect")
                             .class("pwt-rrd-selection")
                             .position(start_x as f32, end_y as f32)
                             .width((end_x - start_x) as f32)
@@ -557,6 +576,7 @@ impl PwtRRDGraph {
                         let py = compute_y(*v) as f32;
                         children.push(
                             Circle::new()
+                                .key("selection-circle1")
                                 .class("pwt-rrd-selected-datapoint")
                                 .position(px, py)
                                 .r(5)
@@ -570,6 +590,7 @@ impl PwtRRDGraph {
                         let py = compute_y(*v) as f32;
                         children.push(
                             Circle::new()
+                                .key("selection-circle2")
                                 .class("pwt-rrd-selected-datapoint")
                                 .position(px, py)
                                 .r(5)
@@ -588,6 +609,7 @@ impl PwtRRDGraph {
 
             children.push(
                 Path::new()
+                    .key("cross")
                     .class("pwt-rrd-cross")
                     .d(format!("M {x} 0 L {x} {max_y} M {min_x} {y} L {max_x} {y}"))
                     .into(),
-- 
2.39.5



_______________________________________________
yew-devel mailing list
yew-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/yew-devel