html5jp_graphs 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (40) hide show
  1. data/.gitigore +2 -0
  2. data/README.rdoc +82 -0
  3. data/Rakefile +22 -0
  4. data/html5jp_graphs.gemspec +17 -0
  5. data/lib/examples/sample_graph_circle_1.html +54 -0
  6. data/lib/examples/sample_graph_circle_2.html +61 -0
  7. data/lib/examples/sample_graph_line_1.html +44 -0
  8. data/lib/examples/sample_graph_line_2.html +53 -0
  9. data/lib/examples/sample_graph_radar_1.html +47 -0
  10. data/lib/examples/sample_graph_radar_2.html +52 -0
  11. data/lib/examples/sample_graph_vbar_1.html +51 -0
  12. data/lib/examples/sample_graph_vbar_2.html +52 -0
  13. data/lib/examples/sample_graph_vbar_3.html +52 -0
  14. data/lib/examples/sample_graph_vbar_4.html +52 -0
  15. data/lib/generators/html5jp_graphs/USAGE +8 -0
  16. data/lib/generators/html5jp_graphs/html5jp_graphs_generator.rb +12 -0
  17. data/lib/generators/html5jp_graphs/templates/excanvas/AUTHORS +10 -0
  18. data/lib/generators/html5jp_graphs/templates/excanvas/COPYING +202 -0
  19. data/lib/generators/html5jp_graphs/templates/excanvas/README +22 -0
  20. data/lib/generators/html5jp_graphs/templates/excanvas/examples/example1.html +93 -0
  21. data/lib/generators/html5jp_graphs/templates/excanvas/examples/example2.html +513 -0
  22. data/lib/generators/html5jp_graphs/templates/excanvas/examples/example3.html +284 -0
  23. data/lib/generators/html5jp_graphs/templates/excanvas/examples/ff.jpg +0 -0
  24. data/lib/generators/html5jp_graphs/templates/excanvas/excanvas-compressed.js +19 -0
  25. data/lib/generators/html5jp_graphs/templates/excanvas/excanvas.js +785 -0
  26. data/lib/generators/html5jp_graphs/templates/excanvas/testcases/arc.html +49 -0
  27. data/lib/generators/html5jp_graphs/templates/excanvas/testcases/linewidth.html +47 -0
  28. data/lib/generators/html5jp_graphs/templates/excanvas/testcases/overflow.html +37 -0
  29. data/lib/generators/html5jp_graphs/templates/excanvas/testcases/quadraticcurve.html +74 -0
  30. data/lib/generators/html5jp_graphs/templates/excanvas/testcases/resizing.html +65 -0
  31. data/lib/generators/html5jp_graphs/templates/graph/circle.js +407 -0
  32. data/lib/generators/html5jp_graphs/templates/graph/line.js +577 -0
  33. data/lib/generators/html5jp_graphs/templates/graph/radar.js +545 -0
  34. data/lib/generators/html5jp_graphs/templates/graph/vbar.js +1156 -0
  35. data/lib/html5jp_graphs.rb +1 -0
  36. data/lib/html5jp_graphs/version.rb +3 -0
  37. data/lib/html5jp_graphs_helper.rb +255 -0
  38. data/tasks/html5jp_graphs_tasks.rake +4 -0
  39. data/test/html5jp_graphs_test.rb +8 -0
  40. metadata +88 -0
@@ -0,0 +1,2 @@
1
+ *~
2
+ .DS_Store
@@ -0,0 +1,82 @@
1
+ = Html5jpGraphs
2
+
3
+ Html5jpGraphs is a Rails Plugin for HTML5.jp Graph Libraries.
4
+
5
+ HTML5.jp Graph Libraries are written by futomi, released under Apache License, Version 2.0.
6
+ http://www.html5.jp/library/index.html
7
+
8
+ There are 4 kinds of graphs in HTML5.jp.
9
+
10
+ * vertical bar chart
11
+ * radar chart
12
+ * line chart
13
+ * pie chart
14
+
15
+ With this plugin, you can easily draw graphs using helper methods.
16
+ Helper methods accepts both simple array data and your original complex model objects.
17
+
18
+ == Install
19
+
20
+ > git clone git://github.com/nay/html5jp_graphs.git vendor/plugins/html5jp_graphs
21
+
22
+ If you use Rails 2.1 or later, you can install with this command.
23
+
24
+ > ruby script/plugin install git://github.com/nay/html5jp_graphs.git
25
+
26
+ ==Setup
27
+
28
+ First of all, you need to include javascripts. You can include these files by using :all option.
29
+
30
+ <%= javascript_include_tag :all %>
31
+
32
+ Also you can include required files separately.
33
+
34
+ * required for all graphs ... excanvas.js, excanvas-compressed.js
35
+ * vertical bar chart ... vbar.js
36
+ * radar chart ... radar.js
37
+ * pie chart ... circle.js
38
+ * line chart ... line.js
39
+
40
+ Then, add :htmltjp_graphs as a helper in your controllers.
41
+
42
+ class GraphsController < ApplicationController
43
+ helper :html5jp_graphs
44
+ end
45
+
46
+ ==Example
47
+ === Draw a Vertical Bar Chart
48
+
49
+ <%= vertical_bar_chart [['accesses', 520, 340, 804, 602], ['clicks', 101, 76, 239, 321]] %>
50
+
51
+ or you can use your own model obejct (with some methods. Please see RDoc for the requirements).
52
+
53
+ <%= vertical_bar_chart access_click_summaries %>
54
+
55
+ === Draw a Radar Chart
56
+
57
+ <%= radar_chart [['review1', 5, 4, 3], ['review2', 3, 5, 2]], :aCap => ['price', 'style', 'sound'] %>
58
+
59
+ <%= radar_chart reviews %>
60
+
61
+ === Draw a Line Chart
62
+
63
+ <%= line_chart [['accesses', 520, 340, 804, 602], ['clicks', 101, 76, 239, 321]] %>
64
+
65
+ <%= line_chart access_click_summaries %>
66
+
67
+ === Draw a Pie Chart
68
+
69
+ <%= pie_chart([["very good", 400], ["good", 300], ["bad", 100], ["very bad", 300]]) %>
70
+
71
+ <%= pie_chart opinions %>
72
+
73
+ === Options
74
+
75
+ You can use all options in HTML5.jp. Note that string options should be wrapped in ' ', or it would be used as a script code.
76
+
77
+ For example, to specify the backgroundColor option to a radar chart, write like this.
78
+
79
+ <%= radar_chart reviews, :backgroundColor => "'red'" %>
80
+
81
+ Copyright (c) 2008 Yasuko Ohba (y.ohba@everyleaf.com), released under the apache license
82
+
@@ -0,0 +1,22 @@
1
+ require 'rake'
2
+ require 'rake/testtask'
3
+ require 'rake/rdoctask'
4
+
5
+ desc 'Default: run unit tests.'
6
+ task :default => :test
7
+
8
+ desc 'Test the html5jp_graphs plugin.'
9
+ Rake::TestTask.new(:test) do |t|
10
+ t.libs << 'lib'
11
+ t.pattern = 'test/**/*_test.rb'
12
+ t.verbose = true
13
+ end
14
+
15
+ desc 'Generate documentation for the html5jp_graphs plugin.'
16
+ Rake::RDocTask.new(:rdoc) do |rdoc|
17
+ rdoc.rdoc_dir = 'rdoc'
18
+ rdoc.title = 'Html5jpGraphs'
19
+ rdoc.options << '--line-numbers' << '--inline-source'
20
+ rdoc.rdoc_files.include('README.rdoc')
21
+ rdoc.rdoc_files.include('lib/**/*.rb')
22
+ end
@@ -0,0 +1,17 @@
1
+ # -*- encoding: utf-8 -*-
2
+ require File.expand_path('../lib/html5jp_graphs/version', __FILE__)
3
+
4
+ Gem::Specification.new do |gem|
5
+ gem.authors = ["nay3", "Koirhico Ohba"]
6
+ gem.email = ["y.ohba@everyleaf.com"]
7
+ gem.description = %q{html5jp_graphs is a Rails Plugin for HTML5.jp graph libraries. It supports vertical bar chart, radar chart, pie chart, and line chart.}
8
+ gem.summary = %q{Rails Plugin for HTML5.jp Graph Libraries.}
9
+ gem.homepage = "http://github.com/nay/html5jp_graphs"
10
+
11
+ gem.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
12
+ gem.files = `git ls-files`.split("\n")
13
+ gem.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
14
+ gem.name = "html5jp_graphs"
15
+ gem.require_paths = ["lib"]
16
+ gem.version = Html5jpGraphs::VERSION
17
+ end
@@ -0,0 +1,54 @@
1
+ <!--
2
+ Copyright 2007 futomi http://www.html5.jp/
3
+
4
+ Licensed under the Apache License, Version 2.0 (the "License");
5
+ you may not use this file except in compliance with the License.
6
+ You may obtain a copy of the License at
7
+
8
+ http://www.apache.org/licenses/LICENSE-2.0
9
+
10
+ Unless required by applicable law or agreed to in writing, software
11
+ distributed under the License is distributed on an "AS IS" BASIS,
12
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ See the License for the specific language governing permissions and
14
+ limitations under the License.
15
+ -->
16
+ <html>
17
+ <head>
18
+ <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
19
+ <meta http-equiv="Content-Language" content="ja" />
20
+ <meta http-equiv="Content-Style-Type" content="text/css" />
21
+ <meta http-equiv="Content-Script-Type" content="text/javascript" />
22
+ <title>円グラフ サンプル - jsライブラリ - HTML5.JP</title>
23
+ <style type="text/css">
24
+ canvas {border:1px solid #4c4c4c;}
25
+ </style>
26
+ <!--[if IE]><script type="text/javascript" src="../html5jp/excanvas/excanvas.js"></script><![endif]-->
27
+ <script type="text/javascript" src="../html5jp/graph/circle.js"></script>
28
+ <script type="text/javascript">
29
+ window.onload = function() {
30
+ var cg = new html5jp.graph.circle("sample");
31
+ if( ! cg ) { return; }
32
+ var items = [
33
+ ["sample01", 150],
34
+ ["sample02", 100],
35
+ ["sample03", 80],
36
+ ["sample04", 60],
37
+ ["sample05", 30],
38
+ ["sample06", 20],
39
+ ["sample07", 10],
40
+ ["sample08", 10],
41
+ ["sample09", 10],
42
+ ["sample10", 10],
43
+ ["sample11", 10],
44
+ ["sample12", 10]
45
+ ];
46
+ cg.draw(items);
47
+ };
48
+ </script>
49
+ </head>
50
+ <body>
51
+ <h1>円グラフ サンプル - jsライブラリ - HTML5.JP</h1>
52
+ <div><canvas width="400" height="300" id="sample"></canvas></div>
53
+ </body>
54
+ </html>
@@ -0,0 +1,61 @@
1
+ <!--
2
+ Copyright 2007 futomi http://www.html5.jp/
3
+
4
+ Licensed under the Apache License, Version 2.0 (the "License");
5
+ you may not use this file except in compliance with the License.
6
+ You may obtain a copy of the License at
7
+
8
+ http://www.apache.org/licenses/LICENSE-2.0
9
+
10
+ Unless required by applicable law or agreed to in writing, software
11
+ distributed under the License is distributed on an "AS IS" BASIS,
12
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ See the License for the specific language governing permissions and
14
+ limitations under the License.
15
+ -->
16
+ <html>
17
+ <head>
18
+ <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
19
+ <meta http-equiv="Content-Language" content="ja" />
20
+ <meta http-equiv="Content-Style-Type" content="text/css" />
21
+ <meta http-equiv="Content-Script-Type" content="text/javascript" />
22
+ <title>円グラフ サンプル - jsライブラリ - HTML5.JP</title>
23
+ <style type="text/css">
24
+ canvas {border:1px solid #4c4c4c;}
25
+ </style>
26
+ <!--[if IE]><script type="text/javascript" src="../html5jp/excanvas/excanvas.js"></script><![endif]-->
27
+ <script type="text/javascript" src="../html5jp/graph/circle.js"></script>
28
+ <script type="text/javascript">
29
+ window.onload = function() {
30
+ var cg = new html5jp.graph.circle("sample");
31
+ if( ! cg ) { return; }
32
+ var items = [
33
+ ["sample01", 150, "#ff8899"],
34
+ ["sample02", 100],
35
+ ["sample03", 80],
36
+ ["sample04", 60],
37
+ ["sample05", 30],
38
+ ["sample06", 20],
39
+ ["sample07", 10],
40
+ ["sample08", 10],
41
+ ["sample09", 10],
42
+ ["sample10", 10],
43
+ ["sample11", 10],
44
+ ["sample12", 10]
45
+ ];
46
+ var params = {
47
+ backgroundColor: "#eeffee",
48
+ shadow: false,
49
+ captionNum: false,
50
+ startAngle: -45,
51
+ otherCaption: "その他"
52
+ };
53
+ cg.draw(items, params);
54
+ };
55
+ </script>
56
+ </head>
57
+ <body>
58
+ <h1>円グラフ - jsライブラリ - HTML5.JP</h1>
59
+ <div><canvas width="400" height="300" id="sample"></canvas></div>
60
+ </body>
61
+ </html>
@@ -0,0 +1,44 @@
1
+ <!--
2
+ Copyright 2007 futomi http://www.html5.jp/
3
+
4
+ Licensed under the Apache License, Version 2.0 (the "License");
5
+ you may not use this file except in compliance with the License.
6
+ You may obtain a copy of the License at
7
+
8
+ http://www.apache.org/licenses/LICENSE-2.0
9
+
10
+ Unless required by applicable law or agreed to in writing, software
11
+ distributed under the License is distributed on an "AS IS" BASIS,
12
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ See the License for the specific language governing permissions and
14
+ limitations under the License.
15
+ -->
16
+ <html>
17
+ <head>
18
+ <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
19
+ <meta http-equiv="Content-Language" content="ja" />
20
+ <meta http-equiv="Content-Style-Type" content="text/css" />
21
+ <meta http-equiv="Content-Script-Type" content="text/javascript" />
22
+ <title>折線グラフ サンプル 1 - jsライブラリ - HTML5.JP</title>
23
+ <style type="text/css">
24
+ canvas {border:1px solid #4c4c4c;}
25
+ </style>
26
+ <!--[if IE]><script type="text/javascript" src="../html5jp/excanvas/excanvas.js"></script><![endif]-->
27
+ <script type="text/javascript" src="../html5jp/graph/line.js"></script>
28
+ <script type="text/javascript">
29
+ window.onload = function() {
30
+ var lg = new html5jp.graph.line("sample");
31
+ if( ! lg ) { return; }
32
+ var items = [
33
+ ["商品A", 20, 58, 40, 14, 38, 20, 40],
34
+ ["商品B", 10, 14, 58, 80, 70, 90, 20]
35
+ ];
36
+ lg.draw(items);
37
+ };
38
+ </script>
39
+ </head>
40
+ <body>
41
+ <h1>折線グラフ サンプル 1 - jsライブラリ - HTML5.JP</h1>
42
+ <div><canvas width="400" height="300" id="sample"></canvas></div>
43
+ </body>
44
+ </html>
@@ -0,0 +1,53 @@
1
+ <!--
2
+ Copyright 2007 futomi http://www.html5.jp/
3
+
4
+ Licensed under the Apache License, Version 2.0 (the "License");
5
+ you may not use this file except in compliance with the License.
6
+ You may obtain a copy of the License at
7
+
8
+ http://www.apache.org/licenses/LICENSE-2.0
9
+
10
+ Unless required by applicable law or agreed to in writing, software
11
+ distributed under the License is distributed on an "AS IS" BASIS,
12
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ See the License for the specific language governing permissions and
14
+ limitations under the License.
15
+ -->
16
+ <html>
17
+ <head>
18
+ <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
19
+ <meta http-equiv="Content-Language" content="ja" />
20
+ <meta http-equiv="Content-Style-Type" content="text/css" />
21
+ <meta http-equiv="Content-Script-Type" content="text/javascript" />
22
+ <title>折線グラフ サンプル 2 - jsライブラリ - HTML5.JP</title>
23
+ <style type="text/css">
24
+ canvas {border:1px solid #4c4c4c;}
25
+ </style>
26
+ <!--[if IE]><script type="text/javascript" src="../html5jp/excanvas/excanvas.js"></script><![endif]-->
27
+ <script type="text/javascript" src="../html5jp/graph/line.js"></script>
28
+ <script type="text/javascript">
29
+ window.onload = function() {
30
+ var lg = new html5jp.graph.line("sample");
31
+ if( ! lg ) { return; }
32
+ var items = [
33
+ ["商品A", 20, 58, 40, 14, 38, 20, 40],
34
+ ["商品B", 10, 14, 58, 80, 70, 90, 20]
35
+ ];
36
+ var params = {
37
+ x: ["曜日", "日", "月", "火", "水", "木", "金", "土"],
38
+ y: ["注文数(個)", 0, 20, 40, 60, 80, 100],
39
+ yMax: 100,
40
+ yMin: 0,
41
+ lineWidth: [1,2],
42
+ dotRadius: [3,4],
43
+ dotType: ["disc", "square"]
44
+ };
45
+ lg.draw(items, params);
46
+ };
47
+ </script>
48
+ </head>
49
+ <body>
50
+ <h1>折線グラフ サンプル 2 - jsライブラリ - HTML5.JP</h1>
51
+ <div><canvas width="400" height="300" id="sample"></canvas></div>
52
+ </body>
53
+ </html>
@@ -0,0 +1,47 @@
1
+ <!--
2
+ Copyright 2007 futomi http://www.html5.jp/
3
+
4
+ Licensed under the Apache License, Version 2.0 (the "License");
5
+ you may not use this file except in compliance with the License.
6
+ You may obtain a copy of the License at
7
+
8
+ http://www.apache.org/licenses/LICENSE-2.0
9
+
10
+ Unless required by applicable law or agreed to in writing, software
11
+ distributed under the License is distributed on an "AS IS" BASIS,
12
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ See the License for the specific language governing permissions and
14
+ limitations under the License.
15
+ -->
16
+ <html>
17
+ <head>
18
+ <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
19
+ <meta http-equiv="Content-Language" content="ja" />
20
+ <meta http-equiv="Content-Style-Type" content="text/css" />
21
+ <meta http-equiv="Content-Script-Type" content="text/javascript" />
22
+ <title>レーダーチャート サンプル 1 - jsライブラリ - HTML5.JP</title>
23
+ <style type="text/css">
24
+ canvas {border:1px solid #4c4c4c;}
25
+ </style>
26
+ <!--[if IE]><script type="text/javascript" src="../html5jp/excanvas/excanvas.js"></script><![endif]-->
27
+ <script type="text/javascript" src="../html5jp/graph/radar.js"></script>
28
+ <script type="text/javascript">
29
+ window.onload = function() {
30
+ var rc = new html5jp.graph.radar("sample");
31
+ if( ! rc ) { return; }
32
+ var items = [
33
+ ["商品A", 5, 2, 4, 5, 3, 2, 4, 4],
34
+ ["商品B", 3, 4, 3, 4, 5, 4, 5, 1]
35
+ ];
36
+ var params = {
37
+ aCap: ["安さ", "性能", "デザイン", "人気", "使いやすさ", "寿命", "軽さ", "強さ"]
38
+ }
39
+ rc.draw(items, params);
40
+ };
41
+ </script>
42
+ </head>
43
+ <body>
44
+ <h1>レーダーチャート サンプル 1 - jsライブラリ - HTML5.JP</h1>
45
+ <div><canvas width="400" height="300" id="sample"></canvas></div>
46
+ </body>
47
+ </html>
@@ -0,0 +1,52 @@
1
+ <!--
2
+ Copyright 2007 futomi http://www.html5.jp/
3
+
4
+ Licensed under the Apache License, Version 2.0 (the "License");
5
+ you may not use this file except in compliance with the License.
6
+ You may obtain a copy of the License at
7
+
8
+ http://www.apache.org/licenses/LICENSE-2.0
9
+
10
+ Unless required by applicable law or agreed to in writing, software
11
+ distributed under the License is distributed on an "AS IS" BASIS,
12
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ See the License for the specific language governing permissions and
14
+ limitations under the License.
15
+ -->
16
+ <html>
17
+ <head>
18
+ <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
19
+ <meta http-equiv="Content-Language" content="ja" />
20
+ <meta http-equiv="Content-Style-Type" content="text/css" />
21
+ <meta http-equiv="Content-Script-Type" content="text/javascript" />
22
+ <title>レーダーチャート サンプル 2 - jsライブラリ - HTML5.JP</title>
23
+ <style type="text/css">
24
+ canvas {border:1px solid #4c4c4c;}
25
+ </style>
26
+ <!--[if IE]><script type="text/javascript" src="../html5jp/excanvas/excanvas.js"></script><![endif]-->
27
+ <script type="text/javascript" src="../html5jp/graph/radar.js"></script>
28
+ <script type="text/javascript">
29
+ window.onload = function() {
30
+ var rc = new html5jp.graph.radar("sample");
31
+ if( ! rc ) { return; }
32
+ var items = [
33
+ ["商品A", 5, 2, 4, 5, 3, 2, 4, 4],
34
+ ["商品B", 3, 4, 3, 4, 5, 4, 5, 1]
35
+ ];
36
+ var params = {
37
+ aCap: ["安さ", "性能", "デザイン", "人気", "使いやすさ", "寿命", "軽さ", "強さ"],
38
+ aMax: 6,
39
+ aMin: 0,
40
+ chartShape: "circle",
41
+ faceColors: ["green", "olive"],
42
+ aLinePositions: [0,1,2,3,4,5,6]
43
+ };
44
+ rc.draw(items, params);
45
+ };
46
+ </script>
47
+ </head>
48
+ <body>
49
+ <h1>レーダーチャート サンプル 2 - jsライブラリ - HTML5.JP</h1>
50
+ <div><canvas width="400" height="300" id="sample"></canvas></div>
51
+ </body>
52
+ </html>