-
Notifications
You must be signed in to change notification settings - Fork 77
/
area_pieces.rs
65 lines (64 loc) · 2.27 KB
/
area_pieces.rs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
use charming::{
component::{Axis, VisualMap, VisualMapPiece, VisualMapType},
df,
element::{
AreaStyle, AxisType, Label, LineStyle, MarkLine, MarkLineData, MarkLineVariant, Symbol,
},
series::Line,
Chart,
};
pub fn chart() -> Chart {
Chart::new()
.x_axis(Axis::new().type_(AxisType::Category).boundary_gap(false))
.y_axis(
Axis::new()
.type_(AxisType::Value)
.boundary_gap(("0", "20%")),
)
.visual_map(
VisualMap::new()
.type_(VisualMapType::Piecewise)
.show(false)
.dimension(0)
.series_index(0)
.pieces(vec![
VisualMapPiece::new()
.min(1)
.max(3)
.color("rgba(0, 0, 180, 0.4)"),
VisualMapPiece::new()
.min(5)
.max(7)
.color("rgba(0, 0, 180, 0.4)"),
]),
)
.series(
Line::new()
.smooth(true)
.symbol(Symbol::None)
.line_style(LineStyle::new().width(5).color("#5470C6"))
.area_style(AreaStyle::new())
.mark_line(
MarkLine::new()
.symbol(vec![Symbol::None, Symbol::None])
.label(Label::new().show(false))
.data(vec![
MarkLineVariant::Simple(MarkLineData::new().x_axis(1)),
MarkLineVariant::Simple(MarkLineData::new().x_axis(3)),
MarkLineVariant::Simple(MarkLineData::new().x_axis(6)),
MarkLineVariant::Simple(MarkLineData::new().x_axis(7)),
]),
)
.data(df![
["2019-10-10", 200],
["2019-10-11", 560],
["2019-10-12", 750],
["2019-10-13", 580],
["2019-10-14", 250],
["2019-10-15", 300],
["2019-10-16", 450],
["2019-10-17", 300],
["2019-10-18", 100],
]),
)
}