Module: GoogleChart::Data

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

Constant Summary collapse

@@simple =
('A'..'Z').to_a + ('a'..'z').to_a + ('0'..'9').to_a
@@extended =
alphabet.map {|a| alphabet.map {|b| a + b }}.flatten

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#encoding=(value) ⇒ Object

Sets the attribute encoding

Parameters:

  • value

    the value to set the attribute encoding to.



8
9
10
# File 'lib/google_chart/data.rb', line 8

def encoding=(value)
  @encoding = value
end

#scale=(value) ⇒ Object (writeonly)

Sets the attribute scale

Parameters:

  • value

    the value to set the attribute scale to.



8
9
10
# File 'lib/google_chart/data.rb', line 8

def scale=(value)
  @scale = value
end

Class Method Details

.included(klass) ⇒ Object



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

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

Instance Method Details

#dataObject



21
22
23
24
# File 'lib/google_chart/data.rb', line 21

def data
  set_scale
  'chd=' + send(:"#{encoding}_encode", reduce(@data)) if @data
end

#data=(data) ⇒ Object



14
15
16
17
18
19
# File 'lib/google_chart/data.rb', line 14

def data=(data)
  @data = data.any? {|e| Array === e } ? data : [data]
  if @data.all? {|set| set.compact.empty? }
    raise ArgumentError, 'data must contain at least 1 non-nil value'
  end
end