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_html(nonce: nil) ⇒ Object Also known as: to_s



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

def to_html(nonce: nil)
  Spec.new(spec).to_html(nonce: nonce)
end

#to_irubyObject



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

def to_iruby
  Spec.new(spec).to_iruby
end

#to_iruby_mimebundleObject



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

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

#to_jsonObject



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

def to_json
  spec.to_json
end