forked from GiovineItalia/Gadfly.jl
/
data.jl
58 lines (50 loc) · 1018 Bytes
/
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
@varset Data begin
x
y
xmin
xmax
ymin
ymax
xintercept
yintercept
xgroup
ygroup
xtick
ytick
xtick_labels
ytick_labels
xviewmin
xviewmax
yviewmin
yviewmax
size
xsize
ysize
color
label
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 Data.names
vs = {getfield(d, name) for d in ds}
vs = {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