Module: GoogleChart::RangeMarker

Included in:
BarChart, LineChart
Defined in:
lib/google_chart/range_marker.rb

Constant Summary collapse

@@range_marker_orientations =
{ :h => 'r', :v => 'R' }

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.included(klass) ⇒ Object



4
5
6
# File 'lib/google_chart/range_marker.rb', line 4

def self.included(klass)
  klass.register!(:ranges)
end

Instance Method Details

#rangesObject



14
15
16
17
18
19
20
21
22
23
24
# File 'lib/google_chart/range_marker.rb', line 14

def ranges
  unless @ranges.nil? || @ranges.empty?
    'chm=' + @ranges.collect {|r|
      r[0] = @@range_marker_orientations[r[0]]
      r[1..-1] = ['000000cc', *r[1..-1]] if r.size == 3
      # The middle parameter is required by Google Charts but ignored for range markers
      r = r[0..1] + ['x'] + r[2..-1]
      r.join(',')
    }.join('|')
  end
end

#ranges=(ranges) ⇒ Object



10
11
12
# File 'lib/google_chart/range_marker.rb', line 10

def ranges=(ranges)
  @ranges = ranges.any? {|e| e.is_a?(Array) } ? ranges : [ranges]
end