forked from yuankunzhang/charming
-
Notifications
You must be signed in to change notification settings - Fork 0
/
multiple_funnels.rs
98 lines (97 loc) · 2.9 KB
/
multiple_funnels.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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
use charming::{
component::{DataView, Feature, Legend, Restore, SaveAsImage, Title, Toolbox},
df,
element::{Label, LabelPosition, Orient, Sort, Tooltip, Trigger},
series::Funnel,
Chart,
};
pub fn chart() -> Chart {
Chart::new()
.title(Title::new().text("Funnel").left("left").top("bottom"))
.tooltip(
Tooltip::new()
.trigger(Trigger::Item)
.formatter("{a} <br/>{b} : {c}%"),
)
.toolbox(
Toolbox::new()
.orient(Orient::Vertical)
.top("center")
.feature(
Feature::new()
.save_as_image(SaveAsImage::new())
.restore(Restore::new())
.data_view(DataView::new().read_only(true)),
),
)
.legend(
Legend::new()
.orient(Orient::Vertical)
.left("left")
.data(vec!["Show", "Click", "Visit", "Inquiry", "Order"]),
)
.series(
Funnel::new()
.name("Funnel")
.width("40%")
.height("45%")
.left("5%")
.top("50%")
.data(df![
(60, "Visit"),
(30, "Inquiry"),
(10, "Order"),
(80, "Click"),
(100, "Show")
]),
)
.series(
Funnel::new()
.name("Pyramid")
.width("40%")
.height("45%")
.left("5%")
.top("5%")
.sort(Sort::Ascending)
.data(df![
(60, "Visit"),
(30, "Inquiry"),
(10, "Order"),
(80, "Click"),
(100, "Show")
]),
)
.series(
Funnel::new()
.name("Funnel")
.width("40%")
.height("45%")
.left("55%")
.top("5%")
.label(Label::new().position(LabelPosition::Left))
.data(df![
(60, "Visit"),
(30, "Inquiry"),
(10, "Order"),
(80, "Click"),
(100, "Show")
]),
)
.series(
Funnel::new()
.name("Pyramid")
.width("40%")
.height("45%")
.left("55%")
.top("50%")
.sort(Sort::Ascending)
.label(Label::new().position(LabelPosition::Left))
.data(df![
(60, "Visit"),
(30, "Inquiry"),
(10, "Order"),
(80, "Click"),
(100, "Show")
]),
)
}