Class: Trackplot::Components::ReferenceLine

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

Instance Attribute Summary

Attributes inherited from Base

#options

Instance Method Summary collapse

Methods inherited from Base

#type

Constructor Details

#initialize(**options) ⇒ ReferenceLine

Returns a new instance of ReferenceLine.



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

def initialize(**options)
  super
end

Instance Method Details

#to_configObject



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

def to_config
  direction = options[:y] ? "y" : "x"
  value = options[:y] || options[:x]

  {
    type: "reference_line",
    direction: direction,
    value: value,
    label: options[:label],
    color: options[:color] || "#ef4444",
    dashed: options.fetch(:dashed, true),
    stroke_width: options[:stroke_width] || 1.5
  }.compact
end