Skip to main content

egui_charts/drawings/domain/
bars_pattern.rs

1//! How a bars pattern draws its copy of the source bars.
2
3use serde::{Deserialize, Serialize};
4
5/// How a bars pattern draws each copied bar.
6#[derive(Debug, Clone, Copy, Default, PartialEq, Eq, Serialize, Deserialize)]
7#[non_exhaustive]
8pub enum BarsPatternMode {
9    /// An OHLC bar: a line from the high to the low, the open ticked left and the close right.
10    #[default]
11    Bars,
12    /// A line through the closes.
13    Line,
14}
15
16/// How a bars pattern copies its source bars. Drawings saved without one use the defaults.
17#[derive(Debug, Clone, Copy, Default, PartialEq, Eq, Serialize, Deserialize)]
18#[serde(default)]
19#[non_exhaustive]
20pub struct BarsPatternConfig {
21    /// How each copied bar is drawn.
22    pub mode: BarsPatternMode,
23    /// Whether the copy runs backwards in time: its first bar is the last source bar, and each
24    /// bar's open and close trade places.
25    pub mirrored: bool,
26    /// Whether the copy is turned upside down around the middle of the source bars' range, so
27    /// that it keeps that range.
28    pub flipped: bool,
29}