class Gruff::Store::XYData
@private
Attributes
Public Class Methods
Source
# File lib/gruff/store/xy_data.rb, line 18 def initialize(label, x_points, y_points, color) y_points = Array(y_points) x_points = x_points ? Array(x_points) : Array.new(y_points.length) raise ArgumentError, 'x_points.length != y_points.length!' if x_points.length != y_points.length @label = label.to_s @x_points = x_points @y_points = y_points @color = color end
@rbs label: String
| Symbol @rbs x_points
: Array[nil | Float | Integer] | nil @rbs y_points
: Array[nil | Float | Integer] | nil @rbs color: String
Public Instance Methods
Source
# File lib/gruff/store/xy_data.rb, line 46 def columns y_points.length end
@rbs return: Integer
Source
# File lib/gruff/store/xy_data.rb, line 36 def coordinate_and_pointsizes raise NotImplementedError, 'This method is not implemented for XYData' end
Source
# File lib/gruff/store/xy_data.rb, line 32 def coordinates x_points.zip(y_points) end
@rbs return: Array[[Float | Integer | nil, Float | Integer | nil]]
Source
# File lib/gruff/store/xy_data.rb, line 41 def empty? y_points.empty? end
@rbs return: bool
Source
# File lib/gruff/store/xy_data.rb, line 57 def max y_points.compact.max end
@rbs return: Float | Integer
Also aliased as: max_y
Source
# File lib/gruff/store/xy_data.rb, line 68 def max_x x_points.compact.max end
@rbs return: Float | Integer
Source
# File lib/gruff/store/xy_data.rb, line 51 def min y_points.compact.min end
@rbs return: Float | Integer
Also aliased as: min_y
Source
# File lib/gruff/store/xy_data.rb, line 63 def min_x x_points.compact.min end
@rbs return: Float | Integer
Source
# File lib/gruff/store/xy_data.rb, line 77 def normalize(minimum_x:, minimum_y:, spread_x:, spread_y:) norm_x_points = x_points.map do |x| x.nil? ? nil : (x.to_f - minimum_x.to_f) / spread_x end norm_y_points = y_points.map do |y| y.nil? ? nil : (y.to_f - minimum_y.to_f) / spread_y end self.class.new(label, norm_x_points, norm_y_points, color) end
@rbs minimum_x: Float | Integer @rbs minimum_y: Float | Integer @rbs spread_x: Float | Integer @rbs spread_y: Float | Integer @rbs return: Gruff::Store::XYData