Class: Daytona::Charts::BarChart

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

Instance Attribute Summary collapse

Attributes inherited from Chart2D

#x_label, #y_label

Attributes inherited from Chart

#png, #title, #type

Instance Method Summary collapse

Constructor Details

#initialize(data) ⇒ BarChart

Returns a new instance of BarChart.

Parameters:

  • data (Hash<Symbol, Object>)


170
171
172
173
174
# File 'lib/daytona/common/charts.rb', line 170

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

Instance Attribute Details

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

Returns The bars of the chart.

Returns:



167
168
169
# File 'lib/daytona/common/charts.rb', line 167

def elements
  @elements
end

Instance Method Details

#to_hHash<Symbol, Object>

Returns:

  • (Hash<Symbol, Object>)


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

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