Module: Plot

Defined in:
lib/plot.rb

Defined Under Namespace

Classes: Mark, MarkProxy, Plot, PlotDefinition, PlotProxy

Class Method Summary collapse

Class Method Details

._contextObject



16
17
18
# File 'lib/plot.rb', line 16

def self._context
    @context
end

.call(method, *args) ⇒ Object



33
34
35
36
# File 'lib/plot.rb', line 33

def self.call(method, *args)
    puts *args
    @context.call("Plot['#{method}']", *args)
end

.define(&block) ⇒ Object



25
26
27
28
29
30
# File 'lib/plot.rb', line 25

def self.define(&block)
    definition = PlotDefinition.new(nil)
    plot_proxy = PlotProxy.new(definition)
    plot_proxy.instance_eval(&block)
    return definition
end

.encode_source(source) ⇒ Object



20
21
22
# File 'lib/plot.rb', line 20

def self.encode_source(source)
    @runtime.send(:encode_source,source)
end

.plot(marks, data, options) ⇒ Object



38
39
40
41
# File 'lib/plot.rb', line 38

def self.plot(marks, data, options)
    rendered_marks = marks.keys.map { |m| marks[m.to_s].render(data[m.to_sym]) }
    @context.call("function(marks, options) { const rendered_marks = marks.map((m) => eval(m)); return Plot.plot({ marks: rendered_marks, ...options }).outerHTML.toString() }", rendered_marks, options)
end