gerbilcharts 0.7.4 → 0.8.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 2d029786a988fb9db2da4f048c2aaf142e34dbc5
4
+ data.tar.gz: dfb2ae9401f4e592b87cf400216c209af55212b7
5
+ SHA512:
6
+ metadata.gz: 3de4722ffee541a1c66559e933c28dd9ac48b341517ea3e557208c6a035ba77cf8b8eeaf748389a118af18fe5c75d08dbe237c5d16e7216569ee5457ca79b120
7
+ data.tar.gz: 57297f9eca55aeb093caabc91df9059a97e399ab98ed95f877c9135236bc6833a3d066dbb11adb0ef2689eb2beae9398a7e55839f5f7bf63bcfb4f519a140562
@@ -14,12 +14,18 @@ class BucketizedTimeSeriesGraphModel < TimeSeriesGraphModel
14
14
  attr_reader :behavior # :average or :max or :sum
15
15
  attr_reader :last_sweep_pos # :nodoc:
16
16
 
17
- def initialize(name,bucketsec, opt={:behavior => :average})
17
+ def initialize(name,bucketsec, opt={:behavior => :average, :vartype => :bits_per_sec })
18
18
  super(name,opt)
19
19
  @bucket_size_secs=bucketsec
20
20
  @samp_count =0
21
21
  @behavior = opt[:behavior]
22
22
  @last_sweep_pos=0
23
+ @aggregation_factor = case opt[:vartype]
24
+ when :bits_per_sec ; @bucket_size_secs / 8.0
25
+ when :per_sec ; @bucket_size_secs
26
+ when :counter ; 1.0
27
+ else ; @bucket_size_secs / 8.0
28
+ end
23
29
  end
24
30
 
25
31
  def sweep_interval
@@ -10,6 +10,7 @@ class MonotonousGraphModel < GraphModel
10
10
  attr_reader :yarr # the y values
11
11
  attr_reader :xrange,:yrange # raw ranges
12
12
  attr_reader :rounderx, :roundery # rounded ranges according to presets
13
+ attr_reader :aggregation_factor # how to aggregate? bits/bytes*bucketsize
13
14
 
14
15
  def initialize(name,opt={})
15
16
  super(name)
@@ -19,6 +20,7 @@ class MonotonousGraphModel < GraphModel
19
20
  @roundery = RoundRange
20
21
  @xarr=[]
21
22
  @yarr=[]
23
+ @aggregation_factor=1
22
24
  end
23
25
 
24
26
  # add a tuple, apply a transformer lambda is supplied by the user
@@ -159,7 +161,7 @@ class MonotonousGraphModel < GraphModel
159
161
  # todo : 5 = stddev
160
162
  # todo : support :ninety_fifth
161
163
  #
162
- def get_statistical_analysis(mode = :normal)
164
+ def get_statistical_analysis()
163
165
  return [0,0,0,0,0] if @yarr.size==0
164
166
 
165
167
  a = []
@@ -170,6 +172,7 @@ class MonotonousGraphModel < GraphModel
170
172
  @yarr.each do |v|
171
173
  a[3] = a[3] + v
172
174
  end
175
+ a[3] = a[3] * @aggregation_factor
173
176
  a[2] = a[3]/@yarr.size
174
177
  a[4] = latest_val
175
178
  return a
@@ -12,8 +12,8 @@ module GerbilCharts::Surfaces
12
12
  class BubbleSurface < Surface
13
13
 
14
14
  BUBGRAINS = [1e+9,1e+8,1e+7,1000000,100000,10000,1000,100,10,1]
15
- SHAPESZ = [40, 36, 35, 34, 31, 30, 20, 16, 12,8]
16
- RSCALE = 0.50
15
+ SHAPESZ = [60, 55, 50, 45, 40, 35, 30 , 25, 20,8]
16
+ SHAPETXT = ['1G', '100M', '10M', '1M', '100K', '10K', '1K' , '100', '10', '']
17
17
 
18
18
  def initialize(opts={})
19
19
  super(opts)
@@ -51,6 +51,7 @@ class BubbleSurface < Surface
51
51
  rbub.translate_x xpos
52
52
 
53
53
  parent.modelgroup.each_model_with_index do | mod, i|
54
+
54
55
  val = mod.sweep(sweep_pos)
55
56
  allshapes << valtocircles(val)
56
57
  end
@@ -66,7 +67,9 @@ class BubbleSurface < Surface
66
67
 
67
68
 
68
69
  ai.each do |shp|
69
- shp.x = rbub.left + rand*(rbub.width)
70
+ shp.x = rbub.left + rand(50)
71
+ shp.x = rbub.left+10 if shp.x < rbub.left
72
+ shp.x = rbub.right-10 if shp.x > rbub.right
70
73
  shp.y = rbub.bottom - rand*(rbub.height*0.75)
71
74
  g.addshape(shp, opts)
72
75
  end
@@ -84,14 +87,13 @@ class BubbleSurface < Surface
84
87
  splitup=BUBGRAINS.collect do |grain_size|
85
88
  n=(val/grain_size)
86
89
  val = val%grain_size
87
- (n*RSCALE).to_i
90
+ n.to_i
88
91
  end
89
92
 
90
-
91
93
  ret=[]
92
94
  shapes=SHAPESZ.each_with_index do |s,i|
93
95
  splitup[i].times do |t|
94
- ret << GerbilCharts::SVGDC::SVGCircle.new(0, 0, s)
96
+ ret << GerbilCharts::SVGDC::SVGCircleText.new(0, 0, s, SHAPETXT[i] )
95
97
  end
96
98
  end
97
99
 
@@ -4,8 +4,8 @@ module GerbilCharts::Surfaces
4
4
  # legend panel shows names/colors of items in a separate box (transparent)
5
5
  class DetailedLegend < GraphElement
6
6
 
7
- WIDTH_MAX = 500
8
- STAT_TABLE_OFFSET=120
7
+ WIDTH_MAX = 600
8
+ STAT_TABLE_SIZE=300
9
9
 
10
10
  attr_reader :width
11
11
  attr_reader :showvalues
@@ -62,7 +62,7 @@ class DetailedLegend < GraphElement
62
62
  rbox.bottom = rbox.top+10
63
63
 
64
64
 
65
- stat_label_pos = rbox.right + STAT_TABLE_OFFSET
65
+ stat_label_pos = @bounds.right - STAT_TABLE_SIZE
66
66
  lab = %w(Max Min Avg Latest Total).inject("") { |m,ai| m += ai.rjust(9)}
67
67
  if @show_stats
68
68
  g.textout(stat_label_pos, rbox.bottom-2, lab, {'xml:space' => 'preserve', :class => "legendstats"} )
@@ -83,17 +83,17 @@ class DetailedLegend < GraphElement
83
83
  boxopts = { :id => "item#{i}" }
84
84
  boxopts.store(:fill , color_for_id(i)) if i > 10
85
85
  g.rectangle_r(rbox, boxopts )
86
- g.textout(rbox.right+5, rbox.bottom-2, mod.name,opts)
86
+ g.textout(rbox.right+5, rbox.bottom-2, mod.name.slice(0..40),opts)
87
87
 
88
88
  stat_ana = mod.get_statistical_analysis
89
- bucketsize = mod.respond_to?(:bucket_size_secs)? mod.bucket_size_secs: 1
89
+ bucketsize = mod.respond_to?(:bucket_size_secs)? mod.bucket_size_secs: 8
90
+
90
91
 
91
- stat_label_pos = rbox.right + STAT_TABLE_OFFSET
92
92
  outs = mod.formatted_val(stat_ana[1]).to_s.rjust(9) +
93
93
  mod.formatted_val(stat_ana[0]).to_s.rjust(9) +
94
94
  mod.formatted_val(stat_ana[2]).to_s.rjust(9) +
95
95
  mod.formatted_val(stat_ana[4]).to_s.rjust(9) +
96
- fmt_prefix_2(stat_ana[3]*bucketsize/8).to_s.rjust(9)
96
+ fmt_prefix_2(stat_ana[3]).to_s.rjust(9)
97
97
  if @show_stats
98
98
  g.textout(stat_label_pos, rbox.bottom-2, outs, {'xml:space' => 'preserve', :class => 'legendstats'} )
99
99
  end
@@ -19,4 +19,23 @@ class SVGCircle < SVGShape
19
19
 
20
20
  end
21
21
 
22
+
23
+ class SVGCircleText < SVGCircle
24
+
25
+ attr_accessor :txt
26
+
27
+ def initialize(x,y,r,text)
28
+ super(x,y,r)
29
+ @txt=text
30
+ end
31
+
32
+ def render(xfrag)
33
+ super(xfrag)
34
+ h = { "text-anchor" => "middle" , :x => @x, :y => @y, :class => 'legendtext' }
35
+ xfrag.text(@txt, h )
36
+ end
37
+
38
+ end
39
+
40
+
22
41
  end
metadata CHANGED
@@ -1,78 +1,69 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gerbilcharts
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.4
5
- prerelease:
4
+ version: 0.8.0
6
5
  platform: ruby
7
6
  authors:
8
7
  - vivek
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2013-10-15 00:00:00.000000000 Z
11
+ date: 2015-08-05 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
14
  name: shoulda
16
15
  requirement: !ruby/object:Gem::Requirement
17
- none: false
18
16
  requirements:
19
- - - ! '>='
17
+ - - ">="
20
18
  - !ruby/object:Gem::Version
21
19
  version: '0'
22
20
  type: :development
23
21
  prerelease: false
24
22
  version_requirements: !ruby/object:Gem::Requirement
25
- none: false
26
23
  requirements:
27
- - - ! '>='
24
+ - - ">="
28
25
  - !ruby/object:Gem::Version
29
26
  version: '0'
30
27
  - !ruby/object:Gem::Dependency
31
28
  name: bundler
32
29
  requirement: !ruby/object:Gem::Requirement
33
- none: false
34
30
  requirements:
35
- - - ! '>='
31
+ - - ">="
36
32
  - !ruby/object:Gem::Version
37
33
  version: '0'
38
34
  type: :development
39
35
  prerelease: false
40
36
  version_requirements: !ruby/object:Gem::Requirement
41
- none: false
42
37
  requirements:
43
- - - ! '>='
38
+ - - ">="
44
39
  - !ruby/object:Gem::Version
45
40
  version: '0'
46
41
  - !ruby/object:Gem::Dependency
47
42
  name: jeweler
48
43
  requirement: !ruby/object:Gem::Requirement
49
- none: false
50
44
  requirements:
51
- - - ! '>='
45
+ - - ">="
52
46
  - !ruby/object:Gem::Version
53
47
  version: '0'
54
48
  type: :development
55
49
  prerelease: false
56
50
  version_requirements: !ruby/object:Gem::Requirement
57
- none: false
58
51
  requirements:
59
- - - ! '>='
52
+ - - ">="
60
53
  - !ruby/object:Gem::Version
61
54
  version: '0'
62
55
  - !ruby/object:Gem::Dependency
63
56
  name: simplecov
64
57
  requirement: !ruby/object:Gem::Requirement
65
- none: false
66
58
  requirements:
67
- - - ! '>='
59
+ - - ">="
68
60
  - !ruby/object:Gem::Version
69
61
  version: '0'
70
62
  type: :development
71
63
  prerelease: false
72
64
  version_requirements: !ruby/object:Gem::Requirement
73
- none: false
74
65
  requirements:
75
- - - ! '>='
66
+ - - ">="
76
67
  - !ruby/object:Gem::Version
77
68
  version: '0'
78
69
  description: Gerbilcharts is a server side charting library that outputs SVG text
@@ -83,6 +74,8 @@ extra_rdoc_files:
83
74
  - LICENSE.txt
84
75
  - README.rdoc
85
76
  files:
77
+ - LICENSE.txt
78
+ - README.rdoc
86
79
  - lib/gerbilcharts.rb
87
80
  - lib/gerbilcharts/charts.rb
88
81
  - lib/gerbilcharts/charts/area_chart.rb
@@ -163,34 +156,28 @@ files:
163
156
  - lib/gerbilcharts/svgdc/svgdc.rb
164
157
  - lib/gerbilcharts/svgdc/transformations.rb
165
158
  - lib/gerbilcharts/version.rb
166
- - LICENSE.txt
167
- - README.rdoc
168
159
  homepage: http://github.com/vivekrajan/gerbilcharts
169
160
  licenses:
170
161
  - MIT
162
+ metadata: {}
171
163
  post_install_message:
172
164
  rdoc_options: []
173
165
  require_paths:
174
166
  - lib
175
167
  required_ruby_version: !ruby/object:Gem::Requirement
176
- none: false
177
168
  requirements:
178
- - - ! '>='
169
+ - - ">="
179
170
  - !ruby/object:Gem::Version
180
171
  version: '0'
181
- segments:
182
- - 0
183
- hash: 216602382949750896
184
172
  required_rubygems_version: !ruby/object:Gem::Requirement
185
- none: false
186
173
  requirements:
187
- - - ! '>='
174
+ - - ">="
188
175
  - !ruby/object:Gem::Version
189
176
  version: '0'
190
177
  requirements: []
191
178
  rubyforge_project:
192
- rubygems_version: 1.8.23
179
+ rubygems_version: 2.2.2
193
180
  signing_key:
194
- specification_version: 3
181
+ specification_version: 4
195
182
  summary: SVG timeseries charting
196
183
  test_files: []