Class: Charty::Backends::GoogleCharts
- Inherits:
-
Object
- Object
- Charty::Backends::GoogleCharts
- Defined in:
- lib/charty/backends/google_charts.rb
Class Attribute Summary collapse
Instance Attribute Summary collapse
-
#context ⇒ Object
readonly
Returns the value of attribute context.
Instance Method Summary collapse
- #initilize ⇒ Object
- #label(x, y) ⇒ Object
- #old_style_render(context, filename) ⇒ Object
- #plot(plot, context) ⇒ Object
- #series=(series) ⇒ Object
Class Attribute Details
.chart_id ⇒ Object
11 12 13 |
# File 'lib/charty/backends/google_charts.rb', line 11 def chart_id @chart_id ||= 0 end |
.google_charts_src ⇒ Object
21 22 23 |
# File 'lib/charty/backends/google_charts.rb', line 21 def google_charts_src @google_charts_src ||= 'https://www.gstatic.com/charts/loader.js' end |
.with_api_load_tag ⇒ Object
15 16 17 18 19 |
# File 'lib/charty/backends/google_charts.rb', line 15 def with_api_load_tag return @with_api_load_tag unless @with_api_load_tag.nil? @with_api_load_tag = true end |
Instance Attribute Details
#context ⇒ Object (readonly)
Returns the value of attribute context.
6 7 8 |
# File 'lib/charty/backends/google_charts.rb', line 6 def context @context end |
Instance Method Details
#initilize ⇒ Object
26 27 |
# File 'lib/charty/backends/google_charts.rb', line 26 def initilize end |
#label(x, y) ⇒ Object
29 30 |
# File 'lib/charty/backends/google_charts.rb', line 29 def label(x, y) end |
#old_style_render(context, filename) ⇒ Object
36 37 38 |
# File 'lib/charty/backends/google_charts.rb', line 36 def old_style_render(context, filename) plot(nil, context) end |
#plot(plot, context) ⇒ Object
40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 |
# File 'lib/charty/backends/google_charts.rb', line 40 def plot(plot, context) @context = context self.class.chart_id = self.class.chart_id + 1 case context.method when :bar generate_render_js("ColumnChart") when :barh generate_render_js("BarChart") when :scatter generate_render_js("ScatterChart") when :bubble generate_render_js("BubbleChart") when :curve generate_render_js("LineChart") else raise NotImplementedError end end |
#series=(series) ⇒ Object
32 33 34 |
# File 'lib/charty/backends/google_charts.rb', line 32 def series=(series) @series = series end |