lib/gruff/ldata_mixin.rb
# Draw the lines, done after the base bars are done
Draw the lines, done after the base bars are done
Draw the lines done after the base bars are done
def draw_ldata
    @norm_ldata.each_with_index do |ldata_row, row_index|
      prev_x = prev_y = nil
      values = ldata_row[Gruff::Base::DATA_VALUES_INDEX]
      attrs = ldata_row[Gruff::Base::DATA_ATTRS_INDEX]
      group = attrs[:group]
      if @ldata_offset_and_increment[group].nil?
	puts "Invalid group #{group} given on line data. Resetting to group 0"
	group = 0
      end
      offset, increment = @ldata_offset_and_increment[group]
      values.each_with_index do |data_point, point_index|
        next unless data_point
	line_y = @graph_top + 
	  (@graph_height - data_point * @graph_height)
	line_x = offset + increment * (point_index)
	if prev_x
	  draw_ldata_line(attrs, prev_x, prev_y,
			  line_x, line_y, line_x, line_y) 
	else
	  draw_ldata_line(attrs, line_x, line_y,
			  line_x, line_y, line_x, line_y) 
	end
	prev_x = line_x
	prev_y = line_y
      end
    end
    @d.draw(@base_image)
  end
def draw_ldata @norm_ldata . each_with_index do | ldata_row , row_index | prev_x = prev_y = nil values = ldata_row [ Gruff :: Base :: DATA_VALUES_INDEX ] attrs = ldata_row [ Gruff :: Base :: DATA_ATTRS_INDEX ] group = attrs [ :group ] if @ldata_offset_and_increment [ group ] . nil? puts "Invalid group #{group} given on line data. Resetting to group 0" group = 0 end offset , increment = @ldata_offset_and_increment [ group ] values . each_with_index do | data_point , point_index | next unless data_point line_y = @graph_top + ( @graph_height - data_point * @graph_height ) line_x = offset + increment * ( point_index ) if prev_x draw_ldata_line ( attrs , prev_x , prev_y , line_x , line_y , line_x , line_y ) else draw_ldata_line ( attrs , line_x , line_y , line_x , line_y , line_x , line_y ) end prev_x = line_x prev_y = line_y end end @d . draw ( @base_image ) end
Draw the lines, done after the base bars are done
Draw the lines done after the base bars are done