Module: Echarts::Binary

Defined in:
lib/echarts/binary.rb

Class Method Summary collapse

Class Method Details

.get_config(value, title, subtitle, yLabel) ⇒ 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
# File 'lib/echarts/binary.rb', line 3

def self.get_config(value, title, subtitle, yLabel)
  {
    grid: {
      top: 80,
    },
    title: {
      text: title,
      subtext: subtitle,
    },
    toolbox: {
      top: 'middle',
      right: 5,
      orient: "vertical",
      feature: {
        saveAsImage: {},
      },
    },
    tooltip: {
      trigger: "axis",
    },
    series: [
      {
        name: 'Alert',
        type: 'pie',
        radius: '50%',
        data: [
          { value: value, name: yLabel, itemStyle: { color: value == 0 ? 'limegreen' : 'tomato' } },
        ],
        emphasis: {
          itemStyle: {
            shadowBlur: 10,
            shadowOffsetX: 0,
            shadowColor: 'rgba(0, 0, 0, 0.5)'
          }
        },
      },
    ],
  }
end