woodhull-gruff 0.3.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (80) hide show
  1. data/History.txt +111 -0
  2. data/MIT-LICENSE +21 -0
  3. data/Manifest.txt +79 -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 +27 -0
  35. data/lib/gruff/accumulator_bar.rb +27 -0
  36. data/lib/gruff/area.rb +58 -0
  37. data/lib/gruff/bar.rb +84 -0
  38. data/lib/gruff/bar_conversion.rb +46 -0
  39. data/lib/gruff/base.rb +1116 -0
  40. data/lib/gruff/bullet.rb +109 -0
  41. data/lib/gruff/deprecated.rb +39 -0
  42. data/lib/gruff/line.rb +105 -0
  43. data/lib/gruff/mini/bar.rb +32 -0
  44. data/lib/gruff/mini/legend.rb +77 -0
  45. data/lib/gruff/mini/pie.rb +36 -0
  46. data/lib/gruff/mini/side_bar.rb +35 -0
  47. data/lib/gruff/net.rb +142 -0
  48. data/lib/gruff/photo_bar.rb +100 -0
  49. data/lib/gruff/pie.rb +124 -0
  50. data/lib/gruff/scene.rb +209 -0
  51. data/lib/gruff/side_bar.rb +115 -0
  52. data/lib/gruff/side_stacked_bar.rb +74 -0
  53. data/lib/gruff/spider.rb +130 -0
  54. data/lib/gruff/stacked_area.rb +67 -0
  55. data/lib/gruff/stacked_bar.rb +54 -0
  56. data/lib/gruff/stacked_mixin.rb +23 -0
  57. data/rails_generators/gruff/gruff_generator.rb +63 -0
  58. data/rails_generators/gruff/templates/controller.rb +32 -0
  59. data/rails_generators/gruff/templates/functional_test.rb +24 -0
  60. data/test/gruff_test_case.rb +123 -0
  61. data/test/test_accumulator_bar.rb +50 -0
  62. data/test/test_area.rb +134 -0
  63. data/test/test_bar.rb +283 -0
  64. data/test/test_base.rb +8 -0
  65. data/test/test_bullet.rb +26 -0
  66. data/test/test_legend.rb +68 -0
  67. data/test/test_line.rb +513 -0
  68. data/test/test_mini_bar.rb +32 -0
  69. data/test/test_mini_pie.rb +20 -0
  70. data/test/test_mini_side_bar.rb +37 -0
  71. data/test/test_net.rb +230 -0
  72. data/test/test_photo.rb +41 -0
  73. data/test/test_pie.rb +154 -0
  74. data/test/test_scene.rb +100 -0
  75. data/test/test_side_bar.rb +12 -0
  76. data/test/test_sidestacked_bar.rb +89 -0
  77. data/test/test_spider.rb +216 -0
  78. data/test/test_stacked_area.rb +52 -0
  79. data/test/test_stacked_bar.rb +52 -0
  80. metadata +160 -0
@@ -0,0 +1,111 @@
1
+ == 0.3.5
2
+
3
+ * ???
4
+
5
+ == 0.3.4
6
+
7
+ * Reverted DEBUG=true. Will add a check in the release process so this doesn't happen again.
8
+ * Future releases will end in an odd number for development (topfunky-gruff on GitHub) or even for production releases.
9
+
10
+ == 0.3.3
11
+
12
+ * Legend line wrapping [Mat Schaffer]
13
+ * Stacked area graph fixes [James Coglan]
14
+
15
+ == 0.3.2
16
+
17
+ * Include init.rb for use as a Rails plugin.
18
+
19
+ == 0.3.1
20
+
21
+ * Fixed missing bullet graph bug (experimental, will be in a future release).
22
+
23
+ == 0.3.0
24
+
25
+ * Fixed bug where pie graphs weren't drawing their label correctly.
26
+
27
+ == 0.2.9
28
+
29
+ * Patch to make SideBar accurate instead of stacked [Marik]
30
+ * Will be extracting net, pie, stacked, and side-stacked to separate gem
31
+ in next release.
32
+
33
+ == 0.2.8
34
+
35
+ * New accumulator bar graph (experimental)
36
+ * Better mini graphs
37
+ * Bug fixes
38
+
39
+ == 0.2.7
40
+
41
+ * Regenerated Manifest.txt
42
+ * Added scene sample to package
43
+ * Added mini side_bar (EXPERIMENTAL)
44
+ * Added @zero_degree option to Gruff::Pie so first slice can start somewhere other than 3 o'clock
45
+ * Increased size of numbers in Gruff::Mini::Pie
46
+ * Added legend_box_size accessor
47
+
48
+ == 0.2.6
49
+
50
+ * Fixed missing side_bar.rb in Manifest.txt
51
+
52
+ == 0.2.5
53
+
54
+ * New mini graph types (Experimental)
55
+ * Marker lines can be different color than text labels
56
+ * Theme definition cleanup
57
+
58
+ == 0.2.4
59
+
60
+ * Added option to hide line numbers
61
+ * Fixed code that was causing warnings
62
+
63
+ == 0.2.3
64
+
65
+ * Cleaned up measurements so the graph expands to fill the available space
66
+ * Added x-axis and y-axis label options
67
+
68
+ == 0.1.2
69
+
70
+ * minimum_value and maximum_value can be set after data() to manually scale the graph
71
+ * Fixed infinite loop bug when values are all equal
72
+ * Added experimental net and spider graphs
73
+ * Added non-linear scene graph for a simple interface to complex layered graphs
74
+ * Initial refactoring of tests
75
+ * A host of other bug fixes
76
+
77
+ == 0.0.8
78
+
79
+ * NEW Sidestacked Bar Graphs. [Alun Eyre]
80
+ * baseline_value larger than data will now show correctly. [Mike Perham]
81
+ * hide_dots and hide_lines are now options for line graphs.
82
+
83
+ == 0.0.6
84
+
85
+ * Fixed hang when no data is passed.
86
+
87
+ == 0.0.4
88
+
89
+ * Added bar graphs
90
+ * Added area graphs
91
+ * Added pie graphs
92
+ * Added render_image_background for using images as background on a theme
93
+ * Fixed small size legend centering issue
94
+ * Added initial line marker rounding to significant digits (Christian Winkler)
95
+ * Line graphs line width is scaled with number of points being drawn (Christian Winkler)
96
+
97
+ == 0.0.3
98
+
99
+ * Added option to draw line graphs without the lines (points only), thanks to Eric Hodel
100
+ * Removed font-minimum check so graphs look better at 300px width
101
+
102
+ == 0.0.2
103
+
104
+ * Fixed to_blob (thanks to Carlos Villela)
105
+ * Added bar graphs (initial functionality...will be enhanced)
106
+ * Removed rendered test output from gem
107
+
108
+ == 0.0.1
109
+
110
+ * Initial release.
111
+ * 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,79 @@
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/line.rb
43
+ lib/gruff/mini/bar.rb
44
+ lib/gruff/mini/legend.rb
45
+ lib/gruff/mini/pie.rb
46
+ lib/gruff/mini/side_bar.rb
47
+ lib/gruff/net.rb
48
+ lib/gruff/photo_bar.rb
49
+ lib/gruff/pie.rb
50
+ lib/gruff/scene.rb
51
+ lib/gruff/side_bar.rb
52
+ lib/gruff/side_stacked_bar.rb
53
+ lib/gruff/spider.rb
54
+ lib/gruff/stacked_area.rb
55
+ lib/gruff/stacked_bar.rb
56
+ lib/gruff/stacked_mixin.rb
57
+ rails_generators/gruff/gruff_generator.rb
58
+ rails_generators/gruff/templates/controller.rb
59
+ rails_generators/gruff/templates/functional_test.rb
60
+ test/gruff_test_case.rb
61
+ test/test_accumulator_bar.rb
62
+ test/test_area.rb
63
+ test/test_bar.rb
64
+ test/test_base.rb
65
+ test/test_bullet.rb
66
+ test/test_legend.rb
67
+ test/test_line.rb
68
+ test/test_mini_bar.rb
69
+ test/test_mini_pie.rb
70
+ test/test_mini_side_bar.rb
71
+ test/test_net.rb
72
+ test/test_photo.rb
73
+ test/test_pie.rb
74
+ test/test_scene.rb
75
+ test/test_side_bar.rb
76
+ test/test_sidestacked_bar.rb
77
+ test/test_spider.rb
78
+ test/test_stacked_area.rb
79
+ 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 = "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,27 @@
1
+ # Extra full path added to fix loading errors on some installations.
2
+
3
+ %w(
4
+ base
5
+ area
6
+ bar
7
+ line
8
+ pie
9
+ spider
10
+ net
11
+ stacked_area
12
+ stacked_bar
13
+ side_stacked_bar
14
+ side_bar
15
+ accumulator_bar
16
+
17
+ scene
18
+
19
+ mini/legend
20
+ mini/bar
21
+ mini/pie
22
+ mini/side_bar
23
+ ).each do |filename|
24
+ require File.dirname(__FILE__) + "/gruff/#{filename}"
25
+ end
26
+
27
+ # 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