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
@@ -0,0 +1,930 @@
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
11
+
12
+ RGraph = window.RGraph || {isrgraph:true,isRGraph:true,rgraph:true};
13
+ RGraph.SVG = RGraph.SVG || {};
14
+
15
+ // Module pattern
16
+ (function (win, doc, undefined)
17
+ {
18
+ RGraph.SVG.Segmented = function (conf)
19
+ {
20
+ //
21
+ // A setter that the constructor uses (at the end)
22
+ // to set all of the properties
23
+ //
24
+ // @param string name The name of the property to set
25
+ // @param string value The value to set the property to
26
+ //
27
+ this.set = function (name, value)
28
+ {
29
+ if (arguments.length === 1 && typeof name === 'object') {
30
+ for (i in arguments[0]) {
31
+ if (typeof i === 'string') {
32
+
33
+ name = ret.name;
34
+ value = ret.value;
35
+
36
+ this.set(name, value);
37
+ }
38
+ }
39
+ } else {
40
+
41
+
42
+ var ret = RGraph.SVG.commonSetter({
43
+ object: this,
44
+ name: name,
45
+ value: value
46
+ });
47
+
48
+ name = ret.name;
49
+ value = ret.value;
50
+
51
+ this.properties[name] = value;
52
+ }
53
+
54
+ return this;
55
+ };
56
+
57
+
58
+
59
+
60
+
61
+
62
+
63
+
64
+ //
65
+ // A getter.
66
+ //
67
+ // @param name string The name of the property to get
68
+ //
69
+ this.get = function (name)
70
+ {
71
+ return this.properties[name];
72
+ };
73
+
74
+
75
+
76
+
77
+
78
+
79
+
80
+
81
+ this.min = RGraph.SVG.stringsToNumbers(conf.min);
82
+ this.max = RGraph.SVG.stringsToNumbers(conf.max);
83
+ this.value = RGraph.SVG.stringsToNumbers(conf.value);
84
+ this.currentValue = null; // Used by animations
85
+ this.id = conf.id;
86
+ this.uid = RGraph.SVG.createUID();
87
+ this.container = document.getElementById(this.id);
88
+ this.layers = {}; // MUST be before the SVG tag is created!
89
+ this.svg = RGraph.SVG.createSVG({object: this,container: this.container});
90
+ this.isRGraph = true;
91
+ this.isrgraph = true;
92
+ this.rgraph = true;
93
+ this.width = Number(this.svg.getAttribute('width'));
94
+ this.height = Number(this.svg.getAttribute('height'));
95
+ this.type = 'segmented';
96
+ this.colorsParsed = false;
97
+ this.originalColors = {};
98
+ this.gradientCounter = 1;
99
+ this.nodes = {};
100
+ this.shadowNodes = [];
101
+ this.firstDraw = true; // After the first draw this will be false
102
+
103
+ // Bounds checking
104
+ if (this.value > this.max) this.value = this.max;
105
+ if (this.value < this.min) this.value = this.min;
106
+
107
+
108
+
109
+
110
+
111
+
112
+
113
+ // Add this object to the ObjectRegistry
114
+ RGraph.SVG.OR.add(this);
115
+
116
+ // Set the DIV container to be inline-block
117
+ this.container.style.display = 'inline-block';
118
+
119
+ this.properties =
120
+ {
121
+ radius: null,
122
+ centerx: null,
123
+ centery: null,
124
+ width: null,
125
+
126
+ marginLeft: 15,
127
+ marginRight: 15,
128
+ marginTop: 15,
129
+ marginBottom: 15,
130
+
131
+ backgroundColor: 'black',
132
+ colors: ['red','white'],
133
+
134
+ textFont: 'Arial, Verdana, sans-serif',
135
+ textSize: 60,
136
+ textColor: 'gray',
137
+ textBold: false,
138
+ textItalic: false,
139
+ text: null,
140
+
141
+ labelsCenter: true,
142
+ labelsCenterSpecificFormattedDecimals: 0,
143
+ labelsCenterSpecificFormattedPoint: '.',
144
+ labelsCenterSpecificFormattedThousand: ',',
145
+ labelsCenterSpecificFormattedUnitsPre: '',
146
+ labelsCenterSpecificFormattedUnitsPost: '',
147
+ labelsCenterFont: null,
148
+ labelsCenterSize: null,
149
+ labelsCenterColor: null,
150
+ labelsCenterBold: null,
151
+ labelsCenterItalic: null,
152
+ labelsCenterUnitsPre: null,
153
+ labelsCenterUnitsPost: null,
154
+ labelsCenterDecimals: null,
155
+ labelsCenterPoint: null,
156
+ labelsCenterThousand: null,
157
+ labelsCenterSpecific: null,
158
+ labelsCenterOffsetx: 0,
159
+ labelsCenterOffsety: 0,
160
+
161
+ radialsCount: 36,
162
+
163
+ adjustable: false,
164
+
165
+ effectRoundrobinMultiplier: 1
166
+ };
167
+
168
+
169
+
170
+
171
+ //
172
+ // Copy the global object properties to this instance
173
+ //
174
+ RGraph.SVG.getGlobals(this);
175
+
176
+
177
+
178
+
179
+
180
+ //
181
+ // "Decorate" the object with the generic effects if the effects library has been included
182
+ //
183
+ if (RGraph.SVG.FX && typeof RGraph.SVG.FX.decorate === 'function') {
184
+ RGraph.SVG.FX.decorate(this);
185
+ }
186
+
187
+
188
+
189
+
190
+
191
+ // Add the responsive function to the object
192
+ this.responsive = RGraph.SVG.responsive;
193
+
194
+
195
+
196
+
197
+
198
+ var properties = this.properties;
199
+
200
+
201
+
202
+
203
+
204
+
205
+
206
+
207
+ //
208
+ // The draw method draws the Bar chart
209
+ //
210
+ this.draw = function ()
211
+ {
212
+ // Fire the beforedraw event
213
+ RGraph.SVG.fireCustomEvent(this, 'onbeforedraw');
214
+
215
+
216
+ // Reset this to prevent it from growing
217
+ this.nodes = {};
218
+
219
+ // Should the first thing that's done inthe.draw() function
220
+ // except for the onbeforedraw event
221
+ this.width = Number(this.svg.getAttribute('width'));
222
+ this.height = Number(this.svg.getAttribute('height'));
223
+
224
+
225
+
226
+ // Create the defs tag if necessary
227
+ RGraph.SVG.createDefs(this);
228
+
229
+
230
+
231
+ // Add these
232
+ this.graphWidth = this.width - properties.marginLeft - properties.marginRight;
233
+ this.graphHeight = this.height - properties.marginTop - properties.marginBottom;
234
+
235
+
236
+
237
+ // Work out the center point
238
+ this.centerx = (this.graphWidth / 2) + properties.marginLeft;
239
+ this.centery = (this.graphHeight / 2) + properties.marginTop;
240
+ this.radius = Math.min(this.graphWidth / 2, this.graphHeight / 2);
241
+
242
+
243
+
244
+ // Allow the user to override the calculated centerx/y/radius
245
+ this.centerx = typeof properties.centerx === 'number' ? properties.centerx : this.centerx;
246
+ this.centery = typeof properties.centery === 'number' ? properties.centery : this.centery;
247
+ this.radius = typeof properties.radius === 'number' ? properties.radius : this.radius;
248
+
249
+ //
250
+ // Allow the centerx/centery/radius to be a plus/minus
251
+ //
252
+ if (typeof properties.radius === 'string' && properties.radius.match(/^\+|-\d+$/) ) this.radius += parseFloat(properties.radius);
253
+ if (typeof properties.centerx === 'string' && properties.centerx.match(/^\+|-\d+$/) ) this.centerx += parseFloat(properties.centerx);
254
+ if (typeof properties.centery === 'string' && properties.centery.match(/^\+|-\d+$/) ) this.centery += parseFloat(properties.centery);
255
+
256
+
257
+
258
+ // Parse the colors for gradients
259
+ RGraph.SVG.resetColorsToOriginalValues({object:this});
260
+ this.parseColors();
261
+
262
+
263
+
264
+
265
+
266
+ // Draw the segments
267
+ this.path = this.drawMeter();
268
+ this.currentValue = this.value;
269
+
270
+
271
+
272
+
273
+ // Draw the labels
274
+ this.drawLabels();
275
+
276
+
277
+
278
+
279
+
280
+
281
+
282
+
283
+ //
284
+ // Ajusting
285
+ //
286
+ if (properties.adjustable && !this.adjusting_event_listeners_installed) {
287
+
288
+ this.adjusting_mousedown = false;
289
+
290
+ var obj = this;
291
+
292
+ var func = function (e)
293
+ {
294
+ var div = e.currentTarget,
295
+ mouseX = e.offsetX,
296
+ mouseY = e.offsetY;
297
+
298
+ if (RGraph.SVG.ISFF) {
299
+ mouseX = e.pageX - e.currentTarget.offsetLeft;
300
+ mouseY = e.pageY - e.currentTarget.offsetTop;
301
+ }
302
+
303
+ var radius = RGraph.SVG.TRIG.getHypLength({
304
+ x1: mouseX,
305
+ y1: mouseY,
306
+ x2: obj.centerx,
307
+ y2: obj.centery,
308
+ object: obj
309
+ });
310
+
311
+ if (radius > obj.radius) {
312
+ return;
313
+ }
314
+
315
+ var value = obj.getValue(e);
316
+
317
+
318
+ obj.value = value;
319
+ obj.currentValue = value;
320
+
321
+ RGraph.SVG.clear(obj.svg);
322
+ obj.draw();
323
+ };
324
+
325
+
326
+
327
+
328
+ this.container.addEventListener('mousedown', function (e)
329
+ {
330
+ obj.adjusting_mousedown = true;
331
+ func(e);
332
+
333
+ // Fire the adjustbegin event
334
+ RGraph.SVG.fireCustomEvent(obj, 'onadjustbegin');
335
+ }, false);
336
+
337
+ this.container.addEventListener('mousemove', function (e)
338
+ {
339
+ if (obj.adjusting_mousedown) {
340
+ func(e);
341
+
342
+ // Fire the adjust event
343
+ RGraph.SVG.fireCustomEvent(obj, 'onadjust');
344
+ }
345
+ }, false);
346
+
347
+ window.addEventListener('mouseup', function (e)
348
+ {
349
+ obj.adjusting_mousedown = false;
350
+
351
+ // Fire the adjustend event
352
+ RGraph.SVG.fireCustomEvent(obj, 'onadjustend');
353
+ }, false);
354
+
355
+ this.adjusting_event_listeners_installed = true;
356
+ }
357
+
358
+
359
+
360
+
361
+
362
+
363
+
364
+
365
+ //
366
+ // Allow the addition of custom text via the
367
+ // text: property.
368
+ //
369
+ RGraph.SVG.addCustomText(this);
370
+
371
+
372
+
373
+
374
+
375
+
376
+
377
+
378
+
379
+
380
+
381
+
382
+ //
383
+ // Fire the onfirstdraw event
384
+ //
385
+ if (this.firstDraw) {
386
+ this.firstDraw = false;
387
+ RGraph.SVG.fireCustomEvent(this, 'onfirstdraw');
388
+ }
389
+
390
+
391
+
392
+
393
+ // Fire the draw event
394
+ RGraph.SVG.fireCustomEvent(this, 'ondraw');
395
+
396
+
397
+
398
+
399
+
400
+
401
+
402
+ //
403
+ // Install any inline responsive configuration. This
404
+ // should be last in the draw function - even after
405
+ // the draw events.
406
+ //
407
+ RGraph.SVG.installInlineResponsive(this);
408
+
409
+
410
+
411
+
412
+
413
+
414
+
415
+
416
+
417
+
418
+
419
+ return this;
420
+ };
421
+
422
+
423
+
424
+
425
+
426
+
427
+
428
+
429
+ //
430
+ // New create() shortcut function
431
+ // For example:
432
+ // this.create('rect,x:0,y:0,width:100,height:100'[,parent]);
433
+ //
434
+ // @param str string The tag definition to parse and create
435
+ // @param object The (optional) parent element
436
+ // @return object The new tag
437
+ //
438
+ this.create = function (str)
439
+ {
440
+ var def = RGraph.SVG.create.parseStr(this, str);
441
+ def.svg = this.svg;
442
+
443
+ // By default the parent is the SVG tag - but if
444
+ // requested then change it to the tag that has
445
+ // been given
446
+ if (arguments[1]) {
447
+ def.parent = arguments[1];
448
+ }
449
+
450
+ return RGraph.SVG.create(def);
451
+ };
452
+
453
+
454
+
455
+
456
+
457
+
458
+
459
+
460
+ //
461
+ // Draws the meter
462
+ //
463
+ this.drawMeter = function ()
464
+ {
465
+ var width = typeof properties.width === 'number' ? properties.width : this.radius / 2;
466
+
467
+ // Allow for +/-xx style width
468
+ if (typeof properties.width === 'string') {
469
+ width += Number(properties.width);
470
+ }
471
+
472
+
473
+ // First thing to do is clear the canvas to the backgroundColor
474
+ if (properties.backgroundColor) {
475
+ var rect = RGraph.SVG.create({
476
+ svg: this.svg,
477
+ type: 'rect',
478
+ parent: this.svg.all,
479
+ attr: {
480
+ fill: properties.backgroundColor,
481
+ x: 0,
482
+ y: 0,
483
+ width: this.width,
484
+ height: this.height
485
+ }
486
+ });
487
+ }
488
+
489
+
490
+
491
+
492
+
493
+
494
+ // Draw the circle that becomes the non-indicator part of the chart
495
+ var degrees = 360 / properties.radialsCount;
496
+ degrees /= 2,
497
+ colored = Math.round(((this.value - this.min) / (this.max - this.min)) * (properties.radialsCount * 2));
498
+
499
+
500
+
501
+
502
+ // Calculate the radial width of each segment
503
+ var radialWidth = RGraph.SVG.TRIG.TWOPI / properties.radialsCount;
504
+
505
+ //
506
+ // Draw the background segments
507
+ //
508
+ for (var i=1; i<(properties.radialsCount * 2); i+=2) {
509
+
510
+ var start = (RGraph.SVG.TRIG.toRadians({degrees: (i * degrees) - (degrees / 2)}) * properties.effectRoundrobinMultiplier),
511
+ end = (RGraph.SVG.TRIG.toRadians({degrees: (i * degrees) + (degrees / 2)}) * properties.effectRoundrobinMultiplier);
512
+
513
+
514
+ var path = RGraph.SVG.TRIG.getArcPath3({
515
+ cx: this.centerx,
516
+ cy: this.centery,
517
+ radius: this.radius,
518
+ start: start,
519
+ end: end,
520
+ lineto: false
521
+ });
522
+
523
+ var path2 = RGraph.SVG.TRIG.getArcPath3({
524
+ cx: this.centerx,
525
+ cy: this.centery,
526
+ radius: this.radius - width,
527
+ start: end,
528
+ end: start,
529
+ anticlockwise: true
530
+ });
531
+
532
+
533
+ // Draw the outer arc
534
+ RGraph.SVG.create({
535
+ svg: this.svg,
536
+ parent: this.svg.all,
537
+ type: 'path',
538
+ attr: {
539
+ d: path + ' ' + path2 + ' z',
540
+ fill: i > colored ? properties.colors[1] : properties.colors[0]
541
+ }
542
+ });
543
+ }
544
+ };
545
+
546
+
547
+
548
+
549
+
550
+
551
+
552
+
553
+ //
554
+ // Draw the labels
555
+ //
556
+ this.drawLabels = function ()
557
+ {
558
+ // Draw the center label
559
+ if (properties.labelsCenter) {
560
+
561
+ var center = RGraph.SVG.numberFormat({
562
+ object: this,
563
+ num: (this.value * this.properties.effectRoundrobinMultiplier).toFixed(properties.labelsCenterDecimals),
564
+ prepend: properties.labelsCenterUnitsPre,
565
+ append: properties.labelsCenterUnitsPost,
566
+ point: properties.labelsCenterPoint,
567
+ thousand: properties.labelsCenterThousand,
568
+ formatter: properties.labelsCenterFormatter
569
+ });
570
+
571
+
572
+
573
+ if (properties.labelsCenterSpecific) {
574
+ properties.labelsCenterSpecific = RGraph.SVG.labelSubstitution({
575
+ object: this,
576
+ text: properties.labelsCenterSpecific,
577
+ index: 0,
578
+ value: this.value,
579
+ decimals: properties.labelsCenterSpecificFormattedDecimals || 0,
580
+ unitsPre: properties.labelsCenterSpecificFormattedUnitsPre || '',
581
+ unitsPost: properties.labelsCenterSpecificFormattedUnitsPost || '',
582
+ thousand: properties.labelsCenterSpecificFormattedThousand || ',',
583
+ point: properties.labelsCenterSpecificFormattedPoint || '.'
584
+ });
585
+ }
586
+
587
+ // Get the text configuration
588
+ var textConf = RGraph.SVG.getTextConf({
589
+ object: this,
590
+ prefix: 'labelsCenter'
591
+ });
592
+
593
+ var text = RGraph.SVG.text({
594
+ object: this,
595
+ parent: this.svg.all,
596
+ tag: 'labels.center',
597
+
598
+ text: typeof properties.labelsCenterSpecific === 'string' ? properties.labelsCenterSpecific : center,
599
+
600
+ x: this.centerx + properties.labelsCenterOffsetx,
601
+ y: this.centery + properties.labelsCenterOffsety,
602
+
603
+ valign: 'center',
604
+ halign: 'center',
605
+
606
+ font: textConf.font,
607
+ size: textConf.size,
608
+ bold: textConf.bold,
609
+ italic: textConf.italic,
610
+ color: textConf.color
611
+ });
612
+
613
+ // Store a reference to the center label
614
+ this.nodes.labelsCenter = text;
615
+ }
616
+ };
617
+
618
+
619
+
620
+
621
+
622
+
623
+
624
+
625
+ //
626
+ // This allows for easy specification of gradients
627
+ //
628
+ this.parseColors = function ()
629
+ {
630
+ // Save the original colors so that they can be restored when the canvas is reset
631
+ if (!Object.keys(this.originalColors).length) {
632
+ this.originalColors = {
633
+ colors: RGraph.SVG.arrayClone(properties.colors),
634
+ backgroundColor: RGraph.SVG.arrayClone(properties.backgroundColor)
635
+ }
636
+ }
637
+
638
+
639
+ // colors
640
+ var colors = properties.colors;
641
+
642
+ if (colors) {
643
+ for (var i=0; i<colors.length; ++i) {
644
+ colors[i] = RGraph.SVG.parseColorLinear({
645
+ object: this,
646
+ color: colors[i],
647
+ start: this.centerx - this.radius,
648
+ end: this.centerx + this.radius,
649
+ direction: 'horizontal'
650
+ });
651
+ }
652
+ }
653
+
654
+ // Background color
655
+ properties.backgroundColor = RGraph.SVG.parseColorLinear({
656
+ object: this,
657
+ color: properties.backgroundColor,
658
+ start: properties.marginLeft,
659
+ end: this.width - properties.marginRight,
660
+ direction: 'horizontal'
661
+ });
662
+ };
663
+
664
+
665
+
666
+
667
+
668
+
669
+
670
+
671
+ //
672
+ // Using a function to add events makes it easier to facilitate method
673
+ // chaining
674
+ //
675
+ // @param string type The type of even to add
676
+ // @param function func
677
+ //
678
+ this.on = function (type, func)
679
+ {
680
+ if (type.substr(0,2) !== 'on') {
681
+ type = 'on' + type;
682
+ }
683
+
684
+ RGraph.SVG.addCustomEventListener(this, type, func);
685
+
686
+ return this;
687
+ };
688
+
689
+
690
+
691
+
692
+
693
+
694
+
695
+
696
+ //
697
+ // Used in chaining. Runs a function there and then - not waiting for
698
+ // the events to fire (eg the onbeforedraw event)
699
+ //
700
+ // @param function func The function to execute
701
+ //
702
+ this.exec = function (func)
703
+ {
704
+ func(this);
705
+
706
+ return this;
707
+ };
708
+
709
+
710
+
711
+
712
+
713
+
714
+
715
+
716
+ //
717
+ // This function returns the pertinent angle for a particular click (or other mouse event)
718
+ //
719
+ // @param obj e The event object
720
+ //
721
+ this.getAngle = function (e)
722
+ {
723
+ if (typeof e === 'number') {
724
+ var angle = ((e - this.min) / (this.max - this.min)) * RGraph.SVG.TRIG.TWOPI;
725
+ angle = angle - RGraph.SVG.TRIG.HALFPI;
726
+
727
+ } else {
728
+ var mouseX = e.offsetX,
729
+ mouseY = e.offsetY;
730
+
731
+ var angle = RGraph.SVG.TRIG.getAngleByXY({
732
+ cx: this.centerx,
733
+ cy: this.centery,
734
+ x: mouseX,
735
+ y: mouseY
736
+ });
737
+
738
+ angle -= RGraph.SVG.TRIG.HALFPI;
739
+ }
740
+
741
+ return angle;
742
+ };
743
+
744
+
745
+
746
+
747
+
748
+
749
+
750
+
751
+ //
752
+ // This function returns the pertinent value for a particular click (or other mouse event)
753
+ //
754
+ // @param obj e The event object
755
+ //
756
+ this.getValue = function (e)
757
+ {
758
+ // An angle has been given (it should to be in radians)
759
+ if (typeof e === 'number') {
760
+ var angle = e;
761
+ } else {
762
+ // Get the angle of the click
763
+ var angle = this.getAngle(e);
764
+ }
765
+ var value = (( (angle + RGraph.SVG.TRIG.HALFPI) / RGraph.SVG.TRIG.TWOPI) * (this.max - this.min)) + this.min;
766
+
767
+ // Ensure that the value is in range
768
+ value = Math.max(value, this.min);
769
+ value = Math.min(value, this.max);
770
+
771
+ return value;
772
+ };
773
+
774
+
775
+
776
+
777
+
778
+
779
+
780
+
781
+ //
782
+ // This function returns the pertinent radius (from the centerx/y) of a given event object
783
+ // (eg from a click or mouse event).
784
+ //
785
+ // @param obj e The event object
786
+ //
787
+ this.getRadius = function (e)
788
+ {
789
+ var x = e.offsetX,
790
+ y = e.offsetY;
791
+
792
+ var radius = RGraph.SVG.TRIG.getHypLength({
793
+ x1: x,
794
+ y1: y,
795
+ x2: this.centerx,
796
+ y2: this.centery
797
+ });
798
+
799
+ return radius;
800
+ };
801
+
802
+
803
+
804
+
805
+
806
+
807
+
808
+
809
+ //
810
+ // Segmented donut Grow
811
+ //
812
+ // This effect gradually increases the represented value
813
+ //
814
+ // @param An object of options - eg: {frames: 60}
815
+ // @param function An optional callback function
816
+ //
817
+ this.grow = function ()
818
+ {
819
+ var obj = this;
820
+
821
+ this.currentValue = typeof this.currentValue === 'number' ? this.currentValue : this.min;
822
+
823
+ // Limit value to the max and min values
824
+ this.value = Math.min(this.value, this.max);
825
+ this.value = Math.max(this.value, this.min);
826
+
827
+ var opt = arguments[0] || {},
828
+ frames = opt.frames || 60,
829
+ frame = 0,
830
+ diff = this.value - this.currentValue,
831
+ step = diff / frames,
832
+ callback = arguments[1] || function () {},
833
+ initial = this.currentValue
834
+
835
+
836
+
837
+ function iterator ()
838
+ {
839
+ obj.value = initial + (frame++ * step);
840
+
841
+ RGraph.SVG.redraw(obj.svg);
842
+
843
+ if (frame++ >= frames) {
844
+ this.currentValue = this.value;
845
+ callback(obj);
846
+ } else {
847
+ RGraph.SVG.FX.update(iterator);
848
+ }
849
+ }
850
+
851
+ iterator();
852
+
853
+ return this;
854
+ };
855
+
856
+
857
+
858
+
859
+
860
+
861
+
862
+
863
+ //
864
+ // RoundRobin
865
+ //
866
+ // This effect gradually increases the size of each segment
867
+ //
868
+ // @param object OPTIONAL Options for the effect
869
+ // @param function OPTIONAL A callback function
870
+ //
871
+ this.roundrobin =
872
+ this.roundRobin = function ()
873
+ {
874
+ var obj = this,
875
+ opt = arguments[0] || {},
876
+ callback = arguments[1] || function () {},
877
+ frame = 0,
878
+ frames = opt.frames || 60,
879
+ radius = this.radius;
880
+
881
+ var iterator = function ()
882
+ {
883
+ // Took this straight out of the common core file
884
+ var multiplier = Math.sin((frame / frames) * RGraph.SVG.TRIG.HALFPI);
885
+ obj.set('effectRoundrobinMultiplier',multiplier);
886
+
887
+ RGraph.SVG.redraw();
888
+
889
+ if (frame++ >= frames) {
890
+ this.currentValue = this.value;
891
+ callback(obj);
892
+ } else {
893
+ RGraph.SVG.FX.update(iterator);
894
+ }
895
+ };
896
+
897
+ iterator();
898
+
899
+ return this;
900
+ };
901
+
902
+
903
+
904
+
905
+
906
+
907
+
908
+ //
909
+ // Set the options that the user has provided
910
+ //
911
+ for (i in conf.options) {
912
+ if (typeof i === 'string') {
913
+ this.set(i, conf.options[i]);
914
+ }
915
+ }
916
+
917
+
918
+
919
+ return this;
920
+ };
921
+
922
+
923
+
924
+
925
+
926
+
927
+
928
+
929
+ // End module pattern
930
+ })(window, document);