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 70B831FF0B4 for ; Fri, 27 Nov 2026 17:13:47 +0100 (CET) Received: from gate001.proxmox.com (localhost.localdomain [127.0.0.1]) by gate001.proxmox.com (Proxmox) with ESMTP id 4741A21879; Fri, 27 Nov 2026 17:13:14 +0100 (CET) From: Dominik Csapak To: pdm-devel@lists.proxmox.com Subject: [PATCH yew-widget-toolkit 23/38] widget: charts: map: draw points as a dot with a halo and their count Date: Fri, 27 Nov 2026 17:12:20 +0100 Message-ID: <20261127161241.3713494-24-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.251 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: ZM5SAVVUO27MMBQWMM7JSQDCJOWMDDOG X-Message-ID-Hash: ZM5SAVVUO27MMBQWMM7JSQDCJOWMDDOG 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 default point was a translucent circle with an outline, which is hard to spot between the lines of a map. Draw a solid dot with a translucent halo instead. A cluster of several points shows how many they are, so one can see that without hovering it. Since the map scales with its container, the style sheet gets the size of a screen pixel on the map as '--pwt-map-pixel-size'. It needs that to keep outlines and the font size the same for every size of the map. The look is defined in the style sheet with the new 'pwt-map-location-halo', 'pwt-map-location-dot' and 'pwt-map-location-count' classes. Signed-off-by: Dominik Csapak --- src/widget/charts/map/map_point.rs | 44 ++++++++++++++++-------------- src/widget/charts/map/mod.rs | 5 ++++ 2 files changed, 28 insertions(+), 21 deletions(-) diff --git a/src/widget/charts/map/map_point.rs b/src/widget/charts/map/map_point.rs index 85bebe9..e3d8ff4 100644 --- a/src/widget/charts/map/map_point.rs +++ b/src/widget/charts/map/map_point.rs @@ -1,5 +1,5 @@ use crate::prelude::*; -use crate::widget::canvas::{Circle, Group}; +use crate::widget::canvas::{Circle, Group, Text}; use crate::widget::charts::map::{Coordinates, MapPoint}; use crate::widget::{Column, container::span}; @@ -15,30 +15,32 @@ pub struct PointsRenderArgs<'a, T: MapPointData> { } /// The default renderer for a map cluster. +/// +/// Draws a dot with a halo around it. A cluster of several points shows their number, and a +/// selected one gets a pulsing ring. pub fn render_point_default(args: &PointsRenderArgs) -> Group { + let circle = |class: &'static str| { + Circle::new() + .class(class) + .cx(args.center.x) + .cy(args.center.y) + }; + let count = args.points.len(); + Group::new() .class("pwt-map-location") - .with_child( - Circle::new() - .style( - "--pwt-map-location-radius", - format!("{:.3}px", args.suggested_radius), - ) - .cx(args.center.x) - .cy(args.center.y), - ) - .with_optional_child( - args.selected.then_some( - Circle::new() - .class("pwt-map-location-animated") - .style( - "--pwt-map-location-radius", - format!("{:.3}px", args.suggested_radius), - ) - .cx(args.center.x) - .cy(args.center.y), - ), + .style( + "--pwt-map-location-radius", + format!("{:.3}px", args.suggested_radius), ) + .with_optional_child(args.selected.then(|| circle("pwt-map-location-animated"))) + .with_child(circle("pwt-map-location-halo")) + .with_child(circle("pwt-map-location-dot")) + .with_optional_child((count > 1).then(|| { + Text::new(count.to_string()) + .class("pwt-map-location-count") + .position(args.center.x as f32, args.center.y as f32) + })) } /// The default info renderer for a map cluster. diff --git a/src/widget/charts/map/mod.rs b/src/widget/charts/map/mod.rs index 093cfe1..69dba92 100644 --- a/src/widget/charts/map/mod.rs +++ b/src/widget/charts/map/mod.rs @@ -598,6 +598,11 @@ impl yew::Component for MapComp { (false, _) => None, }, ) + // lets the style sheet size things in screen pixels, independent of the size of the map + .style( + "--pwt-map-pixel-size", + format!("{:.3}px", 1.0 / self.fit_scale), + ) .class("pwt-map") .class("pwt-map-overlay") .attribute("viewBox", view_box); -- 2.47.3