-
Notifications
You must be signed in to change notification settings - Fork 77
/
funnel_chart.rs
58 lines (57 loc) · 1.89 KB
/
funnel_chart.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
use charming::{
component::{DataView, Feature, Legend, Restore, SaveAsImage, Title, Toolbox},
df,
element::{
Emphasis, ItemStyle, Label, LabelLine, LabelPosition, LineStyle, LineStyleType, Sort,
Tooltip, Trigger,
},
series::Funnel,
Chart,
};
pub fn chart() -> Chart {
Chart::new()
.title(Title::new().text("Funnel"))
.tooltip(
Tooltip::new()
.trigger(Trigger::Item)
.formatter("{a} <br/>{b} : {c}%"),
)
.toolbox(
Toolbox::new().feature(
Feature::new()
.data_view(DataView::new().read_only(false))
.restore(Restore::new())
.save_as_image(SaveAsImage::new()),
),
)
.legend(Legend::new().data(vec!["Show", "Click", "Visit", "Inquiry", "Order"]))
.series(
Funnel::new()
.name("Funnel")
.left("10%")
.top(60)
.bottom(60)
.width("80%")
.min(0)
.max(100)
.min_size("0%")
.max_size("100%")
.sort(Sort::Descending)
.gap(2)
.label(Label::new().show(true).position(LabelPosition::Inside))
.label_line(
LabelLine::new()
.length(10)
.line_style(LineStyle::new().width(1).type_(LineStyleType::Solid)),
)
.item_style(ItemStyle::new().border_color("#fff").border_width(1))
.emphasis(Emphasis::new().label(Label::new().font_size(20)))
.data(df![
(60, "Visit"),
(30, "Inquiry"),
(10, "Order"),
(80, "Click"),
(100, "Show"),
]),
)
}