Class: RailsCharts::DonutChart

Inherits:
PieChart show all
Defined in:
lib/rails_charts/donut_chart.rb

Constant Summary

Constants inherited from BaseChart

BaseChart::CHART_JS_PATTERN

Instance Attribute Summary

Attributes inherited from BaseChart

#chart_id, #container_id, #data, #debug, #height, #klass, #locale, #options, #other_options, #renderer, #style, #theme, #vertical, #width

Instance Method Summary collapse

Methods inherited from PieChart

#build_options, #type, #x_axis, #y_axis

Methods inherited from LineChart

#type, #x, #x_axis, #y, #y_axis

Methods inherited from BaseChart

#axises, #build_options, #js_code, #option, #x_axis, #y_axis

Constructor Details

#initialize(data, options = {}) ⇒ DonutChart

Returns a new instance of DonutChart.



4
5
6
# File 'lib/rails_charts/donut_chart.rb', line 4

def initialize(data, options = {})
  super(data, options)
end

Instance Method Details

#defaultsObject



15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/rails_charts/donut_chart.rb', line 15

def defaults
  {
    tooltip: {
      item: {
        trigger: 'item',
      },
    }, 
    series: {
      radius: ['40%', '70%']
    },
    emphasis: {
      itemStyle: {
        shadowBlur: 10,
        shadowOffsetX: 0,
        shadowColor: 'rgba(0, 0, 0, 0.5)'
      }
    } 
  }
end

#generate_series_optionsObject



8
9
10
11
12
13
# File 'lib/rails_charts/donut_chart.rb', line 8

def generate_series_options
  {
    data: data.map{|k, v| {name: k, value: v} },
    type: type
  }
end