2 require File.dirname(__FILE__) + '/base'
4 class Gruff::Area < Gruff::Base
9 return unless @has_data
11 @x_increment = @graph_width / (@column_count - 1).to_f
12 @d = @d.stroke 'transparent'
14 @norm_data.each do |data_row|
15 poly_points = Array.new
17 @d = @d.fill data_row[DATA_COLOR_INDEX]
19 data_row[1].each_with_index do |data_point, index|
20 # Use incremented x and scaled y
21 new_x = @graph_left + (@x_increment * index)
22 new_y = @graph_top + (@graph_height - data_point * @graph_height)
24 if prev_x > 0 and prev_y > 0 then
28 #@d = @d.polyline(prev_x, prev_y, new_x, new_y)
30 poly_points << @graph_left
31 poly_points << @graph_bottom - 1
35 #@d = @d.polyline(@graph_left, @graph_bottom, new_x, new_y)
38 draw_label(new_x, index)
44 # Add closing points, draw polygon
45 poly_points << @graph_right
46 poly_points << @graph_bottom - 1
47 poly_points << @graph_left
48 poly_points << @graph_bottom - 1
50 @d = @d.polyline(*poly_points)