public
Description: The ruby on rails plugin for teethgrinder's Open Flash Chart (version 2)
Homepage: http://pullmonkey.com/projects/open_flash_chart2/
Clone URL: git://github.com/pullmonkey/open_flash_chart.git
fixing stack overflow bug
dfl (author)
Mon Oct 27 10:17:04 -0700 2008
commit  95983957d727486ee4d7463972202287cf31c730
tree    ca9bacb89a032841d2500907892e889bb202671a
parent  ca9a94e76c063b9ee2d4ecfd56840312eddf3645
...
22
23
24
25
 
 
26
27
28
29
30
31
 
 
 
 
 
32
33
34
...
77
78
79
 
80
81
82
 
 
83
84
85
86
 
 
87
88
 
89
90
91
92
93
 
94
95
96
...
22
23
24
 
25
26
27
28
29
30
31
 
32
33
34
35
36
37
38
39
...
82
83
84
85
86
 
 
87
88
89
90
 
 
91
92
93
 
94
95
96
97
98
99
100
101
102
103
0
@@ -22,13 +22,18 @@ module OpenFlashChart
0
       # 7) grid_colour as grid-colour
0
       # 8) threed as 3d
0
       # 9) tick_length as tick-length
0
-      returning self.to_json.gsub("threed","3d") do |output|
0
+      returning self.to_json do |output|
0
+        output.gsub!("threed","3d")
0
         %w(font_size dot_size outline_colour halo_size start_angle tick_height grid_colour tick_length no_labels label_colour gradient_fill fill_alpha on_click spoke_labels).each do |replace|
0
           output.gsub!(replace, replace.gsub("_", "-"))
0
         end
0
       end
0
     end
0
-    # for those still using to_s and that do not get a stack overflow
0
+
0
+    def to_json
0
+      self.instance_values.to_json
0
+    end    
0
+
0
     alias_method :to_s, :render
0
 
0
     def add_element(element)
0
@@ -77,19 +82,21 @@ module OpenFlashChart
0
     alias_method "tooltip=", :set_tooltip
0
 
0
 
0
+
0
     def method_missing(method_name, *args, &blk)
0
-      method_name = method_name.to_s
0
-      if method_name =~ /(.*)=/   # i.e., if it is something x_legend=
0
+      case method_name.to_s
0
+      when /(.*)=/   # i.e., if it is something x_legend=
0
         # if the user wants to set an instance variable then let them
0
         # the other args (args[0]) are ignored since it is a set method
0
-        return self.instance_variable_set("@#{$1}", args[0])
0
-      elsif method_name =~/^set_(.*)/
0
+        self.instance_variable_set("@#{$1}", args[0])
0
+      when /^set_(.*)/
0
         # backwards compatible ... the user can still use the same set_y_legend methods if they want
0
-        return self.instance_variable_set("@#{$1}", args[0])
0
+        self.instance_variable_set("@#{$1}", args[0])
0
       else
0
         # if the method/attribute is missing and it is not a set method then hmmmm better let the user know
0
         super
0
       end
0
     end
0
+
0
   end
0
 end
0
\ No newline at end of file
...
7
8
9
10
 
11
12
13
...
7
8
9
 
10
11
12
13
0
@@ -7,7 +7,7 @@ class TestItController < ApplicationController
0
         @graph = open_flash_chart_object( 600, 300, url_for( :action => 'index', :format => :json ) )
0
       }
0
       wants.json { 
0
-        chart = OpenFlashChart::Base.new( :title => Title.new("MY TITLE") ) do |c|
0
+        chart = OpenFlashChart::Chart.new( "MY TITLE" ) do |c|
0
           c << BarGlass.new( :values => (1..10).sort_by{rand} )
0
         end
0
         render :text => chart, :layout => false

Comments