gerbilcharts 0.8.0 → 0.10.0

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: 2d029786a988fb9db2da4f048c2aaf142e34dbc5
4
- data.tar.gz: dfb2ae9401f4e592b87cf400216c209af55212b7
3
+ metadata.gz: 463652e497be145b0f44cef398008ed555b7f0da
4
+ data.tar.gz: 05a9cdaa19116dbf6c56d8c85c8bab62cf55948d
5
5
  SHA512:
6
- metadata.gz: 3de4722ffee541a1c66559e933c28dd9ac48b341517ea3e557208c6a035ba77cf8b8eeaf748389a118af18fe5c75d08dbe237c5d16e7216569ee5457ca79b120
7
- data.tar.gz: 57297f9eca55aeb093caabc91df9059a97e399ab98ed95f877c9135236bc6833a3d066dbb11adb0ef2689eb2beae9398a7e55839f5f7bf63bcfb4f519a140562
6
+ metadata.gz: af622b8b57abb84ee854306abdaf11e30b5a9fc265f71ff1bbd4d49b790f67b70350f7fb2caff1daed2dcbae30384116752e045eed996bcc62193f28112cb7e3
7
+ data.tar.gz: 78236e46462ae49bfd94bbac1a7853072e8f0ec485d07a2386c9fcb41c90c4f07cfd0bcae8b4ddd98f5078faeb5f17e51167f5d54fb112f73bc08fc85c2583a4
@@ -21,6 +21,7 @@ class AreaChart < ChartBase
21
21
 
22
22
  # other elements
23
23
  @thechart.add_child(GerbilCharts::Surfaces::SurfaceBackground.new(:orient => ORIENT_OVERLAY))
24
+ @thechart.add_child(GerbilCharts::Surfaces::MarkBand.new(:orient => ORIENT_OVERLAY))
24
25
  @thechart.add_child(GerbilCharts::Surfaces::BasicGrid.new(:orient => ORIENT_OVERLAY))
25
26
  @thechart.add_child(GerbilCharts::Surfaces::TitlePanel.new(:orient => ORIENT_OVERLAY, :dim => 30))
26
27
  @thechart.add_child(GerbilCharts::Surfaces::AreaSurface.new(:orient => ORIENT_OVERLAY),:anchor => true)
@@ -11,14 +11,19 @@ class GraphModelGroup
11
11
  attr_accessor :emptycaption
12
12
  attr_accessor :units
13
13
  attr_accessor :x_markers
14
- attr_accessor :ref_model
14
+ attr_accessor :ref_models
15
+ attr_accessor :annotations
16
+ attr_accessor :range_bands
15
17
 
16
18
  def initialize(n="Untitled-Group",opts={})
17
19
  @models=[]
18
20
  @name=n
19
21
  @units=opts[:units] || ""
22
+ @ref_models=[]
23
+ @annotations=[] # array of [{:x, :y, :label}]
24
+ @range_bands=[] # array of models [{:upper=>nil,:lower=>nil} ]
20
25
  end
21
-
26
+
22
27
  def <<(m)
23
28
  @models << m
24
29
  end
@@ -26,7 +31,7 @@ class GraphModelGroup
26
31
  def add(m)
27
32
  @models << m
28
33
  end
29
-
34
+
30
35
  def delete(m)
31
36
  @models.delete(m)
32
37
  end
@@ -197,7 +202,15 @@ class GraphModelGroup
197
202
  reffy.update(m.yrange.rmax+reffy.rmax) if m.yrange.rmax
198
203
  end
199
204
 
200
- reffy.update(ref_model.yrange.rmax) if has_ref_model?
205
+ @ref_models.each do |ref_model|
206
+ reffy.update(ref_model.yrange.rmax)
207
+ end
208
+
209
+ @range_bands.each do |range_band|
210
+ reffy.update(range_band[:upper].yrange.rmax)
211
+ reffy.update(range_band[:lower].yrange.rmax)
212
+ end
213
+
201
214
  return models[0].round_given_y(reffy)
202
215
 
203
216
  end
@@ -208,7 +221,16 @@ class GraphModelGroup
208
221
  @models.each do |m|
209
222
  reffy.update(m.yrange.rmax+reffy.rmax)
210
223
  end
211
- reffy.update(ref_model.yrange.rmax) if has_ref_model?
224
+
225
+ @ref_models.each do |ref_model|
226
+ reffy.update(ref_model.yrange.rmax)
227
+ end
228
+
229
+ @range_bands.each do |range_band|
230
+ reffy.update(range_band[:upper].yrange.rmax)
231
+ reffy.update(range_band[:lower].yrange.rmax)
232
+ end
233
+
212
234
  return models[0].round_given_y(reffy)
213
235
  end
214
236
 
@@ -302,11 +324,6 @@ class GraphModelGroup
302
324
  not x_markers.nil?
303
325
  end
304
326
 
305
- def has_ref_model?
306
- not @ref_model.nil?
307
- end
308
-
309
-
310
327
 
311
328
  private
312
329
 
@@ -333,7 +350,15 @@ private
333
350
  reffy.update(acc_y)
334
351
  end
335
352
 
336
- reffy.update(ref_model.yrange.rmax) if has_ref_model?
353
+
354
+ @ref_models.each do |ref_model|
355
+ reffy.update(ref_model.yrange.rmax)
356
+ end
357
+
358
+ @range_bands.each do |range_band|
359
+ reffy.update(range_band[:upper].yrange.rmax)
360
+ reffy.update(range_band[:lower].yrange.rmax)
361
+ end
337
362
 
338
363
  return models[0].round_given_y(reffy)
339
364
 
@@ -117,6 +117,12 @@ class MonotonousGraphModel < GraphModel
117
117
  yield @xarr[i],@yarr[i]
118
118
  end
119
119
  end
120
+
121
+ def each_tuple_reverse
122
+ @xarr.length.downto(1) do |i|
123
+ yield @xarr[i-1],@yarr[i-1]
124
+ end
125
+ end
120
126
 
121
127
  # crop all tuples older than a cutoff window
122
128
  #
@@ -77,7 +77,9 @@ class AreaSurface < Surface
77
77
  g.end_polygon(:id => "item#{i}", "opacity"=>"0.8")
78
78
  end
79
79
 
80
- draw_ref_model_line(g,rx,ry) if parent.modelgroup.has_ref_model?
80
+ draw_ref_model_lines(g,rx,ry)
81
+ draw_range_bands(g,rx,ry)
82
+ draw_annotations(g,rx,ry)
81
83
 
82
84
  end
83
85
 
@@ -68,6 +68,10 @@ class Legend < GraphElement
68
68
  opts.merge!(:onmouseover => "OpacityDown(evt)", :onmouseout => "OpacityUp(evt)")
69
69
  opts.store(:gerbiltooltip1, mod.name)
70
70
  opts.store(:gerbiltooltip2, "Latest Value = #{mod.latest_val}")
71
+
72
+ if mod.hasHref?
73
+ opts.store(:href, mod.href)
74
+ end
71
75
 
72
76
  # Selector
73
77
  ctlbox = Rect.new
@@ -55,7 +55,11 @@ class LineSurface < Surface
55
55
  g.endline(:id => "lineitem#{i}")
56
56
  end
57
57
 
58
- draw_ref_model_line(g,rx,ry) if parent.modelgroup.has_ref_model?
58
+ draw_ref_model_lines(g,rx,ry)
59
+
60
+ draw_range_bands(g,rx,ry)
61
+
62
+ draw_annotations(g,rx,ry)
59
63
 
60
64
  end
61
65
 
@@ -10,21 +10,21 @@ class MarkBand < GraphElement
10
10
 
11
11
  def int_render(g)
12
12
 
13
- return unless parent.modelgroup.has_x_markers?
13
+ return unless parent.modelgroup.has_x_markers?
14
14
 
15
- range_options_x = parent.get_global_option(:scaling_x,:auto)
16
- range_options_y = parent.get_global_option(:scaling_y,:auto)
15
+ range_options_x = parent.get_global_option(:scaling_x,:auto)
16
+ range_options_y = parent.get_global_option(:scaling_y,:auto)
17
17
 
18
- rx = parent.modelgroup.effective_range_x(range_options_x)
19
- ry = parent.modelgroup.effective_range_y(range_options_y)
18
+ rx = parent.modelgroup.effective_range_x(range_options_x)
19
+ ry = parent.modelgroup.effective_range_y(range_options_y)
20
20
 
21
- mx_arr = parent.modelgroup.x_markers
21
+ mx_arr = parent.modelgroup.x_markers
22
22
 
23
- band_r=@bounds.clone
24
- band_r.left = scale_x mx_arr[0],rx
25
- band_r.right = scale_x mx_arr[1],rx
23
+ band_r=@bounds.clone
24
+ band_r.left = scale_x mx_arr[0],rx
25
+ band_r.right = scale_x mx_arr[1],rx
26
26
 
27
- g.rectangle_r(band_r, {:class => 'x_mk'})
27
+ g.rectangle_r(band_r, {:class => 'x_mk'})
28
28
 
29
29
  end
30
30
  end
@@ -49,7 +49,10 @@ class SquareLineSurface < Surface
49
49
  g.endline(:id => "lineitem#{i}")
50
50
  end
51
51
 
52
- draw_ref_model_line(g,rx,ry) if parent.modelgroup.has_ref_model?
52
+ draw_ref_model_lines(g,rx,ry)
53
+ draw_range_bands(g,rx,ry)
54
+ draw_annotations(g,rx,ry)
55
+
53
56
  end
54
57
 
55
58
  end
@@ -21,8 +21,8 @@ class StackedAreaSurface < Surface
21
21
 
22
22
 
23
23
  # draw reference if any
24
- if parent.modelgroup.has_ref_model?
25
- ref_model = parent.modelgroup.ref_model
24
+ if parent.modelgroup.ref_models.size > 0
25
+ ref_model = parent.modelgroup.ref_models[0]
26
26
 
27
27
  y_zero = scale_y 0,ry
28
28
  g.begin_polygon
@@ -17,31 +17,97 @@ class Surface < GraphElement
17
17
  parent.set_ajaxContext(:axmxx => mxx, :axmxy => mxy, :axsurface => type)
18
18
  end
19
19
 
20
- def draw_ref_model_line(g,rx,ry)
21
- ref_model = parent.modelgroup.ref_model
20
+ def draw_ref_model_lines(g,rx,ry)
21
+
22
+
23
+ parent.modelgroup.ref_models.each do |ref_model|
22
24
 
23
- ref_model.each_tuple do |x,y|
24
- xpos = scale_x x,rx
25
- ypos = scale_y y,ry
26
- g.lineto xpos,ypos
27
- end
28
-
29
- g.endline(:class => "refline")
30
-
31
- # show latest pt & label
32
- ref_model.first do |x,y|
33
- g.textout(@bounds.left+5, scale_y(y,ry)-5,
34
- ref_model.latest_formatted_val,
35
- {:class => "reflinelabel"})
36
- end
37
- ref_model.latest do |x,y|
38
- g.textout(@bounds.right-5, scale_y(y,ry)-5, ref_model.latest_formatted_val,
39
- {:class => "reflinelabel", "text-anchor" => "end" })
25
+ ref_model.each_tuple do |x,y|
26
+ xpos = scale_x x,rx
27
+ ypos = scale_y y,ry
28
+ g.lineto xpos,ypos
29
+ end
30
+
31
+ g.endline(:class => "refline")
32
+
33
+ # show latest pt & label
34
+ ref_model.first do |x,y|
35
+ g.textout(@bounds.left+5, scale_y(y,ry)-5,
36
+ ref_model.latest_formatted_val,
37
+ {:class => "reflinelabel"})
38
+ end
39
+ ref_model.latest do |x,y|
40
+ g.textout(@bounds.right-5, scale_y(y,ry)-5, ref_model.latest_formatted_val,
41
+ {:class => "reflinelabel", "text-anchor" => "end" })
42
+
43
+ g.textout(@bounds.right-5, scale_y(y,ry)+15, ref_model.name,
44
+ {:class => "reflinelabel", "text-anchor" => "end" })
45
+ end
46
+
47
+
48
+ end
49
+
50
+
51
+ end
52
+
53
+
54
+ def draw_range_bands(g,rx,ry)
55
+
56
+ parent.modelgroup.range_bands.each do |range_band|
57
+
58
+ rb_upper = range_band[:upper]
59
+ rb_lower = range_band[:lower]
60
+
61
+ g.begin_polygon
62
+
63
+ firstpoint = nil
64
+
65
+ rb_upper.each_tuple do |x,y|
66
+
67
+ xpos = scale_x x,rx
68
+ ypos = scale_y y,ry
69
+
70
+ g.polygon_point xpos,ypos
71
+
72
+ firstpoint = [xpos,ypos] if firstpoint.nil?
73
+ end
74
+
75
+ rb_lower.each_tuple_reverse do |x,y|
76
+
77
+ xpos = scale_x x,rx
78
+ ypos = scale_y y,ry
79
+
80
+ g.polygon_point xpos,ypos
81
+ end
82
+ g.polygon_point firstpoint[0],firstpoint[1]
83
+
84
+ g.end_polygon(:id => "ref_mod")
85
+
40
86
  end
41
87
 
88
+ end
89
+
90
+ def draw_annotations(g,rx,ry)
91
+
92
+
93
+ parent.modelgroup.annotations.each do |anno|
94
+
95
+ xpos = scale_x anno[:x],rx
96
+ ypos = scale_y anno[:y],ry
97
+
98
+ g.line xpos,ypos, xpos, ypos-20
99
+
100
+ g.textout(xpos, ypos-20,
101
+ anno[:label],
102
+ {:class => "reflinelabel"})
103
+
104
+ g.circle(xpos,ypos,5)
105
+
106
+ end
42
107
 
43
108
  end
44
109
 
110
+
45
111
  end
46
112
  end
47
113
 
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.8.0
4
+ version: 0.10.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - vivek
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-08-05 00:00:00.000000000 Z
11
+ date: 2015-09-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: shoulda