Class: Vega::BaseChart

Inherits:
Object
  • Object
show all
Extended by:
MethodHelpers
Defined in:
lib/vega/base_chart.rb

Direct Known Subclasses

Chart, LiteChart

Instance Method Summary collapse

Constructor Details

#initializeBaseChart

Returns a new instance of BaseChart.



5
6
7
8
9
10
11
12
13
# File 'lib/vega/base_chart.rb', line 5

def initialize
  @spec = {
    "$schema": @schema,
    width: "container",
    height: "container"
    # maybe add later
    # config: {mark: {tooltip: true}}
  }
end

Instance Method Details

#embed_options!(value) ⇒ Object



15
16
17
18
# File 'lib/vega/base_chart.rb', line 15

def embed_options!(value)
  usermeta!(embedOptions: value)
  self
end

#to_irubyObject



25
26
27
# File 'lib/vega/base_chart.rb', line 25

def to_iruby
  Spec.new(spec).to_iruby
end

#to_iruby_mimebundleObject



30
31
32
# File 'lib/vega/base_chart.rb', line 30

def to_iruby_mimebundle(**)
  [[to_iruby].to_h, {}]
end

#to_jsonObject



34
35
36
# File 'lib/vega/base_chart.rb', line 34

def to_json
  spec.to_json
end

#to_sObject



21
22
23
# File 'lib/vega/base_chart.rb', line 21

def to_s
  Spec.new(spec).to_s
end