Skip to content

Commit

Permalink
fix some missing field
Browse files Browse the repository at this point in the history
  • Loading branch information
yg0x01 committed Oct 12, 2024
1 parent 8e7447d commit 8bf2bc3
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
9 changes: 9 additions & 0 deletions charming/src/element/mark_line.rs
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,9 @@ pub struct MarkLine {
#[serde(skip_serializing_if = "Vec::is_empty")]
symbol: Vec<Symbol>,

#[serde(skip_serializing_if = "Option::is_none")]
precision: Option<f64>,

#[serde(skip_serializing_if = "Vec::is_empty")]
data: Vec<MarkLineVariant>,
}
Expand All @@ -186,6 +189,7 @@ impl MarkLine {
zlevel: None,
z: None,
symbol: vec![],
precision: None,
data: vec![],
}
}
Expand Down Expand Up @@ -215,6 +219,11 @@ impl MarkLine {
self
}

pub fn precision<F: Into<f64>>(mut self, precision: F) -> Self {
self.precision = Some(precision.into());
self
}

pub fn data<M: Into<MarkLineVariant>>(mut self, data: Vec<M>) -> Self {
self.data = data.into_iter().map(|m| m.into()).collect();
self
Expand Down
11 changes: 10 additions & 1 deletion charming/src/series/line.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use crate::{
datatype::{DataFrame, DataPoint},
element::{
smoothness::Smoothness, AreaStyle, CoordinateSystem, DimensionEncode, Emphasis, ItemStyle,
Label, LineStyle, MarkArea, MarkLine, MarkPoint, Symbol, SymbolSize,
Label, LineStyle, MarkArea, MarkLine, MarkPoint, Symbol, SymbolSize, Tooltip,
},
};

Expand Down Expand Up @@ -77,6 +77,9 @@ pub struct Line {
#[serde(skip_serializing_if = "Option::is_none")]
y_axis_index: Option<f64>,

#[serde(skip_serializing_if = "Option::is_none")]
tooltip: Option<Tooltip>,

#[serde(skip_serializing_if = "Vec::is_empty")]
data: DataFrame,
}
Expand Down Expand Up @@ -112,6 +115,7 @@ impl Line {
encode: None,
x_axis_index: None,
y_axis_index: None,
tooltip: None,
data: vec![],
}
}
Expand Down Expand Up @@ -223,6 +227,11 @@ impl Line {
self
}

pub fn tooltip(mut self, tooltip: Tooltip) -> Self {
self.tooltip = Some(tooltip);
self
}

pub fn data<D: Into<DataPoint>>(mut self, data: Vec<D>) -> Self {
self.data = data.into_iter().map(|d| d.into()).collect();
self
Expand Down

0 comments on commit 8bf2bc3

Please sign in to comment.