Sha256: d77dd3162a948019a8e61b03f9cdfd375986575ce73d2d33ab28a947ea26b2f3
Contents?: true
Size: 1.21 KB
Versions: 2
Compression:
Stored size: 1.21 KB
Contents
# frozen_string_literal: true ## # Original Author: David Stokar # # This class perfoms the y coordinats conversion for the bar class. # # There are three cases: # # 1. Bars all go from zero in positive direction # 2. Bars all go from zero to negative direction # 3. Bars either go from zero to positive or from zero to negative # # @private class Gruff::BarConversion attr_writer :mode attr_writer :zero attr_writer :graph_top attr_writer :graph_height attr_writer :minimum_value attr_writer :spread def get_left_y_right_y_scaled(data_point) result = [] case @mode when 1 # minimum value >= 0 ( only positive values ) result[0] = @graph_top + @graph_height * (1 - data_point) + 1 result[1] = @graph_top + @graph_height - 1 when 2 # only negative values result[0] = @graph_top + 1 result[1] = @graph_top + @graph_height * (1 - data_point) - 1 when 3 # positive and negative values val = data_point - @minimum_value / @spread result[0] = @graph_top + @graph_height * (1 - (val - @zero)) + 1 result[1] = @graph_top + @graph_height * (1 - @zero) - 1 else result[0] = 0.0 result[1] = 0.0 end result end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
gruff-0.11.0 | lib/gruff/helper/bar_conversion.rb |
gruff-0.11.0-java | lib/gruff/helper/bar_conversion.rb |