topfunky-gruff 0.3.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (78) hide show
  1. data/History.txt +98 -0
  2. data/MIT-LICENSE +21 -0
  3. data/Manifest.txt +76 -0
  4. data/README.txt +40 -0
  5. data/Rakefile +54 -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 +83 -0
  38. data/lib/gruff/bar_conversion.rb +46 -0
  39. data/lib/gruff/base.rb +1073 -0
  40. data/lib/gruff/deprecated.rb +39 -0
  41. data/lib/gruff/line.rb +105 -0
  42. data/lib/gruff/mini/bar.rb +32 -0
  43. data/lib/gruff/mini/legend.rb +77 -0
  44. data/lib/gruff/mini/pie.rb +36 -0
  45. data/lib/gruff/mini/side_bar.rb +35 -0
  46. data/lib/gruff/net.rb +142 -0
  47. data/lib/gruff/photo_bar.rb +100 -0
  48. data/lib/gruff/pie.rb +124 -0
  49. data/lib/gruff/scene.rb +209 -0
  50. data/lib/gruff/side_bar.rb +114 -0
  51. data/lib/gruff/side_stacked_bar.rb +73 -0
  52. data/lib/gruff/spider.rb +130 -0
  53. data/lib/gruff/stacked_area.rb +66 -0
  54. data/lib/gruff/stacked_bar.rb +53 -0
  55. data/lib/gruff/stacked_mixin.rb +23 -0
  56. data/rails_generators/gruff/gruff_generator.rb +63 -0
  57. data/rails_generators/gruff/templates/controller.rb +32 -0
  58. data/rails_generators/gruff/templates/functional_test.rb +24 -0
  59. data/test/gruff_test_case.rb +123 -0
  60. data/test/test_accumulator_bar.rb +50 -0
  61. data/test/test_area.rb +134 -0
  62. data/test/test_bar.rb +283 -0
  63. data/test/test_base.rb +8 -0
  64. data/test/test_bullet.rb +26 -0
  65. data/test/test_legend.rb +71 -0
  66. data/test/test_line.rb +513 -0
  67. data/test/test_mini_bar.rb +32 -0
  68. data/test/test_mini_pie.rb +20 -0
  69. data/test/test_mini_side_bar.rb +37 -0
  70. data/test/test_net.rb +230 -0
  71. data/test/test_photo.rb +41 -0
  72. data/test/test_pie.rb +154 -0
  73. data/test/test_scene.rb +100 -0
  74. data/test/test_side_bar.rb +12 -0
  75. data/test/test_sidestacked_bar.rb +89 -0
  76. data/test/test_spider.rb +216 -0
  77. data/test/test_stacked_bar.rb +52 -0
  78. metadata +157 -0
@@ -0,0 +1,98 @@
1
+ == 0.3.2
2
+
3
+ * Include init.rb for use as a Rails plugin.
4
+
5
+
6
+ == 0.3.1
7
+
8
+ * Fixed missing bullet graph bug (experimental, will be in a future release).
9
+
10
+ == 0.3.0
11
+
12
+ * Fixed bug where pie graphs weren't drawing their label correctly.
13
+
14
+ == 0.2.9
15
+
16
+ * Patch to make SideBar accurate instead of stacked [Marik]
17
+ * Will be extracting net, pie, stacked, and side-stacked to separate gem
18
+ in next release.
19
+
20
+ == 0.2.8
21
+
22
+ * New accumulator bar graph (experimental)
23
+ * Better mini graphs
24
+ * Bug fixes
25
+
26
+ == 0.2.7
27
+
28
+ * Regenerated Manifest.txt
29
+ * Added scene sample to package
30
+ * Added mini side_bar (EXPERIMENTAL)
31
+ * Added @zero_degree option to Gruff::Pie so first slice can start somewhere other than 3 o'clock
32
+ * Increased size of numbers in Gruff::Mini::Pie
33
+ * Added legend_box_size accessor
34
+
35
+ == 0.2.6
36
+
37
+ * Fixed missing side_bar.rb in Manifest.txt
38
+
39
+ == 0.2.5
40
+
41
+ * New mini graph types (Experimental)
42
+ * Marker lines can be different color than text labels
43
+ * Theme definition cleanup
44
+
45
+ == 0.2.4
46
+
47
+ * Added option to hide line numbers
48
+ * Fixed code that was causing warnings
49
+
50
+ == 0.2.3
51
+
52
+ * Cleaned up measurements so the graph expands to fill the available space
53
+ * Added x-axis and y-axis label options
54
+
55
+ == 0.1.2
56
+
57
+ * minimum_value and maximum_value can be set after data() to manually scale the graph
58
+ * Fixed infinite loop bug when values are all equal
59
+ * Added experimental net and spider graphs
60
+ * Added non-linear scene graph for a simple interface to complex layered graphs
61
+ * Initial refactoring of tests
62
+ * A host of other bug fixes
63
+
64
+ == 0.0.8
65
+
66
+ * NEW Sidestacked Bar Graphs. [Alun Eyre]
67
+ * baseline_value larger than data will now show correctly. [Mike Perham]
68
+ * hide_dots and hide_lines are now options for line graphs.
69
+
70
+ == 0.0.6
71
+
72
+ * Fixed hang when no data is passed.
73
+
74
+ == 0.0.4
75
+
76
+ * Added bar graphs
77
+ * Added area graphs
78
+ * Added pie graphs
79
+ * Added render_image_background for using images as background on a theme
80
+ * Fixed small size legend centering issue
81
+ * Added initial line marker rounding to significant digits (Christian Winkler)
82
+ * Line graphs line width is scaled with number of points being drawn (Christian Winkler)
83
+
84
+ == 0.0.3
85
+
86
+ * Added option to draw line graphs without the lines (points only), thanks to Eric Hodel
87
+ * Removed font-minimum check so graphs look better at 300px width
88
+
89
+ == 0.0.2
90
+
91
+ * Fixed to_blob (thanks to Carlos Villela)
92
+ * Added bar graphs (initial functionality...will be enhanced)
93
+ * Removed rendered test output from gem
94
+
95
+ == 0.0.1
96
+
97
+ * Initial release.
98
+ * Line graphs only. Other graph styles coming soon.
@@ -0,0 +1,21 @@
1
+ Copyright (c) 2005 Geoffrey Grosenbach 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,76 @@
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/deprecated.rb
41
+ lib/gruff/line.rb
42
+ lib/gruff/mini/bar.rb
43
+ lib/gruff/mini/legend.rb
44
+ lib/gruff/mini/pie.rb
45
+ lib/gruff/mini/side_bar.rb
46
+ lib/gruff/net.rb
47
+ lib/gruff/photo_bar.rb
48
+ lib/gruff/pie.rb
49
+ lib/gruff/scene.rb
50
+ lib/gruff/side_bar.rb
51
+ lib/gruff/side_stacked_bar.rb
52
+ lib/gruff/spider.rb
53
+ lib/gruff/stacked_area.rb
54
+ lib/gruff/stacked_bar.rb
55
+ lib/gruff/stacked_mixin.rb
56
+ rails_generators/gruff/gruff_generator.rb
57
+ rails_generators/gruff/templates/controller.rb
58
+ rails_generators/gruff/templates/functional_test.rb
59
+ test/gruff_test_case.rb
60
+ test/test_accumulator_bar.rb
61
+ test/test_area.rb
62
+ test/test_bar.rb
63
+ test/test_base.rb
64
+ test/test_legend.rb
65
+ test/test_line.rb
66
+ test/test_mini_bar.rb
67
+ test/test_mini_pie.rb
68
+ test/test_mini_side_bar.rb
69
+ test/test_net.rb
70
+ test/test_photo.rb
71
+ test/test_pie.rb
72
+ test/test_scene.rb
73
+ test/test_side_bar.rb
74
+ test/test_sidestacked_bar.rb
75
+ test/test_spider.rb
76
+ 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,54 @@
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
+ end
25
+
26
+ task :release => :verify
27
+
28
+ namespace :test do
29
+
30
+ desc "Run mini tests"
31
+ task :mini => :clean do
32
+ Dir['test/test_mini*'].each do |file|
33
+ system "ruby #{file}"
34
+ end
35
+
36
+ end
37
+
38
+ end
39
+
40
+ ##
41
+ # Catch unmatched tasks and run them as a unit test.
42
+ #
43
+ # Makes it possible to do
44
+ #
45
+ # rake pie
46
+ #
47
+ # To run the +test/test_pie+ and +test/test_mini_pie+ files.
48
+
49
+ rule '' do |t|
50
+ # Rake::Task["clean"].invoke
51
+ Dir["test/test_*#{t.name}*.rb"].each do |filename|
52
+ system "ruby #{filename}"
53
+ end
54
+ 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[1].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