2 # Original Author: David Stokar
4 # This class perfoms the y coordinats conversion for the bar class.
6 # There are three cases:
8 # 1. Bars all go from zero in positive direction
9 # 2. Bars all go from zero to negative direction
10 # 3. Bars either go from zero to positive or from zero to negative
12 class Gruff::BarConversion
15 attr_writer :graph_top
16 attr_writer :graph_height
17 attr_writer :minimum_value
20 def getLeftYRightYscaled( data_point, result )
22 when 1 then # Case one
23 # minimum value >= 0 ( only positiv values )
24 result[0] = @graph_top + @graph_height*(1 - data_point) + 1
25 result[1] = @graph_top + @graph_height - 1
26 when 2 then # Case two
28 result[0] = @graph_top + 1
29 result[1] = @graph_top + @graph_height*(1 - data_point) - 1
30 when 3 then # Case three
31 # positiv and negativ values
32 val = data_point-@minimum_value/@spread
33 if ( data_point >= @zero ) then
34 result[0] = @graph_top + @graph_height*(1 - (val-@zero)) + 1
35 result[1] = @graph_top + @graph_height*(1 - @zero) - 1
37 result[0] = @graph_top + @graph_height*(1 - (val-@zero)) + 1
38 result[1] = @graph_top + @graph_height*(1 - @zero) - 1