Method: Charty::RenderContext#apply

Defined in:
lib/charty/plotter.rb

#apply(backend) ⇒ Object



247
248
249
250
251
252
253
254
255
256
257
258
259
260
# File 'lib/charty/plotter.rb', line 247

def apply(backend)
  case
  when !@series.empty?
    backend.series = @series
  when @function
    linspace = Linspace.new(@range[:x], 100)
    # TODO: set label with function
    # TODO: set ys to xs when gruff curve with function
    @series << Series.new(linspace.to_a, linspace.map{|x| @function.call(x) }, label: "function" )
  end

  @backend = backend
  self
end