Class Gruff::Area
In: lib/gruff/area.rb
Parent: Gruff::Base
StackedMixin StackedBar SideStackedBar StackedArea AccumulatorBar Base Scene Pie Area PhotoBar Bullet Spider SideBar Net Bar Line 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/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_11_0.png

Methods

draw  

Public Instance methods

[Source]

    # File lib/gruff/area.rb, line 6
 6:   def draw
 7:     super
 8: 
 9:     return unless @has_data
10: 
11:     @x_increment = @graph_width / (@column_count - 1).to_f
12:     @d = @d.stroke 'transparent'
13: 
14:     @norm_data.each do |data_row|
15:       poly_points = Array.new
16:       prev_x = prev_y = 0.0
17:       @d = @d.fill data_row[DATA_COLOR_INDEX]
18: 
19:       data_row[DATA_VALUES_INDEX].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)
23: 
24:         if prev_x > 0 and prev_y > 0 then
25:           poly_points << new_x
26:           poly_points << new_y
27:           
28:           #@d = @d.polyline(prev_x, prev_y, new_x, new_y)
29:         else
30:           poly_points << @graph_left
31:           poly_points << @graph_bottom - 1
32:           poly_points << new_x
33:           poly_points << new_y
34:           
35:           #@d = @d.polyline(@graph_left, @graph_bottom, new_x, new_y)
36:         end
37: 
38:         draw_label(new_x, index)
39: 
40:         prev_x = new_x
41:         prev_y = new_y
42:       end
43: 
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
49: 
50:       @d = @d.polyline(*poly_points)
51: 
52:     end
53: 
54:     @d.draw(@base_image)
55:   end

[Validate]