Class: Daytona::Charts::PieChart

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

Instance Attribute Summary collapse

Attributes inherited from Chart

#png, #title, #type

Instance Method Summary collapse

Constructor Details

#initialize(data) ⇒ PieChart

Returns a new instance of PieChart.

Parameters:

  • data (Hash<Symbol, Object>)


210
211
212
213
214
# File 'lib/daytona/common/charts.rb', line 210

def initialize(data)
  super
  @type = ChartType::PIE
  @elements = data.fetch(:elements, []).map { |e| PieData.new(e) }
end

Instance Attribute Details

#elementsArray<Daytona::Charts::PieData> (readonly)

Returns The pie slices of the chart.

Returns:



207
208
209
# File 'lib/daytona/common/charts.rb', line 207

def elements
  @elements
end

Instance Method Details

#to_hHash<Symbol, Object>

Returns:

  • (Hash<Symbol, Object>)


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

def to_h = super.merge(elements: elements.map(&:to_h))