Class: Charty::Backends::Plotly

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

Class Attribute Summary collapse

Instance Attribute Summary collapse

Instance Method Summary collapse

Class Attribute Details

.chart_idObject



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

def chart_id
  @chart_id ||= 0
end

.plotly_srcObject



23
24
25
# File 'lib/charty/backends/plotly.rb', line 23

def plotly_src
  @plotly_src ||= 'https://cdn.plot.ly/plotly-latest.min.js'
end

.with_api_load_tagObject



17
18
19
20
21
# File 'lib/charty/backends/plotly.rb', line 17

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.



8
9
10
# File 'lib/charty/backends/plotly.rb', line 8

def context
  @context
end

Instance Method Details

#initilizeObject



28
29
# File 'lib/charty/backends/plotly.rb', line 28

def initilize
end

#label(x, y) ⇒ Object



31
32
# File 'lib/charty/backends/plotly.rb', line 31

def label(x, y)
end

#plot(plot, context) ⇒ Object



42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
# File 'lib/charty/backends/plotly.rb', line 42

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

  case context.method
  when :bar
    render_graph(context, :bar)
  when :curve
    render_graph(context, :scatter)
  when :scatter
    render_graph(context, nil, options: {data: {mode: "markers"}})
  else
    raise NotImplementedError
  end
end

#render(context, filename) ⇒ Object



38
39
40
# File 'lib/charty/backends/plotly.rb', line 38

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

#series=(series) ⇒ Object



34
35
36
# File 'lib/charty/backends/plotly.rb', line 34

def series=(series)
  @series = series
end