rgraph-rails 5.00 → 6.14

Sign up to get free protection for your applications and to get access to all the features.
Files changed (85) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/publish-geml.yaml +46 -0
  3. data/.gitignore +1 -0
  4. data/README.md +4 -5
  5. data/lib/rgraph-rails/version.rb +1 -1
  6. data/rgraph-rails.gemspec +4 -4
  7. data/vendor/assets/javascripts/RGraph.activity.js +1691 -0
  8. data/vendor/assets/javascripts/RGraph.bar.js +4253 -236
  9. data/vendor/assets/javascripts/RGraph.bipolar.js +3958 -162
  10. data/vendor/assets/javascripts/RGraph.common.annotate.js +414 -35
  11. data/vendor/assets/javascripts/RGraph.common.context.js +635 -30
  12. data/vendor/assets/javascripts/RGraph.common.core.js +10485 -419
  13. data/vendor/assets/javascripts/RGraph.common.csv.js +508 -27
  14. data/vendor/assets/javascripts/RGraph.common.dynamic.js +1693 -90
  15. data/vendor/assets/javascripts/RGraph.common.effects.js +1629 -89
  16. data/vendor/assets/javascripts/RGraph.common.key.js +1003 -53
  17. data/vendor/assets/javascripts/RGraph.common.moment.js +5670 -0
  18. data/vendor/assets/javascripts/RGraph.common.sheets.js +541 -31
  19. data/vendor/assets/javascripts/RGraph.common.sheets.php +351 -0
  20. data/vendor/assets/javascripts/RGraph.common.starburst.js +382 -0
  21. data/vendor/assets/javascripts/RGraph.common.table.js +386 -0
  22. data/vendor/assets/javascripts/RGraph.common.tooltips.js +1433 -32
  23. data/vendor/assets/javascripts/RGraph.drawing.background.js +660 -35
  24. data/vendor/assets/javascripts/RGraph.drawing.circle.js +618 -34
  25. data/vendor/assets/javascripts/RGraph.drawing.image.js +857 -52
  26. data/vendor/assets/javascripts/RGraph.drawing.line.js +712 -0
  27. data/vendor/assets/javascripts/RGraph.drawing.marker1.js +760 -38
  28. data/vendor/assets/javascripts/RGraph.drawing.marker2.js +740 -37
  29. data/vendor/assets/javascripts/RGraph.drawing.marker3.js +573 -36
  30. data/vendor/assets/javascripts/RGraph.drawing.poly.js +667 -36
  31. data/vendor/assets/javascripts/RGraph.drawing.rect.js +638 -34
  32. data/vendor/assets/javascripts/RGraph.drawing.text.js +672 -37
  33. data/vendor/assets/javascripts/RGraph.drawing.xaxis.js +653 -52
  34. data/vendor/assets/javascripts/RGraph.drawing.yaxis.js +714 -51
  35. data/vendor/assets/javascripts/RGraph.fuel.js +1149 -59
  36. data/vendor/assets/javascripts/RGraph.funnel.js +1277 -56
  37. data/vendor/assets/javascripts/RGraph.gantt.js +1646 -82
  38. data/vendor/assets/javascripts/RGraph.gauge.js +1773 -89
  39. data/vendor/assets/javascripts/RGraph.hbar.js +3869 -159
  40. data/vendor/assets/javascripts/RGraph.horseshoe.js +970 -0
  41. data/vendor/assets/javascripts/RGraph.hprogress.js +1829 -81
  42. data/vendor/assets/javascripts/RGraph.line.js +5293 -244
  43. data/vendor/assets/javascripts/RGraph.meter.js +1570 -77
  44. data/vendor/assets/javascripts/RGraph.modaldialog.js +300 -19
  45. data/vendor/assets/javascripts/RGraph.odo.js +1553 -68
  46. data/vendor/assets/javascripts/RGraph.pie.js +3273 -129
  47. data/vendor/assets/javascripts/RGraph.radar.js +2333 -108
  48. data/vendor/assets/javascripts/RGraph.rose.js +2685 -114
  49. data/vendor/assets/javascripts/RGraph.rscatter.js +1920 -80
  50. data/vendor/assets/javascripts/RGraph.scatter.js +4215 -171
  51. data/vendor/assets/javascripts/RGraph.segmented.js +1006 -0
  52. data/vendor/assets/javascripts/RGraph.semicircularprogress.js +1980 -59
  53. data/vendor/assets/javascripts/RGraph.svg.activity.js +1696 -0
  54. data/vendor/assets/javascripts/RGraph.svg.bar.js +2575 -77
  55. data/vendor/assets/javascripts/RGraph.svg.bipolar.js +3533 -106
  56. data/vendor/assets/javascripts/RGraph.svg.common.ajax.js +240 -21
  57. data/vendor/assets/javascripts/RGraph.svg.common.core.js +7105 -299
  58. data/vendor/assets/javascripts/RGraph.svg.common.csv.js +408 -28
  59. data/vendor/assets/javascripts/RGraph.svg.common.fx.js +1291 -68
  60. data/vendor/assets/javascripts/RGraph.svg.common.key.js +451 -20
  61. data/vendor/assets/javascripts/RGraph.svg.common.sheets.js +543 -31
  62. data/vendor/assets/javascripts/RGraph.svg.common.table.js +391 -0
  63. data/vendor/assets/javascripts/RGraph.svg.common.tooltips.js +1072 -23
  64. data/vendor/assets/javascripts/RGraph.svg.funnel.js +1151 -32
  65. data/vendor/assets/javascripts/RGraph.svg.gauge.js +1429 -34
  66. data/vendor/assets/javascripts/RGraph.svg.hbar.js +2692 -65
  67. data/vendor/assets/javascripts/RGraph.svg.horseshoe.js +969 -0
  68. data/vendor/assets/javascripts/RGraph.svg.line.js +2855 -86
  69. data/vendor/assets/javascripts/RGraph.svg.pie.js +1630 -58
  70. data/vendor/assets/javascripts/RGraph.svg.radar.js +1772 -58
  71. data/vendor/assets/javascripts/RGraph.svg.rose.js +2419 -83
  72. data/vendor/assets/javascripts/RGraph.svg.scatter.js +2280 -65
  73. data/vendor/assets/javascripts/RGraph.svg.segmented.js +930 -0
  74. data/vendor/assets/javascripts/RGraph.svg.semicircularprogress.js +1612 -29
  75. data/vendor/assets/javascripts/RGraph.svg.waterfall.js +1525 -50
  76. data/vendor/assets/javascripts/RGraph.thermometer.js +1411 -64
  77. data/vendor/assets/javascripts/RGraph.vprogress.js +1915 -81
  78. data/vendor/assets/javascripts/RGraph.waterfall.js +1896 -89
  79. data/vendor/assets/javascripts/financial-data.js +1067 -0
  80. metadata +37 -16
  81. data/.travis.yml +0 -11
  82. data/vendor/assets/javascripts/RGraph.common.deprecated.js +0 -35
  83. data/vendor/assets/javascripts/RGraph.common.resizing.js +0 -38
  84. data/vendor/assets/javascripts/RGraph.common.zoom.js +0 -15
  85. data/vendor/assets/javascripts/RGraph.cornergauge.js +0 -71
@@ -1,32 +1,542 @@
1
+ 'version:2023-09-16 (6.14)';
2
+ //
3
+ // o--------------------------------------------------------------------------------o
4
+ // | This file is part of the RGraph package - you can learn more at: |
5
+ // | |
6
+ // | https://www.rgraph.net |
7
+ // | |
8
+ // | RGraph is licensed under the Open Source MIT license. That means that it's |
9
+ // | totally free to use and there are no restrictions on what you can do with it! |
10
+ // o--------------------------------------------------------------------------------o
1
11
 
2
- RGraph=window.RGraph||{isRGraph:true};(function(win,doc,undefined)
3
- {RGraph.Sheets=function(key)
4
- {var worksheet,callback,letters='ABCDEFGHIJKLMNOPQRSTUVWXYZ';if(arguments.length===3){worksheet=Number(arguments[1]);callback=arguments[2];}else{worksheet=1;callback=arguments[1];}
5
- var url='https://spreadsheets.google.com/feeds/cells/[KEY]/[WORKSHEET]/public/full?alt=json-in-script&callback=__rgraph_JSONPCallback'.replace(/\[KEY\]/,key).replace(/\[WORKSHEET\]/,worksheet);this.load=function(url,userCallback)
6
- {var obj=this;__rgraph_JSONPCallback=function(json)
7
- {obj.json=json;var grid=[],row=0,col=0;for(var i=0;i<json.feed.entry.length;++i){row=json.feed.entry[i].gs$cell.row-1;col=json.feed.entry[i].gs$cell.col-1;if(!grid[row]){grid[row]=[];}
8
- grid[row][col]=json.feed.entry[i].content.$t;}
9
- var maxcols=0;for(var i=0;i<grid.length;++i){maxcols=grid[i]?Math.max(maxcols,grid[i].length):maxcols;}
10
- for(var i=0;i<grid.length;++i){if(typeof grid[i]==='undefined'){grid[i]=new Array(maxcols);}
11
- for(var j=0;j<maxcols;j++){if(typeof grid[i][j]==='undefined'){grid[i][j]='';}
12
- if(grid[i][j].match(/^[0-9]+$/)){grid[i][j]=parseInt(grid[i][j]);}else if(grid[i][j].match(/^[0-9.]+$/)){grid[i][j]=parseFloat(grid[i][j]);}}}
13
- obj.data=grid;userCallback(obj);};var scriptNode=document.createElement('script');scriptNode.src=url;document.body.appendChild(scriptNode);};this.row=function(index,start)
14
- {var opt={},row;start=start||1;if(arguments&&typeof arguments[2]==='object'&&typeof arguments[2].trim==='boolean'){opt.trim=arguments[2].trim;}else{opt.trim=true;}
15
- row=this.data[index-1].slice(start-1);if(opt.trim){row=RGraph.Sheets.arrayRTrim(row);}
16
- return row;};this.col=function(index,start)
17
- {var opt={},col=[];start=start||1;if(arguments&&typeof arguments[2]==='object'&&typeof arguments[2].trim==='boolean'){opt.trim=arguments[2].trim;}else{opt.trim=true;}
18
- for(var i=0;i<this.data.length;++i){col.push(this.data[i][index-1]);}
19
- if(opt.trim){col=RGraph.Sheets.arrayRTrim(col);}
20
- col=col.slice(start-1);return col;};this.getIndexOfLetters=function(l)
21
- {var parts=l.split('');if(parts.length===1){return letters.indexOf(l)+1;}else if(parts.length===2){var idx=((letters.indexOf(parts[0])+1)*26)+(letters.indexOf(parts[1])+1);return idx;}}
22
- this.get=function(str)
23
- {str=str.toUpperCase();if(str.match(/^[a-z]+$/i)){if(str.length===1){var index=letters.indexOf(str)+1;return this.col(index,1,arguments[1]);}else if(str.length===2){var index=((letters.indexOf(str[0])+1)*26)+letters.indexOf(str[1])+1;return this.col(index,1,arguments[1]);}}
24
- if(str.match(/^[0-9]+$/i)){return this.row(str,null,arguments[1]);}
25
- if(str.match(/^([a-z]{1,2})([0-9]+)$/i)){var letter=RegExp.$1,number=RegExp.$2,col=this.get(letter,{trim:false});return col[number-1];}
26
- if(str.match(/^([a-z]{1,2})([0-9]+):([a-z]{1,2})([0-9]+)$/i)){var letter1=RegExp.$1,number1=RegExp.$2,letter2=RegExp.$3,number2=RegExp.$4
27
- if(letter1===letter2){var cells=[],index=this.getIndexOfLetters(letter1),col=this.col(index,null,{trim:false});for(var i=(number1-1);i<=(number2-1);++i){cells.push(col[i]);}}else if(number1===number2){var cells=[],row=this.row(number1,null,{trim:false}),index1=this.getIndexOfLetters(letter1),index2=this.getIndexOfLetters(letter2)
28
- for(var i=(index1-1);i<=(index2-1);++i){cells.push(row[i]);}}
29
- if(arguments[1]&&arguments[1].trim===false){}else{cells=RGraph.Sheets.arrayRTrim(cells);}
30
- return cells;}};this.load(url,callback);};RGraph.Sheets.arrayRTrim=function(arr)
31
- {var out=[],content=false;for(var i=(arr.length-1);i>=0;i--){if(arr[i]||content){out.push(arr[i]);content=true;}}
32
- arr=out.reverse();return out;};})(window,document);
12
+ //
13
+ // Initialise the various objects
14
+ //
15
+ RGraph = window.RGraph || {isrgraph:true,isRGraph: true,rgraph:true};
16
+
17
+ // Module pattern
18
+ (function (win, doc, undefined)
19
+ {
20
+ RGraph.Sheets = function ()
21
+ {
22
+ var args = RGraph.Sheets.getArgs(arguments, 'oauth,key,worksheet,callback');
23
+
24
+ // Allow three args to be given as well as four
25
+ if (arguments.length === 1) {
26
+ // Nothing to do here
27
+
28
+ } else if (arguments.length === 3) {
29
+ args.oauth = args.oauth;
30
+ args.key = args.key;
31
+ args.callback = args.worksheet; // Need to set this because the order of the args is wrong
32
+ args.worksheet = 'Sheet1';
33
+
34
+ } else if (arguments.length === 4) {
35
+ args.worksheet = args.worksheet;
36
+ }
37
+
38
+ var worksheet = args.worksheet,
39
+ callback = args.callback,
40
+ letters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ',
41
+ key = args.key,
42
+ oauth = args.oauth;
43
+
44
+ var url = ('https://sheets.googleapis.com/v4/spreadsheets/[KEY]/values/[WORKSHEET]?alt=json&key=[OAUTH_KEY]')
45
+ .replace(/\[KEY\]/, args.key)
46
+ .replace(/\[WORKSHEET\]/, encodeURIComponent(args.worksheet))
47
+ .replace(/\[OAUTH_KEY\]/, args.oauth)
48
+
49
+
50
+
51
+
52
+
53
+
54
+
55
+ //
56
+ // Loads the spreadsheet
57
+ //
58
+ this.load = function(url, userCallback)
59
+ {
60
+ var obj = this;
61
+
62
+ RGraph.Sheets.AJAX.getJSON(url, function (json)
63
+ {
64
+ var grid = json.values;
65
+ var rows = grid.length;
66
+ var cells = 0;
67
+
68
+ //
69
+ // Determine the longest row
70
+ //
71
+ for (var i=0; i<grid.length; ++i) {
72
+ cells = Math.max(cells, grid[i].length);
73
+ }
74
+
75
+ //
76
+ // Now that the max row length has been determined go through
77
+ // the grid and pad out each row
78
+ //
79
+ for (var i=0; i<grid.length; ++i) {
80
+ for (var j=grid[i].length; j<cells; ++j) {
81
+ grid[i][j] = '';
82
+ }
83
+ }
84
+
85
+ // Convert numerics strings to numbers
86
+ // eg "234" => 234
87
+ for (var i=0; i<grid.length; ++i) {
88
+ for (var j=0; j<cells; ++j) {
89
+ if (grid[i][j].match(/^[0-9]+$/)) {
90
+ grid[i][j] = parseInt(grid[i][j]);
91
+ } else if (grid[i][j].match(/^[0-9.]+$/)) {
92
+ grid[i][j] = parseFloat(grid[i][j]);
93
+ }
94
+ }
95
+ }
96
+
97
+ //
98
+ // Save the grid on the object
99
+ //
100
+ obj.data = grid;
101
+
102
+
103
+
104
+ //
105
+ // Call the users callback function. Users can access the raw data if
106
+ // they want with the obj.data property or by using the accessor
107
+ // methods (better)
108
+ //
109
+ userCallback(obj);
110
+ });
111
+ };
112
+
113
+
114
+
115
+
116
+
117
+
118
+
119
+
120
+ //
121
+ // Fetches a row of data and returns it
122
+ //
123
+ // @param id number The numeric index of the column to fetch (starts at 1)
124
+ // @param start number The index to start fetching/returning at. The first
125
+ // character is 1
126
+ // @param opt An option object containing options
127
+ //
128
+ this.row = function (index, start)
129
+ {
130
+ var opt = {}, row;
131
+
132
+ // Does the row exist?
133
+ if (!this.data[index - 1]) {
134
+ return [];
135
+ }
136
+
137
+ // Default for start is 1
138
+ start = start || 1;
139
+
140
+ //
141
+ // Parse the .trim argument
142
+ //
143
+
144
+ if (arguments && typeof arguments[2] === 'object' && typeof arguments[2].trim === 'boolean') {
145
+ opt.trim = arguments[2].trim;
146
+ } else {
147
+ opt.trim = true;
148
+ }
149
+
150
+ row = this.data[index - 1].slice(start - 1);
151
+
152
+ // Trim the array if required
153
+ if (opt.trim) {
154
+ row = RGraph.Sheets.arrayRTrim(row);
155
+ }
156
+
157
+ return row;
158
+ };
159
+
160
+
161
+
162
+
163
+
164
+
165
+
166
+
167
+ //
168
+ // Fetches a column of data and returns it
169
+ //
170
+ // @param id number The letter that corresponds to the column
171
+ // @param start number The index to start fetching/returning at. The first
172
+ // character is 1
173
+ // @param opt An option object containing options
174
+ //
175
+ this.col = function (index, start)
176
+ {
177
+ var opt = {},
178
+ col = [];
179
+
180
+ // Default for start is 1
181
+ start = start || 1;
182
+
183
+ if (arguments && typeof arguments[2] === 'object' && typeof arguments[2].trim === 'boolean') {
184
+ opt.trim = arguments[2].trim;
185
+ } else {
186
+ opt.trim = true;
187
+ }
188
+
189
+ for (var i=0; i<this.data.length; ++i) {
190
+ col.push(this.data[i][index - 1]);
191
+ }
192
+
193
+ // Trim the array if required
194
+ if (opt.trim) {
195
+ col = RGraph.Sheets.arrayRTrim(col);
196
+ }
197
+
198
+ // Now account for the start index
199
+
200
+ col = col.slice(start - 1);
201
+
202
+ return col;
203
+ };
204
+
205
+
206
+
207
+
208
+
209
+
210
+
211
+
212
+ //
213
+ // Returns the index (zero index) of the given letters
214
+ //
215
+ this.getIndexOfLetters = function (l)
216
+ {
217
+ var parts = l.split('');
218
+
219
+ if (parts.length === 1) {
220
+ return letters.indexOf(l) + 1;
221
+ } else if (parts.length === 2){
222
+ var idx = ((letters.indexOf(parts[0]) + 1) * 26) + (letters.indexOf(parts[1]) + 1);
223
+ return idx;
224
+ }
225
+ };
226
+
227
+
228
+
229
+
230
+
231
+
232
+
233
+
234
+ //
235
+ // The get method makes retrieving cells very straightforward,
236
+ // for example: obj.get('B1');
237
+ //
238
+ // @param str string The cells(s) to fetch
239
+ // @param string Optional set of options that are passed
240
+ // to the relevant row/col function
241
+ //
242
+ this.get = function (str)
243
+ {
244
+ // Uppercase letters please!
245
+ str = str.toUpperCase();
246
+
247
+ //
248
+ // Handle the style of .get('C') or .get('AA'
249
+ //
250
+ if (str.match(/^\s*([a-z]+)\s*$/i)) {
251
+
252
+ str = RegExp.$1;
253
+
254
+ if (str.length === 1) {
255
+ var index = letters.indexOf(str) + 1;
256
+ return this.col(index, 1, arguments[1]);
257
+
258
+ } else if (str.length === 2) {
259
+ var index = ((letters.indexOf(str[0]) + 1) * 26) + letters.indexOf(str[1]) + 1;
260
+ return this.col(index, 1, arguments[1]);
261
+ }
262
+ }
263
+
264
+
265
+
266
+
267
+ //
268
+ // Handle the style of .get('2');
269
+ //(fetching a whole row
270
+ //
271
+ if (str.match(/^\s*[0-9]+\s*$/i)) {
272
+ return this.row(str, null, arguments[1]);
273
+ }
274
+
275
+
276
+
277
+
278
+ //
279
+ // Handle the style of .get('E2');
280
+ //(fetching a single cell)
281
+ //
282
+ if (str.match(/^\s*([a-z]{1,2})([0-9]+)\s*$/i)) {
283
+
284
+ var letter = RegExp.$1,
285
+ number = RegExp.$2,
286
+ col = this.get(letter, {trim: false});
287
+
288
+
289
+ return col[number - 1];
290
+ }
291
+
292
+
293
+
294
+
295
+ //
296
+ // Handle the style of .get('B2:E2');
297
+ //(fetching the B2 cell to the E2 cell)
298
+ //
299
+ if (str.match(/^\s*([a-z]{1,2})([0-9]+)\s*:\s*([a-z]{1,2})([0-9]+)\s*$/i)) {
300
+
301
+ var letter1 = RegExp.$1,
302
+ letter2 = RegExp.$3,
303
+ number1 = parseInt(RegExp.$2),
304
+ number2 = parseInt(RegExp.$4)
305
+
306
+
307
+ // A column
308
+ if (letter1 === letter2) {
309
+ var cells = [],
310
+ index = this.getIndexOfLetters(letter1),
311
+ col = this.col(index, null, {trim: false});
312
+
313
+ for (var i=(number1 - 1); i<=(number2 - 1); ++i) {
314
+ cells.push(col[i]);
315
+ }
316
+
317
+ // A row
318
+ } else if (number1 === number2) {
319
+
320
+ var cells = [],
321
+ row = this.row(number1, null, {trim: false}),
322
+ index1 = this.getIndexOfLetters(letter1),
323
+ index2 = this.getIndexOfLetters(letter2)
324
+
325
+ for (var i=(index1 - 1); i<=(index2 - 1); ++i) {
326
+ cells.push(row[i]);
327
+ }
328
+
329
+ // A matrix
330
+ } else if (letter1 !== letter2 && number1 !== number2) {
331
+
332
+ var cells = [],
333
+ index1 = this.getIndexOfLetters(letter1),
334
+ index2 = this.getIndexOfLetters(letter2),
335
+ row = [];
336
+
337
+ for (var i=number1; i<=number2; ++i) {
338
+ row = this.row(i).slice(index1 - 1, index2); // Don't need to subtract 1 here as we want to be inclusive
339
+ cells.push(row);
340
+ }
341
+ }
342
+
343
+ // Trim the results
344
+ if (arguments[1] && arguments[1].trim === false) {
345
+ // Nada
346
+ } else {
347
+ cells = RGraph.Sheets.arrayRTrim(cells);
348
+ }
349
+
350
+ return cells;
351
+
352
+ }
353
+ };
354
+
355
+
356
+
357
+
358
+
359
+
360
+
361
+
362
+ //
363
+ // Load the data
364
+ //
365
+ this.load(url, args.callback);
366
+ };
367
+
368
+
369
+
370
+
371
+
372
+
373
+
374
+
375
+ // This function trims an array of empty values. Its here so that the Google
376
+ // Sheets code can be used with the RGraph.common.core file
377
+
378
+ //
379
+ // An arrayRtrim function that removes the empty elements off
380
+ // both ends
381
+ //
382
+ // @param array arr The array to trim.
383
+ // @return array The array
384
+ //
385
+ RGraph.Sheets.arrayRTrim = function (arr)
386
+ {
387
+ var out = [], content = false;
388
+
389
+ // Trim the end
390
+ for (var i=(arr.length - 1); i>=0; i--) {
391
+ if (arr[i] || content) {
392
+ out.push(arr[i]);
393
+ content = true;
394
+ }
395
+ }
396
+
397
+ arr = out.reverse();
398
+
399
+ return out;
400
+ };
401
+
402
+
403
+
404
+
405
+
406
+
407
+
408
+
409
+ //
410
+ // This function allows both object based arguments to functions
411
+ // and also regular arguments as well.
412
+ //
413
+ // You can call it from inside a function like this:
414
+ //
415
+ // args = RGraph.Sheets.getArgs(arguments, 'object,id,foo,bar');
416
+ //
417
+ // So you're passing it the arguments object and a comma seperated list of names
418
+ // for the arguments.
419
+ //
420
+ // @param array args The arguments object that you get when inside a function
421
+ // @param string names A comma seperated list of desired names for the arguments
422
+ // eg: 'object,color,size'
423
+ //
424
+ RGraph.Sheets.getArgs = function (args, names)
425
+ {
426
+ var ret = {};
427
+ var count = 0;
428
+ names = names.trim().split(/ *, */);
429
+
430
+ if ( args
431
+ && args[0]
432
+ && args.length === 1
433
+ && typeof args[0][names[0]] !== 'undefined') {
434
+
435
+ for (var i=0; i<names.length; ++i) {
436
+ if (typeof args[0][names[i]] === 'undefined') {
437
+ args[0][names[i]] = null;
438
+ }
439
+ }
440
+
441
+ return args[0];
442
+ } else {
443
+ for (var i in names) {
444
+ ret[names[i]] = typeof args[count] === 'undefined' ? null : args[count];
445
+
446
+ count += 1;
447
+ }
448
+ }
449
+
450
+ return ret;
451
+ };
452
+
453
+
454
+
455
+
456
+
457
+
458
+
459
+
460
+ //
461
+ // Makes an AJAX call. It calls the given callback (a function) when ready
462
+ //
463
+ // @param args object An object consisting of:
464
+ // o url
465
+ // o callback
466
+ // OR
467
+ //
468
+ // @param string url The URL to retrieve
469
+ // @param function callback A function that is called when the response is ready,
470
+ // there's an example below called "myCallback".
471
+ //
472
+ RGraph.Sheets.AJAX = function ()
473
+ {
474
+ var args = RGraph.Sheets.getArgs(arguments, 'url,callback');
475
+
476
+ // Mozilla, Safari, ...
477
+ if (window.XMLHttpRequest) {
478
+ var httpRequest = new XMLHttpRequest();
479
+
480
+
481
+ // MSIE
482
+ } else if (window.ActiveXObject) {
483
+ var httpRequest = new ActiveXObject("Microsoft.XMLHTTP");
484
+ }
485
+
486
+ httpRequest.onreadystatechange = function ()
487
+ {
488
+ if (this.readyState == 4 && this.status == 200) {
489
+ this.__user_callback__ = args.callback;
490
+ this.__user_callback__(this.responseText);
491
+ }
492
+ }
493
+
494
+ httpRequest.open('GET', args.url, true);
495
+
496
+ // Set a Cache-Control header
497
+ if (httpRequest && httpRequest.setRequestHeader) {
498
+ httpRequest.setRequestHeader('Cache-Control', 'no-cache');
499
+ }
500
+
501
+ httpRequest.send();
502
+ };
503
+
504
+
505
+
506
+
507
+
508
+
509
+
510
+
511
+ //
512
+ // Uses the above function but calls the call back passing JSON (ie a JavaScript object ) as its argument
513
+ //
514
+ // @param args object An object consisting of:
515
+ // o url
516
+ // o callback
517
+ // OR
518
+ //
519
+ // @param url string The URL to fetch
520
+ // @param callback function Your callback function (which is passed the JSON object as an argument)
521
+ //
522
+ RGraph.Sheets.AJAX.getJSON = function ()
523
+ {
524
+ var args = RGraph.Sheets.getArgs(arguments, 'url,callback');
525
+
526
+ RGraph.Sheets.AJAX(args.url, function ()
527
+ {
528
+ var json = eval('(' + this.responseText + ')');
529
+
530
+ args.callback(json);
531
+ });
532
+ };
533
+
534
+
535
+
536
+
537
+
538
+
539
+
540
+
541
+ // End module pattern
542
+ })(window, document);