pfsc-gruff 0.3.6

Sign up to get free protection for your applications and to get access to all the features.
Files changed (82) hide show
  1. data/History.txt +117 -0
  2. data/MIT-LICENSE +21 -0
  3. data/Manifest.txt +81 -0
  4. data/README.txt +40 -0
  5. data/Rakefile +55 -0
  6. data/assets/bubble.png +0 -0
  7. data/assets/city_scene/background/0000.png +0 -0
  8. data/assets/city_scene/background/0600.png +0 -0
  9. data/assets/city_scene/background/2000.png +0 -0
  10. data/assets/city_scene/clouds/cloudy.png +0 -0
  11. data/assets/city_scene/clouds/partly_cloudy.png +0 -0
  12. data/assets/city_scene/clouds/stormy.png +0 -0
  13. data/assets/city_scene/grass/default.png +0 -0
  14. data/assets/city_scene/haze/true.png +0 -0
  15. data/assets/city_scene/number_sample/1.png +0 -0
  16. data/assets/city_scene/number_sample/2.png +0 -0
  17. data/assets/city_scene/number_sample/default.png +0 -0
  18. data/assets/city_scene/sky/0000.png +0 -0
  19. data/assets/city_scene/sky/0200.png +0 -0
  20. data/assets/city_scene/sky/0400.png +0 -0
  21. data/assets/city_scene/sky/0600.png +0 -0
  22. data/assets/city_scene/sky/0800.png +0 -0
  23. data/assets/city_scene/sky/1000.png +0 -0
  24. data/assets/city_scene/sky/1200.png +0 -0
  25. data/assets/city_scene/sky/1400.png +0 -0
  26. data/assets/city_scene/sky/1500.png +0 -0
  27. data/assets/city_scene/sky/1700.png +0 -0
  28. data/assets/city_scene/sky/2000.png +0 -0
  29. data/assets/pc306715.jpg +0 -0
  30. data/assets/plastik/blue.png +0 -0
  31. data/assets/plastik/green.png +0 -0
  32. data/assets/plastik/red.png +0 -0
  33. data/init.rb +2 -0
  34. data/lib/gruff.rb +28 -0
  35. data/lib/gruff/accumulator_bar.rb +27 -0
  36. data/lib/gruff/area.rb +58 -0
  37. data/lib/gruff/bar.rb +87 -0
  38. data/lib/gruff/bar_conversion.rb +46 -0
  39. data/lib/gruff/base.rb +1123 -0
  40. data/lib/gruff/bullet.rb +109 -0
  41. data/lib/gruff/deprecated.rb +39 -0
  42. data/lib/gruff/dot.rb +113 -0
  43. data/lib/gruff/line.rb +135 -0
  44. data/lib/gruff/mini/bar.rb +37 -0
  45. data/lib/gruff/mini/legend.rb +109 -0
  46. data/lib/gruff/mini/pie.rb +36 -0
  47. data/lib/gruff/mini/side_bar.rb +35 -0
  48. data/lib/gruff/net.rb +140 -0
  49. data/lib/gruff/photo_bar.rb +100 -0
  50. data/lib/gruff/pie.rb +126 -0
  51. data/lib/gruff/scene.rb +209 -0
  52. data/lib/gruff/side_bar.rb +118 -0
  53. data/lib/gruff/side_stacked_bar.rb +77 -0
  54. data/lib/gruff/spider.rb +130 -0
  55. data/lib/gruff/stacked_area.rb +67 -0
  56. data/lib/gruff/stacked_bar.rb +57 -0
  57. data/lib/gruff/stacked_mixin.rb +23 -0
  58. data/rails_generators/gruff/gruff_generator.rb +63 -0
  59. data/rails_generators/gruff/templates/controller.rb +32 -0
  60. data/rails_generators/gruff/templates/functional_test.rb +24 -0
  61. data/test/gruff_test_case.rb +123 -0
  62. data/test/test_accumulator_bar.rb +50 -0
  63. data/test/test_area.rb +134 -0
  64. data/test/test_bar.rb +321 -0
  65. data/test/test_base.rb +8 -0
  66. data/test/test_bullet.rb +26 -0
  67. data/test/test_dot.rb +273 -0
  68. data/test/test_legend.rb +68 -0
  69. data/test/test_line.rb +556 -0
  70. data/test/test_mini_bar.rb +33 -0
  71. data/test/test_mini_pie.rb +26 -0
  72. data/test/test_mini_side_bar.rb +37 -0
  73. data/test/test_net.rb +230 -0
  74. data/test/test_photo.rb +41 -0
  75. data/test/test_pie.rb +154 -0
  76. data/test/test_scene.rb +100 -0
  77. data/test/test_side_bar.rb +29 -0
  78. data/test/test_sidestacked_bar.rb +89 -0
  79. data/test/test_spider.rb +216 -0
  80. data/test/test_stacked_area.rb +52 -0
  81. data/test/test_stacked_bar.rb +52 -0
  82. metadata +186 -0
@@ -0,0 +1,117 @@
1
+ == 0.3.6
2
+
3
+ * Fixed manifest to list dot graph [theirishpenguin]
4
+ * Fixed color cycling error [Gunnar Wolf]
5
+ * Handle case where a line graph data set only has one value [Ron Colwill]
6
+
7
+ == 0.3.5
8
+
9
+ * Added dot graph from Erik Andrejko
10
+
11
+ == 0.3.4
12
+
13
+ * Reverted DEBUG=true. Will add a check in the release process so this doesn't happen again.
14
+ * Future releases will end in an odd number for development (topfunky-gruff on GitHub) or even for production releases.
15
+
16
+ == 0.3.3
17
+
18
+ * Legend line wrapping [Mat Schaffer]
19
+ * Stacked area graph fixes [James Coglan]
20
+
21
+ == 0.3.2
22
+
23
+ * Include init.rb for use as a Rails plugin.
24
+
25
+ == 0.3.1
26
+
27
+ * Fixed missing bullet graph bug (experimental, will be in a future release).
28
+
29
+ == 0.3.0
30
+
31
+ * Fixed bug where pie graphs weren't drawing their label correctly.
32
+
33
+ == 0.2.9
34
+
35
+ * Patch to make SideBar accurate instead of stacked [Marik]
36
+ * Will be extracting net, pie, stacked, and side-stacked to separate gem
37
+ in next release.
38
+
39
+ == 0.2.8
40
+
41
+ * New accumulator bar graph (experimental)
42
+ * Better mini graphs
43
+ * Bug fixes
44
+
45
+ == 0.2.7
46
+
47
+ * Regenerated Manifest.txt
48
+ * Added scene sample to package
49
+ * Added mini side_bar (EXPERIMENTAL)
50
+ * Added @zero_degree option to Gruff::Pie so first slice can start somewhere other than 3 o'clock
51
+ * Increased size of numbers in Gruff::Mini::Pie
52
+ * Added legend_box_size accessor
53
+
54
+ == 0.2.6
55
+
56
+ * Fixed missing side_bar.rb in Manifest.txt
57
+
58
+ == 0.2.5
59
+
60
+ * New mini graph types (Experimental)
61
+ * Marker lines can be different color than text labels
62
+ * Theme definition cleanup
63
+
64
+ == 0.2.4
65
+
66
+ * Added option to hide line numbers
67
+ * Fixed code that was causing warnings
68
+
69
+ == 0.2.3
70
+
71
+ * Cleaned up measurements so the graph expands to fill the available space
72
+ * Added x-axis and y-axis label options
73
+
74
+ == 0.1.2
75
+
76
+ * minimum_value and maximum_value can be set after data() to manually scale the graph
77
+ * Fixed infinite loop bug when values are all equal
78
+ * Added experimental net and spider graphs
79
+ * Added non-linear scene graph for a simple interface to complex layered graphs
80
+ * Initial refactoring of tests
81
+ * A host of other bug fixes
82
+
83
+ == 0.0.8
84
+
85
+ * NEW Sidestacked Bar Graphs. [Alun Eyre]
86
+ * baseline_value larger than data will now show correctly. [Mike Perham]
87
+ * hide_dots and hide_lines are now options for line graphs.
88
+
89
+ == 0.0.6
90
+
91
+ * Fixed hang when no data is passed.
92
+
93
+ == 0.0.4
94
+
95
+ * Added bar graphs
96
+ * Added area graphs
97
+ * Added pie graphs
98
+ * Added render_image_background for using images as background on a theme
99
+ * Fixed small size legend centering issue
100
+ * Added initial line marker rounding to significant digits (Christian Winkler)
101
+ * Line graphs line width is scaled with number of points being drawn (Christian Winkler)
102
+
103
+ == 0.0.3
104
+
105
+ * Added option to draw line graphs without the lines (points only), thanks to Eric Hodel
106
+ * Removed font-minimum check so graphs look better at 300px width
107
+
108
+ == 0.0.2
109
+
110
+ * Fixed to_blob (thanks to Carlos Villela)
111
+ * Added bar graphs (initial functionality...will be enhanced)
112
+ * Removed rendered test output from gem
113
+
114
+ == 0.0.1
115
+
116
+ * Initial release.
117
+ * Line graphs only. Other graph styles coming soon.
@@ -0,0 +1,21 @@
1
+ Copyright (c) 2005-2008 Topfunky Corporation boss@topfunky.com
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
21
+
@@ -0,0 +1,81 @@
1
+ History.txt
2
+ MIT-LICENSE
3
+ Manifest.txt
4
+ README.txt
5
+ Rakefile
6
+ assets/bubble.png
7
+ assets/city_scene/background/0000.png
8
+ assets/city_scene/background/0600.png
9
+ assets/city_scene/background/2000.png
10
+ assets/city_scene/clouds/cloudy.png
11
+ assets/city_scene/clouds/partly_cloudy.png
12
+ assets/city_scene/clouds/stormy.png
13
+ assets/city_scene/grass/default.png
14
+ assets/city_scene/haze/true.png
15
+ assets/city_scene/number_sample/1.png
16
+ assets/city_scene/number_sample/2.png
17
+ assets/city_scene/number_sample/default.png
18
+ assets/city_scene/sky/0000.png
19
+ assets/city_scene/sky/0200.png
20
+ assets/city_scene/sky/0400.png
21
+ assets/city_scene/sky/0600.png
22
+ assets/city_scene/sky/0800.png
23
+ assets/city_scene/sky/1000.png
24
+ assets/city_scene/sky/1200.png
25
+ assets/city_scene/sky/1400.png
26
+ assets/city_scene/sky/1500.png
27
+ assets/city_scene/sky/1700.png
28
+ assets/city_scene/sky/2000.png
29
+ assets/pc306715.jpg
30
+ assets/plastik/blue.png
31
+ assets/plastik/green.png
32
+ assets/plastik/red.png
33
+ init.rb
34
+ lib/gruff.rb
35
+ lib/gruff/accumulator_bar.rb
36
+ lib/gruff/area.rb
37
+ lib/gruff/bar.rb
38
+ lib/gruff/bar_conversion.rb
39
+ lib/gruff/base.rb
40
+ lib/gruff/bullet.rb
41
+ lib/gruff/deprecated.rb
42
+ lib/gruff/dot.rb
43
+ lib/gruff/line.rb
44
+ lib/gruff/mini/bar.rb
45
+ lib/gruff/mini/legend.rb
46
+ lib/gruff/mini/pie.rb
47
+ lib/gruff/mini/side_bar.rb
48
+ lib/gruff/net.rb
49
+ lib/gruff/photo_bar.rb
50
+ lib/gruff/pie.rb
51
+ lib/gruff/scene.rb
52
+ lib/gruff/side_bar.rb
53
+ lib/gruff/side_stacked_bar.rb
54
+ lib/gruff/spider.rb
55
+ lib/gruff/stacked_area.rb
56
+ lib/gruff/stacked_bar.rb
57
+ lib/gruff/stacked_mixin.rb
58
+ rails_generators/gruff/gruff_generator.rb
59
+ rails_generators/gruff/templates/controller.rb
60
+ rails_generators/gruff/templates/functional_test.rb
61
+ test/gruff_test_case.rb
62
+ test/test_accumulator_bar.rb
63
+ test/test_area.rb
64
+ test/test_bar.rb
65
+ test/test_base.rb
66
+ test/test_bullet.rb
67
+ test/test_dot.rb
68
+ test/test_legend.rb
69
+ test/test_line.rb
70
+ test/test_mini_bar.rb
71
+ test/test_mini_pie.rb
72
+ test/test_mini_side_bar.rb
73
+ test/test_net.rb
74
+ test/test_photo.rb
75
+ test/test_pie.rb
76
+ test/test_scene.rb
77
+ test/test_side_bar.rb
78
+ test/test_sidestacked_bar.rb
79
+ test/test_spider.rb
80
+ test/test_stacked_area.rb
81
+ test/test_stacked_bar.rb
@@ -0,0 +1,40 @@
1
+ == Gruff Graphs
2
+
3
+ A library for making beautiful graphs.
4
+
5
+ == Samples
6
+
7
+ http://nubyonrails.com/pages/gruff
8
+
9
+ == Documentation
10
+
11
+ http://gruff.rubyforge.org
12
+
13
+ See the test suite in test/line_test.rb for examples.
14
+
15
+ == Rails Plugin
16
+
17
+ Gruff is easy to use with Rails.
18
+
19
+ gem install gruff
20
+ cd vendor/plugins && gem unpack gruff
21
+
22
+ == WARNING
23
+
24
+ This is beta-quality software. It works well according to my tests, but the API may change and other features will be added.
25
+
26
+ == Source
27
+
28
+ The source for this project is now kept at GitHub:
29
+
30
+ http://github.com/topfunky/gruff/tree/master
31
+
32
+ == CONTRIBUTE
33
+
34
+ Patches appreciated, especially if they are in Git format (with metadata so your name shows up in the commit logs).
35
+
36
+ Use these instructions:
37
+
38
+ http://gweezlebur.com/2008/2/1/so-you-want-to-contribute-to-merb-core-part-1
39
+
40
+ http://gweezlebur.com/2008/2/9/contributing-to-merb-part-2
@@ -0,0 +1,55 @@
1
+ require 'rubygems'
2
+ require 'hoe'
3
+ $:.unshift(File.dirname(__FILE__) + "/lib")
4
+ require 'gruff'
5
+
6
+ Hoe.new('Gruff', Gruff::VERSION) do |p|
7
+ p.name = "pfsc-gruff"
8
+ p.author = "Geoffrey Grosenbach"
9
+ p.description = "Beautiful graphs for one or multiple datasets. Can be used on websites or in documents."
10
+ p.email = 'boss@topfunky.com'
11
+ p.summary = "Beautiful graphs for one or multiple datasets."
12
+ p.url = "http://nubyonrails.com/pages/gruff"
13
+ p.clean_globs = ['test/output/*.png']
14
+ p.changes = p.paragraphs_of('History.txt', 0..1).join("\n\n")
15
+ p.remote_rdoc_dir = '' # Release to root
16
+ end
17
+
18
+ desc "Simple require on packaged files to make sure they are all there"
19
+ task :verify => :package do
20
+ # An error message will be displayed if files are missing
21
+ if system %(ruby -e "require 'pkg/gruff-#{Gruff::VERSION}/lib/gruff'")
22
+ puts "\nThe library files are present"
23
+ end
24
+ raise "\n*** Gruff::Base::DEBUG must be set to false for releases ***\n\n" if Gruff::Base::DEBUG
25
+ end
26
+
27
+ task :release => :verify
28
+
29
+ namespace :test do
30
+
31
+ desc "Run mini tests"
32
+ task :mini => :clean do
33
+ Dir['test/test_mini*'].each do |file|
34
+ system "ruby #{file}"
35
+ end
36
+
37
+ end
38
+
39
+ end
40
+
41
+ ##
42
+ # Catch unmatched tasks and run them as a unit test.
43
+ #
44
+ # Makes it possible to do
45
+ #
46
+ # rake pie
47
+ #
48
+ # To run the +test/test_pie+ and +test/test_mini_pie+ files.
49
+
50
+ rule '' do |t|
51
+ # Rake::Task["clean"].invoke
52
+ Dir["test/test_*#{t.name}*.rb"].each do |filename|
53
+ system "ruby #{filename}"
54
+ end
55
+ end
Binary file
Binary file
Binary file
Binary file
Binary file
data/init.rb ADDED
@@ -0,0 +1,2 @@
1
+ # For Rails
2
+ require 'gruff'
@@ -0,0 +1,28 @@
1
+ # Extra full path added to fix loading errors on some installations.
2
+
3
+ %w(
4
+ base
5
+ area
6
+ bar
7
+ line
8
+ dot
9
+ pie
10
+ spider
11
+ net
12
+ stacked_area
13
+ stacked_bar
14
+ side_stacked_bar
15
+ side_bar
16
+ accumulator_bar
17
+
18
+ scene
19
+
20
+ mini/legend
21
+ mini/bar
22
+ mini/pie
23
+ mini/side_bar
24
+ ).each do |filename|
25
+ require File.dirname(__FILE__) + "/gruff/#{filename}"
26
+ end
27
+
28
+ # TODO bullet
@@ -0,0 +1,27 @@
1
+ require File.dirname(__FILE__) + '/base'
2
+
3
+ ##
4
+ # A special bar graph that shows a single dataset as a set of
5
+ # stacked bars. The bottom bar shows the running total and
6
+ # the top bar shows the new value being added to the array.
7
+
8
+ class Gruff::AccumulatorBar < Gruff::StackedBar
9
+
10
+ def draw
11
+ raise(Gruff::IncorrectNumberOfDatasetsException) unless @data.length == 1
12
+
13
+ accumulator_array = []
14
+ index = 0
15
+
16
+ increment_array = @data.first[DATA_VALUES_INDEX].inject([]) {|memo, value|
17
+ memo << ((index > 0) ? (value + memo.max) : value)
18
+ accumulator_array << memo[index] - value
19
+ index += 1
20
+ memo
21
+ }
22
+ data "Accumulator", accumulator_array
23
+
24
+ super
25
+ end
26
+
27
+ end
@@ -0,0 +1,58 @@
1
+
2
+ require File.dirname(__FILE__) + '/base'
3
+
4
+ class Gruff::Area < Gruff::Base
5
+
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
56
+
57
+
58
+ end