Bugs: Browse | Submit New | Admin

[#5496] Gruff errors when presenting one data point to Gruff::Line

Date:
2006-08-23 12:39
Priority:
3
Submitted By:
Nobody
Assigned To:
Nobody (None)
Category:
None
State:
Open
Summary:
Gruff errors when presenting one data point to Gruff::Line

Detailed description
I am drawing line graphs out of a database and came across this error when only one data point was presented to
Gruff::Line

Non-conforming drawing primitive definition `circle': 

vendor/plugins/gruff/lib/gruff/line.rb:82:in `draw'
vendor/plugins/gruff/lib/gruff/line.rb:82:in `draw'
vendor/plugins/gruff/lib/gruff/base.rb:323:in `to_blob'

If I have some more time later today, I'll submit a patch.

Thanks for some cool software.

Regards
  Andre

Add A Comment: Notepad

Please login


Followup

Message
Date: 2006-08-23 13:31
Sender: Andre Sachs

Ignore the prevoius follow up.

--- vendor/plugins/gruff/lib/gruff/line.rb      17 Aug 2006 11:46:20
-0000      1.1
+++ vendor/plugins/gruff/lib/gruff/line.rb      23 Aug 2006 13:23:17
-0000
@@ -37,8 +37,8 @@
     super
 
     return unless @has_data
-      
-    @x_increment = @graph_width / (@column_count - 1).to_f
+    @x_increment = 0
+    @x_increment = @graph_width / (@column_count - 1).to_f if
@column_count > 1
     circle_radius = clip_value_if_greater_than(@columns
/ (@norm_data.first[1].size * 2.5), 5.0)
 
     @d = @d.stroke_opacity 1.0
Date: 2006-08-23 13:00
Sender: Andre Sachs

Divide by zero causes @x_increment to become Infinity.

--- vendor/plugins/gruff/lib/gruff/line.rb      17 Aug 2006 11:46:20
-0000      1.1
+++ vendor/plugins/gruff/lib/gruff/line.rb      23 Aug 2006 12:52:13
-0000
@@ -37,8 +37,8 @@
     super
 
     return unless @has_data
-      
-    @x_increment = @graph_width / (@column_count - 1).to_f
+    @x_increment = 0
+    @x_increment ||= @graph_width / (@column_count - 1).to_f
     circle_radius = clip_value_if_greater_than(@columns
/ (@norm_data.first[1].size * 2.5), 5.0)
 
     @d = @d.stroke_opacity 1.0

Attached Files:

Name Description Download
No Files Currently Attached

Changes:

No Changes Have Been Made to This Item