Skip to main content

gpui_macos/plot/
mod.rs

1//! Plotting for macOS charts.
2//!
3//! The unstyled primitives — scales, shapes, axes, grids, labels, [`Plot`],
4//! [`PlotElement`] and hover tracking — come from `gpui_kit::base::plot` and are
5//! re-exported here. This module adds the macOS-styled [`tooltip`] overlay.
6//!
7//! A custom plot implements [`Plot`] and becomes an element with
8//! [`impl_into_plot!`](crate::impl_into_plot).
9pub use gpui_kit::base::plot::*;
10
11pub mod tooltip;
12
13/// Make a [`Plot`] usable as a child element.
14///
15/// ```ignore
16/// impl_into_plot!(impl<T> MyPlot<T> where T: 'static);
17/// impl_into_plot!(impl<> Sparkline);
18/// ```
19#[macro_export]
20macro_rules! impl_into_plot {
21    (impl<$($generic:ident),*> $ty:ty $(where $($bound:tt)*)?) => {
22        impl<$($generic),*> $crate::gpui_kit::IntoElement for $ty $(where $($bound)*)? {
23            type Element = $crate::gpui_kit::base::plot::PlotElement<Self>;
24
25            fn into_element(self) -> Self::Element {
26                $crate::gpui_kit::base::plot::PlotElement::new(self)
27            }
28        }
29    };
30}