Class: GChart::Meter

Inherits:
Base
  • Object
show all
Defined in:
lib/gchart/meter.rb

Instance Attribute Summary collapse

Attributes inherited from Base

#axes, #chart_background, #colors, #data, #entire_background, #extras, #height, #legend, #max, #title, #width

Instance Method Summary collapse

Methods inherited from Base

#axis, #fetch, #initialize, #size, #size=, #to_url, #write

Constructor Details

This class inherits a constructor from GChart::Base

Instance Attribute Details

#labelObject

Returns the value of attribute label.



3
4
5
# File 'lib/gchart/meter.rb', line 3

def label
  @label
end

Instance Method Details

#render_chart_typeObject

:nodoc:



5
6
7
# File 'lib/gchart/meter.rb', line 5

def render_chart_type #:nodoc:
  "gom"
end

#render_data(params) ⇒ Object

The data for a meter is a single data point expressed as a percent



10
11
12
13
# File 'lib/gchart/meter.rb', line 10

def render_data(params)
  value = data.is_a?(Array) ? data.flatten.first : data
  params["chd"] = "t:#{value.to_f}"
end

#render_legend(params) ⇒ Object

Commandeer render_legend to render the label



24
25
26
27
# File 'lib/gchart/meter.rb', line 24

def render_legend(params)
  self.label = legend if self.label.nil? # Can use legend instead of label
  params["chl"] = label if label
end