Class: Daytona::Charts::Chart

Inherits:
Object
  • Object
show all
Defined in:
lib/daytona/common/charts.rb

Direct Known Subclasses

Chart2D, CompositeChart, PieChart

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(data) ⇒ Chart

Returns a new instance of Chart.

Parameters:

  • data (Hash<Symbol, Object>)


34
35
36
37
38
39
# File 'lib/daytona/common/charts.rb', line 34

def initialize(data)
  @type = data.fetch(:type, nil)
  @title = data.fetch(:title, nil)
  @elements = data.fetch(:elements, [])
  @png = data.fetch(:png, nil)
end

Instance Attribute Details

#elementsArray<Object> (readonly)

Returns The elements of the chart.

Returns:

  • (Array<Object>)

    The elements of the chart



28
29
30
# File 'lib/daytona/common/charts.rb', line 28

def elements
  @elements
end

#pngString, Nil (readonly)

Returns The PNG representation of the chart encoded in base64.

Returns:

  • (String, Nil)

    The PNG representation of the chart encoded in base64



31
32
33
# File 'lib/daytona/common/charts.rb', line 31

def png
  @png
end

#titleString, Nil (readonly)

Returns The title of the chart.

Returns:

  • (String, Nil)

    The title of the chart



25
26
27
# File 'lib/daytona/common/charts.rb', line 25

def title
  @title
end

#typeString, Nil (readonly)

Returns The type of chart.

Returns:

  • (String, Nil)

    The type of chart



22
23
24
# File 'lib/daytona/common/charts.rb', line 22

def type
  @type
end

Instance Method Details

#to_hHash<Symbol, Object>

Returns original metadata.

Returns:

  • (Hash<Symbol, Object>)

    original metadata



42
# File 'lib/daytona/common/charts.rb', line 42

def to_h = { type:, title:, elements:, png: }