Skip to main content

euv_chart/event/
enum.rs

1/// The kind of an event a chart emits.
2#[derive(Clone, Copy, Debug, Default, Eq, Hash, PartialEq)]
3pub enum ChartEventType {
4    /// The pointer was pressed and released over the chart.
5    #[default]
6    Click,
7    /// The pointer was pressed twice over the chart.
8    DoubleClick,
9    /// The pointer moved over the chart.
10    MouseMove,
11    /// The pointer entered a data point.
12    MouseOver,
13    /// The pointer left a data point.
14    MouseOut,
15    /// The pointer left the chart.
16    GlobalOut,
17    /// A legend entry was selected.
18    LegendSelect,
19    /// A legend entry was deselected.
20    LegendUnSelect,
21    /// A legend entry was toggled.
22    LegendToggle,
23    /// The zoom window changed.
24    DataZoom,
25    /// The zoom window settled.
26    DataZoomEnd,
27    /// The tooltip became visible.
28    TooltipShow,
29    /// The tooltip was hidden.
30    TooltipHide,
31}
32
33/// An action a chart can be told to perform.
34///
35/// Actions are the counterpart of events: a chart dispatches events when
36/// the user does something, and the application dispatches actions to
37/// make the chart do something.
38#[derive(Clone, Debug, Default, PartialEq)]
39pub enum ChartAction {
40    /// Highlights a data point.
41    Highlight {
42        /// The index of the series.
43        series_index: usize,
44        /// The index of the data point, or `None` for the whole series.
45        data_index: Option<usize>,
46    },
47    /// Removes the highlight from a data point.
48    Downplay {
49        /// The index of the series.
50        series_index: usize,
51        /// The index of the data point, or `None` for the whole series.
52        data_index: Option<usize>,
53    },
54    /// Shows the tooltip at a position.
55    ShowTip {
56        /// The index of the series the tooltip describes.
57        series_index: usize,
58        /// The index of the data point the tooltip describes.
59        data_index: usize,
60        /// The horizontal position of the tooltip, in canvas pixels.
61        x: f64,
62        /// The vertical position of the tooltip, in canvas pixels.
63        y: f64,
64    },
65    /// Hides the tooltip.
66    #[default]
67    HideTip,
68    /// Zooms the chart to a window of the data.
69    ///
70    /// `start` and `end` are percentages of the whole range.
71    DataZoom {
72        /// The start of the window, as a percentage.
73        start: f64,
74        /// The end of the window, as a percentage.
75        end: f64,
76    },
77    /// Toggles a legend entry.
78    LegendToggle {
79        /// The name of the series.
80        name: String,
81    },
82    /// Restores the chart to its initial state.
83    Restore,
84}