gerbilcharts 0.10.3 → 0.10.10

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 03e128d97f7c5611d9bd5d7fb784190fc7e810ad
4
- data.tar.gz: 2d11b79dd2442346e44f8533b1f85ac735b094ae
3
+ metadata.gz: 9a1ce510c0c862f122e62a8f8344e327fc945b99
4
+ data.tar.gz: 90277699683b3ea5e065d749c44c66ebd257a571
5
5
  SHA512:
6
- metadata.gz: 4c5bfaead62efc5602454b1b3e33d879b4e07c6b5e43e95508b1f4933519d8cfeb1e496e98be4f039732e0ce032e2c3f8599c30dfa721325c08aa75059fed28e
7
- data.tar.gz: e46aefc7c92c8785b0b2c4d9d39a30f0d424f438bf87312694510316b6e0822fefe44c012a2880c41f032e917c0c1733d93eb89e40d8c33a60669535fb160a3a
6
+ metadata.gz: a5c8044f04f71eb6b4631fe24481903896d14e80f2b73934b7aa9be7fc56573e88c7393427a153759a81db30f5031deff573ba2ec41b685abfa9330718bd8ad6
7
+ data.tar.gz: a508675d306932b4c8c57a03ebc9eb1902609b59b697a9d5c064a79abb0482fee90b74b12e986a2189eb0792316c6ae444d6744df377d7f94134c5de788c46fc
@@ -23,17 +23,24 @@ class AreaChart < ChartBase
23
23
  @thechart.add_child(GerbilCharts::Surfaces::SurfaceBackground.new(:orient => ORIENT_OVERLAY))
24
24
  @thechart.add_child(GerbilCharts::Surfaces::MarkBand.new(:orient => ORIENT_OVERLAY))
25
25
  @thechart.add_child(GerbilCharts::Surfaces::BasicGrid.new(:orient => ORIENT_OVERLAY))
26
- @thechart.add_child(GerbilCharts::Surfaces::TitlePanel.new(:orient => ORIENT_OVERLAY, :dim => 30))
27
26
  @thechart.add_child(GerbilCharts::Surfaces::AreaSurface.new(:orient => ORIENT_OVERLAY),:anchor => true)
27
+
28
+ # optional features
29
+ if @feature_timetracker
30
+ @thechart.add_child(GerbilCharts::Surfaces::Tracker.new(:orient => ORIENT_OVERLAY ))
31
+ end
32
+
33
+ # link pivots
34
+ if @feature_linkpivots
35
+ @thechart.add_child(GerbilCharts::Surfaces::LinkPivots.new(:orient => ORIENT_OVERLAY ))
36
+ end
37
+
38
+ @thechart.add_child(GerbilCharts::Surfaces::TitlePanel.new(:orient => ORIENT_OVERLAY, :dim => 30))
28
39
  @thechart.add_child(GerbilCharts::Surfaces::Legend.new(:orient=> ORIENT_OVERLAY, :dim => @legend_width))
29
40
  @thechart.add_child(GerbilCharts::Surfaces::DetailedLegend.new(:orient=> ORIENT_OVERLAY, :dim => 3*@legend_width))
30
41
  @thechart.add_child(GerbilCharts::Surfaces::VerticalAxis.new(:orient => ORIENT_WEST, :dim => 40 ))
31
42
  @thechart.add_child(GerbilCharts::Surfaces::HorizontalTimeAxis.new(:orient => ORIENT_SOUTH, :dim => 25 ))
32
43
 
33
- # optional features
34
- if @feature_timetracker
35
- @thechart.add_child(GerbilCharts::Surfaces::Tracker.new(:orient => ORIENT_OVERLAY ))
36
- end
37
44
  end
38
45
 
39
46
  end
@@ -29,6 +29,7 @@ module GerbilCharts::Charts
29
29
  # [+:scaling_y+] Allowed values are :auto, :auto_0, and an array [min,max] (default = :auto)
30
30
  # [+:circle_data_points+] Draws a tiny circle around datapoints for tooltips
31
31
  # [+:enabletimetracker+] Time tracker javascript selector (default = false)
32
+ # [+:enablelinkpivots+] Link Pivot box javascript selector (default = false)
32
33
  #
33
34
  class ChartBase
34
35
 
@@ -50,6 +51,7 @@ class ChartBase
50
51
  attr_reader :thechart
51
52
  attr_reader :renderopts
52
53
  attr_reader :feature_timetracker
54
+ attr_reader :feature_linkpivots
53
55
  attr_reader :legend_width
54
56
 
55
57
  def initialize(opt={})
@@ -60,6 +62,13 @@ class ChartBase
60
62
  @feature_timetracker=opt[:enabletimetracker]
61
63
  opt.delete :enabletimetracker
62
64
  end
65
+
66
+ @enabletimetracker=false
67
+ if opt[:enablelinkpivots]
68
+ @feature_linkpivots=opt[:enablelinkpivots]
69
+ opt.delete :enablelinkpivots
70
+ end
71
+
63
72
 
64
73
  # pass on options to chart object
65
74
  @thechart = GerbilCharts::Surfaces::Chart.new(opt)
@@ -26,8 +26,18 @@ class LineChart < ChartBase
26
26
  # other elements
27
27
  @thechart.add_child(GerbilCharts::Surfaces::SurfaceBackground.new(:orient => ORIENT_OVERLAY))
28
28
  @thechart.add_child(GerbilCharts::Surfaces::BasicGrid.new(:orient => ORIENT_OVERLAY))
29
- @thechart.add_child(GerbilCharts::Surfaces::TitlePanel.new(:orient => ORIENT_OVERLAY, :dim => 30))
30
29
  @thechart.add_child(GerbilCharts::Surfaces::LineSurface.new(:orient => ORIENT_OVERLAY),:anchor => true)
30
+
31
+ # optional features
32
+ if @feature_timetracker
33
+ @thechart.add_child(GerbilCharts::Surfaces::Tracker.new(:orient => ORIENT_OVERLAY ))
34
+ end
35
+
36
+ # link pivots
37
+ if @feature_linkpivots
38
+ @thechart.add_child(GerbilCharts::Surfaces::LinkPivots.new(:orient => ORIENT_OVERLAY ))
39
+ end
40
+ @thechart.add_child(GerbilCharts::Surfaces::TitlePanel.new(:orient => ORIENT_OVERLAY, :dim => 30))
31
41
  @thechart.add_child(GerbilCharts::Surfaces::Legend.new(:orient=> ORIENT_OVERLAY, :dim => @legend_width))
32
42
  @thechart.add_child(GerbilCharts::Surfaces::DetailedLegend.new(:orient=> ORIENT_OVERLAY, :dim => 3*@legend_width))
33
43
  @thechart.add_child(GerbilCharts::Surfaces::VerticalAxis.new(:orient => ORIENT_WEST, :dim => 40 ))
@@ -28,17 +28,25 @@ class SquareLineChart < ChartBase
28
28
  @thechart.add_child(GerbilCharts::Surfaces::SurfaceBackground.new(:orient => ORIENT_OVERLAY))
29
29
  @thechart.add_child(GerbilCharts::Surfaces::MarkBand.new(:orient => ORIENT_OVERLAY))
30
30
  @thechart.add_child(GerbilCharts::Surfaces::BasicGrid.new(:orient => ORIENT_OVERLAY))
31
- @thechart.add_child(GerbilCharts::Surfaces::TitlePanel.new(:orient => ORIENT_OVERLAY, :dim => 30))
32
31
  @thechart.add_child(GerbilCharts::Surfaces::SquareLineSurface.new(:orient => ORIENT_OVERLAY),:anchor => true)
33
- @thechart.add_child(GerbilCharts::Surfaces::Legend.new(:orient=> ORIENT_OVERLAY, :dim => @legend_width))
34
- @thechart.add_child(GerbilCharts::Surfaces::DetailedLegend.new(:orient=> ORIENT_OVERLAY, :dim => 3*@legend_width))
35
- @thechart.add_child(GerbilCharts::Surfaces::VerticalAxis.new(:orient => ORIENT_WEST, :dim => 40 ))
36
- @thechart.add_child(GerbilCharts::Surfaces::HorizontalTimeAxis.new(:orient => ORIENT_SOUTH, :dim => 25 ))
37
32
 
38
33
  # optional features
39
34
  if @feature_timetracker
40
35
  @thechart.add_child(GerbilCharts::Surfaces::Tracker.new(:orient => ORIENT_OVERLAY ))
41
36
  end
37
+
38
+ # link pivots
39
+ if @feature_linkpivots
40
+ @thechart.add_child(GerbilCharts::Surfaces::LinkPivots.new(:orient => ORIENT_OVERLAY ))
41
+ end
42
+
43
+ @thechart.add_child(GerbilCharts::Surfaces::TitlePanel.new(:orient => ORIENT_OVERLAY, :dim => 30))
44
+ @thechart.add_child(GerbilCharts::Surfaces::Legend.new(:orient=> ORIENT_OVERLAY, :dim => @legend_width))
45
+ @thechart.add_child(GerbilCharts::Surfaces::DetailedLegend.new(:orient=> ORIENT_OVERLAY, :dim => 3*@legend_width))
46
+ @thechart.add_child(GerbilCharts::Surfaces::VerticalAxis.new(:orient => ORIENT_WEST, :dim => 40 ))
47
+ @thechart.add_child(GerbilCharts::Surfaces::HorizontalTimeAxis.new(:orient => ORIENT_SOUTH, :dim => 25 ))
48
+
49
+
42
50
  end
43
51
  end
44
52
 
@@ -16,6 +16,16 @@ class StackedAreaChart < ChartBase
16
16
  @thechart.add_child(GerbilCharts::Surfaces::StackedGrid.new(:orient => ORIENT_OVERLAY))
17
17
  @thechart.add_child(GerbilCharts::Surfaces::TitlePanel.new(:orient => ORIENT_OVERLAY, :dim => 30))
18
18
  @thechart.add_child(GerbilCharts::Surfaces::StackedAreaSurface.new(:orient => ORIENT_OVERLAY),:anchor => true)
19
+
20
+ # optional features
21
+ if @feature_timetracker
22
+ @thechart.add_child(GerbilCharts::Surfaces::Tracker.new(:orient => ORIENT_OVERLAY ))
23
+ end
24
+
25
+ # link pivots
26
+ if @feature_linkpivots
27
+ @thechart.add_child(GerbilCharts::Surfaces::LinkPivots.new(:orient => ORIENT_OVERLAY ))
28
+ end
19
29
  @thechart.add_child(GerbilCharts::Surfaces::Legend.new(:orient=> ORIENT_OVERLAY, :dim => @legend_width))
20
30
  @thechart.add_child(GerbilCharts::Surfaces::DetailedLegend.new(:orient=> ORIENT_OVERLAY, :dim => 3*@legend_width))
21
31
  @thechart.add_child(GerbilCharts::Surfaces::VerticalAxis.new(:orient => ORIENT_WEST, :dim => 40 , :cumulative => true ))
@@ -15,6 +15,7 @@ class GraphModel
15
15
  attr_reader :userlabel1 # map to tooltip 1
16
16
  attr_reader :userlabel2 # map to tooltip 2
17
17
  attr_reader :transformer # value transformer (a lambda function)
18
+ attr_accessor :href_pivot # href for pivot box (used w/ time selector)
18
19
 
19
20
  def initialize(n="Untitled")
20
21
  @name=n
@@ -42,11 +43,22 @@ class GraphModel
42
43
  h1=h.gsub("{","%7B")
43
44
  @href=h1.gsub("}","%7D")
44
45
  end
46
+
47
+ # clean up the href (todo: improve this)
48
+ def setHrefPivot(h)
49
+ h1=h.gsub("{","%7B")
50
+ @href_pivot=h1.gsub("}","%7D")
51
+ end
52
+
45
53
 
46
54
  def hasHref?
47
55
  return @href != nil
48
56
  end
49
57
 
58
+ def hasHrefPivot?
59
+ return @href_pivot != nil
60
+ end
61
+
50
62
  def setUserData(d)
51
63
  @userdata=d
52
64
  end
@@ -168,22 +168,22 @@ class MonotonousGraphModel < GraphModel
168
168
  # todo : support :ninety_fifth
169
169
  #
170
170
  def get_statistical_analysis()
171
- return [0,0,0,0,0] if @yarr.size==0
171
+ return [0,0,0,0,0] if @yarr.size==0
172
172
 
173
- a = []
174
- a[0]= @yrange.rmin
175
- a[1]= @yrange.rmax
176
- a[3]=0
173
+ a = []
174
+ a[0]= @yrange.rmin
175
+ a[1]= @yrange.rmax
176
+ a[3]=0
177
177
 
178
- @yarr.each do |v|
179
- a[3] = a[3] + v
180
- end
181
- a[3] = a[3] * @aggregation_factor
182
- a[2] = a[3]/@yarr.size
183
- a[4] = latest_val
184
- return a
178
+ @yarr.each do |v|
179
+ a[3] = a[3] + v
180
+ end
181
+ a[2] = a[3]/@yarr.size
182
+ a[3] = a[3] * @aggregation_factor
183
+ a[4] = latest_val
184
+ return a
185
185
  end
186
-
186
+
187
187
  private
188
188
  # recompute ranges
189
189
  def recompute_ranges
@@ -16,19 +16,22 @@ public
16
16
  [500000,100000], [800000,200000],
17
17
  [1000000,200000], [2000000,500000], [3000000,500000], [4000000,1000000],
18
18
  [5000000,1000000], [6000000, 1000000],
19
- [8000000,2000000], [10000000,2000000], [20000000,5000000], [50000000, 10000000],
20
- [100000000,25000000], [200000000,50000000], [500000000,100000000],
21
- [1_000_000_000, 250_000_000] , [3_000_000_000, 1_000_000_000] , [5_000_000_000, 1_000_000_000] ,
22
- [10_000_000_000, 2_000_000_000] ,
23
- [100_000_000_000, 20_000_000_000] ,
24
- [1_000_000_000_000,200_000_000_000] ,
19
+ [8000000,2000000], [10000000,2000000], [20000000,5000000], [50_000_000, 10_000_000],
20
+ [100_000_000,25_000_000], [200_000_000,50_000_000], [300_000_000,100_000_000], [500_000_000,100_000_000],
21
+ [1_000_000_000, 250_000_000] , [3_000_000_000, 1_000_000_000] , [5_000_000_000, 1_000_000_000] ,
22
+ [10_000_000_000, 2_000_000_000] ,
23
+ [20_000_000_000, 5_000_000_000] ,
24
+ [50_000_000_000, 10_000_000_000] ,
25
+ [100_000_000_000, 20_000_000_000] ,
26
+ [1_000_000_000_000, 200_000_000_000] ,
27
+ [10_000_000_000_000,2_000_000_000_000] ,
25
28
  ]
26
29
 
27
30
  TIMEPRESETS = [
28
31
  [0,0], [1,0.2], [5,1], [10,1],[20,5],
29
32
  [30,10],[60,10],[120,15], [300,60], [600,120],
30
33
  [900,300], [1800,300],
31
- [3600,900], [7200,1800],[10800,3600], [14400,3600], [21600,3600],
34
+ [3600,300], [7200,900],[10800,1800], [14400,3600], [21600,3600],
32
35
  [43200, 7200], [86400,7200],
33
36
  [172800, 43200], [259200,86400],
34
37
  [604800, 86400], [1209600,172800],
@@ -35,3 +35,4 @@ require 'gerbilcharts/surfaces/square_line_surface'
35
35
  require 'gerbilcharts/surfaces/matrix_surface'
36
36
  require 'gerbilcharts/surfaces/conversation_ring'
37
37
  require 'gerbilcharts/surfaces/bubble_surface'
38
+ require 'gerbilcharts/surfaces/link_pivots'
@@ -45,12 +45,12 @@ class DetailedLegend < GraphElement
45
45
 
46
46
  # toggle detail/mini legend
47
47
  g.rectangle(@bounds.left-5,@bounds.top,5,5, {:href => "javascript:void(0);",
48
- :onclick => "showMiniLegend();",
48
+ :onclick => "showMiniLegend(event);",
49
49
  :fill => "white",
50
50
  :stroke => "none",
51
51
  :gerbiltooltip1 => "Click to show compact legend" })
52
- g.textout(@bounds.left-4,@bounds.top+5,'>', {'font-size' => '9', :href => "javascript:void(0);",
53
- :onclick => "showMiniLegend();", :stroke => '#DDDDDD',
52
+ g.textout(@bounds.left-4,@bounds.top+5,'>', {:class=>'legend-tool',
53
+ :onclick => "showMiniLegend(event);",
54
54
  :gerbiltooltip1 => "Click to show compact legend" })
55
55
 
56
56
 
@@ -80,7 +80,7 @@ class GraphElement
80
80
 
81
81
  # setup SVG group element and call int_render
82
82
  def render(sdc)
83
- sdc.newwin(@group) do |sdc|
83
+ sdc.newwin(@group, { :class => @class } ) do |sdc|
84
84
  int_render(sdc)
85
85
  end
86
86
  end
@@ -25,13 +25,13 @@ class Legend < GraphElement
25
25
 
26
26
  # toggle detail/mini legend
27
27
  g.rectangle(@bounds.left-5,@bounds.top,5,5, {:href => "javascript:void(0);",
28
- :onclick => "showDetailedLegend();",
28
+ :onclick => "showDetailedLegend(event);",
29
29
  :fill => "white",
30
30
  :stroke => "none",
31
31
  :gerbiltooltip1 => "Click to show a detailed legend" })
32
32
 
33
- g.textout(@bounds.left-7,@bounds.top+5,'+', {'font-size' => '9', :href => "javascript:void(0);",
34
- :onclick => "showDetailedLegend();", :stroke => '#DDDDDD' ,
33
+ g.textout(@bounds.left-7,@bounds.top+5,'+', {:class=> 'legend-tool',
34
+ :onclick => "showDetailedLegend(event);",
35
35
  :gerbiltooltip1 => "Click to show a detailed legend" })
36
36
 
37
37
  # shift
@@ -40,8 +40,8 @@ class Legend < GraphElement
40
40
  :fill => "white",
41
41
  :stroke => "none",
42
42
  :gerbiltooltip1 => "Click to move legend to left side" })
43
- g.textout(@bounds.left-7,@bounds.top+15,'<', {'font-size' => '9', :href => "javascript:void(0);",
44
- :onclick => "shiftLegend(#{-@bounds.left+50});", :stroke => '#DDDDDD',
43
+ g.textout(@bounds.left-7,@bounds.top+15,'<', {:class=>'legend-tool',
44
+ :onclick => "shiftLegend(#{-@bounds.left+50});",
45
45
  :gerbiltooltip1 => "Click to move legend to left side" })
46
46
 
47
47
 
@@ -51,8 +51,8 @@ class Legend < GraphElement
51
51
  :fill => "white",
52
52
  :stroke => "none" ,
53
53
  :gerbiltooltip1 => "Click to move legend to right side"})
54
- g.textout(@bounds.left-7,@bounds.top+25,'>', {'font-size' => '9', :href => "javascript:void(0);",
55
- :onclick => "shiftLegend(0);", :stroke => '#DDDDDD',
54
+ g.textout(@bounds.left-7,@bounds.top+25,'>', {:class => 'legend-tool',
55
+ :onclick => "shiftLegend(0);",
56
56
  :gerbiltooltip1 => "Click to move legend to right side"})
57
57
  rbox = Rect.new
58
58
  rbox.initfrom(@bounds)
@@ -0,0 +1,56 @@
1
+ module GerbilCharts::Surfaces
2
+
3
+ # == Link Pivots
4
+ # When time is selected, we show custom links to Jump to other places
5
+ #
6
+ class LinkPivots < GraphElement
7
+
8
+ attr_accessor :just
9
+
10
+ def initialize(opts={})
11
+ @class = "linkpivots"
12
+ super(opts)
13
+ end
14
+
15
+ def int_render(g)
16
+ opts = {:class => "linkpivots", 'text-anchor' => 'middle' }
17
+
18
+ win = g.newwin( "linkpivots", {:class => 'linkpivots' , :visibility => 'hidden' })
19
+ g.setactivewindow(win)
20
+
21
+ # count determines the bounds
22
+ @bounds.top = @bounds.bottom - 20 * parent.modelgroup.count
23
+ if @bounds.top < 0
24
+ @bounds.top =0
25
+ end
26
+
27
+ g.rectangle_r(@bounds)
28
+
29
+ # start
30
+ x = @bounds.left + @bounds.width/2
31
+ y = @bounds.top + 20
32
+
33
+ parent.modelgroup.each_model_with_index do | mod, i|
34
+
35
+ if mod.hasHrefPivot?
36
+ opts.store(:href, mod.href_pivot)
37
+ opts.store(:base_href, mod.href_pivot)
38
+ end
39
+
40
+ opts.merge!( :id => "item#{i}")
41
+ g.textout(x,y, "Drill down into #{mod.name}",opts)
42
+
43
+ y += 20;
44
+
45
+ end
46
+ end
47
+
48
+ def align_to_anchor(anc)
49
+ super
50
+ @bounds.deflate_h(40,40)
51
+ @bounds.top = @bounds.bottom - 40
52
+ end
53
+
54
+
55
+ end
56
+ end
@@ -6,8 +6,7 @@ module GerbilCharts::Surfaces
6
6
  class Surface < GraphElement
7
7
 
8
8
  def initialize(opts={})
9
- @class = "surfacepanel"
10
- super(opts)
9
+ super(opts.merge(:class => 'surfacepanel' ))
11
10
  end
12
11
 
13
12
  def int_render(g)
@@ -48,7 +48,7 @@ class Tracker < GraphElement
48
48
  xfrag.tspan( :id => 'trackertextinterval', :x=>0, :y=>ty) {
49
49
  "15 Minutes"
50
50
  }
51
- xfrag.tspan( :class => 'trackertextfromts', :id => 'trackertextfromts', :x=>0, :dy=>15) {
51
+ xfrag.tspan( :class => 'trackertextfromts', :id => 'trackertextfromts', :x=>0, :dy=>25) {
52
52
  "Starting: Apr 2 1973, 05:00:00 PM"
53
53
  }
54
54
  }
@@ -59,8 +59,8 @@ class Tracker < GraphElement
59
59
  :gerb_fromts=>rx.rmin.tv_sec,
60
60
  :gerb_seconds=>rx.rmax.tv_sec-rx.rmin.tv_sec,
61
61
  :gerb_scale =>(rx.delta)/parent.anchor.bounds.width,
62
- :gerb_tzoffset => Time.new.utc_offset,
63
- :gerb_tzname => Time.new.zone,
62
+ :gerb_tzoffset => Time.new.utc_offset,
63
+ :gerb_tzname => Time.new.zone,
64
64
  :gerb_selts=>1,
65
65
  :gerb_selsecs=>1)
66
66
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gerbilcharts
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.10.3
4
+ version: 0.10.10
5
5
  platform: ruby
6
6
  authors:
7
7
  - vivek
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-10-01 00:00:00.000000000 Z
11
+ date: 2017-06-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: shoulda
@@ -39,7 +39,7 @@ dependencies:
39
39
  - !ruby/object:Gem::Version
40
40
  version: '0'
41
41
  - !ruby/object:Gem::Dependency
42
- name: jeweler
42
+ name: juwelier
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
45
  - - ">="
@@ -124,6 +124,7 @@ files:
124
124
  - lib/gerbilcharts/surfaces/impulse_surface.rb
125
125
  - lib/gerbilcharts/surfaces/legend.rb
126
126
  - lib/gerbilcharts/surfaces/line_surface.rb
127
+ - lib/gerbilcharts/surfaces/link_pivots.rb
127
128
  - lib/gerbilcharts/surfaces/mark_band.rb
128
129
  - lib/gerbilcharts/surfaces/matrix_surface.rb
129
130
  - lib/gerbilcharts/surfaces/panel.rb
@@ -176,7 +177,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
176
177
  version: '0'
177
178
  requirements: []
178
179
  rubyforge_project:
179
- rubygems_version: 2.2.2
180
+ rubygems_version: 2.5.1
180
181
  signing_key:
181
182
  specification_version: 4
182
183
  summary: SVG timeseries charting