public inbox for pdm-devel@lists.proxmox.com
 help / color / mirror / Atom feed
From: Dominik Csapak <d.csapak@proxmox.com>
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	[thread overview]
Message-ID: <20261127161241.3713494-19-d.csapak@proxmox.com> (raw)
In-Reply-To: <20261127161241.3713494-1-d.csapak@proxmox.com>

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 <d.csapak@proxmox.com>
---
 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<T> MapPoint<T> {
 #[derive(Properties, PartialEq, Clone)]
 pub struct Map<T: MapPointData + 'static = AttrValue> {
     /// 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<T: MapPointData + 'static> yew::Component for MapComp<T> {
         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<T: MapPointData + 'static> yew::Component for MapComp<T> {
                 },
             )
             .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<T: MapPointData + 'static> yew::Component for MapComp<T> {
         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





  parent reply	other threads:[~2026-11-27 16:13 UTC|newest]

Thread overview: 41+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-27 16:11 [PATCH datacenter-manager/proxmox-geojson-data/yew-widget-toolkit/yew-widget-toolkit-assets 00/38] map: show running remote migrations and rework the world map Dominik Csapak
2026-11-27 16:11 ` [PATCH proxmox-geojson-data 01/38] generate the borders between countries as lines without duplicates Dominik Csapak
2026-11-28 19:46   ` Thomas Lamprecht
2026-11-27 16:11 ` [PATCH yew-widget-toolkit-assets 02/38] charts: world map: add classes for the map and its features Dominik Csapak
2026-11-27 16:12 ` [PATCH yew-widget-toolkit-assets 03/38] charts: map: stack the map and its points in two layers Dominik Csapak
2026-11-27 16:12 ` [PATCH yew-widget-toolkit-assets 04/38] charts: map: show locations as a dot with a halo Dominik Csapak
2026-11-27 16:12 ` [PATCH yew-widget-toolkit-assets 05/38] charts: map: show the buttons as one panel Dominik Csapak
2026-11-27 16:12 ` [PATCH yew-widget-toolkit-assets 06/38] charts: map: add classes for connections Dominik Csapak
2026-11-27 16:12 ` [PATCH yew-widget-toolkit-assets 07/38] charts: world map: add class for the shade of the night Dominik Csapak
2026-11-27 16:12 ` [PATCH yew-widget-toolkit-assets 08/38] charts: map: add classes for the shares and the ping of a location Dominik Csapak
2026-11-27 16:12 ` [PATCH yew-widget-toolkit-assets 09/38] charts: map: add class for the shadow of a connection Dominik Csapak
2026-11-27 16:12 ` [PATCH yew-widget-toolkit-assets 10/38] charts: map: add class for the labels of locations Dominik Csapak
2026-11-27 16:12 ` [PATCH yew-widget-toolkit-assets 11/38] charts: map: add class for the status of a map Dominik Csapak
2026-11-27 16:12 ` [PATCH yew-widget-toolkit 12/38] widget: charts: map: factor out the radius factor of a cluster Dominik Csapak
2026-11-27 16:12 ` [PATCH yew-widget-toolkit 13/38] widget: charts: map: close the info card with the first click after a drag Dominik Csapak
2026-11-27 16:12 ` [PATCH yew-widget-toolkit 14/38] widget: menu: open the menu of a button above it if there is no room below Dominik Csapak
2026-11-27 16:12 ` [PATCH yew-widget-toolkit 15/38] widget: charts: world map: compare the map data by reference Dominik Csapak
2026-11-27 16:12 ` [PATCH yew-widget-toolkit 16/38] widget: charts: world map: draw polygons as areas and line strings as lines Dominik Csapak
2026-11-27 16:12 ` [PATCH yew-widget-toolkit 17/38] widget: charts: world map: split the map into one path per region Dominik Csapak
2026-11-27 16:12 ` Dominik Csapak [this message]
2026-11-27 16:12 ` [PATCH yew-widget-toolkit 19/38] widget: charts: map: don't render if the pointer moves over the same point Dominik Csapak
2026-11-27 16:12 ` [PATCH yew-widget-toolkit 20/38] widget: charts: map: keep the tooltip on its points when clustering anew Dominik Csapak
2026-11-27 16:12 ` [PATCH yew-widget-toolkit 21/38] widget: charts: world map: add a graticule Dominik Csapak
2026-11-27 16:12 ` [PATCH yew-widget-toolkit 22/38] widget: charts: map: animate changes of the view Dominik Csapak
2026-11-27 16:12 ` [PATCH yew-widget-toolkit 23/38] widget: charts: map: draw points as a dot with a halo and their count Dominik Csapak
2026-11-27 16:12 ` [PATCH yew-widget-toolkit 24/38] widget: charts: map: let the style sheet color the zoom buttons Dominik Csapak
2026-11-27 16:12 ` [PATCH yew-widget-toolkit 25/38] widget: charts: map: allow drawing connections between points Dominik Csapak
2026-11-27 16:12 ` [PATCH yew-widget-toolkit 26/38] widget: charts: map: allow additional buttons in the panel Dominik Csapak
2026-11-27 16:12 ` [PATCH yew-widget-toolkit 27/38] widget: charts: world map: allow shading the night Dominik Csapak
2026-11-27 16:12 ` [PATCH yew-widget-toolkit 28/38] widget: charts: map: add helpers to show shares and to ping a point Dominik Csapak
2026-11-27 16:12 ` [PATCH yew-widget-toolkit 29/38] widget: charts: map: draw a shadow below connections Dominik Csapak
2026-11-27 16:12 ` [PATCH yew-widget-toolkit 30/38] widget: charts: map: allow showing labels next to the points Dominik Csapak
2026-11-27 16:12 ` [PATCH yew-widget-toolkit 31/38] widget: charts: map: allow showing a status in a corner of the map Dominik Csapak
2026-11-27 16:12 ` [PATCH datacenter-manager 32/38] ui: views: map: only load and parse the world map once Dominik Csapak
2026-11-27 16:12 ` [PATCH datacenter-manager 33/38] ui: views: map: only format the titles once when sorting Dominik Csapak
2026-11-27 16:12 ` [PATCH datacenter-manager 34/38] ui: views: map: show running remote migrations Dominik Csapak
2026-11-27 16:12 ` [PATCH datacenter-manager 35/38] ui: views: map: shade the night on the map Dominik Csapak
2026-11-27 16:12 ` [PATCH datacenter-manager 36/38] ui: views: map: show the states of a cluster and ping problems Dominik Csapak
2026-11-27 16:12 ` [PATCH datacenter-manager 37/38] ui: views: map: show the names of the locations Dominik Csapak
2026-11-27 16:12 ` [PATCH datacenter-manager 38/38] ui: views: map: show a summary of the remotes and migrations Dominik Csapak
2026-11-28 23:48 ` [PATCH datacenter-manager/proxmox-geojson-data/yew-widget-toolkit/yew-widget-toolkit-assets 00/38] map: show running remote migrations and rework the world map Thomas Lamprecht

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=20261127161241.3713494-19-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
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal