Skip to content

Commit

Permalink
add callback symbol example to gallery
Browse files Browse the repository at this point in the history
  • Loading branch information
mbn-gy committed Oct 7, 2024
1 parent e2dbc2c commit 62fc603
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 0 deletions.
1 change: 1 addition & 0 deletions gallery/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ lazy_static! {
insert!(m, line, area_pieces);
insert!(m, line, basic_area);
insert!(m, line, basic_line);
insert!(m, line, different_symbols);
insert!(m, line, confidence_band);
insert!(m, line, data_transform_filter);
insert!(m, line, distribution_of_electricity);
Expand Down
19 changes: 19 additions & 0 deletions gallery/src/line/different_symbols.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
use charming::{
component::Axis,
element::{AxisType, Symbol},
series::Line,
Chart,
};

pub fn chart() -> Chart {
Chart::new()
.x_axis(
Axis::new()
.type_(AxisType::Category)
.data(vec!["Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"]),
)
.y_axis(Axis::new().type_(AxisType::Value))
.series(Line::new().data(vec![150, 230, 224, 218, 135, 147, 260])
.symbol_size(20)
.symbol(Symbol::Callback("function (value, params) { return params.dataIndex % 2 === 0 ? value > 200 ? 'diamond' : 'circle' : 'triangle'; }".into())))
}
1 change: 1 addition & 0 deletions gallery/src/line/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ pub mod basic_area;
pub mod basic_line;
pub mod confidence_band;
pub mod data_transform_filter;
pub mod different_symbols;
pub mod distribution_of_electricity;
pub mod gradient_stacked_area;
pub mod large_scale_area;
Expand Down

0 comments on commit 62fc603

Please sign in to comment.