nay-html5jp_graphs 0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (51) hide show
  1. data/README.rdoc +59 -0
  2. data/Rakefile +22 -0
  3. data/html5jp/.DS_Store +0 -0
  4. data/html5jp/AUTHORS +7 -0
  5. data/html5jp/COPYING +202 -0
  6. data/html5jp/examples/sample_graph_circle_1.html +54 -0
  7. data/html5jp/examples/sample_graph_circle_2.html +61 -0
  8. data/html5jp/examples/sample_graph_line_1.html +44 -0
  9. data/html5jp/examples/sample_graph_line_2.html +53 -0
  10. data/html5jp/examples/sample_graph_radar_1.html +47 -0
  11. data/html5jp/examples/sample_graph_radar_2.html +52 -0
  12. data/html5jp/examples/sample_graph_vbar_1.html +51 -0
  13. data/html5jp/examples/sample_graph_vbar_2.html +52 -0
  14. data/html5jp/examples/sample_graph_vbar_3.html +52 -0
  15. data/html5jp/examples/sample_graph_vbar_4.html +52 -0
  16. data/html5jp/html5jp/.DS_Store +0 -0
  17. data/html5jp/html5jp/excanvas/.DS_Store +0 -0
  18. data/html5jp/html5jp/excanvas/AUTHORS +10 -0
  19. data/html5jp/html5jp/excanvas/COPYING +202 -0
  20. data/html5jp/html5jp/excanvas/README +22 -0
  21. data/html5jp/html5jp/excanvas/examples/example1.html +93 -0
  22. data/html5jp/html5jp/excanvas/examples/example2.html +513 -0
  23. data/html5jp/html5jp/excanvas/examples/example3.html +284 -0
  24. data/html5jp/html5jp/excanvas/examples/ff.jpg +0 -0
  25. data/html5jp/html5jp/excanvas/excanvas-compressed.js +19 -0
  26. data/html5jp/html5jp/excanvas/excanvas.js +785 -0
  27. data/html5jp/html5jp/excanvas/testcases/arc.html +49 -0
  28. data/html5jp/html5jp/excanvas/testcases/linewidth.html +47 -0
  29. data/html5jp/html5jp/excanvas/testcases/overflow.html +37 -0
  30. data/html5jp/html5jp/excanvas/testcases/quadraticcurve.html +74 -0
  31. data/html5jp/html5jp/excanvas/testcases/resizing.html +65 -0
  32. data/html5jp/html5jp/graph/circle.js +407 -0
  33. data/html5jp/html5jp/graph/line.js +577 -0
  34. data/html5jp/html5jp/graph/radar.js +545 -0
  35. data/html5jp/html5jp/graph/vbar.js +1156 -0
  36. data/init.rb +1 -0
  37. data/install.rb +10 -0
  38. data/lib/html5jp_graphs_helper.rb +255 -0
  39. data/rdoc/classes/Html5jpGraphsHelper.html +326 -0
  40. data/rdoc/created.rid +1 -0
  41. data/rdoc/files/README.html +121 -0
  42. data/rdoc/files/lib/html5jp_graphs_helper_rb.html +107 -0
  43. data/rdoc/fr_class_index.html +27 -0
  44. data/rdoc/fr_file_index.html +28 -0
  45. data/rdoc/fr_method_index.html +28 -0
  46. data/rdoc/index.html +24 -0
  47. data/rdoc/rdoc-style.css +208 -0
  48. data/tasks/html5jp_graphs_tasks.rake +4 -0
  49. data/test/html5jp_graphs_test.rb +8 -0
  50. data/uninstall.rb +1 -0
  51. metadata +103 -0
data/init.rb ADDED
@@ -0,0 +1 @@
1
+ require File.join(RAILS_ROOT, 'vendor', 'plugins', 'html5jp_graphs', 'install.rb')
data/install.rb ADDED
@@ -0,0 +1,10 @@
1
+ # Copy html5jp JavaScript codes to public/javascripts.
2
+
3
+ Dir.chdir(File.join(RAILS_ROOT, 'vendor', 'plugins', 'html5jp_graphs')) do
4
+ dest_dir = File.join(RAILS_ROOT, 'public', 'javascripts')
5
+ FileUtils.mkdirs(dest_dir) unless File.exist?(dest_dir)
6
+
7
+ Dir.glob("html5jp/html5jp/**/*.js").each do |path|
8
+ FileUtils.cp(path, dest_dir) unless File.exist?(File.join(dest_dir, File.basename(path)))
9
+ end
10
+ end
@@ -0,0 +1,255 @@
1
+ # Html5jpGraphsHelper
2
+ module Html5jpGraphsHelper
3
+
4
+ # Draw a vertical bar chart using Html5jp vertical bar chart (http://www.html5.jp/library/graph_vbar.html).
5
+ #
6
+ # ex.
7
+ # <%= vertical_bar_chart [['accesses', 520, 340, 804, 602], ['clicks', 101, 76, 239, 321]] %>
8
+ #
9
+ # The first argument 'resource' can be one of the following forms.
10
+ # * ['accesses', 520, 340, 804, 602]
11
+ # * [['accesses', 520, 340, 804, 602], ['clicks', 101, 76, 239, 321]]
12
+ # * Any other object which has required methods as follows;
13
+ # * each - to supply record objects.
14
+ # * items - If :x option does not exist and your resource object has items method, it is called to get :x. You can change the method name by :items_method option.
15
+ # * scales - If :y option does not exist and your resource object has scales method, it is called to get :y. You can change the method name by :scales_method option
16
+ # * max_scale - Would be used as :yMax option if it exists.
17
+ # * The record object shoud have methods as follows.
18
+ # * label - Like 'accesses' in the example. You can use other method if you specify :label_method option.
19
+ # * values - Like [520, 340, 804, 602] in the example. You can use other method if you specify :values_method option.
20
+ # * color - If :barColors option does not exist and your record object has color method, it is used for :barColors. You can change the method name by :color_method option.
21
+ # Additionaly, the following options are available.
22
+ # * :canvas_id - element id of the canvas. Default is 'line_chart'. Note that all rader charts in one page sould have unique canvas_ids.
23
+ # * :width - The width of the canvas. Default is 400.
24
+ # * :height - The height of the canvas. Default is 300.
25
+ # * All options in http://www.html5.jp/library/graph_vbar.html. ex. 'backgroundColor' or :backgroundColor.
26
+ # And you can use html_options for the top level div.
27
+ def vertical_bar_chart(resource, options = {}, html_options = {})
28
+ options = {:width => 400, :height => 300, :canvas_id => 'vertical_bar_chart'}.merge(options.symbolize_keys)
29
+ output = canvas(options, html_options)
30
+ output << "\n"
31
+ output << vertical_bar_chart_js(resource, options)
32
+ end
33
+
34
+
35
+ # Draw a radar chart using Html5jp radar chart (http://www.html5.jp/library/graph_radar.html).
36
+ #
37
+ # ex.
38
+ # <%= radar_chart [['review1', 5, 4, 3], ['review2', 3, 5, 2]], :aCap => ['price', 'style', 'sound'] %>
39
+ #
40
+ # The first argument 'resource' can be one of the following forms.
41
+ # * ['my review', 1, 2, 3, 4]
42
+ # * [['my review', 1, 2, 3, 4], ['all reviews', 2, 3, 4, 3]]
43
+ # * Any other object which has required methods as follows;
44
+ # * each - to supply record objects.
45
+ # * items - If :aCap option does not exist and your resource object has items method, it is called to get :aCap. You can change the method name by :items_method option.
46
+ # * The record object shoud have methods as follows.
47
+ # * label - Like 'my review' in the example. You can use other method if you specify :label_method option.
48
+ # * values - Like [1, 2, 3, 4] in the example. You can use other method if you specify :values_method option.
49
+ # * color - If :faceColors option does not exist and your record object has color method, it is used for :faceColors. You can change the method name by :color_method option.
50
+ # Additionaly, the following options are available.
51
+ # * :canvas_id - element id of the canvas. Default is 'rader_chart'. Note that all rader charts in one page sould have unique canvas_ids.
52
+ # * :width - The width of the canvas. Default is 400.
53
+ # * :height - The height of the canvas. Default is 300.
54
+ # * All options in http://www.html5.jp/library/graph_radar.html. ex. 'aMax' or :aMax.
55
+ # And you can use html_options for the top level div.
56
+ def radar_chart(resource, options = {}, html_options = {})
57
+ options = {:width => 400, :height => 300, :canvas_id => 'reader_chart'}.merge(options.symbolize_keys)
58
+ output = canvas(options, html_options)
59
+ output << "\n"
60
+ output << rader_chart_js(resource, options)
61
+ end
62
+
63
+ # Draw a line chart using Html5jp radar chart (http://www.html5.jp/library/graph_line.html).
64
+ #
65
+ # ex.
66
+ # <%= line_chart [['accesses', 520, 340, 804, 602], ['clicks', 101, 76, 239, 321]] %>
67
+ #
68
+ # The first argument 'resource' can be one of the following forms.
69
+ # * ['accesses', 520, 340, 804, 602]
70
+ # * [['accesses', 520, 340, 804, 602], ['clicks', 101, 76, 239, 321]]
71
+ # * Any other object which has required methods as follows;
72
+ # * each - to supply record objects.
73
+ # * items - If :x option does not exist and your resource object has items method, it is called to get :x. You can change the method name by :items_method option.
74
+ # * scales - If :y option does not exist and your resource object has scales method, it is called to get :y. You can change the method name by :scales_method option
75
+ # * max_scale - Would be used as :yMax option if it exists.
76
+ # * min_scale - Would be used as :yMin option if it exists.
77
+ # * The record object shoud have methods as follows.
78
+ # * label - Like 'accesses' in the example. You can use other method if you specify :label_method option.
79
+ # * values - Like [520, 340, 804, 602] in the example. You can use other method if you specify :values_method option.
80
+ # Additionaly, the following options are available.
81
+ # * :canvas_id - element id of the canvas. Default is 'line_chart'. Note that all rader charts in one page sould have unique canvas_ids.
82
+ # * :width - The width of the canvas. Default is 400.
83
+ # * :height - The height of the canvas. Default is 300.
84
+ # * All options in http://www.html5.jp/library/graph_line.html. ex. 'yMax' or :yMax.
85
+ # And you can use html_options for the top level div.
86
+ def line_chart(resource, options = {}, html_options = {})
87
+ options = {:width => 400, :height => 300, :canvas_id => 'line_chart'}.merge(options.symbolize_keys)
88
+ output = canvas(options, html_options)
89
+ output << "\n"
90
+ output << line_chart_js(resource, options)
91
+ end
92
+
93
+ # Draw a pie chart using HTML5jp pie chart (http://www.html5.jp/library/graph_circle.html).
94
+ #
95
+ # ex.
96
+ # <%= pie_chart([["very good", 400], ["good", 300], ["bad", 100], ["very bad", 300]]) %>
97
+ #
98
+ # The first argument 'resource' can be one of the following forms.
99
+ # * [["very good", 400], ["good", 300], ["bad", 100], ["very bad", 300, "red"]]
100
+ # * Any other object which has required methods as follows;
101
+ # * each - to supply record objects.
102
+ # * The record object shoud have methods as follows.
103
+ # * label - Like 'very good' in the example. You can use other method if you specify :label_method option.
104
+ # * value - Like 400 in the example. You can use other method if you specify :value_method option.
105
+ # * color - Like "red" in the example. You can use other method if you specify :color_method option. This is optional.
106
+ # Additionaly, the following options are available.
107
+ # * :canvas_id - element id of the canvas. Default is 'pie_chart'. Note that all rader charts in one page sould have unique canvas_ids.
108
+ # * :width - The width of the canvas. Default is 400.
109
+ # * :height - The height of the canvas. Default is 300.
110
+ # * :sort - If true, sort the records in descending order. Default is false.
111
+ # * All options in http://www.html5.jp/library/graph_circle.html. ex. 'startAngle' or :startAngle.
112
+ # And you can use html_options for the top level div.
113
+ def pie_chart(resource, options = {}, html_options = {})
114
+ options = {:width => 400, :height => 300, :canvas_id => 'pie_chart', :sort => false}.merge(options.symbolize_keys)
115
+ output = canvas(options, html_options)
116
+ output << "\n"
117
+ output << pie_chart_js(resource, options)
118
+ end
119
+
120
+ private
121
+
122
+ def canvas(options, html_options)
123
+ content_tag(:div, content_tag(:canvas, '', :width => options[:width], :height => options[:height], :id => options[:canvas_id]), html_options)
124
+ end
125
+
126
+ def vertical_bar_chart_js(resource, options)
127
+ graph_options = options.dup.delete_if{|key, value| [:canvas_id, :width, :height, :items_method, :scales_method, :max_scale_method, :label_method, :values_method, :color_method].include?(key) || value.blank?}
128
+ options = {:items_method => :items, :scales_method => :scales, :max_scale_method => :max_scale, :label_method => :label, :values_method => :values, :color_method => :color}.merge(options)
129
+
130
+ if resource.kind_of?(Array) && resource.first.kind_of?(Array)
131
+ records = resource
132
+ elsif resource.kind_of?(Array) && resource.first.kind_of?(String)
133
+ records = [resource]
134
+ else
135
+ records = []
136
+ record_colors = []
137
+ for record in resource
138
+ records << [record.send(options[:label_method])].concat(record.send(options[:values_method]))
139
+ record_colors << record.send(options[:color_method]) if !graph_options[:barColors] && record.respond_to?(options[:color_method])
140
+ end
141
+ graph_options[:x] ||= resource.send(options[:items_method]) if resource.respond_to?(options[:items_method])
142
+ graph_options[:y] ||= resource.send(options[:scales_method]) if resource.respond_to?(options[:scales_method])
143
+ graph_options[:yMax] ||= resource.send(options[:max_scale_method]) if resource.respond_to?(options[:max_scale_method])
144
+ graph_options[:barColors] ||= record_colors unless record_colors.find{|c| c}.blank?
145
+ end
146
+
147
+ draw("vbar", options[:canvas_id], records, graph_options)
148
+ end
149
+
150
+ def rader_chart_js(resource, options)
151
+ graph_options = options.dup.delete_if{|key, value| [:canvas_id, :width, :height, :label_method, :values_method, :items_method, :color_method].include?(key) || value.blank?}
152
+ options = {:label_method => :label, :values_method => :values, :items_method => :items, :color_method => :color}.merge(options)
153
+
154
+ if resource.kind_of?(Array) && resource.first.kind_of?(Array)
155
+ records = resource
156
+ elsif resource.kind_of?(Array) && resource.first.kind_of?(String)
157
+ records = [resource]
158
+ else
159
+ records = []
160
+ record_colors = []
161
+ for record in resource
162
+ records << [record.send(options[:label_method])].concat(record.send(options[:values_method]))
163
+ record_colors << record.send(options[:color_method]) if !graph_options[:faceColors] && record.respond_to?(options[:color_method])
164
+ end
165
+ graph_options[:aCap] ||= resource.send(options[:items_method]) if resource.respond_to?(options[:items_method])
166
+ graph_options[:faceColors] ||= record_colors unless record_colors.find{|c| c}.blank?
167
+ end
168
+
169
+ draw("radar", options[:canvas_id], records, graph_options)
170
+ end
171
+
172
+ def line_chart_js(resource, options)
173
+ graph_options = options.dup.delete_if{|key, value| [:canvas_id, :width, :height, :items_method, :scales_method, :max_scale_method, :min_scale_method, :label_method, :values_method].include?(key) || value.blank?}
174
+ options = {:items_method => :items, :scales_method => :scales, :max_scale_method => :max_scale, :min_scale_method => :min_scale, :label_method => :label, :values_method => :values}.merge(options)
175
+
176
+ if resource.kind_of?(Array) && resource.first.kind_of?(Array)
177
+ records = resource
178
+ elsif resource.kind_of?(Array) && resource.first.kind_of?(String)
179
+ records = [resource]
180
+ else
181
+ records = []
182
+ for record in resource
183
+ records << [record.send(options[:label_method])].concat(record.send(options[:values_method]))
184
+ end
185
+ graph_options[:x] ||= resource.send(options[:items_method]) if resource.respond_to?(options[:items_method])
186
+ graph_options[:y] ||= resource.send(options[:scales_method]) if resource.respond_to?(options[:scales_method])
187
+ graph_options[:yMax] ||= resource.send(options[:max_scale_method]) if resource.respond_to?(options[:max_scale_method])
188
+ graph_options[:yMin] ||= resource.send(options[:min_scale_method]) if resource.respond_to?(options[:min_scale_method])
189
+ end
190
+
191
+ draw("line", options[:canvas_id], records, graph_options)
192
+ end
193
+
194
+ def pie_chart_js(resource, options)
195
+ graph_options = options.dup.delete_if{|key, value| [:canvas_id, :items, :width, :height, :label_method, :value_method, :color_method, :sort].include?(key) || value.blank?}
196
+ options = {:label_method => :label, :value_method => :value, :color_method => :color}.merge(options)
197
+
198
+ if resource.kind_of?(Array) && resource.first.kind_of?(Array)
199
+ records = resource
200
+ else
201
+ records = []
202
+ for record in resource
203
+ record_array = [record.send(options[:label_method]), record.send(options[:value_method])]
204
+ record_array << record.send(options[:color_method]) if record.respond_to?(options[:color_method])
205
+ records << record_array
206
+ end
207
+ end
208
+
209
+ records = records.sort {|r1, r2| r2[1] <=> r1[1]} if options[:sort]
210
+
211
+ draw("circle", options[:canvas_id], records, graph_options)
212
+ end
213
+
214
+
215
+ def draw(class_name, canvas_id, records, graph_options)
216
+ javascript_tag <<-EOS
217
+ Event.observe(window, 'load', function() {
218
+ var rc = new html5jp.graph.#{class_name}("#{canvas_id}");
219
+ if( ! rc ) { return; }
220
+ var records = #{to_js_value(records)};
221
+ var options = #{options_to_json(graph_options)};
222
+ rc.draw(records, options);
223
+ });
224
+ EOS
225
+ end
226
+
227
+ # Don't use to_json avoiding url encoding of local characters.
228
+ def options_to_json(options)
229
+ content = options.map{|key, value| "#{key}: #{to_js_value(value)}"}.join(",\n")
230
+ "{#{content}}"
231
+ end
232
+
233
+ def to_js_value(value)
234
+ if value.nil?
235
+ 'null'
236
+ elsif value.kind_of?(Array)
237
+ "[#{value.map{|v| array_element_to_js_value(v)}.join(', ')}]"
238
+ else
239
+ value.to_s
240
+ end
241
+ end
242
+
243
+ def array_element_to_js_value(value)
244
+ if value.nil?
245
+ 'null'
246
+ elsif value.kind_of?(Numeric) || value.to_s =~ /^-?[0-9][0-9]*[\.]?[0-9]*$/
247
+ value
248
+ elsif value.kind_of?(Array)
249
+ "[#{value.map{|v| array_element_to_js_value(v)}.join(', ')}]"
250
+ else
251
+ "\"#{value}\""
252
+ end
253
+ end
254
+
255
+ end
@@ -0,0 +1,326 @@
1
+ <?xml version="1.0" encoding="iso-8859-1"?>
2
+ <!DOCTYPE html
3
+ PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
4
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
5
+
6
+ <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
7
+ <head>
8
+ <title>Module: Html5jpGraphsHelper</title>
9
+ <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
10
+ <meta http-equiv="Content-Script-Type" content="text/javascript" />
11
+ <link rel="stylesheet" href=".././rdoc-style.css" type="text/css" media="screen" />
12
+ <script type="text/javascript">
13
+ // <![CDATA[
14
+
15
+ function popupCode( url ) {
16
+ window.open(url, "Code", "resizable=yes,scrollbars=yes,toolbar=no,status=no,height=150,width=400")
17
+ }
18
+
19
+ function toggleCode( id ) {
20
+ if ( document.getElementById )
21
+ elem = document.getElementById( id );
22
+ else if ( document.all )
23
+ elem = eval( "document.all." + id );
24
+ else
25
+ return false;
26
+
27
+ elemStyle = elem.style;
28
+
29
+ if ( elemStyle.display != "block" ) {
30
+ elemStyle.display = "block"
31
+ } else {
32
+ elemStyle.display = "none"
33
+ }
34
+
35
+ return true;
36
+ }
37
+
38
+ // Make codeblocks hidden by default
39
+ document.writeln( "<style type=\"text/css\">div.method-source-code { display: none }</style>" )
40
+
41
+ // ]]>
42
+ </script>
43
+
44
+ </head>
45
+ <body>
46
+
47
+
48
+
49
+ <div id="classHeader">
50
+ <table class="header-table">
51
+ <tr class="top-aligned-row">
52
+ <td><strong>Module</strong></td>
53
+ <td class="class-name-in-header">Html5jpGraphsHelper</td>
54
+ </tr>
55
+ <tr class="top-aligned-row">
56
+ <td><strong>In:</strong></td>
57
+ <td>
58
+ <a href="../files/lib/html5jp_graphs_helper_rb.html">
59
+ lib/html5jp_graphs_helper.rb
60
+ </a>
61
+ <br />
62
+ </td>
63
+ </tr>
64
+
65
+ </table>
66
+ </div>
67
+ <!-- banner header -->
68
+
69
+ <div id="bodyContent">
70
+
71
+
72
+
73
+ <div id="contextContent">
74
+
75
+ <div id="description">
76
+ <p>
77
+ <a href="Html5jpGraphsHelper.html">Html5jpGraphsHelper</a>
78
+ </p>
79
+
80
+ </div>
81
+
82
+
83
+ </div>
84
+
85
+ <div id="method-list">
86
+ <h3 class="section-bar">Methods</h3>
87
+
88
+ <div class="name-list">
89
+ <a href="#M000001">pie_chart</a>&nbsp;&nbsp;
90
+ <a href="#M000002">radar_chart</a>&nbsp;&nbsp;
91
+ </div>
92
+ </div>
93
+
94
+ </div>
95
+
96
+
97
+ <!-- if includes -->
98
+
99
+ <div id="section">
100
+
101
+
102
+
103
+
104
+
105
+
106
+
107
+
108
+ <!-- if method_list -->
109
+ <div id="methods">
110
+ <h3 class="section-bar">Public Instance methods</h3>
111
+
112
+ <div id="method-M000001" class="method-detail">
113
+ <a name="M000001"></a>
114
+
115
+ <div class="method-heading">
116
+ <a href="#M000001" class="method-signature">
117
+ <span class="method-name">pie_chart</span><span class="method-args">(resource, options = {}, html_options = {})</span>
118
+ </a>
119
+ </div>
120
+
121
+ <div class="method-description">
122
+ <p>
123
+ Draw a pie chart using HTML5jp pie chart (<a
124
+ href="http://www.html5.jp/library/graph_circle.html">www.html5.jp/library/graph_circle.html</a>).
125
+ </p>
126
+ <p>
127
+ ex.
128
+ </p>
129
+ <pre>
130
+ &lt;%= pie_chart([[&quot;very good&quot;, 400], [&quot;good&quot;, 300], [&quot;bad&quot;, 100], [&quot;very bad&quot;, 300]]) %&gt;
131
+ </pre>
132
+ <p>
133
+ The first argument &#8216;resource&#8217; can be one of the following
134
+ forms.
135
+ </p>
136
+ <ul>
137
+ <li>[[&quot;very good&quot;, 400], [&quot;good&quot;, 300], [&quot;bad&quot;,
138
+ 100], [&quot;very bad&quot;, 300, &quot;red&quot;]]
139
+
140
+ </li>
141
+ <li>Any other object which has required methods as follows;
142
+
143
+ <ul>
144
+ <li>each - to supply record objects.
145
+
146
+ </li>
147
+ <li>The record object shoud have methods as follows.
148
+
149
+ <ul>
150
+ <li>label - Like &#8216;very good&#8217; in the example. You can use other
151
+ method if you specify :label_method option.
152
+
153
+ </li>
154
+ <li>value - Like 400 in the example. You can use other method if you specify
155
+ :value_method option.
156
+
157
+ </li>
158
+ <li>color - Like &quot;red&quot; in the example. You can use other method if
159
+ you specify :color_method option. This is optional.
160
+
161
+ </li>
162
+ </ul>
163
+ </li>
164
+ </ul>
165
+ </li>
166
+ </ul>
167
+ <p>
168
+ Additionaly, the following options are available.
169
+ </p>
170
+ <ul>
171
+ <li>:canvas_id - element id of the canvas. Default is
172
+ &#8216;rader_chart&#8217;. Note that all rader charts in one page sould
173
+ have unique canvas_ids.
174
+
175
+ </li>
176
+ <li>:width - The width of the canvas. Default is 400.
177
+
178
+ </li>
179
+ <li>:height - The height of the canvas. Default is 300.
180
+
181
+ </li>
182
+ <li>:sort - If true, sort the records in descending order. Default is false.
183
+
184
+ </li>
185
+ <li>All options in <a
186
+ href="http://www.html5.jp/library/graph_circle.html">www.html5.jp/library/graph_circle.html</a>.
187
+ ex. &#8216;startAngle&#8217; or :startAngle.
188
+
189
+ </li>
190
+ </ul>
191
+ <p>
192
+ And you can use html_options for the top level div.
193
+ </p>
194
+ <p><a class="source-toggle" href="#"
195
+ onclick="toggleCode('M000001-source');return false;">[Source]</a></p>
196
+ <div class="method-source-code" id="M000001-source">
197
+ <pre>
198
+ <span class="ruby-comment cmt"># File lib/html5jp_graphs_helper.rb, line 25</span>
199
+ 25: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">pie_chart</span>(<span class="ruby-identifier">resource</span>, <span class="ruby-identifier">options</span> = {}, <span class="ruby-identifier">html_options</span> = {})
200
+ 26: <span class="ruby-identifier">options</span> = {<span class="ruby-identifier">:width</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-value">400</span>, <span class="ruby-identifier">:height</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-value">300</span>, <span class="ruby-identifier">:canvas_id</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-value str">'pie_chart'</span>}.<span class="ruby-identifier">merge</span>(<span class="ruby-identifier">options</span>.<span class="ruby-identifier">symbolize_keys</span>)
201
+ 27: <span class="ruby-identifier">output</span> = <span class="ruby-identifier">canvas</span>(<span class="ruby-identifier">options</span>, <span class="ruby-identifier">html_options</span>)
202
+ 28: <span class="ruby-identifier">output</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-value str">&quot;\n&quot;</span>
203
+ 29: <span class="ruby-identifier">output</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-identifier">pie_chart_js</span>(<span class="ruby-identifier">resource</span>, <span class="ruby-identifier">options</span>)
204
+ 30: <span class="ruby-keyword kw">end</span>
205
+ </pre>
206
+ </div>
207
+ </div>
208
+ </div>
209
+
210
+ <div id="method-M000002" class="method-detail">
211
+ <a name="M000002"></a>
212
+
213
+ <div class="method-heading">
214
+ <a href="#M000002" class="method-signature">
215
+ <span class="method-name">radar_chart</span><span class="method-args">(resource, options = {}, html_options = {})</span>
216
+ </a>
217
+ </div>
218
+
219
+ <div class="method-description">
220
+ <p>
221
+ Draw a radar chart using Html5jp radar chart (<a
222
+ href="http://www.html5.jp/library/graph_radar.html">www.html5.jp/library/graph_radar.html</a>).
223
+ </p>
224
+ <p>
225
+ ex.
226
+ </p>
227
+ <pre>
228
+ &lt;%= radar_chart [['review1', 5, 4, 3], ['review2', 3, 5, 2]], :aCap =&gt; ['price', 'style', 'sound'] %&gt;
229
+ </pre>
230
+ <p>
231
+ The first argument &#8216;resource&#8217; can be one of the following
232
+ forms.
233
+ </p>
234
+ <ul>
235
+ <li>[&#8216;my review&#8217;, 1, 2, 3, 4]
236
+
237
+ </li>
238
+ <li>[[&#8216;my review&#8217;, 1, 2, 3, 4], [&#8216;all reviews&#8217;, 2, 3,
239
+ 4, 3]]
240
+
241
+ </li>
242
+ <li>Any other object which has required methods as follows;
243
+
244
+ <ul>
245
+ <li>each - to supply record objects.
246
+
247
+ </li>
248
+ <li>items - If :aCap option does not exist and your resource object has items
249
+ method, it is called to get :aCap. You can change the method name by
250
+ :items_method option.
251
+
252
+ </li>
253
+ <li>The record object shoud have methods as follows.
254
+
255
+ <ul>
256
+ <li>label - Like &#8216;my review&#8217; in the example. You can use other
257
+ method if you specify :label_method option.
258
+
259
+ </li>
260
+ <li>values - Like [1, 2, 3, 4] in the example. You can use other method if you
261
+ specify :values_method option.
262
+
263
+ </li>
264
+ <li>color - If :faceColors option does not exist and your record object has
265
+ color method, it is used for :faceColors. You can change the method name by
266
+ :colors_method option.
267
+
268
+ </li>
269
+ </ul>
270
+ </li>
271
+ </ul>
272
+ </li>
273
+ </ul>
274
+ <p>
275
+ Additionaly, the following options are available.
276
+ </p>
277
+ <ul>
278
+ <li>:canvas_id - element id of the canvas. Default is
279
+ &#8216;rader_chart&#8217;. Note that all rader charts in one page sould
280
+ have unique canvas_ids.
281
+
282
+ </li>
283
+ <li>:width - The width of the canvas. Default is 400.
284
+
285
+ </li>
286
+ <li>:height - The height of the canvas. Default is 300.
287
+
288
+ </li>
289
+ <li>All options in <a
290
+ href="http://www.html5.jp/library/graph_radar.html">www.html5.jp/library/graph_radar.html</a>.
291
+ ex. &#8216;aMax&#8217; or :aMax.
292
+
293
+ </li>
294
+ </ul>
295
+ <p>
296
+ And you can use html_options for the top level div.
297
+ </p>
298
+ <p><a class="source-toggle" href="#"
299
+ onclick="toggleCode('M000002-source');return false;">[Source]</a></p>
300
+ <div class="method-source-code" id="M000002-source">
301
+ <pre>
302
+ <span class="ruby-comment cmt"># File lib/html5jp_graphs_helper.rb, line 53</span>
303
+ 53: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">radar_chart</span>(<span class="ruby-identifier">resource</span>, <span class="ruby-identifier">options</span> = {}, <span class="ruby-identifier">html_options</span> = {})
304
+ 54: <span class="ruby-identifier">options</span> = {<span class="ruby-identifier">:width</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-value">400</span>, <span class="ruby-identifier">:height</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-value">300</span>, <span class="ruby-identifier">:canvas_id</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-value str">'reader_chart'</span>}.<span class="ruby-identifier">merge</span>(<span class="ruby-identifier">options</span>.<span class="ruby-identifier">symbolize_keys</span>)
305
+ 55: <span class="ruby-identifier">output</span> = <span class="ruby-identifier">canvas</span>(<span class="ruby-identifier">options</span>, <span class="ruby-identifier">html_options</span>)
306
+ 56: <span class="ruby-identifier">output</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-value str">&quot;\n&quot;</span>
307
+ 57: <span class="ruby-identifier">output</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-identifier">rader_chart_js</span>(<span class="ruby-identifier">resource</span>, <span class="ruby-identifier">options</span>)
308
+ 58: <span class="ruby-keyword kw">end</span>
309
+ </pre>
310
+ </div>
311
+ </div>
312
+ </div>
313
+
314
+
315
+ </div>
316
+
317
+
318
+ </div>
319
+
320
+
321
+ <div id="validator-badges">
322
+ <p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
323
+ </div>
324
+
325
+ </body>
326
+ </html>