gerbilcharts 0.2.12 → 0.2.13

Sign up to get free protection for your applications and to get access to all the features.
data/History.txt CHANGED
@@ -1,10 +1,11 @@
1
- == 0.2.11 2009-12-01
1
+ == 0.2.13 2009-12-01
2
2
  * Changes
3
3
  * inline javascript option now fixed
4
4
  * grid sublines work for first label interval now
5
5
  * detailed legend showing max/min/avg/latest
6
6
  * option to switch between mini and detailed legends
7
7
  * various other fixes and tweaks
8
+ * if no activity detected in model/group then gracefully say so
8
9
 
9
10
  == 0.2.6 2009-10-27
10
11
  * Changes
data/Manifest.txt CHANGED
@@ -42,6 +42,7 @@ lib/gerbilcharts/surfaces/horizontal_name_axis.rb
42
42
  lib/gerbilcharts/surfaces/horizontal_time_axis.rb
43
43
  lib/gerbilcharts/surfaces/impulse_surface.rb
44
44
  lib/gerbilcharts/surfaces/legend.rb
45
+ lib/gerbilcharts/surfaces/detailed_legend.rb
45
46
  lib/gerbilcharts/surfaces/line_surface.rb
46
47
  lib/gerbilcharts/surfaces/mark_band.rb
47
48
  lib/gerbilcharts/surfaces/panel.rb
@@ -69,10 +69,15 @@ class Chart < GraphElement
69
69
  svgdc = GerbilCharts::SVGDC::SVGDC.new(@bounds.width, @bounds.height)
70
70
 
71
71
  dolayout if @needslayout
72
-
73
- @children.each do |ch|
74
- ch.render(svgdc)
75
- end
72
+
73
+ # bail out of empty models quickly
74
+ if @modelgroup.empty?
75
+ svgdc.textout(@bounds.left + @bounds.width/2, @bounds.height/2,
76
+ @modelgroup.empty_caption,{"text-anchor" => "middle", :class => "titletext"})
77
+ else
78
+ @children.each { |ch| ch.render(svgdc) }
79
+ end
80
+
76
81
 
77
82
  @filters.each { |f| svgdc.add_filter(f) }
78
83
 
@@ -0,0 +1,86 @@
1
+ module GerbilCharts::Surfaces
2
+
3
+ # = Legend
4
+ # legend panel shows names/colors of items in a separate box (transparent)
5
+ class DetailedLegend < GraphElement
6
+
7
+ attr_reader :width
8
+ attr_reader :showvalues
9
+
10
+ def initialize(opts={})
11
+ @class = "legendpanel"
12
+ super(opts)
13
+ @width = opts[:dim] if defined? opts[:dim]
14
+ end
15
+
16
+ def int_render(g)
17
+
18
+ w=g.newwin("legendpanel_detail", {:visibility => 'hidden'} )
19
+ g.setactivewindow(w)
20
+
21
+ # count determines the bounds
22
+ @bounds.bottom = @bounds.top + 16 + 15 * parent.modelgroup.count
23
+ g.rectangle_r(@bounds, {:class => @class})
24
+
25
+ # toggle detail/mini legend
26
+ g.rectangle(@bounds.left-5,@bounds.top,5,5, {:href => "javascript:void(0);",
27
+ :onclick => "showMiniLegend();" })
28
+
29
+ rbox = Rect.new
30
+ rbox.initfrom(@bounds)
31
+ rbox.left += 2
32
+ rbox.right = rbox.left + 10
33
+ rbox.top += 2
34
+ rbox.bottom = rbox.top+10
35
+
36
+
37
+ stat_label_pos = rbox.right + [140,@bounds.width-200].max
38
+ stat_label_width = 45
39
+ ["Min", "Max", "Avg", "Latest"].each do |lab|
40
+ g.textout(stat_label_pos, rbox.bottom-2, lab, {:class => "legendstats"} )
41
+ stat_label_pos += stat_label_width
42
+ end
43
+
44
+ rbox.top += 16
45
+ rbox.bottom = rbox.top+10
46
+
47
+ parent.modelgroup.each_model_with_index do | mod, i|
48
+
49
+ # Adding tool tips
50
+ opts = { :class => "legendtext" }
51
+ opts.merge!(:onmouseover => "OpacityDown(evt)", :onmouseout => "OpacityUp(evt)")
52
+ opts.store(:gerbiltooltip1, mod.name)
53
+ opts.store(:gerbiltooltip2, "Latest Value = #{mod.latest_val}")
54
+
55
+ g.rectangle_r(rbox, :id => "item#{i}")
56
+ g.textout(rbox.right+5, rbox.bottom-2, mod.name,opts)
57
+
58
+ stat_ana = mod.get_statistical_analysis
59
+
60
+ stat_label_pos = rbox.right + [140,@bounds.width-200].max
61
+ [0,1,2,4].each do |sid|
62
+ g.textout(stat_label_pos, rbox.bottom-2, mod.formatted_val(stat_ana[sid]), {:class => 'legendstats'} )
63
+ stat_label_pos += stat_label_width
64
+ end
65
+
66
+
67
+ rbox.top += 10 + 5
68
+ rbox.bottom = rbox.top+10
69
+
70
+ end
71
+
72
+ g.setactivewindow
73
+
74
+ end
75
+
76
+ def align_to_anchor(anc)
77
+ super
78
+ @bounds.deflate_v(10,10)
79
+ @bounds.deflate_h(2,4)
80
+ if @width
81
+ @bounds.left = @bounds.right - @width
82
+ end
83
+ end
84
+ end
85
+ end
86
+
@@ -2,7 +2,7 @@ module GerbilCharts
2
2
  module VERSION #:nodoc:
3
3
  MAJOR = 0
4
4
  MINOR = 2
5
- TINY = 12
5
+ TINY = 13
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.2.12
4
+ version: 0.2.13
5
5
  platform: ruby
6
6
  authors:
7
7
  - Vivek Rajagopalan
@@ -80,6 +80,7 @@ files:
80
80
  - lib/gerbilcharts/surfaces/horizontal_time_axis.rb
81
81
  - lib/gerbilcharts/surfaces/impulse_surface.rb
82
82
  - lib/gerbilcharts/surfaces/legend.rb
83
+ - lib/gerbilcharts/surfaces/detailed_legend.rb
83
84
  - lib/gerbilcharts/surfaces/line_surface.rb
84
85
  - lib/gerbilcharts/surfaces/mark_band.rb
85
86
  - lib/gerbilcharts/surfaces/panel.rb