class Charty::RenderContext
Attributes
data[R]
function[R]
labels[R]
method[R]
range[R]
series[R]
title[R]
xlabel[R]
ylabel[R]
Public Class Methods
new(method, **args, &block)
click to toggle source
# File lib/charty/plotter.rb, line 168 def initialize(method, **args, &block) @method = method configurator = Configurator.new(**args) configurator.instance_eval(&block) # TODO: label も外から付けられた方がよさそう (@range, @series, @function, @data, @title, @xlabel, @ylabel, @labels) = configurator.to_a end
Public Instance Methods
apply(backend)
click to toggle source
# 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
range_x()
click to toggle source
# File lib/charty/plotter.rb, line 231 def range_x @range[:x] end
range_y()
click to toggle source
# File lib/charty/plotter.rb, line 235 def range_y @range[:y] end
render(filename=nil)
click to toggle source
# File lib/charty/plotter.rb, line 239 def render(filename=nil) @backend.old_style_render(self, filename) end
save(filename=nil, **kw)
click to toggle source
# File lib/charty/plotter.rb, line 243 def save(filename=nil, **kw) @backend.old_style_save(self, filename, **kw) end