Module: Seer::Chart

Included in:
AreaChart, BarChart, ColumnChart, Gauge, Geomap, LineChart, PieChart
Defined in:
lib/seer/chart.rb

Overview

:nodoc:

Constant Summary collapse

DEFAULT_COLORS =
['#324F69','#919E4B', '#A34D4D', '#BEC8BE']
DEFAULT_LEGEND_LOCATION =
'bottom'
DEFAULT_HEIGHT =
350
DEFAULT_WIDTH =
550

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#chart_elementObject

Returns the value of attribute chart_element.



5
6
7
# File 'lib/seer/chart.rb', line 5

def chart_element
  @chart_element
end

#colorsObject

Returns the value of attribute colors.



5
6
7
# File 'lib/seer/chart.rb', line 5

def colors
  @colors
end

Instance Method Details

#data_columnsObject



34
35
36
37
38
39
# File 'lib/seer/chart.rb', line 34

def data_columns
  _data_columns =  "            data.addRows(#{data_table.size});\r"
  _data_columns << "            data.addColumn('string', '#{label_method}');\r"
  _data_columns << "            data.addColumn('number', '#{data_method}');\r"
  _data_columns
end

#formatted_colorsObject



26
27
28
29
30
31
32
# File 'lib/seer/chart.rb', line 26

def formatted_colors
  if @colors.include?('darker')
    @colors
  else
    "[#{@colors.map{|color| "'#{color.gsub(/\#/,'')}'"} * ','}]"
  end
end

#in_element=(elem) ⇒ Object



12
13
14
# File 'lib/seer/chart.rb', line 12

def in_element=(elem)
  @chart_element = elem
end

#optionsObject



41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
# File 'lib/seer/chart.rb', line 41

def options
  _options = ""
  nonstring_options.each do |opt|
    next unless self.send(opt)
    if opt == :colors
      _options << "            options['#{opt.to_s.camelize(:lower)}'] = #{self.send(:formatted_colors)};\r"
    else
      _options << "            options['#{opt.to_s.camelize(:lower)}'] = #{self.send(opt)};\r"
    end
  end
  string_options.each do |opt|
    next unless self.send(opt)
    _options << "            options['#{opt.to_s.camelize(:lower)}'] = '#{self.send(opt)}';\r"
  end
  _options
end