little_graphs 1.0.1 → 1.0.2

Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile CHANGED
@@ -1,5 +1,4 @@
1
1
  source 'http://rubygems.org'
2
2
  gemspec
3
- gem 'quick_magick'
4
3
  gem 'rspec'
5
4
 
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- little_graphs (0.0.0)
4
+ little_graphs (1.0.1)
5
5
  quick_magick
6
6
 
7
7
  GEM
@@ -23,5 +23,4 @@ PLATFORMS
23
23
 
24
24
  DEPENDENCIES
25
25
  little_graphs!
26
- quick_magick
27
26
  rspec
data/lib/little_graphs.rb CHANGED
@@ -9,13 +9,16 @@ class LittleGraphs
9
9
  end
10
10
 
11
11
  def draw(datapoints, filename = nil)
12
- if filename.nil? then filename = "new.jpeg" end
13
12
  coordinates = define_coordinates(datapoints)
14
13
 
15
14
  f = QuickMagick::Image::solid(@width, @height, :white)
16
15
  f.draw_polyline(coordinates, :fill => :white, :stroke => :blue)
17
16
 
18
- f.save(filename)
17
+ if filename.nil?
18
+ f.to_blob
19
+ else
20
+ f.save(filename)
21
+ end
19
22
  end
20
23
 
21
24
  def define_coordinates(datapoints)
@@ -38,7 +41,7 @@ class LittleGraphs
38
41
  height = @height - 5 # add a margin
39
42
  point_space = height/(datapoints.max - datapoints.min)
40
43
 
41
- datapoints.map { |datapoint| @height - datapoint * point_space }
44
+ datapoints.map { |datapoint| @height - datapoint * point_space - datapoints.min * point_space }
42
45
  end
43
46
 
44
47
  end
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = 'little_graphs'
3
- s.version = '1.0.1'
3
+ s.version = '1.0.2'
4
4
  s.date = '2012-10-15'
5
5
  s.summary = 'Sparklines'
6
6
  s.authors = ['J. Cheng']
@@ -33,7 +33,7 @@ describe LittleGraphs do
33
33
  it 'finds x,y coordinates for 1D array' do
34
34
  lg = LittleGraphs.new
35
35
  coords = lg.define_coordinates([1, 2, 3, 4, 5])
36
- #coords.should == [1,0, 10, 2, 20, 3, 30, 4, 40, 5]
36
+ coords.should == [5, 28, 25, 21, 45, 14, 65, 7, 85, 0]
37
37
  end
38
38
  end
39
39
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: little_graphs
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.1
4
+ version: 1.0.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: