googlecharts 1.5.3 → 1.5.4

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.5.3
1
+ 1.5.4
@@ -104,10 +104,6 @@ class Gchart
104
104
  def size=(size='300x200')
105
105
  @width, @height = size.split("x").map { |dimension| dimension.to_i }
106
106
  end
107
-
108
-
109
-
110
-
111
107
 
112
108
  def size
113
109
  "#{width}x#{height}"
@@ -208,6 +204,7 @@ class Gchart
208
204
  end
209
205
 
210
206
  unless axis_range
207
+ @calculated_axis_range = true
211
208
  @axis_range = ds.map{|mds| [mds[:min_value], mds[:max_value]]}
212
209
  if dimensions == 1 && (type.to_s != 'bar' || horizontal)
213
210
  tmp = axis_range.fetch(0, [])
@@ -460,21 +457,21 @@ class Gchart
460
457
  # a passed axis_range should look like:
461
458
  # [[10,100]] or [[10,100,4]] or [[10,100], [20,300]]
462
459
  # in the second example, 4 is the interval
463
- set = axis_range || datasets
460
+ if @calculated_axis_range
461
+ set = datasets
462
+ else
463
+ set = axis_range || datasets
464
+ end
464
465
  # in the case of a line graph, the first axis range should 1
465
466
  index_increase = type.to_s == 'line' ? 1 : 0
466
467
  if set && set.respond_to?(:each) && set.first.respond_to?(:each)
467
- 'chxr=' + datasets.enum_for(:each_with_index).map do |range, index|
468
- [(index + index_increase), (min_value || range.first), (max_value || range.last)].compact.uniq.join(',')
468
+ 'chxr=' + set.enum_for(:each_with_index).map do |range, index|
469
+ [(index + index_increase), (min_value || range.first), (max_value || range.last)].compact.join(',')
469
470
  end.join("|")
470
471
  else
471
472
  nil
472
473
  end
473
474
  end
474
-
475
-
476
-
477
-
478
475
 
479
476
  def set_geographical_area
480
477
  "chtm=#{geographical_area}"
@@ -2,7 +2,7 @@ module GchartInfo #:nodoc:
2
2
  module VERSION #:nodoc:
3
3
  MAJOR = 1
4
4
  MINOR = 5
5
- TINY = 3
5
+ TINY = 4
6
6
 
7
7
  STRING = [MAJOR, MINOR, TINY].join('.')
8
8
  end
@@ -44,7 +44,7 @@ describe "generating a default Gchart" do
44
44
  it "should use the simple encoding by default with auto max value" do
45
45
  # 9 is the max value in simple encoding, 26 being our max value the 2nd encoded value should be 9
46
46
  Gchart.line(:data => [0, 26]).should include('chd=s:A9')
47
- Gchart.line(:data => [0, 26], :max_value => 26).should == Gchart.line(:data => [0, 26])
47
+ Gchart.line(:data => [0, 26], :max_value => 26).should include('chxr=1,0,26')
48
48
  end
49
49
 
50
50
  it "should support simple encoding with and without max_value" do
@@ -118,6 +118,18 @@ describe "generating a default Gchart" do
118
118
  url.should include('chxr=1,85,593')
119
119
  end
120
120
 
121
+ it "should force the y range properly" do
122
+ url = Gchart.bar(:data => [1,1,1,1,1,1,1,1,6,2,1,1],
123
+ :axis_with_labels => 'x,y',
124
+ :min_value => 0,
125
+ :max_value => 16,
126
+ :axis_labels => [1.upto(12).to_a],
127
+ :axis_range => [[0,0],[0,16]],
128
+ :encoding => "text"
129
+ )
130
+ url.should include('chxr=0,0,16|1,0,16')
131
+ end
132
+
121
133
  it "should take in consideration the max value when creating a range" do
122
134
  data = [85,107,123,131,155,172,173,189,203,222,217,233,250,239,256,267,247,261,275,295,288,305,322,307,325,347,331,346,363,382,343,359,383,352,374,393,358,379,396,416,377,398,419,380,409,426,453,432,452,465,436,460,480,440,457,474,501,457,489,507,347,373,413,402,424,448,475,488,513,475,507,530,440,476,500,518,481,512,531,367,396,423,387,415,446,478,442,469,492,463,489,508,463,491,518,549,503,526,547,493,530,549,493,520,541,564,510,535,564,492,512,537,502,530,548,491,514,538,568,524,548,568,512,533,552,577,520,545,570,516,536,555,514,536,566,521,553,579,604,541,569,595,551,581,602,549,576,606,631,589,615,650,597,624,646,672,605,626,654,584,608,631,574,597,622,559,591,614,644,580,603,629,584,615,631,558,591,618,641,314,356,395,397,429,450,421,454,477,507,458,490,560,593]
123
135
  url = Gchart.line(:data => data, :axis_with_labels => 'x,y', :axis_labels => [(1.upto(24).to_a << 1)], :max_value => 700)
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: googlecharts
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.5.3
4
+ version: 1.5.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Matt Aimonetti
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2010-03-12 00:00:00 -05:00
12
+ date: 2010-03-17 00:00:00 -07:00
13
13
  default_executable:
14
14
  dependencies: []
15
15