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 EBE2D1FF0B4 for ; Fri, 27 Nov 2026 17:13:26 +0100 (CET) Received: from gate001.proxmox.com (localhost.localdomain [127.0.0.1]) by gate001.proxmox.com (Proxmox) with ESMTP id 66ADA21770; Fri, 27 Nov 2026 17:13:05 +0100 (CET) From: Dominik Csapak To: pdm-devel@lists.proxmox.com Subject: [PATCH yew-widget-toolkit 18/38] widget: charts: map: draw the points in an svg element of their own Date: Fri, 27 Nov 2026 17:12:15 +0100 Message-ID: <20261127161241.3713494-19-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.254 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: WHL5DHZJS4TWUMPXN63H3SRXPGZJ5ANA X-Message-ID-Hash: WHL5DHZJS4TWUMPXN63H3SRXPGZJ5ANA 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: on top of the one with the map. When a point changes, e.g. the pulsing ring of a selected one, the browser has to draw that part of the svg element again. That includes the map below the point, which is by far the most expensive part. With the points in an element (and layer) of their own, only they are drawn again. Both elements have the same size and view box, so the coordinates stay the same. The one with the points handles the pointer for both. The layout is defined in the style sheet with the new 'pwt-map-container', 'pwt-map-layers', 'pwt-map-background' and 'pwt-map-overlay' classes. Signed-off-by: Dominik Csapak --- src/widget/charts/map/mod.rs | 39 ++++++++++++++++++++++++------------ 1 file changed, 26 insertions(+), 13 deletions(-) diff --git a/src/widget/charts/map/mod.rs b/src/widget/charts/map/mod.rs index bb1fad8..eb15fd8 100644 --- a/src/widget/charts/map/mod.rs +++ b/src/widget/charts/map/mod.rs @@ -52,6 +52,9 @@ impl MapPoint { #[derive(Properties, PartialEq, Clone)] pub struct Map { /// The map as an SVG element. + /// + /// It is drawn in an SVG element of its own below the points, and does not react to the + /// pointer. map: Html, #[prop_or(1000.0)] @@ -449,7 +452,22 @@ impl yew::Component for MapComp { let is_zoomed = zoom_level != 1.0; let fully_zoomed = zoom_level >= props.max_zoom_level; - let svg = Canvas::new() + let view_box = format!("0 0 {width} {height}"); + + // Only the content of the overlay changes while the map stands still, for example for + // animations. Keeping the map itself in an element of its own saves drawing it again + // each time. + let background = Canvas::new() + .class("pwt-map") + .class("pwt-map-background") + .attribute("viewBox", view_box.clone()) + .with_child( + Group::new() + .with_child(props.map.clone()) + .style("transform", self.zoom.get_transform()), + ); + + let overlay = Canvas::new() .onwheel({ let link = link.clone(); move |event: WheelEvent| { @@ -475,12 +493,8 @@ impl yew::Component for MapComp { }, ) .class("pwt-map") - .attribute("viewBox", format!("0 0 {width} {height}")) - .with_child( - Group::new() - .with_child(props.map.clone()) - .style("transform", self.zoom.get_transform()), - ); + .class("pwt-map-overlay") + .attribute("viewBox", view_box); let mut points = Group::new(); let mut tooltip = None; @@ -550,21 +564,20 @@ impl yew::Component for MapComp { Container::new() .with_std_props(&props.std_props) .listeners(&props.listeners) - .class(css::Display::Block) + .class("pwt-map-container") .with_child(SizeObserver::new( Container::new() - .class(css::Display::Flex) - .class(css::JustifyContent::Center) - .width("100%") - .height("100%") + .class("pwt-map-layers") // Clicking the map background (anything but a point, which stops // propagation) dismisses an open info card. The click that ends a drag goes // to the gesture detector instead of the map, so listen around both. .onclick(link.callback(|_| Msg::CloseInfo)) .onpointerdown(link.callback(|_| Msg::PointerDown)) + .with_child(background) .with_child( GestureDetector::new( - svg.with_child(points) + overlay + .with_child(points) .into_html_with_ref(self.svg_ref.clone()), ) .on_drag(link.callback(Msg::Drag)) -- 2.47.3