Class: Daytona::Charts::PointChart
- Defined in:
- lib/daytona/common/charts.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#elements ⇒ Array<Daytona::Charts::PointData>
readonly
The points of the chart.
-
#x_scale ⇒ String, Nil
readonly
The scale of the x-axis.
-
#x_tick_labels ⇒ Array<String>
readonly
The labels of the x-axis.
-
#x_ticks ⇒ Array<Object>
readonly
The ticks of the x-axis.
-
#y_scale ⇒ String, Nil
readonly
The scale of the y-axis.
-
#y_tick_labels ⇒ Array<String>
readonly
The labels of the y-axis.
-
#y_ticks ⇒ Array<Object>
readonly
The ticks of the y-axis.
Attributes inherited from Chart2D
Attributes inherited from Chart
Instance Method Summary collapse
-
#initialize(data) ⇒ PointChart
constructor
A new instance of PointChart.
-
#to_h ⇒ Hash<Symbol, Object>
Original metadata.
Constructor Details
#initialize(data) ⇒ PointChart
Returns a new instance of PointChart.
103 104 105 106 107 108 109 110 111 112 113 114 |
# File 'lib/daytona/common/charts.rb', line 103 def initialize(data) super @x_scale = data.fetch(:x_scale, nil) @x_ticks = data.fetch(:x_ticks, nil) @x_tick_labels = data.fetch(:x_tick_labels, nil) @y_scale = data.fetch(:y_scale, nil) @y_ticks = data.fetch(:y_ticks, nil) @y_tick_labels = data.fetch(:y_tick_labels, nil) @elements = data.fetch(:elements, []).map { |e| PointData.new(e) } end |
Instance Attribute Details
#elements ⇒ Array<Daytona::Charts::PointData> (readonly)
Returns The points of the chart.
100 101 102 |
# File 'lib/daytona/common/charts.rb', line 100 def elements @elements end |
#x_scale ⇒ String, Nil (readonly)
Returns The scale of the x-axis.
88 89 90 |
# File 'lib/daytona/common/charts.rb', line 88 def x_scale @x_scale end |
#x_tick_labels ⇒ Array<String> (readonly)
Returns The labels of the x-axis.
85 86 87 |
# File 'lib/daytona/common/charts.rb', line 85 def x_tick_labels @x_tick_labels end |
#x_ticks ⇒ Array<Object> (readonly)
Returns The ticks of the x-axis.
82 83 84 |
# File 'lib/daytona/common/charts.rb', line 82 def x_ticks @x_ticks end |
#y_scale ⇒ String, Nil (readonly)
Returns The scale of the y-axis.
97 98 99 |
# File 'lib/daytona/common/charts.rb', line 97 def y_scale @y_scale end |
#y_tick_labels ⇒ Array<String> (readonly)
Returns The labels of the y-axis.
94 95 96 |
# File 'lib/daytona/common/charts.rb', line 94 def y_tick_labels @y_tick_labels end |
#y_ticks ⇒ Array<Object> (readonly)
Returns The ticks of the y-axis.
91 92 93 |
# File 'lib/daytona/common/charts.rb', line 91 def y_ticks @y_ticks end |
Instance Method Details
#to_h ⇒ Hash<Symbol, Object>
Returns original metadata.
117 118 119 120 121 122 123 124 125 126 127 |
# File 'lib/daytona/common/charts.rb', line 117 def to_h super.merge( x_scale:, x_ticks:, x_tick_labels:, y_scale:, y_ticks:, y_tick_labels:, elements: elements.map(&:to_h) ) end |