openpine_vm/visuals/
bar_colors.rs

1use openpine_compiler::instructions::Color;
2use serde::{Deserialize, Serialize};
3
4use crate::{series::Series, visuals::PlotDisplay};
5
6/// Bar color overrides.
7#[derive(Debug, Clone, Serialize, Deserialize)]
8pub struct BarColors {
9    /// Per-bar bar color.
10    pub colors: Series<Option<Color>>,
11    /// Bar index offset.
12    pub offset: i32,
13    /// Whether the setting is user-editable.
14    pub editable: bool,
15    /// Optional limit for the number of visible bars.
16    pub show_last: Option<usize>,
17    /// Optional UI title.
18    pub title: Option<String>,
19    /// Display targets.
20    pub display: PlotDisplay,
21}
22
23impl Default for BarColors {
24    fn default() -> Self {
25        Self {
26            colors: Series::new(),
27            offset: 0,
28            editable: true,
29            show_last: None,
30            title: None,
31            display: PlotDisplay::ALL,
32        }
33    }
34}
35
36impl BarColors {
37    pub(crate) fn append_new(&mut self) {
38        self.colors.append_new();
39    }
40}