sparklines 0.4.3 → 0.4.4

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 (5) hide show
  1. data/CHANGELOG +14 -6
  2. data/Rakefile +6 -2
  3. data/lib/sparklines.rb +9 -5
  4. data/test/test_all.rb +21 -15
  5. metadata +1 -1
data/CHANGELOG CHANGED
@@ -1,30 +1,38 @@
1
- 0.4.2
1
+ == 0.4.4
2
+
3
+ * Fixed stddev rounding bug [Andrew Nutter-Upham]
4
+
5
+ == 0.4.3
6
+
7
+ * Minor change for use with Hoe.
8
+
9
+ == 0.4.2
2
10
 
3
11
  * Added standard deviation bars [Andrew Nutter-Upham]
4
12
 
5
- 0.4.1
13
+ == 0.4.1
6
14
 
7
15
  * Converted to Hoe for rakefile
8
16
  * Added whisker graph [Luke Francl]
9
17
  * General cleanup and bug fixes
10
18
  * Experimental label option
11
19
 
12
- 0.3.0
20
+ == 0.3.0
13
21
 
14
22
  * Changed to a Class for maintainability
15
23
  * All values are normalized (except pie)
16
24
  * A single value can be passed for the pie percentage (instead of an Array)
17
25
 
18
- 0.2.7
26
+ == 0.2.7
19
27
 
20
28
  * Fixed bug where last element of bar graph wouldn't go to the bottom [Esad Hajdarevic esad@esse.at]
21
29
 
22
- 0.2.5
30
+ == 0.2.5
23
31
 
24
32
  * Tests now use Test::Unit
25
33
  * Bar type added
26
34
 
27
- 0.2.1
35
+ == 0.2.1
28
36
 
29
37
  * Added line_color option for smooth graphs
30
38
  * Now available as a gem ('gem install sparklines') and as a rails generator ('gem install sparklines_generator')
data/Rakefile CHANGED
@@ -12,7 +12,11 @@ Hoe.new('Sparklines', Sparklines::VERSION) do |p|
12
12
  p.summary = "Tiny graphs."
13
13
  p.url = "http://nubyonrails.com/pages/sparklines"
14
14
  p.clean_globs = ['test/output/*']
15
- p.changes = "Cleanup project for better compliance with hoe release cycle."
16
-
15
+ p.remote_rdoc_dir = '' # Release to root
16
+ p.changes = p.paragraphs_of('CHANGELOG', 0..1).join("\n\n")
17
17
  # * extra_deps - An array of rubygem dependencies.
18
18
  end
19
+
20
+
21
+ desc "Release and publish documentation"
22
+ task :repubdoc => [:release, :publish_docs]
data/lib/sparklines.rb CHANGED
@@ -74,7 +74,7 @@ Licensed under the MIT license.
74
74
  =end
75
75
  class Sparklines
76
76
 
77
- VERSION = '0.4.3'
77
+ VERSION = '0.4.4'
78
78
 
79
79
  @@label_margin = 5.0
80
80
  @@pointsize = 10.0
@@ -513,11 +513,13 @@ class Sparklines
513
513
  private
514
514
 
515
515
  def normalize_data
516
- @maximum_value = @data.max
516
+ @minumum_value = @data.min
517
+ @maximum_value = @data.max
518
+ abs_min = @minumum_value.abs
517
519
  if @options[:type].to_s == 'pie'
518
520
  @norm_data = @data
519
521
  else
520
- @norm_data = @data.map { |value| value = (value.to_f / @maximum_value) * 100.0 }
522
+ @norm_data = @data.map { |value| value = (value+abs_min).to_f / (@maximum_value+abs_min) * 100.0 }
521
523
  end
522
524
  end
523
525
 
@@ -595,10 +597,12 @@ private
595
597
  #
596
598
  def drawstddevbox(width,height,color)
597
599
  mid=@norm_data.inject(0) {|sum,v| sum+=v}/@norm_data.size
598
- std_dev = standard_deviation(@norm_data)/100*height
600
+ std_dev = standard_deviation(@norm_data)
601
+ lower = (height - 3 - (mid-std_dev)/(101.0/(height-4)))
602
+ upper = (height - 3 - (mid+std_dev)/(101.0/(height-4)))
599
603
  @draw.stroke 'transparent'
600
604
  @draw.fill(color)
601
- @draw.rectangle(0, mid-std_dev, width, mid+std_dev)
605
+ @draw.rectangle(0, lower, width, upper)
602
606
  end
603
607
 
604
608
  def calculate_width(text)
data/test/test_all.rb CHANGED
@@ -144,27 +144,33 @@ class SparklinesTest < Test::Unit::TestCase
144
144
  end
145
145
 
146
146
  def test_standard_deviation
147
- # values = (1..100).map { |v| rand(100) }
148
- #
149
- # File.open("test.png","w+") do |f|
150
- # f.puts Sparklines.plot(
151
- # values,
152
- # :type => 'smooth',
153
- # :height => 100,
154
- # :line_color => '#666',
155
- # :has_std_dev => true,
156
- # :std_dev_color => '#efffef'
157
- # )
158
- # end
159
-
160
147
  quick_graph('standard_deviation', {
161
148
  :type => 'smooth',
162
149
  :height => 100,
163
150
  :line_color => '#666',
164
151
  :has_std_dev => true,
165
152
  :std_dev_color => '#cccccc'
166
- })
167
-
153
+ })
154
+ end
155
+
156
+ def test_standard_deviation_tall
157
+ quick_graph('standard_deviation_tall', {
158
+ :type => 'smooth',
159
+ :height => 300,
160
+ :line_color => '#666',
161
+ :has_std_dev => true,
162
+ :std_dev_color => '#cccccc'
163
+ })
164
+ end
165
+
166
+ def test_standard_deviation_short
167
+ quick_graph('standard_deviation_short', {
168
+ :type => 'smooth',
169
+ :height => 20,
170
+ :line_color => '#666',
171
+ :has_std_dev => true,
172
+ :std_dev_color => '#cccccc'
173
+ })
168
174
  end
169
175
 
170
176
  private
metadata CHANGED
@@ -3,7 +3,7 @@ rubygems_version: 0.9.0
3
3
  specification_version: 1
4
4
  name: sparklines
5
5
  version: !ruby/object:Gem::Version
6
- version: 0.4.3
6
+ version: 0.4.4
7
7
  date: 2007-06-15 00:00:00 -07:00
8
8
  summary: Tiny graphs.
9
9
  require_paths: