Class: StaticChart::Area

Inherits:
StaticChart show all
Defined in:
app/models/static_chart/area.rb

Instance Attribute Summary

Attributes inherited from StaticChart

#options

Instance Method Summary collapse

Methods inherited from StaticChart

#axes, #bg, #colors, #empty?, #font_size, #height, #img_height, #img_width, #initialize, #labels, #render_graph, #retina?, #size, #title, #to_s, #width

Constructor Details

This class inherits a constructor from StaticChart

Instance Method Details

#dataObject



20
21
22
# File 'app/models/static_chart/area.rb', line 20

def data
  @data ||= stack_data(super)
end

#defaultsObject



4
5
6
7
8
# File 'app/models/static_chart/area.rb', line 4

def defaults
  super.merge(
    line_weight: 0,
    axes: :right )
end

#line_weightObject



12
13
14
# File 'app/models/static_chart/area.rb', line 12

def line_weight
  options[:line_weight]
end

#marker_colorsObject



16
17
18
# File 'app/models/static_chart/area.rb', line 16

def marker_colors
  options.fetch(:marker_colors, colors)
end

#maxObject



28
29
30
# File 'app/models/static_chart/area.rb', line 28

def max
  options.fetch(:max, data.flatten.compact.max)
end

#minObject



24
25
26
# File 'app/models/static_chart/area.rb', line 24

def min
  options.fetch(:min, 0) # data.last.min
end

#srcObject



34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
# File 'app/models/static_chart/area.rb', line 34

def src
  src = Gchart.line(
    data: data.reverse,
    bar_colors: colors.reverse,
    bg: bg,
    axis_range: [[min, max]],
    min_value: min,
    max_value: max,
    size: size )

  src << chm
  src << chls
  src << chxs
  src
end