orbital_data/binding.rs
1/// Declarative binding from [`crate::Dataset`] fields to chart geometry.
2#[derive(Clone, Debug, Default, PartialEq, Eq)]
3pub struct ChartFieldBinding {
4 /// Category or time axis field key.
5 pub x_field: Option<String>,
6 /// One or more value series field keys.
7 pub y_fields: Vec<String>,
8 /// Pivot long→wide by grouping on this field (e.g. region column).
9 pub series_by_field: Option<String>,
10 /// Field key driving per-item color.
11 pub color_field: Option<String>,
12 /// Field key for data labels.
13 pub label_field: Option<String>,
14 /// Scatter z-axis / bubble size field key.
15 pub size_field: Option<String>,
16 /// Scatter point identity field key (falls back to record id when unset).
17 pub id_field: Option<String>,
18}
19
20impl ChartFieldBinding {
21 /// Shorthand for a single category axis and one or more value fields.
22 pub fn new(x_field: impl Into<String>, y_fields: Vec<String>) -> Self {
23 Self {
24 x_field: Some(x_field.into()),
25 y_fields,
26 ..Default::default()
27 }
28 }
29}