Skip to main content

fission_charts/
encode.rs

1use serde::{Deserialize, Serialize};
2
3/// Represents column mapping (e.g., mapping dataset dimensions to visual encodings).
4#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
5pub struct Encode {
6    pub x: Option<String>,
7    pub y: Option<String>,
8    pub tooltip: Option<Vec<String>>,
9    pub item_name: Option<String>,
10}
11
12impl Encode {
13    pub fn new() -> Self {
14        Self::default()
15    }
16
17    pub fn x(mut self, x: impl Into<String>) -> Self {
18        self.x = Some(x.into());
19        self
20    }
21
22    pub fn y(mut self, y: impl Into<String>) -> Self {
23        self.y = Some(y.into());
24        self
25    }
26
27    pub fn tooltip(mut self, tooltip: Vec<String>) -> Self {
28        self.tooltip = Some(tooltip);
29        self
30    }
31
32    pub fn item_name(mut self, item_name: impl Into<String>) -> Self {
33        self.item_name = Some(item_name.into());
34        self
35    }
36}