class Gruff::Box::BoxData
@private
Attributes
Public Class Methods
Source
# File lib/gruff/box.rb, line 116 def initialize(label, points, color) @label = label @points = points.compact.sort @color = color end
Public Instance Methods
Source
# File lib/gruff/box.rb, line 166 def first_quartile if points.empty? 0.0 elsif points.size.odd? points[points.size / 4].to_f else (points[points.size / 4].to_f + points[(points.size / 4) - 1].to_f) / 2.0 end end
@rbs return: Float
Source
# File lib/gruff/box.rb, line 200 def interquartile_range third_quartile - first_quartile end
@rbs return: Float | Integer
Source
# File lib/gruff/box.rb, line 188 def lower_outliers min = lower_whisker points.select { |point| point < min } end
@rbs return: Array[Float | Integer]
Source
# File lib/gruff/box.rb, line 149 def lower_whisker min = min_whisker points.select { |point| point >= min }.min end
@rbs return: Float | Integer
Source
# File lib/gruff/box.rb, line 128 def max points.last || 0.0 end
@rbs return: Float | Integer
Source
# File lib/gruff/box.rb, line 138 def max_whisker [max, third_quartile + (1.5 * interquartile_range)].min end
@rbs return: Float | Integer
Source
# File lib/gruff/box.rb, line 155 def median if points.empty? 0.0 elsif points.size.odd? points[points.size / 2].to_f else (points[points.size / 2].to_f + points[(points.size / 2) - 1].to_f) / 2.0 end end
@rbs return: Float
Source
# File lib/gruff/box.rb, line 123 def min points.first || 0.0 end
@rbs return: Float | Integer
Source
# File lib/gruff/box.rb, line 133 def min_whisker [min, first_quartile - (1.5 * interquartile_range)].max end
@rbs return: Float | Integer
Source
# File lib/gruff/box.rb, line 177 def third_quartile if points.empty? 0.0 elsif points.size.odd? points[(points.size * 3) / 4].to_f else (points[(points.size * 3) / 4].to_f + points[((points.size * 3) / 4) - 1].to_f) / 2.0 end end
@rbs return: Float
Source
# File lib/gruff/box.rb, line 194 def upper_outliers max = upper_whisker points.select { |point| point > max } end
@rbs return: Array[Float | Integer]
Source
# File lib/gruff/box.rb, line 143 def upper_whisker max = max_whisker points.select { |point| point <= max }.max end
@rbs return: Float | Integer