Class Gruff::BarConversion
In: lib/gruff/bar_conversion.rb
Parent: Object
StackedMixin StackedBar SideStackedBar StackedArea AccumulatorBar Base Scene Pie Area PhotoBar Bullet Spider SideBar Net Bar Line Dot Pie Observable Group SideBar StandardError IncorrectNumberOfDatasetsException Magick Bar Layer BarConversion lib/gruff/stacked_area.rb lib/gruff/scene.rb lib/gruff/spider.rb lib/gruff/pie.rb lib/gruff/bullet.rb lib/gruff/area.rb lib/gruff/net.rb lib/gruff/bar_conversion.rb lib/gruff/bar.rb lib/gruff/side_bar.rb lib/gruff/line.rb lib/gruff/stacked_bar.rb lib/gruff/dot.rb lib/gruff/side_stacked_bar.rb lib/gruff/photo_bar.rb lib/gruff/base.rb lib/gruff/accumulator_bar.rb lib/gruff/mini/bar.rb lib/gruff/mini/side_bar.rb lib/gruff/mini/pie.rb Legend Mini Deprecated Gruff dot/m_12_0.png

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

Methods

Attributes

graph_height  [W] 
graph_top  [W] 
minimum_value  [W] 
mode  [W] 
spread  [W] 
zero  [W] 

Public Instance methods

[Source]

    # File lib/gruff/bar_conversion.rb, line 20
20:         def getLeftYRightYscaled( data_point, result )
21:                 case @mode
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
27:                         # only negativ values
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
36:         else
37:                                 result[0] = @graph_top + @graph_height*(1 - (val-@zero)) + 1
38:                result[1] = @graph_top + @graph_height*(1 - @zero) - 1
39:         end
40:                 else
41:                         result[0] = 0.0
42:                         result[1] = 0.0
43:                 end                           
44:         end

[Validate]