gerbilcharts 0.1.6 → 0.1.7

Sign up to get free protection for your applications and to get access to all the features.
data/History.txt CHANGED
@@ -1,3 +1,7 @@
1
+ == 0.0.7 2009-08-15
2
+ * Changes
3
+ * Bug fixes with stacked area
4
+
1
5
  == 0.0.5 2009-06-05
2
6
  * Changes
3
7
  * Support render_to_string to inline render in browser
@@ -109,9 +109,7 @@ class GraphModelGroup
109
109
  # rounds both x and y scales, returns two ranges
110
110
  def effective_round_range
111
111
 
112
- if @models.length==0
113
- return 0,0
114
- end
112
+ return 0,0 if @models.empty?
115
113
 
116
114
  reffx = RawRange.new
117
115
  reffy = RawRange.new
@@ -127,11 +125,19 @@ class GraphModelGroup
127
125
 
128
126
  # round the x ranges of all models
129
127
  def effective_round_range_x
128
+
129
+ return 0,0 if @models.empty?
130
130
 
131
131
  reffx = RawRange.new
132
132
  @models.each do |m|
133
133
  reffx.update_r(m.xrange)
134
134
  end
135
+
136
+ if reffx.invalid?
137
+ reffx.update 10
138
+ end
139
+
140
+
135
141
  return models[0].round_given_x(reffx)
136
142
  end
137
143
 
@@ -162,7 +168,7 @@ class GraphModelGroup
162
168
  reffy = RawRange.new
163
169
  reffy.zeromin
164
170
  @models.each do |m|
165
- reffy.update_r(m.yrange)
171
+ reffy.update_r(m.yrange)
166
172
  end
167
173
  return @models[0].round_given_y(reffy)
168
174
  end
@@ -179,6 +185,9 @@ class GraphModelGroup
179
185
 
180
186
  # sum of model ranges with min y being 0
181
187
  def cumulative_round_range_y0
188
+
189
+ return 0,100 if models.empty?
190
+
182
191
  reffy = RawRange.new
183
192
  reffy.update(0)
184
193
  @models.each do |m|
@@ -215,9 +224,7 @@ class GraphModelGroup
215
224
 
216
225
  def cumulative_round_range
217
226
 
218
- if @models.length==0
219
- return 0,0
220
- end
227
+ return 0,0 if @models.empty?
221
228
 
222
229
  reffx = RawRange.new
223
230
  reffy = RawRange.new
@@ -78,7 +78,7 @@ class MonotonousGraphModel < GraphModel
78
78
  end
79
79
 
80
80
  def latest_x_dbtime
81
- return @xarr.last<<32
81
+ return (@xarr.last.tv_sec) << 32
82
82
  end
83
83
 
84
84
  def first
@@ -10,13 +10,19 @@ class RawRange < Presets
10
10
  def initialize
11
11
  @rmax,@rmin=nil,nil
12
12
  end
13
+
14
+ def invalid?
15
+ @rmin.nil?
16
+ end
13
17
 
14
18
  # update - updates the range
15
19
  # newval - new incoming value
16
20
  #
17
21
  def update(newval)
18
- @rmax=newval if @rmax.nil? or newval > @rmax
19
- @rmin=newval if @rmin.nil? or newval < @rmin
22
+ if not newval.nil?
23
+ @rmax=newval if @rmax.nil? or newval > @rmax
24
+ @rmin=newval if @rmin.nil? or newval < @rmin
25
+ end
20
26
  end
21
27
 
22
28
  # update - updates the range (using another range)
@@ -10,9 +10,9 @@ class RoundRange < RawRange
10
10
  # given a raw range, we calculate a round range
11
11
  def initialize(raw_range)
12
12
  super()
13
- @rmin=round_min(raw_range.rmin)
14
- @rmax=round_max(raw_range.rmax)
15
- @lmax=label_step
13
+ @rmin=round_min(raw_range.rmin) if not raw_range.rmin.nil?
14
+ @rmax=round_max(raw_range.rmax) if not raw_range.rmax.nil?
15
+ @lmax=label_step if not raw_range.rmax.nil?
16
16
  end
17
17
 
18
18
  # provide labels
@@ -24,6 +24,8 @@ class RoundRange < RawRange
24
24
  # end
25
25
  #
26
26
  def each_label
27
+
28
+ return if not @lmax
27
29
 
28
30
  raise "Range not aligned with presets (call round range first)" if not @lmax
29
31
  raise "No data points in model" if @rmax == -1
@@ -73,6 +73,11 @@ class SampledTimeSeriesGraphModel < TimeSeriesGraphModel
73
73
  def bucket_diff(tv1,tv2)
74
74
  return (tv2-tv1).abs / @bucketsize
75
75
  end
76
+
77
+ def bucket_size_secs
78
+ return @bucketsize
79
+ end
80
+
76
81
 
77
82
  end
78
83
 
@@ -15,8 +15,13 @@ class TimeSeriesGraphModel < MonotonousGraphModel
15
15
  @roundery=RoundRange
16
16
  end
17
17
 
18
+ # we add Timeval objects (those that respond to tv_sec)
18
19
  def add(timeobj, val)
19
- super timeobj, val
20
+ if timeobj.is_a? Time
21
+ super timeobj, val
22
+ elsif timeobj.is_a? Fixnum
23
+ super Time.at(timeobj),val
24
+ end
20
25
  end
21
26
 
22
27
  # crop older than the given timestamp
@@ -9,6 +9,8 @@ class Grid < GraphElement
9
9
  end
10
10
 
11
11
  def int_render(g)
12
+ return
13
+
12
14
  ry = grid_range_y
13
15
  ry.each_label do |val,label|
14
16
  yp = scale_y val,ry
@@ -13,7 +13,7 @@ class Tracker < GraphElement
13
13
 
14
14
  def int_render(dc)
15
15
 
16
- dc.addshape(SVGCustomWin.new("GerbilTracker",self))
16
+ dc.addshape(GerbilCharts::SVGDC::SVGCustomWin.new("GerbilTracker",self))
17
17
 
18
18
  end
19
19
 
@@ -2,7 +2,7 @@ module GerbilCharts
2
2
  module VERSION #:nodoc:
3
3
  MAJOR = 0
4
4
  MINOR = 1
5
- TINY = 6
5
+ TINY = 7
6
6
 
7
7
  STRING = [MAJOR, MINOR, TINY].join('.')
8
8
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gerbilcharts
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.6
4
+ version: 0.1.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Vivek Rajagopalan
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-06-09 00:00:00 +05:30
12
+ date: 2009-08-17 00:00:00 +05:30
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
@@ -20,7 +20,7 @@ dependencies:
20
20
  requirements:
21
21
  - - ">="
22
22
  - !ruby/object:Gem::Version
23
- version: 1.8.0
23
+ version: 2.3.3
24
24
  version:
25
25
  description: SVG based charting library for timeseries data
26
26
  email: