Class: Chartify::ChartBase
- Inherits:
-
Object
- Object
- Chartify::ChartBase
- Defined in:
- lib/chartify/chart_base.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#columns ⇒ Object
Returns the value of attribute columns.
-
#data ⇒ Object
Returns the value of attribute data.
-
#label_column ⇒ Object
Returns the value of attribute label_column.
-
#title ⇒ Object
Returns the value of attribute title.
Class Method Summary collapse
Instance Method Summary collapse
- #add_row(row) ⇒ Object
-
#initialize ⇒ ChartBase
constructor
data: array of hash [2013-1-2, hours_remain: 2, estimated_hours_remain: 10, 2013-1-3, hours_remain: 4, estimated_hours_remain: 10, 2013-1-4, hours_remain: 10, estimated_hours_remain: 10].
- #render_chart(html_dom_id, options = {}) ⇒ Object
Constructor Details
#initialize ⇒ ChartBase
data: array of hash [2013-1-2, hours_remain: 2, estimated_hours_remain: 10, 2013-1-3, hours_remain: 4, estimated_hours_remain: 10, 2013-1-4, hours_remain: 10, estimated_hours_remain: 10]
12 13 14 |
# File 'lib/chartify/chart_base.rb', line 12 def initialize columns, data = [], [] end |
Instance Attribute Details
#columns ⇒ Object
Returns the value of attribute columns.
5 6 7 |
# File 'lib/chartify/chart_base.rb', line 5 def columns @columns end |
#data ⇒ Object
Returns the value of attribute data.
5 6 7 |
# File 'lib/chartify/chart_base.rb', line 5 def data @data end |
#label_column ⇒ Object
Returns the value of attribute label_column.
5 6 7 |
# File 'lib/chartify/chart_base.rb', line 5 def label_column @label_column end |
#title ⇒ Object
Returns the value of attribute title.
5 6 7 |
# File 'lib/chartify/chart_base.rb', line 5 def title @title end |
Class Method Details
.evaluate_js ⇒ Object
34 35 36 |
# File 'lib/chartify/chart_base.rb', line 34 def self.evaluate_js "eval($('script.chart_script').text());" end |
Instance Method Details
#add_row(row) ⇒ Object
16 17 18 |
# File 'lib/chartify/chart_base.rb', line 16 def add_row(row) data << row end |
#render_chart(html_dom_id, options = {}) ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/chartify/chart_base.rb', line 20 def render_chart(html_dom_id, = {}) api_name = [:web_api_name] || config.web_api_name.to_s class_name = self.class.name.split("::")[1] load "chartify/web_chart/#{api_name}/#{class_name.underscore}.rb" chart = "Chartify::WebChart::#{api_name.camelize}::#{class_name}".constantize.new chart.data, chart.columns, chart.label_column = self.data, self.columns, self.label_column html = <<-HTML <script type="application/javascript" class="chart_script"> #{chart.render(html_dom_id)} </script> HTML html.html_safe end |