Class: Daytona::Charts::PointChart

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

Direct Known Subclasses

LineChart, ScatterChart

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) ⇒ PointChart

Returns a new instance of PointChart.

Parameters:

  • data (Hash<Symbol, Object>)


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

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

Returns The points of the chart.

Returns:



100
101
102
# File 'lib/daytona/common/charts.rb', line 100

def elements
  @elements
end

#x_scaleString, Nil (readonly)

Returns The scale of the x-axis.

Returns:

  • (String, Nil)

    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_labelsArray<String> (readonly)

Returns The labels of the x-axis.

Returns:

  • (Array<String>)

    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_ticksArray<Object> (readonly)

Returns The ticks of the x-axis.

Returns:

  • (Array<Object>)

    The ticks of the x-axis



82
83
84
# File 'lib/daytona/common/charts.rb', line 82

def x_ticks
  @x_ticks
end

#y_scaleString, Nil (readonly)

Returns The scale of the y-axis.

Returns:

  • (String, Nil)

    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_labelsArray<String> (readonly)

Returns The labels of the y-axis.

Returns:

  • (Array<String>)

    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_ticksArray<Object> (readonly)

Returns The ticks of the y-axis.

Returns:

  • (Array<Object>)

    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_hHash<Symbol, Object>

Returns original metadata.

Returns:

  • (Hash<Symbol, Object>)

    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