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 D5CC31FF0B4 for ; Fri, 27 Nov 2026 17:14:28 +0100 (CET) Received: from gate001.proxmox.com (localhost.localdomain [127.0.0.1]) by gate001.proxmox.com (Proxmox) with ESMTP id 345A82178A; Fri, 27 Nov 2026 17:14:14 +0100 (CET) From: Dominik Csapak To: pdm-devel@lists.proxmox.com Subject: [PATCH yew-widget-toolkit 25/38] widget: charts: map: allow drawing connections between points Date: Fri, 27 Nov 2026 17:12:22 +0100 Message-ID: <20261127161241.3713494-26-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: R5G7BNBV6ZRIVX7YE32NPULJNE3QCLGG X-Message-ID-Hash: R5G7BNBV6ZRIVX7YE32NPULJNE3QCLGG 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: so users of the map can show that something moves from one point to another, e.g. a guest that gets migrated between two locations. A connection references its two points by their index in the list of points and is drawn as a quadratic curve between the clusters these points are in. That way it always ends where the points are actually drawn. Connections inside of a single cluster are not shown, and all connections between the same two clusters share one curve. The curve starts and ends at the radius of the clusters instead of at their centers, so that the arrow head at its end is not hidden by the dot of the cluster. It bends upwards like the arc of a flight route, regardless of its direction. Only if there are connections in both directions between two clusters, each one bends to the left of its direction, so they don't overlap. An arrow head at its end shows the direction. Clusters that are so close that there is no room for a curve with a visible direction get none. Each connection can have a label and a tooltip. The label is drawn in the middle of the curve, and the labels of connections that share a curve are combined (e.g. '2x Migration, Sync'). It is left out if the connection is too short for it on the screen, since it would hide most of the connection then, e.g. on a small map. For the tooltip, reuse the one of the map, which can now target a connection instead of a cluster. Since the line itself is too thin to hover it comfortably, connections with a tooltip get an invisible wider line as hit area. The look is defined in the style sheet with the new 'pwt-map-connection*' classes, including the pulses that move along a connection to show its direction. A pulse is drawn as three parts on top of each other, which all end at its head and get shorter. The style sheet draws the shorter ones stronger, so that a pulse fades out towards its tail and its direction is also visible while it stands still. Signed-off-by: Dominik Csapak --- src/widget/charts/map/mod.rs | 457 +++++++++++++++++++++++++++++++-- src/widget/charts/mod.rs | 2 +- src/widget/charts/world_map.rs | 8 +- 3 files changed, 449 insertions(+), 18 deletions(-) diff --git a/src/widget/charts/map/mod.rs b/src/widget/charts/map/mod.rs index cf236f3..069d386 100644 --- a/src/widget/charts/map/mod.rs +++ b/src/widget/charts/map/mod.rs @@ -1,3 +1,4 @@ +use std::collections::BTreeMap; use std::marker::PhantomData; use gloo_render::{AnimationFrame, request_animation_frame}; @@ -17,9 +18,9 @@ use crate::client_to_svg_coords; use crate::dom::align::{AlignOptions, align_to, align_to_xy}; use crate::prelude::*; use crate::touch::{GestureDetector, GestureDragEvent, GesturePhase, GesturePinchZoomEvent}; -use crate::widget::canvas::{Canvas, Circle, Group}; +use crate::widget::canvas::{Canvas, Circle, Group, Path, Text}; use crate::widget::charts::map::zoom_info::ZoomAction; -use crate::widget::{Button, Card, Container, Row, SizeObserver, Tooltip}; +use crate::widget::{Button, Card, Column, Container, Row, SizeObserver, Tooltip}; use pwt_macros::{builder, widget}; /// x and y coordinates to represent a position @@ -44,6 +45,99 @@ impl MapPoint { } } +/// A directed connection between two points of a [Map]. +/// +/// It is drawn as a curve between the clusters that contain the two points, so connections +/// inside of a single cluster are not shown. All connections between the same two clusters share +/// one curve, with their labels and tooltips combined. +#[derive(Clone, PartialEq)] +pub struct MapConnection { + /// Index of the start point in the list of points of the map. + pub from: usize, + /// Index of the end point in the list of points of the map. + pub to: usize, + /// A short text that is shown on the connection, for example what kind of connection it is. + pub label: Option, + /// The details that are shown when hovering the connection. + pub tooltip: Option, +} + +impl MapConnection { + /// Create a new connection between the points with the given indices. + pub fn new(from: usize, to: usize) -> Self { + Self { + from, + to, + label: None, + tooltip: None, + } + } + + /// Builder style method to set the label. + pub fn label(mut self, label: impl Into) -> Self { + self.label = Some(label.into()); + self + } + + /// Builder style method to set the tooltip. + pub fn tooltip(mut self, tooltip: impl Into) -> Self { + self.tooltip = Some(tooltip.into()); + self + } +} + +/// Returns the label for curves shared by connections. +/// +/// Each distinct label is listed once, with the number of its occurrences if there are several. +fn connection_label(connections: &[&MapConnection]) -> Option { + let mut labels_map: BTreeMap<&AttrValue, usize> = BTreeMap::new(); + + for connection in connections { + let Some(label) = &connection.label else { + continue; + }; + + *labels_map.entry(label).or_insert(0) += 1; + } + + if labels_map.is_empty() { + return None; + } + + let labels: Vec = labels_map + .into_iter() + .map(|(label, count)| match count { + 1 => label.to_string(), + count => format!("{count}x {label}"), + }) + .collect(); + Some(labels.join(", ")) +} + +// how far a connection bends away from the straight line, relative to its length +const CONNECTION_CURVATURE: f64 = 0.2; + +// the length of the arrow head of a connection in screen pixels +const CONNECTION_ARROW_SIZE: f64 = 9.0; + +// A pulse of a connection is drawn as several parts on top of each other that all end at its +// head. These are their lengths relative to the whole pulse. The style sheet draws the shorter +// ones stronger, so that the pulse fades out towards its tail. +const CONNECTION_PULSE_PARTS: [f64; 3] = [1.0, 0.6, 0.25]; + +// A label only fits on a connection that is a few times as long as the label. The width of the +// label is estimated from the number of its characters, in screen pixels. +const CONNECTION_LABEL_CHAR_WIDTH: f64 = 7.0; +const CONNECTION_LABEL_MIN_LENGTH_FACTOR: f64 = 2.0; + +/// Whether a label fits on a connection with the given length in screen pixels. +/// +/// A label on a short connection would hide most of it. +fn connection_label_fits(label: &str, length: f64) -> bool { + let width = label.chars().count() as f64 * CONNECTION_LABEL_CHAR_WIDTH; + length >= width * CONNECTION_LABEL_MIN_LENGTH_FACTOR +} + // How fast the shown view follows a change of the view: after this time in milliseconds it has // covered about two thirds of the way, after three times as long nearly all of it. const VIEW_ANIMATION_TIME_CONSTANT: f64 = 70.0; @@ -52,6 +146,110 @@ const VIEW_ANIMATION_TIME_CONSTANT: f64 = 70.0; // frame time of a common display. const FIRST_FRAME_TIME: f64 = 1000.0 / 60.0; +/// A quadratic curve between two circles. +/// +/// It starts and ends on the circles instead of on their centers. +#[derive(Debug, Clone, Copy, PartialEq)] +struct ConnectionCurve { + start: Coordinates, + control: Coordinates, + end: Coordinates, +} + +impl ConnectionCurve { + /// Returns the curve between the two circles, or `None` if they are too close for one. + /// + /// The curve bends upwards like the arc of a flight route. If `separate` is set, it bends to + /// the left of its direction instead, so that it does not overlap with a curve in the opposite + /// direction. + fn new( + from: Coordinates, + from_radius: f64, + to: Coordinates, + to_radius: f64, + separate: bool, + ) -> Option { + let dx = to.x - from.x; + let dy = to.y - from.y; + if (dx * dx + dy * dy) <= (from_radius + to_radius).powi(2) { + return None; + } + + // The left of the direction is the upper side when going to the right. A vertical curve + // has no upper side, so it bends to the left of the map. + let side = if separate || dx > 0.0 || (dx == 0.0 && dy < 0.0) { + CONNECTION_CURVATURE + } else { + -CONNECTION_CURVATURE + }; + let control = Coordinates { + x: (from.x + to.x) / 2.0 + dy * side, + y: (from.y + to.y) / 2.0 - dx * side, + }; + + // The curve leaves and enters the points in the direction of the control point. A circle + // that reaches the control point leaves no room for a curve that still shows a direction. + let towards_control = |point: Coordinates, radius: f64| { + let dx = control.x - point.x; + let dy = control.y - point.y; + let length = (dx * dx + dy * dy).sqrt(); + (radius < length).then(|| Coordinates { + x: point.x + dx / length * radius, + y: point.y + dy / length * radius, + }) + }; + + Some(Self { + start: towards_control(from, from_radius)?, + control, + end: towards_control(to, to_radius)?, + }) + } + + /// The distance between the start and the end of the curve. + fn span(&self) -> f64 { + let dx = self.end.x - self.start.x; + let dy = self.end.y - self.start.y; + (dx * dx + dy * dy).sqrt() + } + + /// The SVG path commands that draw the curve. + fn path(&self) -> String { + format!( + "M{:.2},{:.2} Q{:.2},{:.2} {:.2},{:.2}", + self.start.x, self.start.y, self.control.x, self.control.y, self.end.x, self.end.y + ) + } + + /// The point halfway along the curve. + fn center(&self) -> Coordinates { + Coordinates { + x: 0.25 * self.start.x + 0.5 * self.control.x + 0.25 * self.end.x, + y: 0.25 * self.start.y + 0.5 * self.control.y + 0.25 * self.end.y, + } + } + + /// The SVG path commands for an arrow head of the given length at the end of the curve. + fn arrow_head(&self, length: f64) -> String { + // the curve arrives from the direction of the control point + let dx = self.end.x - self.control.x; + let dy = self.end.y - self.control.y; + let scale = length / (dx * dx + dy * dy).sqrt(); + let (dx, dy) = (dx * scale, dy * scale); + // the middle of the base of the arrow head, which is half as wide as the head is long + let (x, y) = (self.end.x - dx, self.end.y - dy); + format!( + "M{:.2},{:.2} L{:.2},{:.2} L{:.2},{:.2} Z", + self.end.x, + self.end.y, + x - dy / 2.0, + y + dx / 2.0, + x + dy / 2.0, + y - dx / 2.0, + ) + } +} + /// An interactive Map that handles interaction (zooming, panning) and draws /// [MapPoint]s on top of the given SVG element. /// @@ -62,8 +260,8 @@ const FIRST_FRAME_TIME: f64 = 1000.0 / 60.0; 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. + /// It is drawn in an SVG element of its own below the points and connections, and does not + /// react to the pointer. map: Html, #[prop_or(1000.0)] @@ -81,6 +279,11 @@ pub struct Map { /// A list of points to highlight on the map. points: Vec>, + #[prop_or_default] + #[builder] + /// A list of connections to draw between the points of the map. + connections: Vec, + #[prop_or(30.0)] #[builder] /// The maximum zoom level that is allowed. @@ -104,7 +307,7 @@ pub enum Msg { ButtonZoom(ZoomAction), PinchZoom(GesturePinchZoomEvent), Resize(f64, f64), - Tooltip(Option<(usize, i32, i32)>), + Tooltip(Option<(TooltipTarget, i32, i32)>), ToggleInfo(usize), CloseInfo, Drag(GestureDragEvent), @@ -114,6 +317,22 @@ pub enum Msg { AnimateView(f64), } +/// What the tooltip is shown for. +#[derive(Clone, Copy, PartialEq)] +pub enum TooltipTarget { + /// The cluster with the given index. + Cluster(usize), + /// The connections from the first to the second cluster. + Connection(usize, usize), +} + +// the connections that share one curve, because they are between the same two clusters +struct ConnectionGroup<'a> { + from: usize, + to: usize, + connections: Vec<&'a MapConnection>, +} + #[derive(PartialEq, Clone)] // cache to hold the clustering of the points, can change when the zoom or the fit scale changes struct Cluster { @@ -147,7 +366,7 @@ pub struct MapComp { pinch_last_center: Coordinates, fit_scale: f64, svg_ref: NodeRef, - tooltip: Option<(usize, i32, i32)>, + tooltip: Option<(TooltipTarget, i32, i32)>, tooltip_ref: NodeRef, info_anchor_ref: NodeRef, info_ref: NodeRef, @@ -161,14 +380,14 @@ pub struct MapComp { } impl MapComp { - fn create_tooltip(&self, args: &PointsRenderArgs) -> Html { + fn create_tooltip(&self, content: Html) -> Html { Container::new() .attribute("role", "tooltip") .attribute("aria-live", "polite") .attribute("data-show", Some("")) .class("pwt-tooltip") .class("pwt-tooltip-rich") - .with_child(T::render_tooltip(args)) + .with_child(content) .into_html_with_ref(self.tooltip_ref.clone()) } @@ -231,9 +450,15 @@ impl MapComp { .position(|cluster| &cluster.indices == indices) }; self.info_visible = self.info_visible.and_then(remap); - self.tooltip = self - .tooltip - .and_then(|(index, x, y)| Some((remap(index)?, x, y))); + self.tooltip = self.tooltip.and_then(|(target, x, y)| { + let target = match target { + TooltipTarget::Cluster(index) => TooltipTarget::Cluster(remap(index)?), + TooltipTarget::Connection(from, to) => { + TooltipTarget::Connection(remap(from)?, remap(to)?) + } + }; + Some((target, x, y)) + }); self.clusters = clusters; } @@ -301,6 +526,129 @@ impl MapComp { } } + fn group_connections<'a>(&self, ctx: &'a Context) -> Vec> { + let props = ctx.props(); + + let mut cluster_of_point = vec![None; props.points.len()]; + for (cluster_index, cluster) in self.clusters.iter().enumerate() { + for &point_index in &cluster.indices { + cluster_of_point[point_index] = Some(cluster_index); + } + } + let cluster_of_point = |index: usize| cluster_of_point.get(index).copied().flatten(); + + let mut groups: Vec = Vec::new(); + for connection in &props.connections { + let (Some(from), Some(to)) = ( + cluster_of_point(connection.from), + cluster_of_point(connection.to), + ) else { + continue; + }; + if from == to { + continue; + } + + match groups.iter_mut().find(|g| g.from == from && g.to == to) { + Some(group) => group.connections.push(connection), + None => groups.push(ConnectionGroup { + from, + to, + connections: vec![connection], + }), + } + } + groups + } + + /// Renders the connections, and the tooltip if one of them is hovered. + fn render_connections( + &self, + ctx: &Context, + effective_radius: f64, + ) -> (Group, Option) { + let link = ctx.link(); + + let mut tooltip = None; + let mut connections = Group::new(); + + let groups = self.group_connections(ctx); + for group in &groups { + let (from, to) = (&self.clusters[group.from], &self.clusters[group.to]); + let has_opposite = groups + .iter() + .any(|other| other.from == group.to && other.to == group.from); + let Some(curve) = ConnectionCurve::new( + self.shown_view.map_point(from.center), + effective_radius * from.radius_factor(), + self.shown_view.map_point(to.center), + effective_radius * to.radius_factor(), + has_opposite, + ) else { + continue; + }; + let path = curve.path(); + + let mut connection = Group::new().class("pwt-map-connection"); + + let tooltips: Vec = group + .connections + .iter() + .filter_map(|connection| connection.tooltip.clone()) + .collect(); + if !tooltips.is_empty() { + let target = TooltipTarget::Connection(group.from, group.to); + // the line itself is too thin to hover it comfortably + connection.add_child( + Path::new() + .class("pwt-map-connection-hit-area") + .d(path.clone()), + ); + connection = connection + .onpointermove(link.callback(move |event: PointerEvent| { + Msg::Tooltip(Some((target, event.client_x(), event.client_y()))) + })) + .onpointerleave(link.callback(|_| Msg::Tooltip(None))); + + if matches!(self.tooltip, Some((hovered, _, _)) if hovered == target) { + let content = Column::new().gap(1).children(tooltips); + tooltip = Some(self.create_tooltip(content.into())); + } + } + + connection.add_child(Path::new().class("pwt-map-connection-line").d(path.clone())); + for part in CONNECTION_PULSE_PARTS { + connection.add_child( + Path::new() + .class("pwt-map-connection-pulse") + .style("--pwt-map-connection-pulse-part", part.to_string()) + .d(path.clone()), + ); + } + connection.add_child( + Path::new() + .class("pwt-map-connection-arrow") + .d(curve.arrow_head(CONNECTION_ARROW_SIZE / self.fit_scale)), + ); + + let length = curve.span() * self.fit_scale; + if let Some(label) = connection_label(&group.connections) + .filter(|label| connection_label_fits(label, length)) + { + let center = curve.center(); + connection.add_child( + Text::new(label) + .class("pwt-map-connection-label") + .position(center.x as f32, center.y as f32), + ); + } + + connections.add_child(connection); + } + + (connections, tooltip) + } + fn update_info_alignment(&self, ctx: &Context) { if let (Some(_), Some(anchor), Some(el)) = ( self.info_visible, @@ -500,7 +848,7 @@ impl yew::Component for MapComp { self.cluster_points(ctx); } Msg::Tooltip(tooltip) => { - let target = |tooltip: Option<(usize, i32, i32)>| Some(tooltip?.0); + let target = |tooltip: Option<(TooltipTarget, i32, i32)>| Some(tooltip?.0); let same_target = target(self.tooltip) == target(tooltip); self.tooltip = tooltip; if same_target { @@ -607,8 +955,8 @@ impl yew::Component for MapComp { .class("pwt-map-overlay") .attribute("viewBox", view_box); + let (connections, mut tooltip) = self.render_connections(ctx, effective_radius); let mut points = Group::new(); - let mut tooltip = None; let mut info = None; for (index, cluster) in self.clusters.iter().enumerate() { @@ -638,7 +986,7 @@ impl yew::Component for MapComp { .onpointermove(link.callback(move |event: PointerEvent| { let x = event.client_x(); let y = event.client_y(); - Msg::Tooltip(Some((index, x, y))) + Msg::Tooltip(Some((TooltipTarget::Cluster(index), x, y))) })) .onpointerleave(link.callback(move |_| Msg::Tooltip(None))) .onclick(link.callback(move |event: MouseEvent| { @@ -665,8 +1013,8 @@ impl yew::Component for MapComp { } match &self.tooltip { - Some((tooltip_idx, _, _)) if *tooltip_idx == index => { - tooltip = Some(self.create_tooltip(&args)); + Some((TooltipTarget::Cluster(tooltip_idx), _, _)) if *tooltip_idx == index => { + tooltip = Some(self.create_tooltip(T::render_tooltip(&args))); } _ => {} } @@ -688,6 +1036,7 @@ impl yew::Component for MapComp { .with_child( GestureDetector::new( overlay + .with_child(connections) .with_child(points) .into_html_with_ref(self.svg_ref.clone()), ) @@ -768,3 +1117,79 @@ impl yew::Component for MapComp { self.update_info_alignment(ctx); } } + +#[cfg(test)] +mod test { + use super::{ + ConnectionCurve, Coordinates, MapConnection, connection_label, connection_label_fits, + }; + + #[test] + fn test_connection_curve() { + let left = Coordinates { x: 0.0, y: 100.0 }; + let right = Coordinates { x: 100.0, y: 100.0 }; + + // bends upwards in both directions + let curve = ConnectionCurve::new(left, 0.0, right, 0.0, false).unwrap(); + assert_eq!(curve.path(), "M0.00,100.00 Q50.00,80.00 100.00,100.00"); + assert_eq!(curve.center(), Coordinates { x: 50.0, y: 90.0 }); + let curve = ConnectionCurve::new(right, 0.0, left, 0.0, false).unwrap(); + assert_eq!(curve.path(), "M100.00,100.00 Q50.00,80.00 0.00,100.00"); + + // unless opposite directions have to be kept apart + let curve = ConnectionCurve::new(left, 0.0, right, 0.0, true).unwrap(); + assert_eq!(curve.path(), "M0.00,100.00 Q50.00,80.00 100.00,100.00"); + let curve = ConnectionCurve::new(right, 0.0, left, 0.0, true).unwrap(); + assert_eq!(curve.path(), "M100.00,100.00 Q50.00,120.00 0.00,100.00"); + + // vertical curves bend to the left of the map, and start and end on the circles + let top = Coordinates { x: 0.0, y: 0.0 }; + let bottom = Coordinates { x: 0.0, y: 100.0 }; + let curve = ConnectionCurve::new(top, 10.0, bottom, 20.0, false).unwrap(); + assert_eq!(curve.path(), "M-3.71,9.28 Q-20.00,50.00 -7.43,81.43"); + let curve = ConnectionCurve::new(bottom, 20.0, top, 10.0, false).unwrap(); + assert_eq!(curve.path(), "M-7.43,81.43 Q-20.00,50.00 -3.71,9.28"); + + // nothing to draw between touching or overlapping circles + assert_eq!(ConnectionCurve::new(top, 50.0, bottom, 50.0, false), None); + assert_eq!(ConnectionCurve::new(top, 0.0, top, 0.0, false), None); + // or if a circle is so big that the curve would end before it bends towards it + assert_eq!(ConnectionCurve::new(top, 10.0, bottom, 55.0, false), None); + } + + #[test] + fn test_arrow_head() { + // arrives going down, so the arrow head points down + let curve = ConnectionCurve { + start: Coordinates { x: 0.0, y: 0.0 }, + control: Coordinates { x: 50.0, y: 0.0 }, + end: Coordinates { x: 50.0, y: 100.0 }, + }; + assert_eq!( + curve.arrow_head(10.0), + "M50.00,100.00 L45.00,90.00 L55.00,90.00 Z" + ); + assert_eq!(curve.span(), (50.0f64 * 50.0 + 100.0 * 100.0).sqrt()); + } + + #[test] + fn test_connection_label() { + let plain = MapConnection::new(0, 1); + let migration = MapConnection::new(0, 1).label("Migration"); + let sync = MapConnection::new(0, 1).label("Sync"); + + assert_eq!(connection_label(&[&plain]), None); + assert_eq!( + connection_label(&[&migration, &plain]).as_deref(), + Some("Migration") + ); + assert_eq!( + connection_label(&[&migration, &sync, &migration]).as_deref(), + Some("2x Migration, Sync") + ); + + // 9 characters need a connection of 126 pixels + assert!(connection_label_fits("Migration", 126.0)); + assert!(!connection_label_fits("Migration", 125.0)); + } +} diff --git a/src/widget/charts/mod.rs b/src/widget/charts/mod.rs index a152b5a..dd254c2 100644 --- a/src/widget/charts/mod.rs +++ b/src/widget/charts/mod.rs @@ -2,7 +2,7 @@ mod map; pub use map::{ - Coordinates, Map, MapPoint, MapPointData, PointsRenderArgs, render_info_default, + Coordinates, Map, MapConnection, MapPoint, MapPointData, PointsRenderArgs, render_info_default, render_point_default, render_tooltip_default, }; diff --git a/src/widget/charts/world_map.rs b/src/widget/charts/world_map.rs index 172eab9..2ca00f9 100644 --- a/src/widget/charts/world_map.rs +++ b/src/widget/charts/world_map.rs @@ -10,7 +10,7 @@ use yew::virtual_dom::{VComp, VNode}; use crate::prelude::*; use crate::widget::canvas::{Group, Path}; -use crate::widget::charts::{Coordinates, Map, MapPoint, MapPointData}; +use crate::widget::charts::{Coordinates, Map, MapConnection, MapPoint, MapPointData}; use pwt_macros::{builder, widget}; // the constant size of the svg viewport. also use to project lon/lat to svg coordinates @@ -84,6 +84,11 @@ pub struct WorldMap { /// A list of points to highlight on the map. points: Vec>, + #[prop_or_default] + #[builder] + /// A list of connections to draw between the points of the map. Forwarded to the inner [Map]. + connections: Vec, + #[prop_or(30.0)] #[builder] /// The maximum zoom level that is allowed. Forwarded to the inner [Map]. @@ -340,6 +345,7 @@ impl yew::Component for WorldMapComp { .max_zoom_level(props.max_zoom_level) .info_point_radius(props.info_point_radius) .points(props.points.clone()) + .connections(props.connections.clone()) .into() } -- 2.47.3