-
Notifications
You must be signed in to change notification settings - Fork 77
/
waterfall.rs
70 lines (69 loc) · 2.14 KB
/
waterfall.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
66
67
68
69
70
use charming::{
component::{Axis, Grid, Title},
element::{
AxisPointer, AxisPointerType, AxisType, Emphasis, ItemStyle, Label, LabelPosition,
SplitLine, Tooltip, Trigger,
},
series::{bar, Bar, Series},
Chart,
};
pub fn chart() -> Chart {
Chart::new()
.title(
Title::new()
.text("Waterfall Chart")
.subtext("Living Expenses in Shenzhen"),
)
.tooltip(
Tooltip::new()
.trigger(Trigger::Axis)
.formatter(r#"{b0}<br />{a1}: {c1}"#)
.axis_pointer(AxisPointer::new().type_(AxisPointerType::Shadow)),
)
.grid(
Grid::new()
.left("3%")
.right("4%")
.bottom("3%")
.contain_label(true),
)
.x_axis(
Axis::new()
.type_(AxisType::Category)
.split_line(SplitLine::new().show(false))
.data(vec![
"Total",
"Rent",
"Utilities",
"Transportation",
"Meals",
"Other",
]),
)
.y_axis(Axis::new().type_(AxisType::Value))
.series(Series::Bar(
bar::Bar::new()
.name("Placeholder")
.stack("Total")
.item_style(
ItemStyle::new()
.color("transparent")
.border_color("transparent"),
)
.emphasis(
Emphasis::new().item_style(
ItemStyle::new()
.color("transparent")
.border_color("transparent"),
),
)
.data(vec![0, 1700, 1400, 1200, 300, 0]),
))
.series(
Bar::new()
.name("Life Cost")
.stack("Total")
.label(Label::new().show(true).position(LabelPosition::Inside))
.data(vec![2900, 1200, 300, 200, 900, 300]),
)
}