forked from GiovineItalia/Gadfly.jl
/
data.jl
79 lines (69 loc) · 1.39 KB
/
data.jl
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
@varset Data begin
x
y
z
xmin
xmax
ymin
ymax
xintercept
yintercept
middle
lower_hinge
upper_hinge
lower_fence
upper_fence
xgroup
ygroup
xtick
ytick
xtick_labels
ytick_labels
xviewmin
xviewmax
yviewmin
yviewmax
size
xsize
ysize
color
group
label
func
titles, Dict{Symbol, String}, Dict{Symbol, String}()
end
# Produce a new Data instance chaining the values of one or more others.
#
# The bound values in the returned Data instance are chain iterators which will
# iterate through the values contained in all the given Data instances.
#
# Args:
# ds: Some Data instances.
#
# Returns:
# A new Data instance.
#
function chain(ds::Data...)
chained_data = Data()
for name in fieldnames(Data)
vs = Any[getfield(d, name) for d in ds]
vs = Any[v for v in filter(issomething, vs)]
if isempty(vs)
setfield!(chained_data, name, nothing)
else
setfield!(chained_data, name, Iterators.chain(vs...))
end
end
chained_data
end
function show(io::IO, data::Data)
maxlen = 0
print(io, "Data(")
for name in fieldnames(Data)
if getfield(data, name) != nothing
print(io, "\n ", string(name), "=")
show(io, getfield(data, name))
end
end
print(io, "\n)\n")
end