Sha256: 299a90b02b30777cfc9dc1cedb541ef598dcb8e5fb31890b1a750863a8380665

Contents?: true

Size: 1.32 KB

Versions: 25

Compression:

Stored size: 1.32 KB

Contents

##
# 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
#
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 getLeftYRightYscaled( data_point, result )
		case @mode
		when 1 then # Case one
			# minimum value >= 0 ( only positiv values )
      result[0] = @graph_top + @graph_height*(1 - data_point) + 1
  		result[1] = @graph_top + @graph_height - 1
		when 2 then  # Case two
			# only negativ values
   		result[0] = @graph_top + 1
  		result[1] = @graph_top + @graph_height*(1 - data_point) - 1
		when 3 then # Case three
			# positiv and negativ values
    	val = data_point-@minimum_value/@spread
    	if ( data_point >= @zero ) then
    		result[0] = @graph_top + @graph_height*(1 - (val-@zero)) + 1
	    	result[1] = @graph_top + @graph_height*(1 - @zero) - 1
    	else
				result[0] = @graph_top + @graph_height*(1 - (val-@zero)) + 1
	    	result[1] = @graph_top + @graph_height*(1 - @zero) - 1
    	end
		else
			result[0] = 0.0
			result[1] = 0.0
		end				
	end	

end

Version data entries

25 entries across 25 versions & 10 rubygems

Version Path
jslade-gruff-0.3.5 lib/gruff/bar_conversion.rb
schapht-gruff-0.3.5 lib/gruff/bar_conversion.rb
topfunky-gruff-0.3.2 lib/gruff/bar_conversion.rb
topfunky-gruff-0.3.3 lib/gruff/bar_conversion.rb
topfunky-gruff-0.3.5 lib/gruff/bar_conversion.rb
umang-gruff-0.3.6 lib/gruff/bar_conversion.rb
woodhull-gruff-0.3.5 lib/gruff/bar_conversion.rb
gruff-0.3.7 lib/gruff/bar_conversion.rb
fhs-gruff-0.3.6.2 lib/gruff/bar_conversion.rb
pfsc_gruff-0.3.6 lib/gruff/bar_conversion.rb
pfsc-gruff-0.3.6 lib/gruff/bar_conversion.rb
teejayvanslyke-gruff-0.4.1 lib/gruff/bar_conversion.rb
teejayvanslyke-gruff-0.4.0 lib/gruff/bar_conversion.rb
teejayvanslyke-gruff-0.3.8 lib/gruff/bar_conversion.rb
teejayvanslyke-gruff-0.3.6 lib/gruff/bar_conversion.rb
gruff-0.3.6 lib/gruff/bar_conversion.rb
gruff-0.2.8 lib/gruff/bar_conversion.rb
gruff-0.2.5 lib/gruff/bar_conversion.rb
gruff-0.2.7 lib/gruff/bar_conversion.rb
gruff-0.2.6 lib/gruff/bar_conversion.rb