Class: Trackplot::Components::Bar

Inherits:
Base
  • Object
show all
Defined in:
lib/trackplot/components/bar.rb

Instance Attribute Summary collapse

Attributes inherited from Base

#options

Instance Method Summary collapse

Methods inherited from Base

#type

Constructor Details

#initialize(data_key, **options) ⇒ Bar



6
7
8
9
# File 'lib/trackplot/components/bar.rb', line 6

def initialize(data_key, **options)
  @data_key = data_key
  super(**options)
end

Instance Attribute Details

#data_keyObject (readonly)

Returns the value of attribute data_key.



4
5
6
# File 'lib/trackplot/components/bar.rb', line 4

def data_key
  @data_key
end

Instance Method Details

#to_configObject



11
12
13
14
15
16
17
18
19
20
21
# File 'lib/trackplot/components/bar.rb', line 11

def to_config
  {
    type: "bar",
    data_key: data_key,
    color: options[:color],
    opacity: options[:opacity],
    radius: options[:radius] || 4,
    stack: options[:stack],
    y_axis: options[:y_axis]&.to_s
  }.compact
end