Class: Chart
- Inherits:
-
Object
- Object
- Chart
- Defined in:
- app/models/chart.rb
Overview
class to encapsulate the definition of a chart in browser
Instance Attribute Summary collapse
-
#div ⇒ Object
readonly
Returns the value of attribute div.
-
#lines ⇒ Object
readonly
Returns the value of attribute lines.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
Class Method Summary collapse
-
.value_methods(charts) ⇒ Object
class method, given an array of Charts, returns an array of unique value methods for the lines.
Instance Method Summary collapse
-
#as_hash ⇒ Object
returns the values that are to be passed to the client browser, as a hash, inluding the lines.
-
#initialize(div, lines, options = {}) ⇒ Chart
constructor
constructor taking a div id and an array of Lines options should contain :xaxis with :method :xaxis may also contain :min and :max.
Constructor Details
#initialize(div, lines, options = {}) ⇒ Chart
constructor taking a div id and an array of Lines options should contain :xaxis with :method :xaxis may also contain :min and :max
8 9 10 11 12 |
# File 'app/models/chart.rb', line 8 def initialize( div, lines, = {} ) @div = div @lines = lines @options = end |
Instance Attribute Details
#div ⇒ Object (readonly)
Returns the value of attribute div.
3 4 5 |
# File 'app/models/chart.rb', line 3 def div @div end |
#lines ⇒ Object (readonly)
Returns the value of attribute lines.
3 4 5 |
# File 'app/models/chart.rb', line 3 def lines @lines end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
3 4 5 |
# File 'app/models/chart.rb', line 3 def @options end |
Class Method Details
.value_methods(charts) ⇒ Object
class method, given an array of Charts, returns an array of unique value methods for the lines
20 21 22 |
# File 'app/models/chart.rb', line 20 def self.value_methods( charts ) charts.map { |c| ChartLine.value_methods( c.lines ) }.flatten.uniq end |
Instance Method Details
#as_hash ⇒ Object
returns the values that are to be passed to the client browser, as a hash, inluding the lines
15 16 17 |
# File 'app/models/chart.rb', line 15 def as_hash {:div => @div, :lines => @lines.map { |l| l.as_hash }, :options => @options } end |