gerbilcharts 0.2.13 → 0.5.9

Sign up to get free protection for your applications and to get access to all the features.
Files changed (57) hide show
  1. data/History.txt +35 -0
  2. data/Manifest.txt +8 -0
  3. data/README.txt +8 -8
  4. data/lib/gerbilcharts/charts.rb +3 -0
  5. data/lib/gerbilcharts/charts/bubble_chart.rb +30 -0
  6. data/lib/gerbilcharts/charts/conversation_ring.rb +31 -0
  7. data/lib/gerbilcharts/charts/line_chart.rb +1 -0
  8. data/lib/gerbilcharts/charts/matrix_chart.rb +32 -0
  9. data/lib/gerbilcharts/charts/square_line_chart.rb +7 -0
  10. data/lib/gerbilcharts/models.rb +1 -0
  11. data/lib/gerbilcharts/models/bucketized_timeseries_graph_model.rb +1 -1
  12. data/lib/gerbilcharts/models/graph_model_group.rb +19 -2
  13. data/lib/gerbilcharts/models/matrix_model.rb +85 -0
  14. data/lib/gerbilcharts/models/monotonous_graph_model.rb +5 -1
  15. data/lib/gerbilcharts/models/presets.rb +18 -11
  16. data/lib/gerbilcharts/models/raw_range.rb +1 -1
  17. data/lib/gerbilcharts/models/round_range.rb +3 -1
  18. data/lib/gerbilcharts/models/round_time_range.rb +19 -29
  19. data/lib/gerbilcharts/models/sampled_timeseries_graph_model.rb +1 -1
  20. data/lib/gerbilcharts/public/brushmetal.css +123 -74
  21. data/lib/gerbilcharts/public/gerbil.js +104 -64
  22. data/lib/gerbilcharts/surfaces.rb +3 -0
  23. data/lib/gerbilcharts/surfaces/bubble_surface.rb +105 -0
  24. data/lib/gerbilcharts/surfaces/chart.rb +4 -2
  25. data/lib/gerbilcharts/surfaces/conversation_ring.rb +64 -0
  26. data/lib/gerbilcharts/surfaces/detailed_legend.rb +35 -13
  27. data/lib/gerbilcharts/surfaces/graph_element.rb +8 -1
  28. data/lib/gerbilcharts/surfaces/grid.rb +8 -2
  29. data/lib/gerbilcharts/surfaces/horizontal_axis.rb +12 -3
  30. data/lib/gerbilcharts/surfaces/horizontal_time_axis.rb +5 -4
  31. data/lib/gerbilcharts/surfaces/impulse_surface.rb +1 -1
  32. data/lib/gerbilcharts/surfaces/legend.rb +43 -6
  33. data/lib/gerbilcharts/surfaces/mark_band.rb +17 -1
  34. data/lib/gerbilcharts/surfaces/matrix_surface.rb +87 -0
  35. data/lib/gerbilcharts/surfaces/pie_surface.rb +109 -96
  36. data/lib/gerbilcharts/surfaces/rect.rb +18 -0
  37. data/lib/gerbilcharts/surfaces/stacked_area_surface.rb +42 -2
  38. data/lib/gerbilcharts/surfaces/stacked_grid.rb +1 -3
  39. data/lib/gerbilcharts/surfaces/title_panel.rb +7 -2
  40. data/lib/gerbilcharts/surfaces/tracker.rb +4 -1
  41. data/lib/gerbilcharts/surfaces/vertical_axis.rb +2 -2
  42. data/lib/gerbilcharts/svgdc.rb +1 -0
  43. data/lib/gerbilcharts/svgdc/css_inliner.rb +2 -2
  44. data/lib/gerbilcharts/svgdc/svg_ellipse.rb +21 -0
  45. data/lib/gerbilcharts/svgdc/svg_polygon.rb +19 -0
  46. data/lib/gerbilcharts/svgdc/svgdc.rb +4 -1
  47. data/lib/gerbilcharts/version.rb +2 -3
  48. data/test/test_bar.rb +1 -1
  49. data/test/test_bubble.rb +52 -0
  50. data/test/test_conversation.rb +34 -0
  51. data/test/test_lines.rb +3 -3
  52. data/test/test_matrix.rb +34 -0
  53. data/test/test_noob.rb +9 -6
  54. data/test/test_pie.rb +2 -2
  55. data/test/test_ranges.rb +15 -2
  56. data/test/test_sa.rb +88 -0
  57. metadata +14 -2
@@ -6,8 +6,8 @@ module GerbilCharts::Models
6
6
  # and the label values are neat and clean
7
7
  #
8
8
  class Presets
9
-
10
- protected
9
+
10
+ public
11
11
  PRESETS = [
12
12
  [0,0], [1,0.2], [5,1], [10,1],[20,5],
13
13
  [50,10],[100,25],[200,50], [500,100], [1000,200],
@@ -16,9 +16,10 @@ protected
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,4000000], [50000000, 10000000],
20
- [100000000,25000000], [500000000,100000000],
21
- [1000000000,250000000]
19
+ [8000000,2000000], [10000000,2000000], [20000000,5000000], [50000000, 10000000],
20
+ [100000000,25000000], [200000000,50000000], [500000000,100000000],
21
+ [1000000000, 250000000] , [3000000000, 1000000000] , [5000000000, 1000000000] ,
22
+ [10000000000,2000000000] ,
22
23
  ]
23
24
 
24
25
  TIMEPRESETS = [
@@ -26,10 +27,11 @@ protected
26
27
  [30,10],[60,10],[120,15], [300,60], [600,120],
27
28
  [900,300], [1800,300],
28
29
  [3600,900], [7200,1800],[10800,3600], [14400,3600], [21600,7200],
29
- [43200, 10800], [86400,21600],
30
- [172800, 43200], [259200,86400],
30
+ [43200, 10800], [86400,21600],
31
+ [172800, 43200], [259200,86400],
31
32
  [604800, 86400], [1209600,172800],
32
33
  [2419200, 604800],
34
+ [4848400, 604800],
33
35
  [7257600, 2419200],
34
36
  [14515200,7257600],
35
37
  [29030400,7257600],
@@ -58,8 +60,8 @@ protected
58
60
  UNITPRESETS.each do |unit|
59
61
  if raw_value.abs >= unit[0]
60
62
  retval = raw_value / unit[0]
61
- sout=format("%.2f %s", retval, unit[1])
62
- sout.gsub! ".00",""
63
+ sout=format("%.1f%s", retval, unit[1])
64
+ sout.gsub! "\.0",""
63
65
  return sout
64
66
  end
65
67
  end
@@ -71,6 +73,11 @@ protected
71
73
  # interval = desired window in seconds
72
74
  def format_timeval ( tvsec, interval)
73
75
  t = Time.at(tvsec).getlocal
76
+
77
+ if t.hour + t.min == 0
78
+ return t.strftime("%b-%d")
79
+ end
80
+
74
81
  if interval < 60
75
82
  return t.strftime("%M:%S")
76
83
  elsif interval < 300
@@ -80,9 +87,9 @@ protected
80
87
  elsif interval < 86400
81
88
  return t.strftime("%H:%M")
82
89
  elsif interval < 259200
83
- return t.strftime("%a-%H:%M")
90
+ return t.strftime("%H:%M")
84
91
  elsif interval < 604800
85
- return t.strtime("%b-%d")
92
+ return t.strftime("%b-%d")
86
93
  elsif interval < 2419200
87
94
  return t.strftime("%b-%d")
88
95
  else
@@ -12,7 +12,7 @@ class RawRange < Presets
12
12
  end
13
13
 
14
14
  def invalid?
15
- @rmin.nil?
15
+ @rmin.nil? || @rmax.nil?
16
16
  end
17
17
 
18
18
  # update - updates the range
@@ -45,11 +45,13 @@ class RoundRange < RawRange
45
45
  # provide ticks (per label interval)
46
46
  def each_tick(tpl)
47
47
 
48
- raise "Range not aligned with presets (call round range first)" if not @lmax
48
+ return "Range not aligned with presets (call round range first)" if not @lmax
49
49
 
50
50
  return if @lmax==0
51
+ return if tpl==0
51
52
 
52
53
  lint = @lmax/tpl
54
+ return if lint==0
53
55
  if @rmin % lint != 0
54
56
  v = (@rmin+lint) - (@rmin%lint)
55
57
  else
@@ -19,8 +19,10 @@ class RoundTimeRange < RawRange
19
19
  super()
20
20
  @rdelta,@ldelta=round_delta(raw_range.delta)
21
21
  @rmin=raw_range.rmin
22
- @rmax=round_max(raw_range.rmax,@rdelta)
23
- @gmhalfhour = Time.now.gmt_offset%3600
22
+
23
+ # this can be rdelta or ldelta for wider or tighter
24
+ #@rmax=round_max(raw_range.rmax,@rdelta)
25
+ @rmax=round_max(raw_range.rmax,@ldelta)
24
26
  end
25
27
 
26
28
  # provide labels
@@ -30,19 +32,8 @@ class RoundTimeRange < RawRange
30
32
  raise "Range not aligned with presets (call round range first)" if not @ldelta
31
33
 
32
34
  return if @ldelta == 0
33
-
34
- if (@rmin.tv_sec % @ldelta) != @gmhalfhour
35
- ni_sec = (@rmin.tv_sec+@ldelta)/@ldelta
36
35
 
37
- # if labeling hours, make sure you account tz weirdness like india GMT +5:30
38
- if @ldelta >= 3600
39
- v = Time.at(@ldelta * ni_sec.to_i - @gmhalfhour)
40
- else
41
- v = Time.at(@ldelta * ni_sec.to_i)
42
- end
43
- else
44
- v = @rmin
45
- end
36
+ v = get_label_start_time
46
37
 
47
38
  while (v<=@rmax) do
48
39
  yield v, format_timeval(v,@rdelta)
@@ -59,18 +50,7 @@ class RoundTimeRange < RawRange
59
50
 
60
51
  subtick_delta = ideal_subtick_interval(@ldelta)
61
52
 
62
- if (@rmin.tv_sec % @ldelta) != @gmhalfhour
63
- ni_sec = (@rmin.tv_sec+subtick_delta)/subtick_delta
64
-
65
- # if labeling hours, make sure you account tz weirdness like india GMT +5:30
66
- if @ldelta >= 3600
67
- v = Time.at(subtick_delta* ni_sec.to_i - @gmhalfhour)
68
- else
69
- v = Time.at(subtick_delta * ni_sec.to_i)
70
- end
71
- else
72
- v = @rmin
73
- end
53
+ v = get_label_start_time
74
54
 
75
55
  while (v<=@rmax) do
76
56
  yield v
@@ -121,7 +101,7 @@ private
121
101
  # Eg. 10x of 2 hours will be 12 min ticks = FAIL
122
102
  def ideal_subtick_interval(label_interval)
123
103
 
124
- case ldelta
104
+ case label_interval
125
105
  when (0..1*MINUTE); return 10
126
106
  when (1*MINUTE..5*MINUTE); return 1*MINUTE
127
107
  when (5*MINUTE..15*MINUTE); return 3*MINUTE
@@ -134,8 +114,18 @@ private
134
114
  end
135
115
  end
136
116
 
137
-
138
-
117
+ def get_label_start_time
118
+ # if labeling hours, make sure you account tz weirdness like india GMT +5:30
119
+ if @ldelta >= 86400
120
+ v = Time.mktime(@rmin.year, @rmin.month, @rmin.day,
121
+ 0,0,0,0) + 86400
122
+ elsif
123
+ tbase = Time.mktime(@rmin.year, @rmin.month, @rmin.day,0,0,0,0)
124
+ sec_inc = @rmin.tv_sec - tbase.tv_sec
125
+ v = Time.at( tbase.tv_sec + @ldelta*(sec_inc/@ldelta).ceil)
126
+ end
127
+ return v
128
+ end
139
129
  end
140
130
 
141
131
  end
@@ -47,7 +47,7 @@ class SampledTimeSeriesGraphModel < TimeSeriesGraphModel
47
47
 
48
48
  # sweep this bucket
49
49
  def sweep(tval)
50
-
50
+
51
51
  return 0 if @xarr.length == 0
52
52
  return 0 if @last_sweep_pos >= @xarr.length
53
53
 
@@ -1,139 +1,153 @@
1
1
  .surfacepanel
2
2
  {
3
- fill: none;
4
- stroke-width: 1;
5
- stroke: black;
3
+ fill: none;
4
+ stroke-width: 1;
5
+ stroke: black;
6
6
  }
7
7
  .gridlineh
8
8
  {
9
- stroke-width: 1;
10
- stroke: lightgray;
9
+ stroke-width: 0.7;
10
+ stroke: #ccc;
11
11
  }
12
12
  .gridlinev
13
13
  {
14
- stroke-width: 1;
15
- stroke: lightgray;
14
+ stroke-width: 0.7;
15
+ stroke: #ccc;
16
16
  }
17
17
  .gridlinesub
18
18
  {
19
- stroke-width: 0.4;
20
- stroke: lightgray;
19
+ stroke-width: 0.5;
20
+ stroke: #eee;
21
21
  }
22
22
  .surfaceback
23
23
  {
24
- fill: white;
24
+ fill: white;
25
+ stroke: none;
25
26
  }
26
27
  .axispanel
27
28
  {
28
- fill: lightgray;
29
+ fill: #EEEEEE;
30
+ stroke: none;
29
31
  }
30
32
  .axistickmajor
31
33
  {
32
- stroke-width: 2;
33
- stroke: black;
34
+ stroke-width: 2;
35
+ stroke: black;
34
36
  }
35
37
  .axistickminor
36
38
  {
37
- stroke-width: 1;
38
- stroke: black;
39
+ stroke-width: 1;
40
+ stroke: black;
39
41
  }
40
42
  .panel
41
43
  {
42
- fill: white;
44
+ fill: white;
43
45
  }
44
46
 
45
47
  .legend
46
48
  {
47
- fill: red;
49
+ fill: red;
50
+ }
51
+ .x_mk
52
+ {
53
+ fill: yellow;
54
+ fill-opacity: 0.10;
55
+ stroke: gray;
56
+ }
57
+ #ref_mod
58
+ {
59
+ fill: gray;
60
+ fill-opacity: 0.20;
61
+ stroke: none;
48
62
  }
49
63
  #item0
50
64
  {
51
65
  stroke: none;
52
- fill: #1F75FE;
66
+ fill: #2166AC;
53
67
  }
54
68
  #item1
55
69
  {
56
70
  stroke: none;
57
- fill: #B87333;
71
+ fill: #4393C3;
58
72
  }
59
73
  #item2
60
74
  {
61
75
  stroke: none;
62
- fill: gold;
76
+ fill: #92C5DE;
63
77
  }
64
78
  #item3
65
79
  {
66
80
  stroke: none;
67
- fill: magenta;
81
+ fill:#D1E5F0;
68
82
  }
69
83
  #item4
70
84
  {
71
85
  stroke: none;
72
- fill: olive;
86
+ fill:#D6604D; /*FDDBC7*/
73
87
  }
74
88
  #item5
75
89
  {
76
90
  stroke: none;
77
- fill: green;
91
+ fill:#FDDBC7;
78
92
  }
79
93
  #item6
80
94
  {
81
95
  stroke: none;
82
- fill: red;
96
+ fill: #2166AC;
83
97
  }
84
98
  #item7
85
99
  {
86
100
  stroke: none;
87
- fill: #F88017;
101
+ fill: #4393C3;
88
102
  }
89
103
  #item8
90
104
  {
91
105
  stroke: none;
92
- fill: #640E29;
106
+ fill: #92C5DE;
93
107
  }
94
108
  #item9
95
109
  {
96
110
  stroke: none;
97
- fill: aqua;
111
+ fill: #92C5DE;
98
112
  }
99
113
  #item10
100
114
  {
101
115
  stroke: none;
102
- fill: black;
116
+ fill: #D1E5F0;
103
117
  }
104
118
  #lineitem0
105
119
  {
106
- stroke: #1F75FE;
120
+ stroke: #2166AC;
107
121
  stroke-width: 2;
108
122
  }
109
123
  #lineitem1
110
124
  {
111
- stroke: #B87333;
125
+ stroke: #4393C3;
112
126
  stroke-width: 2;
113
127
  }
114
128
  #lineitem2
115
129
  {
116
- stroke: gold;
130
+ stroke:#92C5DE;
117
131
  stroke-width: 2;
118
132
  }
119
133
  #lineitem3
120
134
  {
121
- stroke: magenta;
135
+ stroke:#D1E5F0;
122
136
  stroke-width: 2;
123
137
  }
124
138
  #lineitem4
125
139
  {
126
- stroke: olive;
140
+ stroke:#FDDBC7;
127
141
  stroke-width: 2;
128
142
  }
129
143
  #lineitem5
130
144
  {
131
- stroke: green;
132
- stroke-width: 2;
145
+ stroke: #F4A582;
146
+ stroke-width:2;
133
147
  }
134
148
  #lineitem6
135
149
  {
136
- stroke: red;
150
+ stroke: #D6604D;
137
151
  stroke-width: 2;
138
152
  }
139
153
  #lineitem7
@@ -148,71 +162,106 @@
148
162
  }
149
163
  .axislabel
150
164
  {
151
- font-family: sans;
152
- font-size: 10px;
153
- fill: black;
154
- stroke: none;
165
+ font-family: monospace;
166
+ font-size: 11px;
167
+ fill: black;
168
+ stroke: none;
155
169
  }
156
170
 
157
171
  .axislabelt0
158
172
  {
159
- font-family: sans;
160
- font-size: 8px;
161
- fill: black;
162
- stroke: none;
173
+ font-family: monospace;
174
+ font-size: 9px;
175
+ fill: black;
176
+ stroke: none;
163
177
  }
164
178
  .titletext
165
179
  {
166
- fill: gray;
167
- stroke: none;
168
- font-family: Arial, Helvetica, sans-serif;;
169
- font-size: 24px;
170
- font-weight: bold;
180
+ fill: #999;
181
+ stroke:none;
182
+ font-family: Arial, Helvetica, sans-serif;
183
+ font-size: 22px;
171
184
  }
172
185
  .titlepanel
173
186
  {
174
- fill: white;
175
- fill-opacity: 0.5;
187
+ fill: none;
188
+ fill-opacity: 0.5;
189
+ }
190
+ .titletool
191
+ {
192
+ fill: #AAA;
193
+ stroke:none;
194
+ font-family: Arial, Helvetica, sans-serif;
195
+ font-size: 10px;
176
196
  }
177
197
  .legendpanel
178
198
  {
179
- fill: white;
180
- fill-opacity: 0.5;
199
+ fill: white;
200
+ fill-opacity: 0.6;
201
+ stroke: #ddd;
181
202
  }
182
203
 
183
204
  .legendtext
184
205
  {
185
- font-family: sans;
186
- font-size: 10px;
187
- fill: black;
188
- stroke: none;
206
+ font-family: Arial,Helvetica,sans-serif;
207
+ font-size: 10px;
208
+ fill: black;
209
+ stroke: none;
189
210
  }
190
211
  .legendstats
191
212
  {
192
- font-family: sans;
193
- font-size: 9px;
194
- fill: black;
195
- stroke: none;
213
+ font-family: monospace;
214
+ font-size: 10px;
215
+ fill: black;
216
+ stroke: none;
196
217
  }
197
218
 
198
219
  .elementlabel
199
220
  {
200
- font-family: sans;
201
- font-size: 10px;
202
- fill: black;
203
- stroke: none;
221
+ font-family: Arial,Helvetica,sans-serif;
222
+ font-size: 10px;
223
+ fill: black;
224
+ stroke: none;
225
+ }
226
+ .elementlabel_large
227
+ {
228
+ font-family: Arial,Helvetica,sans-serif;
229
+ font-size: 10px;
230
+ fill: black;
231
+ stroke: none;
232
+ }
233
+ .elementlabel_huge
234
+ {
235
+ font-family: Arial,Helvetica,sans-serif;
236
+ font-size: 12px;
237
+ fill: black;
238
+ stroke: none;
204
239
  }
205
240
  .elementvalue
206
241
  {
207
- font-family: sans;
208
- font-size: 8px;
209
- fill: black;
210
- stroke: none;
242
+ font-family: Arial,Helvetica,sans-serif;
243
+ font-size: 10px;
244
+ fill: black;
245
+ stroke: none;
246
+ }
247
+ .elementvalue_large
248
+ {
249
+ font-family: Arial,Helvetica,sans-serif;
250
+ font-size: 10px;
251
+ fill: black;
252
+ stroke: none;
253
+ }
254
+ .elementvalue_huge
255
+ {
256
+ font-family: Arial,Helvetica,sans-serif;
257
+ font-size: 12px;
258
+ fill: black;
259
+ stroke: none;
211
260
  }
212
261
  .trackerpanel
213
262
  {
214
263
  fill: white;
215
- fill-opacity: 0.01;
264
+ fill-opacity: 0.0;
216
265
  }
217
266
  .trackerrect
218
267
  {
@@ -223,13 +272,13 @@
223
272
  {
224
273
  font-family: courier;
225
274
  font-size: 11px;
226
- fill: black;
227
- stroke: none;
275
+ fill: black;
276
+ stroke: none;
228
277
  }
229
278
  .trackertextfromts
230
279
  {
231
280
  font-family: courier;
232
281
  font-size: 9px;
233
- fill: black;
234
- stroke: none;
282
+ fill: black;
283
+ stroke: none;
235
284
  }