openpine_vm/draw_event.rs
1use serde::{Deserialize, Serialize};
2
3use crate::visuals::SeriesGraphId;
4
5/// A drawing event emitted during VM execution.
6///
7/// These events describe visual operations that occur as the script runs.
8/// In [`OutputMode::Stream`](crate::OutputMode::Stream) mode, native functions
9/// emit `DrawEvent` variants instead of updating the
10/// [`Chart`](crate::visuals::Chart) directly.
11#[derive(Debug, Clone, Serialize, Deserialize)]
12pub enum DrawEvent {
13 /// A new `plot()` series was registered (first bar only).
14 AddPlot {
15 /// The compile-time series graph id.
16 id: SeriesGraphId,
17 /// The plot title, if provided.
18 title: Option<String>,
19 },
20
21 /// A `plot()` value was emitted for the current bar.
22 UpdatePlot {
23 /// The compile-time series graph id.
24 id: SeriesGraphId,
25 /// Zero-based bar index.
26 bar_index: usize,
27 /// The bar's epoch-millisecond timestamp.
28 timestamp: i64,
29 /// The plotted value (`None` means `na`).
30 value: Option<f64>,
31 },
32}