rgraph-rails 1.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (74) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +9 -0
  3. data/.rspec +2 -0
  4. data/.travis.yml +4 -0
  5. data/CODE_OF_CONDUCT.md +13 -0
  6. data/Gemfile +4 -0
  7. data/README.md +73 -0
  8. data/Rakefile +6 -0
  9. data/bin/console +14 -0
  10. data/bin/setup +7 -0
  11. data/lib/rgraph-rails/version.rb +3 -0
  12. data/lib/rgraph-rails.rb +8 -0
  13. data/license.txt +19 -0
  14. data/rgraph-rails.gemspec +26 -0
  15. data/vendor/assets/images/bg.png +0 -0
  16. data/vendor/assets/images/bullet.png +0 -0
  17. data/vendor/assets/images/facebook-large.png +0 -0
  18. data/vendor/assets/images/google-plus-large.png +0 -0
  19. data/vendor/assets/images/logo.png +0 -0
  20. data/vendor/assets/images/meter-image-sd-needle.png +0 -0
  21. data/vendor/assets/images/meter-image-sd.png +0 -0
  22. data/vendor/assets/images/meter-sketch-needle.png +0 -0
  23. data/vendor/assets/images/meter-sketch.png +0 -0
  24. data/vendor/assets/images/odometer-background.png +0 -0
  25. data/vendor/assets/images/rgraph.jpg +0 -0
  26. data/vendor/assets/images/title.png +0 -0
  27. data/vendor/assets/images/twitter-large.png +0 -0
  28. data/vendor/assets/javascripts/RGraph.bar.js +3246 -0
  29. data/vendor/assets/javascripts/RGraph.bipolar.js +2003 -0
  30. data/vendor/assets/javascripts/RGraph.common.annotate.js +399 -0
  31. data/vendor/assets/javascripts/RGraph.common.context.js +600 -0
  32. data/vendor/assets/javascripts/RGraph.common.core.js +4751 -0
  33. data/vendor/assets/javascripts/RGraph.common.csv.js +275 -0
  34. data/vendor/assets/javascripts/RGraph.common.deprecated.js +454 -0
  35. data/vendor/assets/javascripts/RGraph.common.dynamic.js +1194 -0
  36. data/vendor/assets/javascripts/RGraph.common.effects.js +1524 -0
  37. data/vendor/assets/javascripts/RGraph.common.key.js +735 -0
  38. data/vendor/assets/javascripts/RGraph.common.resizing.js +550 -0
  39. data/vendor/assets/javascripts/RGraph.common.tooltips.js +605 -0
  40. data/vendor/assets/javascripts/RGraph.common.zoom.js +223 -0
  41. data/vendor/assets/javascripts/RGraph.drawing.background.js +636 -0
  42. data/vendor/assets/javascripts/RGraph.drawing.circle.js +579 -0
  43. data/vendor/assets/javascripts/RGraph.drawing.image.js +810 -0
  44. data/vendor/assets/javascripts/RGraph.drawing.marker1.js +710 -0
  45. data/vendor/assets/javascripts/RGraph.drawing.marker2.js +672 -0
  46. data/vendor/assets/javascripts/RGraph.drawing.marker3.js +568 -0
  47. data/vendor/assets/javascripts/RGraph.drawing.poly.js +623 -0
  48. data/vendor/assets/javascripts/RGraph.drawing.rect.js +603 -0
  49. data/vendor/assets/javascripts/RGraph.drawing.text.js +648 -0
  50. data/vendor/assets/javascripts/RGraph.drawing.xaxis.js +815 -0
  51. data/vendor/assets/javascripts/RGraph.drawing.yaxis.js +860 -0
  52. data/vendor/assets/javascripts/RGraph.fuel.js +965 -0
  53. data/vendor/assets/javascripts/RGraph.funnel.js +988 -0
  54. data/vendor/assets/javascripts/RGraph.gantt.js +1242 -0
  55. data/vendor/assets/javascripts/RGraph.gauge.js +1391 -0
  56. data/vendor/assets/javascripts/RGraph.hbar.js +1794 -0
  57. data/vendor/assets/javascripts/RGraph.hprogress.js +1307 -0
  58. data/vendor/assets/javascripts/RGraph.line.js +3940 -0
  59. data/vendor/assets/javascripts/RGraph.meter.js +1242 -0
  60. data/vendor/assets/javascripts/RGraph.modaldialog.js +292 -0
  61. data/vendor/assets/javascripts/RGraph.odo.js +1265 -0
  62. data/vendor/assets/javascripts/RGraph.pie.js +1979 -0
  63. data/vendor/assets/javascripts/RGraph.radar.js +1840 -0
  64. data/vendor/assets/javascripts/RGraph.rose.js +1860 -0
  65. data/vendor/assets/javascripts/RGraph.rscatter.js +1332 -0
  66. data/vendor/assets/javascripts/RGraph.scatter.js +3029 -0
  67. data/vendor/assets/javascripts/RGraph.thermometer.js +1131 -0
  68. data/vendor/assets/javascripts/RGraph.vprogress.js +1326 -0
  69. data/vendor/assets/javascripts/RGraph.waterfall.js +1252 -0
  70. data/vendor/assets/javascripts/financial-data.js +1067 -0
  71. data/vendor/assets/stylesheets/ModalDialog.css +90 -0
  72. data/vendor/assets/stylesheets/animations.css +3347 -0
  73. data/vendor/assets/stylesheets/website.css +402 -0
  74. metadata +175 -0
@@ -0,0 +1,275 @@
1
+ // version: 2015-11-02
2
+ /**
3
+ * o--------------------------------------------------------------------------------o
4
+ * | This file is part of the RGraph package - you can learn more at: |
5
+ * | |
6
+ * | http://www.rgraph.net |
7
+ * | |
8
+ * | RGraph is dual licensed under the Open Source GPL (General Public License) |
9
+ * | v2.0 license and a commercial license which means that you're not bound by |
10
+ * | the terms of the GPL. The commercial license is just �99 (GBP) and you can |
11
+ * | read about it here: |
12
+ * | http://www.rgraph.net/license |
13
+ * o--------------------------------------------------------------------------------o
14
+ */
15
+
16
+ /**
17
+ * Initialise the various objects
18
+ */
19
+ RGraph = window.RGraph || {isRGraph: true};
20
+
21
+
22
+
23
+
24
+ RGraph.CSV = function (url, func)
25
+ {
26
+ var RG = RGraph,
27
+ ua = navigator.userAgent,
28
+ ma = Math;
29
+
30
+
31
+
32
+
33
+ /**
34
+ * Some default values
35
+ */
36
+ this.url = url;
37
+ this.ready = func;
38
+ this.data = null;
39
+ this.numrows = null;
40
+ this.numcols = null;
41
+ this.seperator = arguments[2] || ',';
42
+ this.endofline = arguments[3] || /\r?\n/;
43
+
44
+
45
+
46
+
47
+ /**
48
+ * A Custom split function
49
+ *
50
+ * @param string str The CSV string to split
51
+ * @param mixed char The character to split on - or it can also be an object like this:
52
+ * {
53
+ * preserve: false, // Whether to preserve whitespace
54
+ * char: ',' // The character to split on
55
+ * }
56
+ */
57
+ this.splitCSV = function (str, split)
58
+ {
59
+ // Defaults
60
+ var arr = [];
61
+ var field = '';
62
+ var inDoubleQuotes = false;
63
+ var inSingleQuotes = false;
64
+ var preserve = (typeof split === 'object' && split.preserve) ? true : false;
65
+
66
+ // The character to split the CSV string on
67
+ if (typeof split === 'object') {
68
+ if (typeof split.char === 'string') {
69
+ split = split.char;
70
+ } else {
71
+ split = ',';
72
+ }
73
+ } // If not an object just leave the char as it's supplied
74
+
75
+
76
+
77
+ for (var i=0,len=str.length; i<len; i+=1) {
78
+
79
+ char = str.charAt(i);
80
+
81
+ if ( (char === '"') && !inDoubleQuotes) {
82
+ inDoubleQuotes = true;
83
+ continue;
84
+
85
+ } else if ( (char === '"') && inDoubleQuotes) {
86
+ inDoubleQuotes = false;
87
+ continue;
88
+ }
89
+ if ( (char === "'") && !inSingleQuotes) {
90
+ inSingleQuotes = true;
91
+ continue;
92
+
93
+ } else if ( (char === "'") && inSingleQuotes) {
94
+ inSingleQuotes = false;
95
+ continue;
96
+
97
+ } else if (char === split && !inDoubleQuotes && !inSingleQuotes) {
98
+ // TODO look ahead in order to allow for multi-character seperators
99
+ arr.push(field);
100
+ field = '';
101
+ continue;
102
+
103
+ } else {
104
+ field = field + char;
105
+ }
106
+ }
107
+
108
+ // Add the last field
109
+ arr.push(field);
110
+
111
+ // Now trim each value if necessary
112
+ if (!preserve) {
113
+ for (i=0,len=arr.length; i<len; i+=1) {
114
+ arr[i] = arr[i].trim();
115
+ }
116
+ }
117
+
118
+ return arr;
119
+ };
120
+
121
+
122
+
123
+
124
+ /**
125
+ * This function splits the CSV data into an array so that it can be useful.
126
+ */
127
+ this.fetch = function ()
128
+ {
129
+ var sep = this.seperator;
130
+ var eol = this.endofline;
131
+ var obj = this;
132
+
133
+ if (this.url.substring(0,3) == 'id:') {
134
+
135
+ // Get rid of any surrounding whitespace
136
+ var data = document.getElementById(this.url.substring(3)).innerHTML.trim();
137
+
138
+ // Store the CSV data on the CSV object (ie - this object)
139
+ obj.data = data.split(eol);
140
+
141
+ // Store the number of rows
142
+ obj.numrows = obj.data.length;
143
+
144
+ for (var i=0,len=obj.data.length; i<len; i+=1) {
145
+
146
+
147
+ /**
148
+ * Split the individual line
149
+ */
150
+ //var row = obj.data[i].split(sep);
151
+ var row = obj.splitCSV(obj.data[i], {preserve: false, char: sep});
152
+
153
+
154
+ if (!obj.numcols) {
155
+ obj.numcols = row.length;
156
+ }
157
+
158
+ /**
159
+ * If the cell is purely made up of numbers - convert it
160
+ */
161
+ for (var j=0; j<row.length; j+=1) {
162
+ if ((/^[0-9.]+$/).test(row[j])) {
163
+ row[j] = parseFloat(row[j]);
164
+ }
165
+
166
+ // Assign the split-up-row back to the data array
167
+ obj.data[i] = row;
168
+ }
169
+ }
170
+
171
+ // Call the ready function straight away
172
+ obj.ready(obj);
173
+
174
+ } else {
175
+
176
+ RGraph.AJAX.getString(this.url, function (data)
177
+ {
178
+ data = data.replace(/(\r?\n)+$/, '');
179
+
180
+ /**
181
+ * Split the lines in the CSV
182
+ */
183
+ obj.data = data.split(eol);
184
+
185
+ /**
186
+ * Store the number of rows
187
+ */
188
+ obj.numrows = obj.data.length;
189
+
190
+
191
+
192
+ /**
193
+ * Loop thru each lines in the CSV file
194
+ */
195
+ for (var i=0,len=obj.data.length; i<len; i+=1) {
196
+ /**
197
+ * Use the new split function to split each row NOT preserving whitespace
198
+ */
199
+ //var row = obj.data[i].split(sep);
200
+ var row = obj.splitCSV(obj.data[i], {preserve: false, char: sep});
201
+
202
+ if (!obj.numcols) {
203
+ obj.numcols = row.length;
204
+ }
205
+
206
+ /**
207
+ * If the cell is purely made up of numbers - convert it
208
+ */
209
+ for (var j=0; j<row.length; j+=1) {
210
+ if ((/^\-?[0-9.]+$/).test(row[j])) {
211
+ row[j] = parseFloat(row[j]);
212
+ }
213
+
214
+ // Assign the split-up-row back to the data array
215
+ obj.data[i] = row;
216
+ }
217
+
218
+ }
219
+
220
+ // Call the ready function straight away
221
+ obj.ready(obj);
222
+ });
223
+ }
224
+ };
225
+
226
+
227
+
228
+
229
+ /**
230
+ * Returns a row of the CSV file
231
+ *
232
+ * @param number index The index of the row to fetch
233
+ * @param start OPTIONAL If desired you can specify a column to start at (which starts at 0 by default)
234
+ */
235
+ this.getRow = function (index)
236
+ {
237
+ var row = [];
238
+ var start = arguments[1] || 0;
239
+
240
+ for (var i=start; i<this.numcols; i+=1) {
241
+ row.push(this.data[index][i]);
242
+ }
243
+
244
+ return row;
245
+ };
246
+
247
+
248
+
249
+
250
+ /**
251
+ * Returns a column of the CSV file
252
+ *
253
+ * @param number index The index of the column to fetch
254
+ * @param start OPTIONAL If desired you can specify a row to start at (which starts at 0 by default)
255
+ */
256
+ this.getCol =
257
+ this.getColumn = function (index)
258
+ {
259
+ var col = [];
260
+ var start = arguments[1] || 0;
261
+
262
+ for (var i=start; i<this.numrows; i+=1) {
263
+ col.push(this.data[i][index]);
264
+ }
265
+
266
+ return col;
267
+ };
268
+
269
+
270
+
271
+
272
+
273
+ // Fetch the CSV file
274
+ this.fetch();
275
+ };
@@ -0,0 +1,454 @@
1
+ // version: 2015-11-02
2
+ /**
3
+ * o--------------------------------------------------------------------------------o
4
+ * | This file is part of the RGraph package - you can learn more at: |
5
+ * | |
6
+ * | http://www.rgraph.net |
7
+ * | |
8
+ * | RGraph is dual licensed under the Open Source GPL (General Public License) |
9
+ * | v2.0 license and a commercial license which means that you're not bound by |
10
+ * | the terms of the GPL. The commercial license is just �99 (GBP) and you can |
11
+ * | read about it here: |
12
+ * | http://www.rgraph.net/license |
13
+ * o--------------------------------------------------------------------------------o
14
+ */
15
+
16
+ RGraph = window.RGraph || {isRGraph: true};
17
+
18
+ // Module pattern
19
+ (function (win, doc, undefined)
20
+ {
21
+ var RG = RGraph,
22
+ ua = navigator.userAgent,
23
+ ma = Math;
24
+
25
+
26
+
27
+
28
+ /**
29
+ * This is a useful function which is basically a shortcut for drawing left, right, top and bottom alligned text.
30
+ *
31
+ * @param object context The context
32
+ * @param string font The font
33
+ * @param int size The size of the text
34
+ * @param int x The X coordinate
35
+ * @param int y The Y coordinate
36
+ * @param string text The text to draw
37
+ * @parm string The vertical alignment. Can be null. "center" gives center aligned text, "top" gives top aligned text.
38
+ * Anything else produces bottom aligned text. Default is bottom.
39
+ * @param string The horizontal alignment. Can be null. "center" gives center aligned text, "right" gives right aligned text.
40
+ * Anything else produces left aligned text. Default is left.
41
+ * @param bool Whether to show a bounding box around the text. Defaults not to
42
+ * @param int The angle that the text should be rotate at (IN DEGREES)
43
+ * @param string Background color for the text
44
+ * @param bool Whether the text is bold or not
45
+ */
46
+ RG.text =
47
+ RG.Text = function (context, font, size, x, y, text)
48
+ {
49
+ // "Cache" the args as a local variable
50
+ var args = arguments;
51
+
52
+ // Handle undefined - change it to an empty string
53
+ if ((typeof(text) != 'string' && typeof(text) != 'number') || text == 'undefined') {
54
+ return;
55
+ }
56
+
57
+
58
+
59
+
60
+ /**
61
+ * This accommodates multi-line text
62
+ */
63
+ if (typeof(text) == 'string' && text.match(/\r\n/)) {
64
+
65
+ var dimensions = RGraph.MeasureText('M', args[11], font, size);
66
+
67
+ /**
68
+ * Measure the text (width and height)
69
+ */
70
+
71
+ var arr = text.split('\r\n');
72
+
73
+ /**
74
+ * Adjust the Y position
75
+ */
76
+
77
+ // This adjusts the initial y position
78
+ if (args[6] && args[6] == 'center') y = (y - (dimensions[1] * ((arr.length - 1) / 2)));
79
+
80
+ for (var i=1; i<arr.length; ++i) {
81
+
82
+ RGraph.Text(context,
83
+ font,
84
+ size,
85
+ args[9] == -90 ? (x + (size * 1.5)) : x,
86
+ y + (dimensions[1] * i),
87
+ arr[i],
88
+ args[6] ? args[6] : null,
89
+ args[7],
90
+ args[8],
91
+ args[9],
92
+ args[10],
93
+ args[11],
94
+ args[12]);
95
+ }
96
+
97
+ // Update text to just be the first line
98
+ text = arr[0];
99
+ }
100
+
101
+
102
+ // Accommodate MSIE
103
+ if (document.all && RGraph.ISOLD) {
104
+ y += 2;
105
+ }
106
+
107
+
108
+ context.font = (args[11] ? 'Bold ': '') + size + 'pt ' + font;
109
+
110
+ var i;
111
+ var origX = x;
112
+ var origY = y;
113
+ var originalFillStyle = context.fillStyle;
114
+ var originalLineWidth = context.lineWidth;
115
+
116
+ // Need these now the angle can be specified, ie defaults for the former two args
117
+ if (typeof(args[6]) == 'undefined') args[6] = 'bottom'; // Vertical alignment. Default to bottom/baseline
118
+ if (typeof(args[7]) == 'undefined') args[7] = 'left'; // Horizontal alignment. Default to left
119
+ if (typeof(args[8]) == 'undefined') args[8] = null; // Show a bounding box. Useful for positioning during development. Defaults to false
120
+ if (typeof(args[9]) == 'undefined') args[9] = 0; // Angle (IN DEGREES) that the text should be drawn at. 0 is middle right, and it goes clockwise
121
+
122
+ // The alignment is recorded here for purposes of Opera compatibility
123
+ if (navigator.userAgent.indexOf('Opera') != -1) {
124
+ context.canvas.__rgraph_valign__ = args[6];
125
+ context.canvas.__rgraph_halign__ = args[7];
126
+ }
127
+
128
+ // First, translate to x/y coords
129
+ context.save();
130
+
131
+ context.canvas.__rgraph_originalx__ = x;
132
+ context.canvas.__rgraph_originaly__ = y;
133
+
134
+ context.translate(x, y);
135
+ x = 0;
136
+ y = 0;
137
+
138
+ // Rotate the canvas if need be
139
+ if (args[9]) {
140
+ context.rotate(args[9] / (180 / RGraph.PI));
141
+ }
142
+
143
+
144
+ // Vertical alignment - defaults to bottom
145
+ if (args[6]) {
146
+
147
+ var vAlign = args[6];
148
+
149
+ if (vAlign == 'center') {
150
+ context.textBaseline = 'middle';
151
+ } else if (vAlign == 'top') {
152
+ context.textBaseline = 'top';
153
+ }
154
+ }
155
+
156
+
157
+ // Hoeizontal alignment - defaults to left
158
+ if (args[7]) {
159
+
160
+ var hAlign = args[7];
161
+ var width = context.measureText(text).width;
162
+
163
+ if (hAlign) {
164
+ if (hAlign == 'center') {
165
+ context.textAlign = 'center';
166
+ } else if (hAlign == 'right') {
167
+ context.textAlign = 'right';
168
+ }
169
+ }
170
+ }
171
+
172
+
173
+ context.fillStyle = originalFillStyle;
174
+
175
+ /**
176
+ * Draw a bounding box if requested
177
+ */
178
+ context.save();
179
+ context.fillText(text,0,0);
180
+ context.lineWidth = 1;
181
+
182
+ var width = context.measureText(text).width;
183
+ var width_offset = (hAlign == 'center' ? (width / 2) : (hAlign == 'right' ? width : 0));
184
+ var height = size * 1.5; // !!!
185
+ var height_offset = (vAlign == 'center' ? (height / 2) : (vAlign == 'top' ? height : 0));
186
+ var ieOffset = RGraph.ISOLD ? 2 : 0;
187
+
188
+ if (args[8]) {
189
+
190
+ context.strokeRect(-3 - width_offset,
191
+ 0 - 3 - height - ieOffset + height_offset,
192
+ width + 6,
193
+ height + 6);
194
+ /**
195
+ * If requested, draw a background for the text
196
+ */
197
+ if (args[10]) {
198
+ context.fillStyle = args[10];
199
+ context.fillRect(-3 - width_offset,
200
+ 0 - 3 - height - ieOffset + height_offset,
201
+ width + 6,
202
+ height + 6);
203
+ }
204
+
205
+
206
+ context.fillStyle = originalFillStyle;
207
+
208
+
209
+ /**
210
+ * Do the actual drawing of the text
211
+ */
212
+ context.fillText(text,0,0);
213
+ }
214
+ context.restore();
215
+
216
+ // Reset the lineWidth
217
+ context.lineWidth = originalLineWidth;
218
+
219
+ context.restore();
220
+ };
221
+
222
+
223
+
224
+
225
+ /**
226
+ * This function returns the mouse position in relation to the canvas
227
+ *
228
+ * @param object e The event object.
229
+ */
230
+ RG.getMouseXY = function (e)
231
+ {
232
+ var el = (RGraph.ISOLD ? event.srcElement : e.target);
233
+ var x;
234
+ var y;
235
+
236
+ // ???
237
+ var paddingLeft = el.style.paddingLeft ? parseInt(el.style.paddingLeft) : 0;
238
+ var paddingTop = el.style.paddingTop ? parseInt(el.style.paddingTop) : 0;
239
+ var borderLeft = el.style.borderLeftWidth ? parseInt(el.style.borderLeftWidth) : 0;
240
+ var borderTop = el.style.borderTopWidth ? parseInt(el.style.borderTopWidth) : 0;
241
+
242
+ if (RGraph.ISIE8) e = event;
243
+
244
+ // Browser with offsetX and offsetY
245
+ if (typeof(e.offsetX) == 'number' && typeof(e.offsetY) == 'number') {
246
+ x = e.offsetX;
247
+ y = e.offsetY;
248
+
249
+ // FF and other
250
+ } else {
251
+ x = 0;
252
+ y = 0;
253
+
254
+ while (el != document.body && el) {
255
+ x += el.offsetLeft;
256
+ y += el.offsetTop;
257
+
258
+ el = el.offsetParent;
259
+ }
260
+
261
+ x = e.pageX - x;
262
+ y = e.pageY - y;
263
+ }
264
+
265
+ return [x, y];
266
+ };
267
+
268
+
269
+
270
+
271
+ /**
272
+ * This function attempts to "fill in" missing functions from the canvas
273
+ * context object. Only two at the moment - measureText() nd fillText().
274
+ *
275
+ * @param object context The canvas 2D context
276
+ */
277
+ RG.oldBrowserCompat =
278
+ RG.OldBrowserCompat = function (co)
279
+ {
280
+ if (!co) {
281
+ return;
282
+ }
283
+
284
+ if (!co.measureText) {
285
+
286
+ // This emulates the measureText() function
287
+ co.measureText = function (text)
288
+ {
289
+ var textObj = document.createElement('DIV');
290
+ textObj.innerHTML = text;
291
+ textObj.style.position = 'absolute';
292
+ textObj.style.top = '-100px';
293
+ textObj.style.left = 0;
294
+ document.body.appendChild(textObj);
295
+
296
+ var width = {width: textObj.offsetWidth};
297
+
298
+ textObj.style.display = 'none';
299
+
300
+ return width;
301
+ }
302
+ }
303
+
304
+ if (!co.fillText) {
305
+ // This emulates the fillText() method
306
+ co.fillText = function (text, targetX, targetY)
307
+ {
308
+ return false;
309
+ }
310
+ }
311
+
312
+ // If IE8, add addEventListener()
313
+ if (!co.canvas.addEventListener) {
314
+ window.addEventListener = function (ev, func, bubble)
315
+ {
316
+ return this.attachEvent('on' + ev, func);
317
+ }
318
+
319
+ co.canvas.addEventListener = function (ev, func, bubble)
320
+ {
321
+ return this.attachEvent('on' + ev, func);
322
+ }
323
+ }
324
+ };
325
+
326
+
327
+
328
+
329
+ /**
330
+ * Similar to the jQuery each() function - this lets you iterate easily over an array. The 'this' variable is set]
331
+ * to the array in the callback function.
332
+ *
333
+ * @param array arr The array
334
+ * @param function func The function to call
335
+ * @param object Optionally you can specify the object that the "this" variable is set to
336
+ */
337
+ RG.each = function (arr, func)
338
+ {
339
+ for(var i=0, len=arr.length; i<len; i+=1) {
340
+
341
+ if (typeof arguments[2] !== 'undefined') {
342
+ var ret = func.call(arguments[2], i, arr[i]);
343
+ } else {
344
+ var ret = func.call(arr, i, arr[i]);
345
+ }
346
+
347
+ if (ret === false) {
348
+ return;
349
+ }
350
+ }
351
+ };
352
+
353
+
354
+
355
+
356
+ /**
357
+ * An old function the was used before all 4 gutters were added
358
+ *
359
+ * DEPRECATED
360
+ *
361
+ * @param object obj The chart object
362
+ */
363
+ RG.getHeight =
364
+ RG.GetHeight = function (obj)
365
+ {
366
+ return obj.canvas.height;
367
+ };
368
+
369
+
370
+
371
+
372
+ /**
373
+ * An old function the was used before all 4 gutters were added
374
+ *
375
+ * DEPRECATED
376
+ *
377
+ * @param object obj The chart object
378
+ */
379
+ RG.getWidth =
380
+ RG.GetWidth = function (obj)
381
+ {
382
+ return obj.canvas.width;
383
+ };
384
+
385
+
386
+
387
+
388
+ /**
389
+ * A timer function for measuring... time!
390
+ *
391
+ * @param string label A string to associate with this 'checkpoint'
392
+ */
393
+ RG.timer =
394
+ RG.Timer = function (label)
395
+ {
396
+ if(typeof RG.TIMER_LAST_CHECKPOINT == 'undefined') {
397
+
398
+ RG.TIMER_LAST_CHECKPOINT = Date.now();
399
+ }
400
+
401
+ var now = Date.now();
402
+
403
+ console.log(label+': ' + (now - RG.TIMER_LAST_CHECKPOINT).toString());
404
+
405
+ RG.TIMER_LAST_CHECKPOINT = now;
406
+ };
407
+
408
+
409
+
410
+
411
+ /**
412
+ * If you prefer, you can use the SetConfig() method to set the configuration information
413
+ * for your chart. You may find that setting the configuration this way eases reuse.
414
+ *
415
+ * @param object obj The graph object
416
+ * @param object config The graph configuration information
417
+ */
418
+ RG.setConfig =
419
+ RG.SetConfig = function (obj, config)
420
+ {
421
+ for (i in config) {
422
+ if (typeof i === 'string') {
423
+ obj.Set(i, config[i]);
424
+ }
425
+ }
426
+
427
+ return obj;
428
+ };
429
+
430
+
431
+
432
+
433
+ // End module pattern
434
+ })(window, document);
435
+
436
+
437
+
438
+
439
+ /**
440
+ * Checks whether strings or numbers are empty or not. It also
441
+ * handles null or variables set to undefined. If a variable really
442
+ * is undefined - ie it hasn't been declared at all - you need to use
443
+ * "typeof variable" and check the return value - which will be undefined.
444
+ *
445
+ * @param mixed value The variable to check
446
+ */
447
+ window.$empty = function (value)
448
+ {
449
+ if (!value || value.length <= 0) {
450
+ return true;
451
+ }
452
+
453
+ return false;
454
+ };