Class: Trackplot::SparklineBuilder

Inherits:
Object
  • Object
show all
Defined in:
lib/trackplot/sparkline_builder.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(data, **options) ⇒ SparklineBuilder



8
9
10
11
# File 'lib/trackplot/sparkline_builder.rb', line 8

def initialize(data, **options)
  @data = DataAdapter.normalize(data)
  @options = options
end

Instance Attribute Details

#dataObject (readonly)

Returns the value of attribute data.



6
7
8
# File 'lib/trackplot/sparkline_builder.rb', line 6

def data
  @data
end

#optionsObject (readonly)

Returns the value of attribute options.



6
7
8
# File 'lib/trackplot/sparkline_builder.rb', line 6

def options
  @options
end

Instance Method Details

#render(view_context) ⇒ Object



13
14
15
16
17
18
19
20
21
22
# File 'lib/trackplot/sparkline_builder.rb', line 13

def render(view_context)
  config = build_config

  view_context.(
    "trackplot-sparkline",
    nil,
    config: config.to_json,
    style: sparkline_style
  )
end