-
Notifications
You must be signed in to change notification settings - Fork 0
/
piechart.red
89 lines (71 loc) · 2.47 KB
/
piechart.red
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
Red [
Title: "piechart.red"
Build: 1.0.0.0
]
do read http://redlang.red/google-piecharts.red
do read http://redlang.red/parse-text-data.red
piechart: function ['.data [word! block! unset! string!] /title .title /clipboard ][
switch/default type?/word get/any '.data [
data: none ; to initialize
unset! [
either clipboard [
data: parse-text-data read-clipboard
.google-pie-chart data
][
print {HELP - Command examples:
- piechart ; for help
- piechart [label1 10 "label 2" 20] ; for one line data block
- piechart [ ; for multiple lines data block
label1 10
"label 2" 20
]
- piechart/title [Salary 5000 Financials 1000] "My Revenues"
- piechart/title "My Revenues" [Salary 5000 Financials 1000]
- piechart/clipboard ; for reading block of data from clipboard without bracket
- For passing data variable, embed variable with () for example:
.data: [label1 10 "label 2" 20]
piechart (.data)
}
ans: ask "Do you want to process from clipboard ? (Y/N - N by default): "
if ans = "Y" [
piechart/clipboard
]
]
]
block! string! word! [
either title [
.google-pie-chart/title .data .title
][
.google-pie-chart .data
]
]
] [
print {
For passing data variable, embed variable with () for example:
.data: [
"Adsense Revenue" 300
"Sponsors" 500
"Gifts" 50
"Others" 58
]
piechart (.data)
}
]
]
if not value? '.system [
print {
Command examples:
- piechart ; for help
- piechart [label1 10 "label 2" 20] ; for one line data block
- piechart [ ; for multiple lines data block
label1 10
"label 2" 20
]
- piechart/title [Salary 5000 Financials 1000] "My Revenues"
- piechart/title "My Revenues" [Salary 5000 Financials 1000]
- piechart/clipboard ; for string of data from clipboard without bracket
- For passing data variable, embed variable with () for example:
.data: [label1 10 "label 2" 20]
piechart (.data)
}
]