rgraph-rails 1.0.1

Sign up to get free protection for your applications and to get access to all the features.
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,1524 @@
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
+ * This is a library of a few functions that make it easier to do
18
+ * effects like fade-ins or eaxpansion.
19
+ */
20
+
21
+ /**
22
+ * Initialise the various objects
23
+ */
24
+ RGraph = window.RGraph || {isRGraph: true};
25
+ RGraph.Effects = RGraph.Effects || {};
26
+ RGraph.Effects.Common = {};
27
+
28
+ // Module pattern
29
+ (function (win, doc, undefined)
30
+ {
31
+ var RG = RGraph,
32
+ ua = navigator.userAgent,
33
+ ma = Math;
34
+
35
+
36
+
37
+
38
+ /**
39
+ * This functions adds the generic effects to thechart object
40
+ *
41
+ * @param object obj The chart object
42
+ */
43
+ RG.Effects.decorate = function (obj)
44
+ {
45
+ for (i in RG.Effects.Common) {
46
+ if (typeof RG.Effects.Common[i] === 'function') {
47
+
48
+ obj[i] = RG.Effects.Common[i];
49
+ }
50
+ }
51
+ };
52
+
53
+
54
+
55
+
56
+
57
+ /**
58
+ * A function used to replace the canvas with a DIV, which in turn holds the canvas. This way the page
59
+ * layout doesn't shift in the canvas is resized.
60
+ *
61
+ * @param object canvas The canvas to replace.
62
+ */
63
+ RG.Effects.replaceCanvasWithDIV =
64
+ RG.Effects.ReplaceCanvasWithDIV =
65
+ RG.Effects.wrap = function (canvas)
66
+ {
67
+ if (!canvas.rgraph_wrapper) {
68
+ // Create the place holder DIV
69
+ var div = $('<div></div>')
70
+ .css({
71
+ width: canvas.width + 'px',
72
+ height: canvas.height + 'px',
73
+ cssFloat: canvas.style.cssFloat,
74
+ left: canvas.style.left,
75
+ top: canvas.style.top,
76
+ display: 'inline-block'
77
+ })
78
+ .get(0);
79
+
80
+ // Add the new DIV to the DOM
81
+ canvas.parentNode.insertBefore(div, canvas);
82
+
83
+ // Remove the canvas from the document
84
+ canvas.parentNode.removeChild(canvas);
85
+
86
+ // Add it back in as a child of the place holder
87
+ div.appendChild(canvas);
88
+
89
+ // Reset the positioning information on the canvas
90
+ canvas.style.position = 'relative';
91
+ canvas.style.left = (div.offsetWidth / 2) + 'px';
92
+ canvas.style.top = (div.offsetHeight / 2) + 'px';
93
+ canvas.style.cssFloat = '';
94
+
95
+ // Add a reference to the canvas to the DIV so that repeated plays of the anumation
96
+ // don't keep replacing the canvas with a new DIV
97
+ canvas.rgraph_wrapper = div;
98
+ }
99
+
100
+ var div = canvas.rgraph_wrapper;
101
+
102
+ return div;
103
+ };
104
+
105
+
106
+
107
+
108
+
109
+ /**
110
+ * fadeIn
111
+ *
112
+ * This function simply uses the CSS opacity property - initially set to zero and
113
+ * increasing to 1 over the period of 0.5 second
114
+ */
115
+ RG.Effects.Common.fadeIn = function ()
116
+ {
117
+ // This function gets added to the chart object - so the this
118
+ // variable is the chart object
119
+ var obj = this;
120
+ var opt = arguments[0] || {};
121
+ var frames = opt.frames || 30;
122
+ var duration = (frames / 60) * 1000;
123
+ var frame = 0;
124
+ var callback = arguments[1] || function () {};
125
+
126
+
127
+ // Initially the opacity should be zero
128
+ obj.canvas.style.opacity = 0;
129
+
130
+ // Draw the chart
131
+ RG.redrawCanvas(obj.canvas);
132
+
133
+ // Now fade the chart in
134
+ for (var i=1; i<=frames; ++i) {
135
+ (function (index)
136
+ {
137
+ setTimeout(function ()
138
+ {
139
+ obj.canvas.style.opacity = (index / frames);
140
+ }, (index / frames) * duration);
141
+ })(i)
142
+ }
143
+
144
+ setTimeout(function () {callback(obj);}, duration);
145
+
146
+
147
+ return obj;
148
+ };
149
+
150
+
151
+
152
+
153
+ /**
154
+ * fadeOut
155
+ *
156
+ * This function is a reversal of the above function - fading out instead of in
157
+ */
158
+ RG.Effects.Common.fadeOut = function ()
159
+ {
160
+ // This function gets added to the chart object - so the this
161
+ // variable is the chart object
162
+ var obj = this;
163
+ var opt = arguments[0] || {};
164
+ var frames = opt.frames || 30;
165
+ var duration = (frames / 60) * 1000;
166
+ var frame = 0;
167
+ var callback = arguments[1] || function () {};
168
+
169
+
170
+ // Now fade the chart in
171
+ for (var i=1; i<=frames; ++i) {
172
+ (function (index)
173
+ {
174
+ setTimeout(function ()
175
+ {
176
+ obj.canvas.style.opacity = 1 - (index / frames);
177
+ }, (index / frames) * duration);
178
+ })(i)
179
+ }
180
+
181
+ setTimeout(function () {callback(obj);}, duration);
182
+
183
+ return this;
184
+
185
+ /**
186
+ * Callback
187
+ */
188
+ callback(obj);
189
+ };
190
+
191
+
192
+
193
+
194
+ /**
195
+ * fadeSlideIn
196
+ *
197
+ * This function fades the canvas in in a sliding motion
198
+ */
199
+ RG.Effects.Common.fadeSlideIn = function ()
200
+ {
201
+ // This function gets added to the chart object - so the this
202
+ // variable is the chart object
203
+ var obj = this;
204
+ var opt = arguments[0] || {};
205
+ var frames = opt.frames || 30;
206
+ var frame = 0;
207
+ var pc = -20;
208
+ var step = (120 - pc) / frames;
209
+ var canvasXY = RG.getCanvasXY(obj.canvas);
210
+ var color = opt.color || 'white';
211
+ var callback = arguments[1] || function () {};
212
+
213
+
214
+ // Draw the chart
215
+ RG.redrawCanvas(obj.canvas);
216
+
217
+
218
+ // Create the cover
219
+ $('<div id="rgraph_fadeslide_cover_' + obj.id + '"></div>').css({
220
+ background: 'linear-gradient(135deg, rgba(255,255,255,0) ' + pc + '%, ' + color + ' ' + (pc + 20) + '%)',
221
+ width:obj.canvas.width + 'px',
222
+ height: obj.canvas.height + 'px',
223
+ top: canvasXY[1] + 'px',
224
+ left: canvasXY[0] + 'px',
225
+ position: 'absolute'
226
+ }).appendTo($(obj.canvas.parentNode));
227
+
228
+ function iterator ()
229
+ {
230
+ if (pc < 120) {
231
+ $('div#rgraph_fadeslide_cover_' + obj.id).css({
232
+ background: 'linear-gradient(135deg, rgba(255,255,255,0) ' + pc + '%, ' + color + ' ' + (pc + 20) + '%)'
233
+ });
234
+ pc += step;
235
+ RG.Effects.updateCanvas(iterator);
236
+
237
+ } else {
238
+
239
+ $('div#rgraph_fadeslide_cover_' + obj.id).remove();
240
+
241
+ callback(obj);
242
+ }
243
+ }
244
+
245
+ iterator();
246
+ };
247
+
248
+
249
+
250
+
251
+ /**
252
+ * fadeSlideOut
253
+ *
254
+ Fades the canvas out in a sliding motion
255
+ */
256
+ RG.Effects.Common.fadeSlideOut = function ()
257
+ {
258
+ // This function gets added to the chart object - so the this
259
+ // variable is the chart object
260
+ var obj = this;
261
+ var opt = arguments[0] || {};
262
+ var frames = opt.frames || 30;
263
+ var frame = 0;
264
+ var pc = -20;
265
+ var step = (120 - pc) / frames;
266
+ var canvasXY = RG.getCanvasXY(obj.canvas);
267
+ var color = opt.color || 'white';
268
+ var callback = arguments[1] || function () {};
269
+
270
+
271
+ // Draw the chart
272
+ RG.redrawCanvas(obj.canvas);
273
+
274
+ // Create the cover
275
+ $('<div id="rgraph_fadeslide_cover_' + obj.id + '"></div>').css({
276
+ background: 'linear-gradient(135deg, ' + color + ' ' + pc + '%, rgba(255,255,255,0) ' + (pc + 20) + '%)',
277
+ width:obj.canvas.width + 'px',
278
+ height: obj.canvas.height + 'px',
279
+ top: canvasXY[1] + 'px',
280
+ left: canvasXY[0] + 'px',
281
+ position: 'absolute'
282
+ }).appendTo($(obj.canvas.parentNode));
283
+
284
+ function iterator ()
285
+ {
286
+ if (pc < 120) {
287
+ $('div#rgraph_fadeslide_cover_' + obj.id).css({
288
+ background: 'linear-gradient(135deg, ' + color + ' ' + pc + '%, rgba(255,255,255,0) ' + (pc + 20) + '%)'
289
+ });
290
+ pc += step;
291
+ RG.Effects.updateCanvas(iterator);
292
+
293
+ } else {
294
+
295
+ RG.clear(obj.canvas, color)
296
+
297
+ $('div#rgraph_fadeslide_cover_' + obj.id).remove();
298
+
299
+ callback(obj);
300
+ }
301
+ }
302
+
303
+ iterator();
304
+ };
305
+
306
+
307
+
308
+
309
+
310
+ /**
311
+ * fadeCircularIn
312
+ *
313
+ * This function uses radial CSS gradients to cover the canvas with a radial fade in effect
314
+ * (from the center outwards)
315
+ */
316
+ RG.Effects.Common.fadeCircularInOutwards = function ()
317
+ {
318
+ // This function gets added to the chart object - so the this
319
+ // variable is the chart object
320
+ var obj = this;
321
+ var opt = arguments[0] || {};
322
+ var frames = opt.frames || 120;
323
+ var frame = 0;
324
+ var radius = 0;
325
+ var canvasXY = RG.getCanvasXY(obj.canvas);
326
+ var color = opt.color || 'white';
327
+ var callback = arguments[1] || function () {};
328
+
329
+
330
+ // Draw the chart
331
+ RG.redrawCanvas(obj.canvas);
332
+
333
+
334
+
335
+ // Create the cover
336
+ $('<div id="rgraph_fadeslide_cover_' + obj.id + '"></div>').css({
337
+ background: 'radial-gradient(rgba(255,255,255,0) 0%, white ' + radius + '%)',
338
+ width:obj.canvas.width + 'px',
339
+ height: obj.canvas.height + 'px',
340
+ top: canvasXY[1],
341
+ left: canvasXY[0],
342
+ position: 'absolute'
343
+ }).appendTo($(obj.canvas.parentNode));
344
+
345
+ function iterator ()
346
+ {
347
+ if (frame < frames) {
348
+
349
+ $('div#rgraph_fadeslide_cover_' + obj.id).css({
350
+ background: 'radial-gradient(rgba(255,255,255,0) ' + ((frame++ / frames) * 100) + '%, ' + color + ' ' + ((frame++ / frames) * 150) + '%)'
351
+ });
352
+
353
+ RG.Effects.updateCanvas(iterator);
354
+
355
+ } else {
356
+
357
+ $('div#rgraph_fadeslide_cover_' + obj.id).remove();
358
+
359
+ callback(obj);
360
+ }
361
+ }
362
+
363
+ iterator();
364
+ };
365
+
366
+
367
+
368
+
369
+ /**
370
+ * fadeCircularOut
371
+ *
372
+ * This function uses radial CSS gradients to cover the canvas with a radial fade out effect
373
+ * (from the center outwards)
374
+ */
375
+ RG.Effects.Common.fadeCircularOutOutwards = function ()
376
+ {
377
+ // This function gets added to the chart object - so the this
378
+ // variable is the chart object
379
+ var obj = this;
380
+ var opt = arguments[0] || {};
381
+ var frames = opt.frames || 120;
382
+ var frame = 0;
383
+ var canvasXY = RG.getCanvasXY(obj.canvas);
384
+ var color = opt.color || 'white';
385
+ var callback = arguments[1] || function () {};
386
+
387
+
388
+ // Draw the chart
389
+ RG.redrawCanvas(obj.canvas);
390
+
391
+
392
+
393
+ // Create the cover
394
+ $('<div id="rgraph_fadeslide_cover_' + obj.id + '"></div>').css({
395
+ background: 'radial-gradient(rgba(255,255,255,0) 0%, white 0%)',
396
+ width:obj.canvas.width + 'px',
397
+ height: obj.canvas.height + 'px',
398
+ top: canvasXY[1],
399
+ left: canvasXY[0],
400
+ position: 'absolute'
401
+ }).appendTo($(obj.canvas.parentNode));
402
+
403
+ function iterator ()
404
+ {
405
+ if (frame < frames) {
406
+
407
+ $('div#rgraph_fadeslide_cover_' + obj.id).css({
408
+ background: 'radial-gradient(' + color + ' ' + ((frame++ / frames) * 100) + '%, rgba(255,255,255,0) ' + ((frame++ / frames) * 150) + '%)'
409
+ });
410
+ RG.Effects.updateCanvas(iterator);
411
+
412
+ } else {
413
+
414
+ RG.clear(obj.canvas, color);
415
+
416
+ $('div#rgraph_fadeslide_cover_' + obj.id).remove();
417
+
418
+ callback(obj);
419
+ }
420
+ }
421
+
422
+ iterator();
423
+ };
424
+
425
+
426
+
427
+
428
+ /**
429
+ * fadeCircularInInwards
430
+ */
431
+ RG.Effects.Common.fadeCircularInInwards = function ()
432
+ {
433
+ // This function gets added to the chart object - so the this
434
+ // variable is the chart object
435
+ var obj = this;
436
+ var opt = arguments[0] || {};
437
+ var frames = opt.frames || 120;
438
+ var frame = 0;
439
+ var radius = ma.max(obj.canvas.width, obj.canvas.height);
440
+ var canvasXY = RG.getCanvasXY(obj.canvas);
441
+ var color = opt.color || 'white';
442
+ var callback = arguments[1] || function () {};
443
+
444
+
445
+ // Draw the chart
446
+ RG.redrawCanvas(obj.canvas);
447
+
448
+
449
+
450
+ // Create the cover
451
+ $('<div id="rgraph_fadeslide_cover_' + obj.id + '"></div>').css({
452
+ background: 'radial-gradient(rgba(255,255,255,0) 100%, rgba(255,255,255,0) 0%)',
453
+ width:obj.canvas.width + 'px',
454
+ height: obj.canvas.height + 'px',
455
+ top: canvasXY[1] + 'px',
456
+ left: canvasXY[0] + 'px',
457
+ position: 'absolute'
458
+ }).appendTo($(obj.canvas.parentNode));
459
+
460
+ function iterator ()
461
+ {
462
+ if (frame < frames) {
463
+
464
+ $('div#rgraph_fadeslide_cover_' + obj.id).css({
465
+ background: 'radial-gradient(' + color + ' ' + (( (frames - frame++) / frames) * 100) + '%, rgba(255,255,255,0) ' + (( (frames - frame++) / frames) * 120) + '%)'
466
+ });
467
+ RG.Effects.updateCanvas(iterator);
468
+
469
+ } else {
470
+
471
+ $('div#rgraph_fadeslide_cover_' + obj.id).remove();
472
+
473
+ callback(obj);
474
+ }
475
+ }
476
+
477
+ iterator();
478
+ };
479
+
480
+
481
+
482
+
483
+ /**
484
+ * fadeCircularOutReverse
485
+ */
486
+ RG.Effects.Common.fadeCircularOutInwards = function ()
487
+ {
488
+ // This function gets added to the chart object - so the this
489
+ // variable is the chart object
490
+ var obj = this;
491
+ var opt = arguments[0] || {};
492
+ var frames = opt.frames || 120;
493
+ var frame = 0;
494
+ var radius = ma.max(obj.canvas.width, obj.canvas.height);
495
+ var canvasXY = RG.getCanvasXY(obj.canvas);
496
+ var color = opt.color || 'white';
497
+ var callback = arguments[1] || function () {};
498
+
499
+
500
+ // Draw the chart
501
+ RG.redrawCanvas(obj.canvas);
502
+
503
+
504
+
505
+ // Create the cover
506
+ $('<div id="rgraph_fadeslide_cover_' + obj.id + '"></div>').css({
507
+ background: 'radial-gradient(rgba(255,255,255,0) 0%, rgba(255,255,255,0) 0%)',
508
+ width:obj.canvas.width + 'px',
509
+ height: obj.canvas.height + 'px',
510
+ top: canvasXY[1],
511
+ left: canvasXY[0],
512
+ position: 'absolute'
513
+ }).appendTo($(obj.canvas.parentNode));
514
+
515
+ function iterator ()
516
+ {
517
+ if (frame < frames) {
518
+
519
+ $('div#rgraph_fadeslide_cover_' + obj.id).css({
520
+ background: 'radial-gradient(rgba(255,255,255,0) ' + (( (frames - frame++) / frames) * 100) + '%, ' + color + ' ' + (( (frames - frame++) / frames) * 120) + '%)'
521
+ });
522
+ RG.Effects.updateCanvas(iterator);
523
+
524
+ } else {
525
+
526
+ RG.clear(obj.canvas);
527
+
528
+ $('div#rgraph_fadeslide_cover_' + obj.id).remove();
529
+
530
+ callback(obj);
531
+ }
532
+ }
533
+
534
+ iterator();
535
+ };
536
+
537
+
538
+
539
+
540
+ /**
541
+ * Expand
542
+ *
543
+ * This effect is like the tooltip effect of the same name. I starts in the middle
544
+ * and expands out to full size.
545
+ *
546
+ * @param object obj The graph object
547
+ */
548
+ RG.Effects.Common.expand = function ()
549
+ {
550
+ // This function gets added to the chart object - so the this
551
+ // variable is the chart object
552
+ var obj = this;
553
+ var opt = arguments[0] || {};
554
+ var bounce = typeof opt.bounce === 'boolean' ? opt.bounce : true;
555
+ var frames = opt.frames || 60;
556
+ var duration = (frames / 60) * 1000;
557
+ var callback = arguments[1] || function () {};
558
+
559
+ if (!this.canvas.rgraph_wrapper) {
560
+ var div = RG.Effects.wrap(this.canvas);
561
+ this.canvas.rgraph_wrapper = div;
562
+ } else {
563
+ div = this.canvas.rgraph_wrapper;
564
+ }
565
+
566
+ div.style.position = 'relative';
567
+ //this.canvas.style.position = 'relative'; // absolute should work here too - but doesn't in Chrome
568
+ this.canvas.style.top = (this.canvas.height / 2) + 'px';
569
+ this.canvas.style.left = (this.canvas.width / 2) + 'px';
570
+
571
+ this.canvas.style.width = 0;
572
+ this.canvas.style.height = 0;
573
+
574
+ this.canvas.style.opacity = 0;
575
+
576
+
577
+ RG.clear(this.canvas);
578
+ RG.redrawCanvas(this.canvas);
579
+
580
+ if (bounce) {
581
+
582
+ jQuery('#' + obj.id).animate({opacity: 1, width: (obj.canvas.width * 1.2) + 'px', height: (obj.canvas.height * 1.2) + 'px', left: (obj.canvas.width * -0.1) + 'px', top: (obj.canvas.height * -0.1) + 'px'}, duration * 0.5, function ()
583
+ {
584
+ jQuery('#' + obj.id).animate({width: (obj.canvas.width * 0.9) + 'px', height: (obj.canvas.height * 0.9) + 'px', top: (obj.canvas.height * 0.05) + 'px', left: (obj.canvas.width * 0.05) + 'px'}, duration * 0.25, function ()
585
+ {
586
+ jQuery('#' + obj.id).animate({width: obj.canvas.width + 'px', height: obj.canvas.height + 'px', top: 0, left: 0}, duration * 0.25, function () {callback(obj);});
587
+ });
588
+ });
589
+
590
+ } else {
591
+
592
+ jQuery(obj.canvas).animate({
593
+ opacity: 1,
594
+ width: obj.canvas.width + 'px',
595
+ height: obj.canvas.height + 'px',
596
+ left: 0,
597
+ top: 0
598
+ }, duration, function () {callback(obj);})
599
+ }
600
+
601
+
602
+
603
+ return this;
604
+ };
605
+
606
+
607
+
608
+
609
+ /**
610
+ * Contract
611
+ *
612
+ * This effect is a good one to use with the Expand effect to make a transition
613
+ *
614
+ * @param object You can specify frames here: {frames: 120}
615
+ * @param function Optional callback to run when the effect is done.
616
+ */
617
+ RG.Effects.Common.contract = function ()
618
+ {
619
+ // This function gets added to the chart object - so the this
620
+ // variable is the chart object
621
+ var obj = this;
622
+ var opt = arguments[0] || {};
623
+ var frames = opt.frames || 60;
624
+ var duration = (frames / 60) * 1000;
625
+ var callback = arguments[1] || function () {};
626
+
627
+ if (!obj.canvas.rgraph_wrapper) {
628
+ var div = RG.Effects.wrap(obj.canvas);
629
+ obj.canvas.rgraph_wrapper = div;
630
+ } else {
631
+ div = obj.canvas.rgraph_wrapper;
632
+ }
633
+
634
+
635
+ div.style.position = 'relative';
636
+ //canvas.style.position = 'absolute'; // Chrome bug...?
637
+ obj.canvas.style.top = 0;
638
+ obj.canvas.style.left = 0;
639
+
640
+
641
+ jQuery('#' + obj.id).animate({
642
+ width: (obj.canvas.width * 1.2) + 'px',
643
+ height: (obj.canvas.height * 1.2) + 'px',
644
+ left: (obj.canvas.width * -0.1) + 'px',
645
+ top: (obj.canvas.height * -0.1) + 'px'
646
+ }, duration * 0.25, function ()
647
+ {
648
+ jQuery('#' + obj.id).animate({
649
+ opacity: 0,
650
+ width: 0,
651
+ height: 0,
652
+ left: (obj.canvas.width * 0.5) + 'px',
653
+ top: (obj.canvas.height * 0.5) + 'px'
654
+ }, duration * 0.75, function () {callback(obj);});
655
+ });
656
+
657
+
658
+ return this;
659
+ };
660
+
661
+
662
+
663
+
664
+ /**
665
+ * Reveal
666
+ *
667
+ * This effect issmilar to the Expand effect - the canvas is slowly revealed from
668
+ * the centre outwards
669
+ *
670
+ * @param object Options for the effect. You can give frames here
671
+ * @param function An optional callback function
672
+ */
673
+ RG.Effects.Common.reveal = function ()
674
+ {
675
+ // This function gets added to the chart object - so the this
676
+ // variable is the chart object
677
+ var obj = this;
678
+ var opt = arguments[0] || {};
679
+ var frames = opt.frames || 60;
680
+ var duration = (frames / 60) * 1000;
681
+ var callback = arguments[1] || function () {};
682
+ var xy = RG.getCanvasXY(obj.canvas);
683
+
684
+
685
+
686
+
687
+ var divs = [
688
+ ['rgraph_reveal_left_' + obj.id, xy[0], xy[1], obj.canvas.width / 2, obj.canvas.height],
689
+ ['rgraph_reveal_right_' + obj.id,(xy[0] + (obj.canvas.width / 2)),xy[1],(obj.canvas.width / 2),obj.canvas.height],
690
+ ['rgraph_reveal_top_' + obj.id,xy[0],xy[1],obj.canvas.width,(obj.canvas.height / 2)],
691
+ ['rgraph_reveal_bottom_' + obj.id,xy[0],(xy[1] + (obj.canvas.height / 2)),obj.canvas.width,(obj.canvas.height / 2)]
692
+ ];
693
+
694
+ for (var i=0,len=divs.length; i<len; ++i) {
695
+ var div = document.createElement('DIV');
696
+ div.id = divs[i][0];
697
+ div.style.width = divs[i][3]+ 'px';
698
+ div.style.height = divs[i][4] + 'px';
699
+ div.style.left = divs[i][1] + 'px';
700
+ div.style.top = divs[i][2] + 'px';
701
+ div.style.position = 'absolute';
702
+ div.style.backgroundColor = opt && typeof opt.color === 'string' ? opt.color : 'white';
703
+ document.body.appendChild(div);
704
+ }
705
+
706
+
707
+ // Clear the canvas and redraw it
708
+ RG.clear(obj.canvas);
709
+ RG.redrawCanvas(obj.canvas);
710
+
711
+
712
+ // Animate the shrinking of the DIVs
713
+ jQuery('#rgraph_reveal_left_' + obj.id).animate({width: 0}, duration);
714
+ jQuery('#rgraph_reveal_right_' + obj.id).animate({left: '+=' + (obj.canvas.width / 2),width: 0}, duration);
715
+ jQuery('#rgraph_reveal_top_' + obj.id).animate({height: 0}, duration);
716
+ jQuery('#rgraph_reveal_bottom_' + obj.id).animate({top: '+=' + (obj.canvas.height / 2),height: 0}, duration);
717
+
718
+ // Remove the DIVs from the DOM 100ms after the animation ends
719
+ setTimeout(function ()
720
+ {
721
+ doc.body.removeChild(doc.getElementById("rgraph_reveal_top_" + obj.id));
722
+ doc.body.removeChild(doc.getElementById("rgraph_reveal_bottom_" + obj.id));
723
+ doc.body.removeChild(doc.getElementById("rgraph_reveal_left_" + obj.id));
724
+ doc.body.removeChild(doc.getElementById("rgraph_reveal_right_" + obj.id));
725
+
726
+ callback(obj);
727
+ }, duration);
728
+
729
+
730
+ return this;
731
+ };
732
+
733
+
734
+
735
+
736
+ /**
737
+ * RevealCircular
738
+ *
739
+ * This effect is smilar to the Reveal effect - the canvas is slowly revealed from
740
+ * the centre outwards using a circular shape
741
+ *
742
+ * @param object An object of options - eg {frames: 30}
743
+ * @param function An optional callback function that runs when the effect is finished
744
+ */
745
+ RG.Effects.Common.revealCircular =
746
+ RG.Effects.Common.revealcircular = function ()
747
+ {
748
+ // This function gets added to the chart object - so the this
749
+ // variable is the chart object
750
+ var obj = this;
751
+ var opt = arguments[0] || {};
752
+ var frames = opt.frames || 30;
753
+ var frame = 0;
754
+ var callback = arguments[1] || function () {};
755
+ var currentRadius = 0
756
+ var centerx = obj.canvas.width / 2;
757
+ var centery = obj.canvas.height / 2;
758
+ var targetRadius = ma.max(obj.canvas.height, obj.canvas.width);
759
+ var step = targetRadius / frames;
760
+ var color = opt.background || opt.color || opt.backgroundColor || 'transparent';
761
+
762
+
763
+
764
+
765
+ /**
766
+ * This is the iterator function which gradually increases the radius of the clip circle
767
+ */
768
+ function iterator ()
769
+ {
770
+ // Begin by clearing the canvas
771
+ RG.clear(obj.canvas, color);
772
+
773
+ obj.context.save();
774
+ // First draw the circle and clip to it
775
+ obj.context.beginPath();
776
+ obj.context.arc(centerx, centery, currentRadius, 0, RG.TWOPI, false);
777
+ obj.context.clip();
778
+
779
+ // Clear the canvas to a white color
780
+ if (opt.background) {
781
+ RG.clear(obj.canvas, opt.background);
782
+ }
783
+
784
+ // Now draw the chart
785
+ obj.draw();
786
+ obj.context.restore();
787
+
788
+
789
+ // Increment the radius
790
+ if (currentRadius < targetRadius) {
791
+ currentRadius += step;
792
+ RG.Effects.updateCanvas(iterator);
793
+
794
+ } else {
795
+ callback(obj);
796
+ }
797
+ }
798
+
799
+ iterator();
800
+
801
+ return this;
802
+ };
803
+
804
+
805
+
806
+
807
+ /**
808
+ * Conceal
809
+ *
810
+ * This effect is the reverse of the Reveal effect - instead of revealing the canvas it
811
+ * conceals it. Combined with the reveal effect would make for a nice wipe effect.
812
+ *
813
+ * @param object obj The chart object
814
+ */
815
+ RG.Effects.Common.conceal = function ()
816
+ {
817
+ // This function gets added to the chart object - so the this
818
+ // variable is the chart object
819
+ var obj = this;
820
+ var opt = arguments[0] || {};
821
+ var frames = opt.frames || 60;
822
+ var duration = (frames / 60) * 1000;
823
+ var frame = 0;
824
+ var callback = arguments[1] || function () {};
825
+ var xy = RG.getCanvasXY(obj.canvas);
826
+ var color = opt.background || opt.color || opt.backgroundColor || 'white';
827
+
828
+
829
+
830
+
831
+ var divs = [
832
+ ['rgraph_conceal_left_' + obj.id, xy[0], xy[1], 0, obj.canvas.height],
833
+ ['rgraph_conceal_right_' + obj.id,(xy[0] + obj.canvas.width),xy[1],0,obj.canvas.height],
834
+ ['rgraph_conceal_top_' + obj.id,xy[0],xy[1],obj.canvas.width,0],
835
+ ['rgraph_conceal_bottom_' + obj.id,xy[0],(xy[1] + obj.canvas.height),obj.canvas.width,0]
836
+ ];
837
+
838
+
839
+
840
+
841
+ for (var i=0,len=divs.length; i<len; ++i) {
842
+ var div = doc.createElement('DIV');
843
+ div.id = divs[i][0];
844
+ div.style.width = divs[i][3]+ 'px';
845
+ div.style.height = divs[i][4] + 'px';
846
+ div.style.left = divs[i][1] + 'px';
847
+ div.style.top = divs[i][2] + 'px';
848
+ div.style.position = 'absolute';
849
+ div.style.backgroundColor = color;
850
+ doc.body.appendChild(div);
851
+ }
852
+
853
+
854
+ jQuery('#rgraph_conceal_left_' + obj.id).animate({width: '+=' + (obj.canvas.width / 2)}, duration);
855
+ jQuery('#rgraph_conceal_right_' + obj.id).animate({left: '-=' + (obj.canvas.width / 2),width: (obj.canvas.width / 2)}, duration);
856
+ jQuery('#rgraph_conceal_top_' + obj.id).animate({height: '+=' + (obj.canvas.height / 2)}, duration);
857
+ jQuery('#rgraph_conceal_bottom_' + obj.id).animate({top: '-=' + (obj.canvas.height / 2),height: (obj.canvas.height / 2)}, duration);
858
+
859
+ // Remove the DIVs from the DOM 100ms after the animation ends
860
+ setTimeout(
861
+ function ()
862
+ {
863
+ doc.body.removeChild(doc.getElementById("rgraph_conceal_top_" + obj.id));
864
+ doc.body.removeChild(doc.getElementById("rgraph_conceal_bottom_" + obj.id));
865
+ doc.body.removeChild(doc.getElementById("rgraph_conceal_left_" + obj.id));
866
+ doc.body.removeChild(doc.getElementById("rgraph_conceal_right_" + obj.id));
867
+
868
+ RG.clear(obj.canvas, color);
869
+
870
+ callback(obj);
871
+
872
+ }, duration);
873
+
874
+ return this;
875
+ };
876
+
877
+
878
+
879
+
880
+ /**
881
+ * Horizontal Blinds (open)
882
+ *
883
+ * @params object obj The graph object
884
+ */
885
+ RG.Effects.Common.hBlindsOpen =
886
+ RG.Effects.Common.hblindsOpen = function ()
887
+ {
888
+ // This function gets added to the chart object - so the this
889
+ // variable is the chart object
890
+ var obj = this;
891
+ var opt = arguments[0] || {};
892
+ var frames = opt.frames || 60;
893
+ var duration = (frames / 60) * 1000;
894
+ var frame = 0;
895
+ var callback = arguments[1] || function () {};
896
+ var color = opt.background || opt.color || opt.backgroundColor || 'white';
897
+ var xy = RG.getCanvasXY(this.canvas);
898
+ var height = this.canvas.height / 5;
899
+
900
+ /**
901
+ * First draw the chart
902
+ */
903
+ RG.clear(this.canvas);
904
+ RG.redrawCanvas(this.canvas);
905
+
906
+ for (var i=0; i<5; ++i) {
907
+ var div = doc.createElement('DIV');
908
+ div.id = 'rgraph_hblinds_' + i + '_' + obj.id;
909
+ div.style.width = this.canvas.width + 'px';
910
+ div.style.height = height + 'px';
911
+ div.style.left = xy[0] + 'px';
912
+ div.style.top = (xy[1] + (this.canvas.height * (i / 5))) + 'px';
913
+ div.style.position = 'absolute';
914
+ div.style.backgroundColor = color;
915
+ document.body.appendChild(div);
916
+
917
+ jQuery('#rgraph_hblinds_' + i + '_' + obj.id).animate({height: 0}, duration);
918
+ }
919
+
920
+ setTimeout(function () {doc.body.removeChild(doc.getElementById('rgraph_hblinds_0_' + obj.id));}, duration);
921
+ setTimeout(function () {doc.body.removeChild(doc.getElementById('rgraph_hblinds_1_' + obj.id));}, duration);
922
+ setTimeout(function () {doc.body.removeChild(doc.getElementById('rgraph_hblinds_2_' + obj.id));}, duration);
923
+ setTimeout(function () {doc.body.removeChild(doc.getElementById('rgraph_hblinds_3_' + obj.id));}, duration);
924
+ setTimeout(function () {doc.body.removeChild(doc.getElementById('rgraph_hblinds_4_' + obj.id));}, duration);
925
+ setTimeout(function () {callback(obj);}, duration);
926
+
927
+ return this;
928
+ };
929
+
930
+
931
+
932
+
933
+ /**
934
+ * Horizontal Blinds (close)
935
+ *
936
+ * @params object obj The graph object
937
+ */
938
+ RG.Effects.Common.hBlindsClose =
939
+ RG.Effects.Common.hblindsclose = function ()
940
+ {
941
+ // This function gets added to the chart object - so the this
942
+ // variable is the chart object
943
+ var obj = this;
944
+ var opt = arguments[0] || {};
945
+ var frames = opt.frames || 60;
946
+ var duration = (frames / 60) * 1000;
947
+ var frame = 0;
948
+ var callback = arguments[1] || function () {};
949
+ var color = opt.background || opt.color || opt.backgroundColor || 'white';
950
+ var xy = RG.getCanvasXY(this.canvas);
951
+ var height = this.canvas.height / 5;
952
+
953
+
954
+
955
+ for (var i=0; i<5; ++i) {
956
+ var div = doc.createElement('DIV');
957
+ div.id = 'rgraph_hblinds_' + i + '_' + obj.id;
958
+ div.style.width = this.canvas.width + 'px';
959
+ div.style.height = 0;
960
+ div.style.left = xy[0] + 'px';
961
+ div.style.top = (xy[1] + (this.canvas.height * (i / 5))) + 'px';
962
+ div.style.position = 'absolute';
963
+ div.style.backgroundColor = color;
964
+ doc.body.appendChild(div);
965
+
966
+ jQuery('#rgraph_hblinds_' + i + '_' + obj.id).animate({height: height + 'px'}, duration);
967
+ }
968
+
969
+
970
+
971
+ setTimeout(function () {RG.clear(obj.canvas);}, duration + 100);
972
+ setTimeout(function () {doc.body.removeChild(doc.getElementById('rgraph_hblinds_0_' + obj.id));}, duration + 100);
973
+ setTimeout(function () {doc.body.removeChild(doc.getElementById('rgraph_hblinds_1_' + obj.id));}, duration + 100);
974
+ setTimeout(function () {doc.body.removeChild(doc.getElementById('rgraph_hblinds_2_' + obj.id));}, duration + 100);
975
+ setTimeout(function () {doc.body.removeChild(doc.getElementById('rgraph_hblinds_3_' + obj.id));}, duration + 100);
976
+ setTimeout(function () {doc.body.removeChild(doc.getElementById('rgraph_hblinds_4_' + obj.id));}, duration + 100);
977
+ setTimeout(function () {callback(obj);}, duration + 100);
978
+ };
979
+
980
+
981
+
982
+
983
+ /**
984
+ * Vertical Blinds (open)
985
+ *
986
+ * @params object obj The graph object
987
+ */
988
+ RG.Effects.Common.vBlindsOpen =
989
+ RG.Effects.Common.vblindsopen = function ()
990
+ {
991
+ // This function gets added to the chart object - so the this
992
+ // variable is the chart object
993
+ var obj = this;
994
+ var opt = arguments[0] || {};
995
+ var frames = opt.frames || 60;
996
+ var duration = (frames / 60) * 1000;
997
+ var frame = 0;
998
+ var callback = arguments[1] || function () {};
999
+ var color = opt.background || opt.color || opt.backgroundColor || 'white';
1000
+ var xy = RG.getCanvasXY(this.canvas);
1001
+ var width = this.canvas.width / 10;
1002
+
1003
+ /**
1004
+ * First draw the chart
1005
+ */
1006
+ //RG.clear(obj.canvas);
1007
+ RG.redrawCanvas(obj.canvas);
1008
+
1009
+ for (var i=0; i<10; ++i) {
1010
+ var div = doc.createElement('DIV');
1011
+ div.id = 'rgraph_vblinds_' + i + '_' + obj.id;
1012
+ div.style.width = width + 'px';
1013
+ div.style.height = this.canvas.height + 'px';
1014
+ div.style.left = (xy[0] + (this.canvas.width * (i / 10))) + 'px';
1015
+ div.style.top = (xy[1]) + 'px';
1016
+ div.style.position = 'absolute';
1017
+ div.style.backgroundColor = color;
1018
+ doc.body.appendChild(div);
1019
+
1020
+ jQuery('#rgraph_vblinds_' + i + '_' + obj.id).animate({width: 0}, duration);
1021
+ }
1022
+
1023
+ setTimeout(function () {doc.body.removeChild(doc.getElementById('rgraph_vblinds_0_' + obj.id));}, duration + 100);
1024
+ setTimeout(function () {doc.body.removeChild(doc.getElementById('rgraph_vblinds_1_' + obj.id));}, duration + 100);
1025
+ setTimeout(function () {doc.body.removeChild(doc.getElementById('rgraph_vblinds_2_' + obj.id));}, duration + 100);
1026
+ setTimeout(function () {doc.body.removeChild(doc.getElementById('rgraph_vblinds_3_' + obj.id));}, duration + 100);
1027
+ setTimeout(function () {doc.body.removeChild(doc.getElementById('rgraph_vblinds_4_' + obj.id));}, duration + 100);
1028
+ setTimeout(function () {doc.body.removeChild(doc.getElementById('rgraph_vblinds_5_' + obj.id));}, duration + 100);
1029
+ setTimeout(function () {doc.body.removeChild(doc.getElementById('rgraph_vblinds_6_' + obj.id));}, duration + 100);
1030
+ setTimeout(function () {doc.body.removeChild(doc.getElementById('rgraph_vblinds_7_' + obj.id));}, duration + 100);
1031
+ setTimeout(function () {doc.body.removeChild(doc.getElementById('rgraph_vblinds_8_' + obj.id));}, duration + 100);
1032
+ setTimeout(function () {doc.body.removeChild(doc.getElementById('rgraph_vblinds_9_' + obj.id));}, duration + 100);
1033
+
1034
+ setTimeout(function () {callback(obj);}, duration + 100);
1035
+
1036
+ return this;
1037
+ };
1038
+
1039
+
1040
+
1041
+
1042
+ /**
1043
+ * Vertical Blinds (close)
1044
+ *
1045
+ * @params object obj The graph object
1046
+ */
1047
+ RG.Effects.Common.vblindsclose =
1048
+ RG.Effects.Common.vBlindsClose = function ()
1049
+ {
1050
+ // This function gets added to the chart object - so the this
1051
+ // variable is the chart object
1052
+ var obj = this;
1053
+ var opt = arguments[0] || {};
1054
+ var frames = opt.frames || 60;
1055
+ var duration = (frames / 60) * 1000;
1056
+ var frame = 0;
1057
+ var callback = arguments[1] || function () {};
1058
+ var color = opt.background || opt.color || opt.backgroundColor || 'white';
1059
+ var xy = RG.getCanvasXY(this.canvas);
1060
+ var width = this.canvas.width / 10;
1061
+
1062
+ // Don't draw the chart
1063
+
1064
+ // Create the blinds
1065
+ for (var i=0; i<10; ++i) {
1066
+ var div = doc.createElement('DIV');
1067
+ div.id = 'rgraph_vblinds_' + i + '_' + obj.id;
1068
+ div.style.width = 0;
1069
+ div.style.height = this.canvas.height + 'px';
1070
+ div.style.left = (xy[0] + (this.canvas.width * (i / 10))) + 'px';
1071
+ div.style.top = (xy[1]) + 'px';
1072
+ div.style.position = 'absolute';
1073
+ div.style.backgroundColor = color;
1074
+ doc.body.appendChild(div);
1075
+
1076
+ jQuery('#rgraph_vblinds_' + i + '_' + obj.id).animate({width: width}, duration);
1077
+ }
1078
+
1079
+ setTimeout(function () {RG.clear(obj.canvas);}, duration + 100);
1080
+
1081
+ setTimeout(function () {doc.body.removeChild(doc.getElementById('rgraph_vblinds_0_' + obj.id));}, duration + 100);
1082
+ setTimeout(function () {doc.body.removeChild(doc.getElementById('rgraph_vblinds_1_' + obj.id));}, duration + 100);
1083
+ setTimeout(function () {doc.body.removeChild(doc.getElementById('rgraph_vblinds_2_' + obj.id));}, duration + 100);
1084
+ setTimeout(function () {doc.body.removeChild(doc.getElementById('rgraph_vblinds_3_' + obj.id));}, duration + 100);
1085
+ setTimeout(function () {doc.body.removeChild(doc.getElementById('rgraph_vblinds_4_' + obj.id));}, duration + 100);
1086
+ setTimeout(function () {doc.body.removeChild(doc.getElementById('rgraph_vblinds_5_' + obj.id));}, duration + 100);
1087
+ setTimeout(function () {doc.body.removeChild(doc.getElementById('rgraph_vblinds_6_' + obj.id));}, duration + 100);
1088
+ setTimeout(function () {doc.body.removeChild(doc.getElementById('rgraph_vblinds_7_' + obj.id));}, duration + 100);
1089
+ setTimeout(function () {doc.body.removeChild(doc.getElementById('rgraph_vblinds_8_' + obj.id));}, duration + 100);
1090
+ setTimeout(function () {doc.body.removeChild(doc.getElementById('rgraph_vblinds_9_' + obj.id));}, duration + 100);
1091
+
1092
+ setTimeout(function () {callback(obj);}, duration + 100);
1093
+
1094
+ return this;
1095
+ };
1096
+
1097
+
1098
+
1099
+
1100
+ /**
1101
+ * Slide in
1102
+ *
1103
+ * This function is a wipe that can be used when switching the canvas to a new graph
1104
+ *
1105
+ * @param object obj The graph object
1106
+ */
1107
+ RG.Effects.Common.slideIn = function ()
1108
+ {
1109
+ // This function gets added to the chart object - so the this
1110
+ // variable is the chart object
1111
+ var obj = this;
1112
+ var opt = arguments[0] || {};
1113
+ var frames = opt.frames || 60;
1114
+ var duration = (frames / 60) * 1000;
1115
+ var frame = 0;
1116
+ var callback = arguments[1] || function () {};
1117
+ var color = opt.background || opt.color || opt.backgroundColor || 'white';
1118
+ var xy = RG.getCanvasXY(this.canvas);
1119
+ var width = this.canvas.width / 10;
1120
+ var div = RG.Effects.wrap(obj.canvas);
1121
+ var from = opt.from || 'left';
1122
+
1123
+ div.style.overflow = 'hidden';
1124
+
1125
+ RG.clear(obj.canvas);
1126
+ RG.redrawCanvas(obj.canvas);
1127
+
1128
+
1129
+ canvas.style.position = 'relative';
1130
+
1131
+ if (from == 'left') {
1132
+ obj.canvas.style.left = (0 - div.offsetWidth) + 'px';
1133
+ obj.canvas.style.top = 0;
1134
+ } else if (from == 'top') {
1135
+ obj.canvas.style.left = 0;
1136
+ obj.canvas.style.top = (0 - div.offsetHeight) + 'px';
1137
+ } else if (from == 'bottom') {
1138
+ obj.canvas.style.left = 0;
1139
+ obj.canvas.style.top = div.offsetHeight + 'px';
1140
+ } else {
1141
+ obj.canvas.style.left = div.offsetWidth + 'px';
1142
+ obj.canvas.style.top = 0;
1143
+ }
1144
+
1145
+ jQuery('#' + obj.id).animate({left:0,top:0}, duration, function ()
1146
+ {
1147
+ callback(obj);
1148
+ });
1149
+
1150
+ return this;
1151
+ };
1152
+
1153
+
1154
+
1155
+
1156
+ /**
1157
+ * Slide out
1158
+ *
1159
+ * This function is a wipe that can be used when switching the canvas to a new graph
1160
+ *
1161
+ * @param object Optional object containing configuration.
1162
+ * @param function Optional callback function
1163
+ */
1164
+ RG.Effects.Common.slideOut = function ()
1165
+ {
1166
+ // This function gets added to the chart object - so the this
1167
+ // variable is the chart object
1168
+ var obj = this;
1169
+ var opt = arguments[0] || {};
1170
+ var frames = opt.frames || 60;
1171
+ var duration = (frames / 60) * 1000;
1172
+ var frame = 0;
1173
+ var callback = arguments[1] || function () {};
1174
+ var color = opt.background || opt.color || opt.backgroundColor || 'white';
1175
+ var xy = RG.getCanvasXY(this.canvas);
1176
+ var width = this.canvas.width / 10;
1177
+ var div = RG.Effects.wrap(obj.canvas);
1178
+ var to = opt.to || 'left';
1179
+
1180
+ div.style.overflow= 'hidden';
1181
+
1182
+ obj.canvas.style.position = 'relative';
1183
+ obj.canvas.style.left = 0;
1184
+ obj.canvas.style.top = 0;
1185
+
1186
+ if (to == 'left') {
1187
+ jQuery('#' + obj.id).animate({left: (0 - obj.canvas.width) + 'px'}, duration, function () {callback(obj);});
1188
+ } else if (to == 'top') {
1189
+ jQuery('#' + obj.id).animate({left: 0, top: (0 - div.offsetHeight) + 'px'}, duration, function () {callback(obj);});
1190
+ } else if (to == 'bottom') {
1191
+ jQuery('#' + obj.id).animate({top: (0 + div.offsetHeight) + 'px'}, duration, function () {callback(obj);});
1192
+ } else {
1193
+ jQuery('#' + obj.id).animate({left: (0 + obj.canvas.width) + 'px'}, duration, function () {callback(obj);});
1194
+ }
1195
+
1196
+ return this;
1197
+ };
1198
+
1199
+
1200
+
1201
+
1202
+ /**
1203
+ * Horizontal Scissors (open)
1204
+ *
1205
+ * @param @object Optional array of options
1206
+ * @param function Optional callback function
1207
+ *
1208
+ */
1209
+ RG.Effects.Common.hscissorsopen =
1210
+ RG.Effects.Common.hScissorsOpen = function ()
1211
+ {
1212
+ // This function gets added to the chart object - so the this
1213
+ // variable is the chart object
1214
+ var obj = this;
1215
+ var opt = arguments[0] || {};
1216
+ var frames = opt.frames || 60;
1217
+ var duration = (frames / 60) * 1000;
1218
+ var frame = 0;
1219
+ var callback = arguments[1] || function () {};
1220
+ var color = opt.background || opt.color || opt.backgroundColor || 'white';
1221
+ var xy = RG.getCanvasXY(this.canvas);
1222
+ var width = this.canvas.width / 10;
1223
+ var to = opt.to || 'left';
1224
+ var height = obj.canvas.height / 5;
1225
+
1226
+ /**
1227
+ * First draw the chart
1228
+ */
1229
+ RG.clear(obj.canvas);
1230
+ RG.redrawCanvas(obj.canvas);
1231
+
1232
+ for (var i=0; i<5; ++i) {
1233
+ var div = doc.getElementById("rgraph_hscissors_" + i + '_' + obj.id)
1234
+ if (!div) {
1235
+ var div = doc.createElement('DIV');
1236
+ div.id = 'rgraph_hscissors_' + i + '_' + obj.id;
1237
+ div.style.width = obj.canvas.width + 'px';
1238
+ div.style.height = height + 'px';
1239
+ div.style.left = xy[0] + 'px';
1240
+ div.style.top = (xy[1] + (obj.canvas.height * (i / 5))) + 'px';
1241
+ div.style.position = 'absolute';
1242
+ div.style.backgroundColor = color;
1243
+ doc.body.appendChild(div);
1244
+ }
1245
+
1246
+ if (i % 2 == 0) {
1247
+ jQuery('#' + 'rgraph_hscissors_' + i + '_' + obj.id).animate({left: xy[0] + obj.canvas.width + 'px', width: 0}, duration);
1248
+ } else {
1249
+ jQuery('#' + 'rgraph_hscissors_' + i + '_' + obj.id).animate({width: 0}, duration);
1250
+ }
1251
+ }
1252
+
1253
+ setTimeout(function ()
1254
+ {
1255
+ doc.body.removeChild(doc.getElementById('rgraph_hscissors_0_' + obj.id));
1256
+ doc.body.removeChild(doc.getElementById('rgraph_hscissors_1_' + obj.id));
1257
+ doc.body.removeChild(doc.getElementById('rgraph_hscissors_2_' + obj.id));
1258
+ doc.body.removeChild(doc.getElementById('rgraph_hscissors_3_' + obj.id));
1259
+ doc.body.removeChild(doc.getElementById('rgraph_hscissors_4_' + obj.id));
1260
+
1261
+ callback(obj);
1262
+ }, duration);
1263
+
1264
+
1265
+ return this;
1266
+ };
1267
+
1268
+
1269
+
1270
+
1271
+ /**
1272
+ * Horizontal Scissors (Close)
1273
+ *
1274
+ * @param @object Optional object of options
1275
+ * @param function Optional callback function
1276
+ *
1277
+ */
1278
+ RG.Effects.Common.hScissorsClose =
1279
+ RG.Effects.Common.hscissorsclose = function ()
1280
+ {
1281
+ // This function gets added to the chart object - so the this
1282
+ // variable is the chart object
1283
+ var obj = this;
1284
+ var opt = arguments[0] || {};
1285
+ var frames = opt.frames || 60;
1286
+ var duration = (frames / 60) * 1000;
1287
+ var frame = 0;
1288
+ var callback = arguments[1] || function () {};
1289
+ var color = opt.background || opt.color || opt.backgroundColor || 'white';
1290
+ var xy = RG.getCanvasXY(this.canvas);
1291
+ var height = obj.canvas.height / 5;
1292
+
1293
+
1294
+
1295
+ /**
1296
+ * First draw the chart
1297
+ */
1298
+ //RG.clear(obj.canvas);
1299
+ RG.redrawCanvas(obj.canvas);
1300
+
1301
+ for (var i=0; i<5; ++i) {
1302
+ var div = doc.createElement('DIV');
1303
+ div.id = 'rgraph_hscissors_' + i + '_' + obj.id;
1304
+ div.style.width = 0;
1305
+ div.style.height = height + 'px';
1306
+ div.style.left = (i % 2 == 0 ? xy[0] + obj.canvas.width : xy[0]) + 'px';
1307
+ div.style.top = (xy[1] + (obj.canvas.height * (i / 5))) + 'px';
1308
+ div.style.position = 'absolute';
1309
+ div.style.backgroundColor = color;
1310
+ doc.body.appendChild(div);
1311
+
1312
+ if (i % 2 == 0) {
1313
+ jQuery('#' + 'rgraph_hscissors_' + i + '_' + obj.id).animate({left: xy[0] + 'px', width: obj.canvas.width + 'px'}, duration);
1314
+ } else {
1315
+ jQuery('#' + 'rgraph_hscissors_' + i + '_' + obj.id).animate({width: obj.canvas.width + 'px'}, duration);
1316
+ }
1317
+ }
1318
+
1319
+ setTimeout(function () {callback(obj);}, duration);
1320
+
1321
+ return this;
1322
+ };
1323
+
1324
+
1325
+
1326
+
1327
+ /**
1328
+ * Vertical Scissors (open)
1329
+ *
1330
+ * @param @object Optional object of options
1331
+ * @param function Optional callback function
1332
+ *
1333
+ */
1334
+ RG.Effects.Common.vScissorsOpen =
1335
+ RG.Effects.Common.vscissorsopen = function ()
1336
+ {
1337
+ // This function gets added to the chart object - so the this
1338
+ // variable is the chart object
1339
+ var obj = this;
1340
+ var opt = arguments[0] || {};
1341
+ var frames = opt.frames || 60;
1342
+ var duration = (frames / 60) * 1000;
1343
+ var frame = 0;
1344
+ var callback = arguments[1] || function () {};
1345
+ var xy = RG.getCanvasXY(obj.canvas);
1346
+ var color = opt.background || opt.color || opt.backgroundColor || 'white';
1347
+ var xy = RG.getCanvasXY(this.canvas);
1348
+ var width = this.canvas.width / 10;
1349
+
1350
+ /**
1351
+ * First draw the chart
1352
+ */
1353
+ //RG.clear(obj.canvas);
1354
+ RG.redrawCanvas(obj.canvas);
1355
+
1356
+ for (var i=0; i<10; ++i) {
1357
+ var div = doc.getElementById("rgraph_vscissors_" + i + '_' + obj.id);
1358
+
1359
+ if (!div) {
1360
+ var div = doc.createElement('DIV');
1361
+ div.id = 'rgraph_vscissors_' + i + '_' + obj.id;
1362
+ div.style.width = width + 'px';
1363
+ div.style.height = obj.canvas.height + 'px';
1364
+ div.style.left = xy[0] + (obj.canvas.width * (i / 10)) + 'px';
1365
+ div.style.top = xy[1] + 'px';
1366
+ div.style.position = 'absolute';
1367
+ div.style.backgroundColor = color;
1368
+ doc.body.appendChild(div);
1369
+ }
1370
+
1371
+ if (i % 2 == 0) {
1372
+ jQuery('#' + 'rgraph_vscissors_' + i + '_' + obj.id).animate({top: xy[1] + obj.canvas.height + 'px', height: 0}, duration);
1373
+ } else {
1374
+ jQuery('#' + 'rgraph_vscissors_' + i + '_' + obj.id).animate({height: 0}, duration);
1375
+ }
1376
+ }
1377
+
1378
+ setTimeout(function ()
1379
+ {
1380
+ doc.body.removeChild(doc.getElementById('rgraph_vscissors_0' + '_' + obj.id));
1381
+ doc.body.removeChild(doc.getElementById('rgraph_vscissors_1' + '_' + obj.id));
1382
+ doc.body.removeChild(doc.getElementById('rgraph_vscissors_2' + '_' + obj.id));
1383
+ doc.body.removeChild(doc.getElementById('rgraph_vscissors_3' + '_' + obj.id));
1384
+ doc.body.removeChild(doc.getElementById('rgraph_vscissors_4' + '_' + obj.id));
1385
+
1386
+ callback(obj);
1387
+
1388
+ }, duration);
1389
+
1390
+ return this;
1391
+ };
1392
+
1393
+
1394
+
1395
+
1396
+ /**
1397
+ * Vertical Scissors (close)
1398
+ *
1399
+ * @param object obj The graph object
1400
+ * @param @object An array of options
1401
+ * @param function Optional callback function
1402
+ *
1403
+ */
1404
+ RG.Effects.Common.vscissorsclose =
1405
+ RG.Effects.Common.vScissorsClose = function ()
1406
+ {
1407
+ // This function gets added to the chart object - so the this
1408
+ // variable is the chart object
1409
+ var obj = this;
1410
+ var opt = arguments[0] || {};
1411
+ var frames = opt.frames || 60;
1412
+ var duration = (frames / 60) * 1000;
1413
+ var frame = 0;
1414
+ var callback = arguments[1] || function () {};
1415
+ var xy = RG.getCanvasXY(obj.canvas);
1416
+ var color = opt.background || opt.color || opt.backgroundColor || 'white';
1417
+ var xy = RG.getCanvasXY(this.canvas);
1418
+ var width = this.canvas.width / 10;
1419
+
1420
+ /**
1421
+ * First draw the chart
1422
+ */
1423
+ //RG.clear(obj.canvas);
1424
+ RG.redrawCanvas(obj.canvas);
1425
+
1426
+ for (var i=0; i<10; ++i) {
1427
+ var div = doc.getElementById("rgraph_vscissors_" + i + '_' + obj.id)
1428
+ if (!div) {
1429
+ var div = doc.createElement('DIV');
1430
+ div.id = 'rgraph_vscissors_' + i + '_' + obj.id;
1431
+ div.style.width = width + 'px';
1432
+ div.style.height = 0;
1433
+ div.style.left = xy[0] + (width * i) + 'px';
1434
+ div.style.top = (i % 2 == 0 ? xy[1] + obj.canvas.height : xy[1]) + 'px';
1435
+ div.style.position = 'absolute';
1436
+ div.style.backgroundColor = color;
1437
+ doc.body.appendChild(div);
1438
+ }
1439
+
1440
+ if (i % 2 == 0) {
1441
+ jQuery('#' + 'rgraph_vscissors_' + i + '_' + obj.id).animate({top: xy[1] + 'px', height: obj.canvas.height + 'px'}, duration);
1442
+ } else {
1443
+ jQuery('#' + 'rgraph_vscissors_' + i + '_' + obj.id).animate({height: obj.canvas.height + 'px'}, duration);
1444
+ }
1445
+ }
1446
+
1447
+ setTimeout(function () {callback(obj);}, duration);
1448
+
1449
+ return this;
1450
+ };
1451
+
1452
+
1453
+
1454
+
1455
+ /**
1456
+ * The Animate function. Similar to the jQuery Animate() function - simply pass it a
1457
+ * map of the properties and their target values, and this function will animate
1458
+ * them to get to those values.
1459
+ *
1460
+ * @param object map A map (an associative array) of the properties and their target values.
1461
+ * @param An optional function which will be called when the animation is complete
1462
+ */
1463
+ RG.Effects.Common.animate = function (map)
1464
+ {
1465
+ var obj = this;
1466
+ obj.draw();
1467
+
1468
+ var totalFrames = (map && map['frames']) ? map['frames'] : 30;
1469
+ var currentFrame = new Array();
1470
+ var originalValues = new Array();
1471
+ var diffs = new Array();
1472
+ var steps = new Array();
1473
+ var callback = arguments[1]
1474
+
1475
+ function iterator ()
1476
+ {
1477
+ var id = [obj.id + '_' + obj.type];
1478
+
1479
+ // Initialise the arrays
1480
+ if (!currentFrame[id]) {
1481
+ currentFrame[id] = totalFrames;
1482
+ originalValues[id] = {};
1483
+ diffs[id] = {};
1484
+ steps[id] = {};
1485
+ }
1486
+
1487
+ for (var i in map) {
1488
+ if (typeof map[i] === 'string' || typeof map[i] === 'number') {
1489
+
1490
+ // If this the first frame, record the proginal value
1491
+ if (currentFrame[id] == totalFrames) {
1492
+ originalValues[id][i] = obj.get(i);
1493
+ diffs[id][i] = map[i] - originalValues[id][i];
1494
+ steps[id][i] = diffs[id][i] / totalFrames;
1495
+ }
1496
+
1497
+ obj.set(i, obj.get(i) + steps[id][i]);
1498
+
1499
+ RG.clear(obj.canvas);
1500
+ obj.draw();
1501
+ }
1502
+ }
1503
+
1504
+ // If the current frame number is above zero, run the animation iterator again
1505
+ if (--currentFrame[id] > 0) {
1506
+ RG.Effects.updateCanvas(iterator);
1507
+
1508
+ // Optional callback
1509
+ } else {
1510
+
1511
+ if (typeof callback === 'function') {
1512
+ callback(obj);
1513
+ }
1514
+ }
1515
+ }
1516
+
1517
+ iterator();
1518
+ }
1519
+
1520
+
1521
+
1522
+
1523
+ // End Module pattern
1524
+ })(window, document);