Class: Charty::Backends::GoogleCharts

Inherits:
Object
  • Object
show all
Defined in:
lib/charty/backends/google_charts.rb

Class Attribute Summary collapse

Instance Attribute Summary collapse

Instance Method Summary collapse

Class Attribute Details

.chart_idObject


11
12
13
# File 'lib/charty/backends/google_charts.rb', line 11

def chart_id
  @chart_id ||= 0
end

.google_charts_srcObject


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_tagObject


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

#contextObject (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

#initilizeObject


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