Module: Echarts::Vector

Defined in:
lib/echarts/vector.rb

Class Method Summary collapse

Class Method Details

.get_config(x, value, min, max, lower_bound, upper_bound, title, subtitle, xLabel, yLabel, color_min = "limegreen", color_max = "tomato", color_generic = "dodgerblue") ⇒ Object



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
# File 'lib/echarts/vector.rb', line 3

def self.get_config(x, value, min, max, lower_bound, upper_bound, title, subtitle, xLabel, yLabel, color_min = "limegreen", color_max = "tomato", color_generic = "dodgerblue")
  # Rails.logger.debug("X: #{x.inspect}")
  {
    grid: {
      top: 80,
    },
    title: {
      text: title,
      subtext: subtitle,
    },
    toolbox: {
      top: 'middle',
      right: 5,
      orient: "vertical",
      feature: {
        saveAsImage: {},
        dataView: {},
        dataZoom: {},
        restore: {},
      },
    },
    tooltip: {
      trigger: "axis",
    },
    xAxis: {
      type: "category",
      data: x,
      name: xLabel,
    },
    yAxis: {
      type: "value",
      name: yLabel,
      min: lower_bound,
      max: upper_bound,
    },
    series: [
      {
        name: "Values",
        data: value,
        type: "line",
        smooth: true,
        # stack: 'Total',
        itemStyle: { color: color_generic },
        markLine: {
          data: [
            # Min  line (create an array repeating the min value for each x value)
            {
              name: "Min Reference",
              yAxis: min,
              lineStyle: { color: color_min },
            },
            # Max line (create an array repeating the max value for each x value)
            {
              name: "Max Reference",
              yAxis: max,
              lineStyle: { color: color_max },
            },
          ],
        },
      },
    ],
  }
end