Class: Charty::GoogleChart

Inherits:
PlotterAdapter show all
Defined in:
lib/charty/backends/google_chart.rb

Constant Summary collapse

Name =
"google_chart"

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from PlotterAdapter

create, inherited

Instance Attribute Details

#contextObject (readonly)

Returns the value of attribute context


4
5
6
# File 'lib/charty/backends/google_chart.rb', line 4

def context
  @context
end

Class Method Details

.chart_idObject


10
11
12
# File 'lib/charty/backends/google_chart.rb', line 10

def self.chart_id
  @chart_id ||= 0
end

.chart_id=(chart_id) ⇒ Object


6
7
8
# File 'lib/charty/backends/google_chart.rb', line 6

def self.chart_id=(chart_id)
  @chart_id = chart_id
end

Instance Method Details

#initilizeObject


14
15
# File 'lib/charty/backends/google_chart.rb', line 14

def initilize
end

#label(x, y) ⇒ Object


17
18
# File 'lib/charty/backends/google_chart.rb', line 17

def label(x, y)
end

#plot(plot, context) ⇒ Object


28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# File 'lib/charty/backends/google_chart.rb', line 28

def plot(plot, context)
  @context = context
  self.class.chart_id = self.class.chart_id + 1

  case context.method
  when :bar
    generate_render_js("BarChart")
  when :scatter
    generate_render_js("ScatterChart")
  when :bubble
    generate_render_js("BubbleChart")
  else
    raise NotImplementedError
  end
end

#render(context, filename) ⇒ Object


24
25
26
# File 'lib/charty/backends/google_chart.rb', line 24

def render(context, filename)
  plot(nil, context)
end

#series=(series) ⇒ Object


20
21
22
# File 'lib/charty/backends/google_chart.rb', line 20

def series=(series)
  @series = series
end