gerbilcharts 0.1.7 → 0.1.8

Sign up to get free protection for your applications and to get access to all the features.
@@ -33,7 +33,7 @@ class MonotonousGraphModel < GraphModel
33
33
 
34
34
  @xrange.update x_val
35
35
 
36
- @xarr<<x_val
36
+ @xarr << x_val
37
37
 
38
38
  if @transformer
39
39
  trval = @transformer.xform(y_val)
@@ -63,8 +63,7 @@ class MonotonousGraphModel < GraphModel
63
63
  def count
64
64
  @xarr.size
65
65
  end
66
-
67
-
66
+
68
67
  def latest
69
68
  yield @xarr.last, @yarr.last
70
69
  end
@@ -17,22 +17,40 @@ class TimeSeriesGraphModel < MonotonousGraphModel
17
17
 
18
18
  # we add Timeval objects (those that respond to tv_sec)
19
19
  def add(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
+ super normalize_time_input(timeobj),val
25
21
  end
26
22
 
27
23
  # crop older than the given timestamp
28
24
  def crop_older(cutofftime)
29
- crop_at(cutofftime)
25
+ crop_at(normalize_time_input(cutofftime))
30
26
  end
31
27
 
32
28
  # just a check if we need time series
33
29
  def is_timeseries?
34
30
  return true
35
31
  end
32
+
33
+ # normalize input timestamp
34
+ def normalize_time_input(tin)
35
+ if tin.is_a? Time
36
+ return tin
37
+ elsif tin.is_a? Fixnum
38
+ return Time.at(tin)
39
+ elsif tin.is_a? Bignum
40
+ if tin > 0xffffffff
41
+ return Time.at(tin>>32)
42
+ else
43
+ return Time.at(tin)
44
+ end
45
+ end
46
+
47
+ return tin if tin.is_a? Time
48
+ return Time.at(tin) if tin.is_a? Fixnum
49
+ return Time.at(tin>>32) if tin.is_a? Bignum
50
+ raise "Timeseries graph model expects Time,Bignum,Fixnum to represent time"
51
+ end
52
+
53
+
36
54
 
37
55
  end
38
56
 
@@ -2,7 +2,7 @@ module GerbilCharts
2
2
  module VERSION #:nodoc:
3
3
  MAJOR = 0
4
4
  MINOR = 1
5
- TINY = 7
5
+ TINY = 8
6
6
 
7
7
  STRING = [MAJOR, MINOR, TINY].join('.')
8
8
  end
@@ -62,7 +62,7 @@ class TestChartsNoob < Test::Unit::TestCase
62
62
 
63
63
 
64
64
  # demo to reuse the model ina bar
65
- mybarchart = GerbilCharts::Charts::BarChart.new( :width => 450, :height => 200, :style => 'brushmetal.css')
65
+ mybarchart = GerbilCharts::Charts::BarChart.new( :width => 450, :height => 200, :style => 'brushmetal.css', :auto_tooltips => true)
66
66
  mybarchart.modelgroup=modelgroup
67
67
  mybarchart.render('/tmp/n_daily_traffic_bar.svg')
68
68
 
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.7
4
+ version: 0.1.8
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-08-17 00:00:00 +05:30
12
+ date: 2009-09-08 00:00:00 +05:30
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency