MCPcopy Create free account
hub / github.com/donkeyteethUX/iced_plot / update

Method update

src/plot_widget.rs:582–633  ·  view source on GitHub ↗

Handle a message sent to the plot widget.

(&mut self, msg: PlotUiMessage)

Source from the content-addressed store, hash-verified

580 series_label: series.label.as_deref().unwrap_or(""),
581 point_index: point_id.point_index,
582 },
583 &mut highlight_point,
584 );
585 let tooltip = tooltip_text.map(|text| TooltipUiPayload {
586 screen_xy: Self::world_to_screen_position(
587 Self::tooltip_anchor_world(&highlight_point),
588 camera_bounds,
589 self.x_axis_scale,
590 self.y_axis_scale,
591 &highlight_point.transform,
592 ),
593 text,
594 });
595 let new_payload = (highlight_point, tooltip);
596 match points.entry(point_id) {
597 indexmap::map::Entry::Occupied(mut occupied) => {
598 if PartialEq::ne(occupied.get(), &new_payload) {
599 occupied.insert(new_payload);
600 changed = true;
601 }
602 }
603 indexmap::map::Entry::Vacant(vacant) => {
604 vacant.insert(new_payload);
605 changed = true;
606 }
607 }
608 }
609 changed
610 }
611 /// Handle a message sent to the plot widget.
612 pub fn update(&mut self, msg: PlotUiMessage) {
613 match msg {
614 PlotUiMessage::ToggleLegend => {
615 self.legend_collapsed = !self.legend_collapsed;
616 }
617 PlotUiMessage::ToggleControlsOverlay => {
618 self.controls_overlay_open = !self.controls_overlay_open;
619 }
620 PlotUiMessage::ToggleSeriesVisibility(id) => {
621 self.toggle_visibility(&id);
622 }
623 PlotUiMessage::RenderUpdate(payload) => {
624 // Update camera and bounds when ticks are updated (camera changed)
625 if let Some(camera_bounds) = payload.camera_bounds
626 && self.camera_bounds != Some(*camera_bounds)
627 {
628 self.camera_bounds = Some(*camera_bounds);
629 // Update tooltip positions when camera/bounds change
630 self.update_tooltip_positions();
631 }
632
633 match payload.hover_pick {
634 Some(HoverPickEvent::Hover(point_id)) => {
635 self.hovered_points.clear();
636 self.handle_hover_pick::<false>(point_id);

Callers

nothing calls this directly

Calls 2

toggle_visibilityMethod · 0.80

Tested by

no test coverage detected