openpine_vm/visuals/
plotarrow.rs

1use openpine_compiler::instructions::Color;
2use serde::{Deserialize, Serialize};
3
4use crate::{
5    series::Series,
6    visuals::{PlotDisplay, PlotFormat},
7};
8
9/// Plot arrow series.
10#[derive(Debug, Clone, Serialize, Deserialize)]
11pub struct PlotArrow {
12    /// Plot title (`None` when the caller did not supply one).
13    pub title: Option<String>,
14    /// Per-bar plot value.
15    pub series: Series<Option<f64>>,
16    /// Per-bar color for up arrows.
17    pub up_colors: Series<Option<Color>>,
18    /// Per-bar color for down arrows.
19    pub down_colors: Series<Option<Color>>,
20    /// Bar index offset.
21    pub offset: i32,
22    /// Minimum arrow height.
23    pub min_height: usize,
24    /// Maximum arrow height.
25    pub max_height: usize,
26    /// Whether the plot is user-editable.
27    pub editable: bool,
28    /// Optional limit for the number of visible bars.
29    pub show_last: Option<usize>,
30    /// Display targets.
31    pub display: PlotDisplay,
32    /// Optional formatting hint.
33    pub format: Option<PlotFormat>,
34    /// Optional decimal precision.
35    pub precision: Option<i32>,
36    /// Whether to force overlay rendering.
37    pub force_overlay: bool,
38}
39
40impl PlotArrow {
41    pub(crate) fn append_new(&mut self) {
42        self.series.append_new();
43        self.up_colors.append_new();
44        self.down_colors.append_new();
45    }
46}