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
|
# File 'lib/echarts/multiple_vectors.rb', line 3
def self.get_config(stacks, legend, min, max, lower_bound, upper_bound, title, subtitle, xLabel, yLabel, color_min = "limegreen", color_max = "tomato")
x_values = stacks.map { |stack| stack.map(&:first) }.flatten.uniq.sort
{
grid: {
top: 80,
},
legend: {
bottom: 2,
show: true,
data: legend,
type: "scroll",
},
title: {
text: title,
subtext: subtitle,
},
toolbox: {
top: 'middle',
right: 5,
orient: "vertical",
feature: {
saveAsImage: {},
dataView: {},
dataZoom: {},
restore: {},
},
},
tooltip: {
trigger: "axis",
},
xAxis: {
type: "value",
name: xLabel,
boundaryGap: false,
data: x_values,
min: x_values.first.floor,
max: x_values.last.ceil,
},
yAxis: {
type: "value",
name: yLabel,
min: lower_bound,
max: upper_bound,
},
series: stacks.map.with_index do |stack, index|
{
name: legend[index],
data: stack,
type: "line",
smooth: true,
markLine: {
data: [
{
name: "Min Reference",
yAxis: min,
lineStyle: { color: color_min },
},
{
name: "Max Reference",
yAxis: max,
lineStyle: { color: color_max },
}
]
}
}
end
}
end
|