Skip to content

Commit

Permalink
Merge pull request #101 from yg0x01/main
Browse files Browse the repository at this point in the history
fix line symbol_size param type
  • Loading branch information
LukaOber authored Oct 11, 2024
2 parents 196fb3f + 9c0bc7a commit de2d2e0
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
6 changes: 3 additions & 3 deletions 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,
Label, LineStyle, MarkArea, MarkLine, MarkPoint, Symbol, SymbolSize,
},
};

Expand All @@ -27,7 +27,7 @@ pub struct Line {
symbol: Option<Symbol>,

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

#[serde(skip_serializing_if = "Option::is_none")]
show_symbol: Option<bool>,
Expand Down Expand Up @@ -137,7 +137,7 @@ impl Line {
self
}

pub fn symbol_size<F: Into<f64>>(mut self, symbol_size: F) -> Self {
pub fn symbol_size<F: Into<SymbolSize>>(mut self, symbol_size: F) -> Self {
self.symbol_size = Some(symbol_size.into());
self
}
Expand Down
4 changes: 2 additions & 2 deletions gallery/src/line/different_symbols.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use charming::{
component::Axis,
element::{AxisType, Symbol},
element::{AxisType, Symbol, SymbolSize},
series::Line,
Chart,
};
Expand All @@ -14,6 +14,6 @@ pub fn chart() -> Chart {
)
.y_axis(Axis::new().type_(AxisType::Value))
.series(Line::new().data(vec![150, 230, 224, 218, 135, 147, 260])
.symbol_size(20)
.symbol_size(SymbolSize::Function("function (value, params) { return params.dataIndex % 2 === 0 ? value > 200 ? 10 : 20 : 30; }".into()))
.symbol(Symbol::Callback("function (value, params) { return params.dataIndex % 2 === 0 ? value > 200 ? 'diamond' : 'circle' : 'triangle'; }".into())))
}

0 comments on commit de2d2e0

Please sign in to comment.