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,544 @@
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
+
57
+ //
58
+ // Loads the spreadsheet
59
+ //
60
+ this.load = function(url, userCallback)
61
+ {
62
+ var obj = this;
63
+
64
+ RGraph.Sheets.AJAX.getJSON(url, function (json)
65
+ {
66
+ var grid = json.values;
67
+ var rows = grid.length;
68
+ var cells = 0;
69
+
70
+ //
71
+ // Determine the longest row
72
+ //
73
+ for (var i=0; i<grid.length; ++i) {
74
+ cells = Math.max(cells, grid[i].length);
75
+ }
76
+
77
+ //
78
+ // Now that the max row length has been determined go through
79
+ // the grid and pad out each row
80
+ //
81
+ for (var i=0; i<grid.length; ++i) {
82
+ for (var j=grid[i].length; j<cells; ++j) {
83
+ grid[i][j] = '';
84
+ }
85
+ }
86
+
87
+ // Convert numerics strings to numbers
88
+ // eg "234" => 234
89
+ for (var i=0; i<grid.length; ++i) {
90
+ for (var j=0; j<cells; ++j) {
91
+ if (grid[i][j].match(/^[0-9]+$/)) {
92
+ grid[i][j] = parseInt(grid[i][j]);
93
+ } else if (grid[i][j].match(/^[0-9.]+$/)) {
94
+ grid[i][j] = parseFloat(grid[i][j]);
95
+ }
96
+ }
97
+ }
98
+
99
+ //
100
+ // Save the grid on the object
101
+ //
102
+ obj.data = grid;
103
+
104
+
105
+
106
+ //
107
+ // Call the users callback function. Users can access the raw data if
108
+ // they want with the obj.data property or by using the accessor
109
+ // methods (better)
110
+ //
111
+ userCallback(obj);
112
+ });
113
+ };
114
+
115
+
116
+
117
+
118
+
119
+
120
+
121
+
122
+ //
123
+ // Fetches a row of data and returns it
124
+ //
125
+ // @param id number The numeric index of the column to fetch (starts at 1)
126
+ // @param start number The index to start fetching/returning at. The first
127
+ // character is 1
128
+ // @param opt An option object containing options
129
+ //
130
+ this.row = function (index, start)
131
+ {
132
+ var opt = {}, row;
133
+
134
+ // Does the row exist?
135
+ if (!this.data[index - 1]) {
136
+ return [];
137
+ }
138
+
139
+ // Default for start is 1
140
+ start = start || 1;
141
+
142
+ //
143
+ // Parse the .trim argument
144
+ //
145
+
146
+ if (arguments && typeof arguments[2] === 'object' && typeof arguments[2].trim === 'boolean') {
147
+ opt.trim = arguments[2].trim;
148
+ } else {
149
+ opt.trim = true;
150
+ }
151
+
152
+ row = this.data[index - 1].slice(start - 1);
153
+
154
+ // Trim the array if required
155
+ if (opt.trim) {
156
+ row = RGraph.Sheets.arrayRTrim(row);
157
+ }
158
+
159
+ return row;
160
+ };
161
+
162
+
163
+
164
+
165
+
166
+
167
+
168
+
169
+ //
170
+ // Fetches a column of data and returns it
171
+ //
172
+ // @param id number The letter that corresponds to the column
173
+ // @param start number The index to start fetching/returning at. The first
174
+ // character is 1
175
+ // @param opt An option object containing options
176
+ //
177
+ this.col = function (index, start)
178
+ {
179
+ var opt = {},
180
+ col = [];
181
+
182
+ // Default for start is 1
183
+ start = start || 1;
184
+
185
+ if (arguments && typeof arguments[2] === 'object' && typeof arguments[2].trim === 'boolean') {
186
+ opt.trim = arguments[2].trim;
187
+ } else {
188
+ opt.trim = true;
189
+ }
190
+
191
+ for (var i=0; i<this.data.length; ++i) {
192
+ col.push(this.data[i][index - 1]);
193
+ }
194
+
195
+ // Trim the array if required
196
+ if (opt.trim) {
197
+ col = RGraph.Sheets.arrayRTrim(col);
198
+ }
199
+
200
+ // Now account for the start index
201
+
202
+ col = col.slice(start - 1);
203
+
204
+ return col;
205
+ };
206
+
207
+
208
+
209
+
210
+
211
+
212
+
213
+
214
+ //
215
+ // Returns the index (zero index) of the given letters
216
+ //
217
+ this.getIndexOfLetters = function (l)
218
+ {
219
+ var parts = l.split('');
220
+
221
+ if (parts.length === 1) {
222
+ return letters.indexOf(l) + 1;
223
+ } else if (parts.length === 2){
224
+ var idx = ((letters.indexOf(parts[0]) + 1) * 26) + (letters.indexOf(parts[1]) + 1);
225
+ return idx;
226
+ }
227
+ };
228
+
229
+
230
+
231
+
232
+
233
+
234
+
235
+
236
+ //
237
+ // The get method makes retrieving cells very straightforward,
238
+ // for example: obj.get('B1');
239
+ //
240
+ // @param str string The cells(s) to fetch
241
+ // @param string Optional set of options that are passed
242
+ // to the relevant row/col function
243
+ //
244
+ this.get = function (str)
245
+ {
246
+ // Uppercase letters please!
247
+ str = str.toUpperCase();
248
+
249
+ //
250
+ // Handle the style of .get('C') or .get('AA'
251
+ //
252
+ if (str.match(/^\s*([a-z]+)\s*$/i)) {
253
+
254
+ str = RegExp.$1;
255
+
256
+ if (str.length === 1) {
257
+ var index = letters.indexOf(str) + 1;
258
+ return this.col(index, 1, arguments[1]);
259
+
260
+ } else if (str.length === 2) {
261
+ var index = ((letters.indexOf(str[0]) + 1) * 26) + letters.indexOf(str[1]) + 1;
262
+ return this.col(index, 1, arguments[1]);
263
+ }
264
+ }
265
+
266
+
267
+
268
+
269
+ //
270
+ // Handle the style of .get('2');
271
+ //(fetching a whole row
272
+ //
273
+ if (str.match(/^\s*[0-9]+\s*$/i)) {
274
+ return this.row(str, null, arguments[1]);
275
+ }
276
+
277
+
278
+
279
+
280
+ //
281
+ // Handle the style of .get('E2');
282
+ //(fetching a single cell)
283
+ //
284
+ if (str.match(/^\s*([a-z]{1,2})([0-9]+)\s*$/i)) {
285
+
286
+ var letter = RegExp.$1,
287
+ number = RegExp.$2,
288
+ col = this.get(letter, {trim: false});
289
+
290
+
291
+ return col[number - 1];
292
+ }
293
+
294
+
295
+
296
+
297
+ //
298
+ // Handle the style of .get('B2:E2');
299
+ //(fetching the B2 cell to the E2 cell)
300
+ //
301
+ if (str.match(/^\s*([a-z]{1,2})([0-9]+)\s*:\s*([a-z]{1,2})([0-9]+)\s*$/i)) {
302
+
303
+ var letter1 = RegExp.$1,
304
+ letter2 = RegExp.$3,
305
+ number1 = parseInt(RegExp.$2),
306
+ number2 = parseInt(RegExp.$4)
307
+
308
+
309
+ // A column
310
+ if (letter1 === letter2) {
311
+ var cells = [],
312
+ index = this.getIndexOfLetters(letter1),
313
+ col = this.col(index, null, {trim: false});
314
+
315
+ for (var i=(number1 - 1); i<=(number2 - 1); ++i) {
316
+ cells.push(col[i]);
317
+ }
318
+
319
+ // A row
320
+ } else if (number1 === number2) {
321
+
322
+ var cells = [],
323
+ row = this.row(number1, null, {trim: false}),
324
+ index1 = this.getIndexOfLetters(letter1),
325
+ index2 = this.getIndexOfLetters(letter2)
326
+
327
+ for (var i=(index1 - 1); i<=(index2 - 1); ++i) {
328
+ cells.push(row[i]);
329
+ }
330
+
331
+ // A matrix
332
+ } else if (letter1 !== letter2 && number1 !== number2) {
333
+
334
+ var cells = [],
335
+ index1 = this.getIndexOfLetters(letter1),
336
+ index2 = this.getIndexOfLetters(letter2),
337
+ row = [];
338
+
339
+ for (var i=number1; i<=number2; ++i) {
340
+ row = this.row(i).slice(index1 - 1, index2); // Don't need to subtract 1 here as we want to be inclusive
341
+ cells.push(row);
342
+ }
343
+ }
344
+
345
+ // Trim the results
346
+ if (arguments[1] && arguments[1].trim === false) {
347
+ // Nada
348
+ } else {
349
+ cells = RGraph.Sheets.arrayRTrim(cells);
350
+ }
351
+
352
+ return cells;
353
+
354
+ }
355
+ };
356
+
357
+
358
+
359
+
360
+
361
+
362
+
363
+
364
+ //
365
+ // Load the data
366
+ //
367
+ this.load(url, args.callback);
368
+ };
369
+
370
+
371
+
372
+
373
+
374
+
375
+
376
+
377
+ // This function trims an array of empty values. Its here so that the Google
378
+ // Sheets code can be used without the RGraph.common.core file
379
+
380
+ //
381
+ // An arrayRtrim function that removes the empty elements off
382
+ // both ends
383
+ //
384
+ // @param array arr The array to trim.
385
+ // @return array The array
386
+ //
387
+ RGraph.Sheets.arrayRTrim = function (arr)
388
+ {
389
+ var out = [], content = false;
390
+
391
+ // Trim the end
392
+ for (var i=(arr.length - 1); i>=0; i--) {
393
+ if (arr[i] || content) {
394
+ out.push(arr[i]);
395
+ content = true;
396
+ }
397
+ }
398
+
399
+ arr = out.reverse();
400
+
401
+ return out;
402
+ };
403
+
404
+
405
+
406
+
407
+
408
+
409
+
410
+
411
+ //
412
+ // This function allows both object based arguments to functions
413
+ // and also regular arguments as well.
414
+ //
415
+ // You can call it from inside a function like this:
416
+ //
417
+ // args = RGraph.Sheets.getArgs(arguments, 'object,id,foo,bar');
418
+ //
419
+ // So you're passing it the arguments object and a comma seperated list of names
420
+ // for the arguments.
421
+ //
422
+ // @param array args The arguments object that you get when inside a function
423
+ // @param string names A comma seperated list of desired names for the arguments
424
+ // eg: 'object,color,size'
425
+ //
426
+ RGraph.Sheets.getArgs = function (args, names)
427
+ {
428
+ var ret = {};
429
+ var count = 0;
430
+ names = names.trim().split(/ *, */);
431
+
432
+ if ( args
433
+ && args[0]
434
+ && args.length === 1
435
+ && typeof args[0][names[0]] !== 'undefined') {
436
+
437
+ for (var i=0; i<names.length; ++i) {
438
+ if (typeof args[0][names[i]] === 'undefined') {
439
+ args[0][names[i]] = null;
440
+ }
441
+ }
442
+
443
+ return args[0];
444
+ } else {
445
+ for (var i in names) {
446
+ ret[names[i]] = typeof args[count] === 'undefined' ? null : args[count];
447
+
448
+ count += 1;
449
+ }
450
+ }
451
+
452
+ return ret;
453
+ };
454
+
455
+
456
+
457
+
458
+
459
+
460
+
461
+
462
+ //
463
+ // Makes an AJAX call. It calls the given callback (a function) when ready
464
+ //
465
+ // @param args object An object consisting of:
466
+ // o url
467
+ // o callback
468
+ // OR
469
+ //
470
+ // @param string url The URL to retrieve
471
+ // @param function callback A function that is called when the response is ready,
472
+ // there's an example below called "myCallback".
473
+ //
474
+ RGraph.Sheets.AJAX = function ()
475
+ {
476
+ var args = RGraph.Sheets.getArgs(arguments, 'url,callback');
477
+
478
+ // Mozilla, Safari, ...
479
+ if (window.XMLHttpRequest) {
480
+ var httpRequest = new XMLHttpRequest();
481
+
482
+
483
+ // MSIE
484
+ } else if (window.ActiveXObject) {
485
+ var httpRequest = new ActiveXObject("Microsoft.XMLHTTP");
486
+ }
487
+
488
+ httpRequest.onreadystatechange = function ()
489
+ {
490
+ if (this.readyState == 4 && this.status == 200) {
491
+ this.__user_callback__ = args.callback;
492
+ this.__user_callback__(this.responseText);
493
+ }
494
+ }
495
+
496
+ httpRequest.open('GET', args.url, true);
497
+
498
+ // Set a Cache-Control header
499
+ if (httpRequest && httpRequest.setRequestHeader) {
500
+ httpRequest.setRequestHeader('Cache-Control', 'no-cache');
501
+ }
502
+
503
+ httpRequest.send();
504
+ };
505
+
506
+
507
+
508
+
509
+
510
+
511
+
512
+
513
+ //
514
+ // Uses the above function but calls the call back passing JSON (ie a JavaScript object ) as its argument
515
+ //
516
+ // @param args object An object consisting of:
517
+ // o url
518
+ // o callback
519
+ // OR
520
+ //
521
+ // @param url string The URL to fetch
522
+ // @param callback function Your callback function (which is passed the JSON object as an argument)
523
+ //
524
+ RGraph.Sheets.AJAX.getJSON = function ()
525
+ {
526
+ var args = RGraph.Sheets.getArgs(arguments, 'url,callback');
527
+
528
+ RGraph.Sheets.AJAX(args.url, function ()
529
+ {
530
+ var json = eval('(' + this.responseText + ')');
531
+
532
+ args.callback(json);
533
+ });
534
+ };
535
+
536
+
537
+
538
+
539
+
540
+
541
+
542
+
543
+ // End module pattern
544
+ })(window, document);