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 5CE1D1FF0B4 for ; Fri, 27 Nov 2026 17:13:58 +0100 (CET) Received: from gate001.proxmox.com (localhost.localdomain [127.0.0.1]) by gate001.proxmox.com (Proxmox) with ESMTP id 1D3F1218BB; Fri, 27 Nov 2026 17:13:15 +0100 (CET) From: Dominik Csapak To: pdm-devel@lists.proxmox.com Subject: [PATCH yew-widget-toolkit 28/38] widget: charts: map: add helpers to show shares and to ping a point Date: Fri, 27 Nov 2026 17:12:25 +0100 Message-ID: <20261127161241.3713494-29-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.249 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: UNXXGLOQVY5FMPHJ2GOGVCJ5B3AVWEEO X-Message-ID-Hash: UNXXGLOQVY5FMPHJ2GOGVCJ5B3AVWEEO 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: A cluster only has one color, so one could not see how its points are divided, e.g. how many of them are fine and how many have a problem. `render_point_shares` renders a ring around the dot for that, with a part in the given color for each share. `render_point_ping` renders a ring that slowly spreads from the point, to draw attention to points that need it. Both are meant to be added to the default point in a custom `render_point`. Their look is defined in the style sheet with the new 'pwt-map-location-shares' and 'pwt-map-location-ping' classes. Signed-off-by: Dominik Csapak --- src/widget/charts/map/map_point.rs | 43 ++++++++++++++++++++++++++++++ src/widget/charts/map/mod.rs | 4 +-- src/widget/charts/mod.rs | 2 +- 3 files changed, 46 insertions(+), 3 deletions(-) diff --git a/src/widget/charts/map/map_point.rs b/src/widget/charts/map/map_point.rs index e3d8ff4..0a27c9b 100644 --- a/src/widget/charts/map/map_point.rs +++ b/src/widget/charts/map/map_point.rs @@ -43,6 +43,49 @@ pub fn render_point_default(args: &PointsRenderArgs) -> Grou })) } +/// Renders a ring that shows how the points of a cluster are divided, for example by their state. +/// +/// Each share is a number of points and the CSS color to draw them in, starting at the top and +/// going clockwise. Add the ring to what [render_point_default] returns. +pub fn render_point_shares( + args: &PointsRenderArgs, + shares: &[(usize, AttrValue)], +) -> Group { + let total: usize = shares.iter().map(|(count, _)| count).sum(); + let mut ring = Group::new().class("pwt-map-location-shares"); + let mut start = 0; + for (count, color) in shares.iter().filter(|(count, _)| *count > 0) { + ring.add_child( + Circle::new() + .cx(args.center.x) + .cy(args.center.y) + // with the circumference as 1, a share is a dash with the length of its fraction + .attribute("pathLength", "1") + .style("stroke", color.clone()) + .style( + "stroke-dasharray", + format!("{:.4} 1", *count as f64 / total as f64), + ) + .style( + "stroke-dashoffset", + format!("{:.4}", -(start as f64 / total as f64)), + ), + ); + start += count; + } + ring +} + +/// Renders a slow ping around a cluster, to draw attention to it. +/// +/// Add it to what [render_point_default] returns. +pub fn render_point_ping(args: &PointsRenderArgs) -> Circle { + Circle::new() + .class("pwt-map-location-ping") + .cx(args.center.x) + .cy(args.center.y) +} + /// The default info renderer for a map cluster. pub fn render_info_default(args: &PointsRenderArgs) -> Html { Column::new() diff --git a/src/widget/charts/map/mod.rs b/src/widget/charts/map/mod.rs index 6aea261..54e7f81 100644 --- a/src/widget/charts/map/mod.rs +++ b/src/widget/charts/map/mod.rs @@ -7,8 +7,8 @@ use wasm_bindgen::{JsCast, UnwrapThrowExt}; mod map_point; pub use map_point::{ - MapPointData, PointsRenderArgs, render_info_default, render_point_default, - render_tooltip_default, + MapPointData, PointsRenderArgs, render_info_default, render_point_default, render_point_ping, + render_point_shares, render_tooltip_default, }; mod zoom_info; diff --git a/src/widget/charts/mod.rs b/src/widget/charts/mod.rs index addfccc..c2d922f 100644 --- a/src/widget/charts/mod.rs +++ b/src/widget/charts/mod.rs @@ -5,7 +5,7 @@ mod alpha_image; mod map; pub use map::{ Coordinates, Map, MapConnection, MapPoint, MapPointData, PointsRenderArgs, render_info_default, - render_point_default, render_tooltip_default, + render_point_default, render_point_ping, render_point_shares, render_tooltip_default, }; mod pie; -- 2.47.3