rgraph-rails 4.62 → 4.64

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (67) hide show
  1. checksums.yaml +5 -5
  2. data/README.md +3 -4
  3. data/lib/rgraph-rails/version.rb +1 -1
  4. data/vendor/assets/javascripts/RGraph.bar.js +240 -3742
  5. data/vendor/assets/javascripts/RGraph.bipolar.js +165 -2005
  6. data/vendor/assets/javascripts/RGraph.common.annotate.js +35 -395
  7. data/vendor/assets/javascripts/RGraph.common.context.js +30 -595
  8. data/vendor/assets/javascripts/RGraph.common.core.js +418 -5359
  9. data/vendor/assets/javascripts/RGraph.common.csv.js +20 -276
  10. data/vendor/assets/javascripts/RGraph.common.deprecated.js +35 -450
  11. data/vendor/assets/javascripts/RGraph.common.dynamic.js +88 -1395
  12. data/vendor/assets/javascripts/RGraph.common.effects.js +90 -1545
  13. data/vendor/assets/javascripts/RGraph.common.key.js +52 -753
  14. data/vendor/assets/javascripts/RGraph.common.resizing.js +37 -563
  15. data/vendor/assets/javascripts/RGraph.common.sheets.js +29 -352
  16. data/vendor/assets/javascripts/RGraph.common.tooltips.js +32 -450
  17. data/vendor/assets/javascripts/RGraph.common.zoom.js +14 -219
  18. data/vendor/assets/javascripts/RGraph.cornergauge.js +71 -0
  19. data/vendor/assets/javascripts/RGraph.drawing.background.js +34 -570
  20. data/vendor/assets/javascripts/RGraph.drawing.circle.js +33 -544
  21. data/vendor/assets/javascripts/RGraph.drawing.image.js +51 -755
  22. data/vendor/assets/javascripts/RGraph.drawing.marker1.js +37 -645
  23. data/vendor/assets/javascripts/RGraph.drawing.marker2.js +36 -633
  24. data/vendor/assets/javascripts/RGraph.drawing.marker3.js +35 -514
  25. data/vendor/assets/javascripts/RGraph.drawing.poly.js +37 -559
  26. data/vendor/assets/javascripts/RGraph.drawing.rect.js +33 -548
  27. data/vendor/assets/javascripts/RGraph.drawing.text.js +36 -664
  28. data/vendor/assets/javascripts/RGraph.drawing.xaxis.js +50 -812
  29. data/vendor/assets/javascripts/RGraph.drawing.yaxis.js +51 -856
  30. data/vendor/assets/javascripts/RGraph.fuel.js +58 -964
  31. data/vendor/assets/javascripts/RGraph.funnel.js +55 -984
  32. data/vendor/assets/javascripts/RGraph.gantt.js +77 -1354
  33. data/vendor/assets/javascripts/RGraph.gauge.js +85 -1421
  34. data/vendor/assets/javascripts/RGraph.hbar.js +162 -2788
  35. data/vendor/assets/javascripts/RGraph.hprogress.js +80 -1401
  36. data/vendor/assets/javascripts/RGraph.line.js +249 -4248
  37. data/vendor/assets/javascripts/RGraph.meter.js +74 -1280
  38. data/vendor/assets/javascripts/RGraph.modaldialog.js +19 -301
  39. data/vendor/assets/javascripts/RGraph.odo.js +71 -1264
  40. data/vendor/assets/javascripts/RGraph.pie.js +137 -2288
  41. data/vendor/assets/javascripts/RGraph.radar.js +110 -1847
  42. data/vendor/assets/javascripts/RGraph.rose.js +108 -1977
  43. data/vendor/assets/javascripts/RGraph.rscatter.js +80 -1432
  44. data/vendor/assets/javascripts/RGraph.scatter.js +172 -3163
  45. data/vendor/assets/javascripts/RGraph.semicircularprogress.js +60 -1120
  46. data/vendor/assets/javascripts/RGraph.svg.bar.js +66 -1735
  47. data/vendor/assets/javascripts/RGraph.svg.common.ajax.js +21 -246
  48. data/vendor/assets/javascripts/RGraph.svg.common.core.js +255 -3937
  49. data/vendor/assets/javascripts/RGraph.svg.common.csv.js +20 -276
  50. data/vendor/assets/javascripts/RGraph.svg.common.fx.js +68 -1303
  51. data/vendor/assets/javascripts/RGraph.svg.common.key.js +19 -205
  52. data/vendor/assets/javascripts/RGraph.svg.common.sheets.js +29 -352
  53. data/vendor/assets/javascripts/RGraph.svg.common.tooltips.js +22 -273
  54. data/vendor/assets/javascripts/RGraph.svg.funnel.js +32 -0
  55. data/vendor/assets/javascripts/RGraph.svg.hbar.js +59 -1400
  56. data/vendor/assets/javascripts/RGraph.svg.line.js +70 -1580
  57. data/vendor/assets/javascripts/RGraph.svg.pie.js +55 -1131
  58. data/vendor/assets/javascripts/RGraph.svg.radar.js +57 -1502
  59. data/vendor/assets/javascripts/RGraph.svg.rose.js +66 -1817
  60. data/vendor/assets/javascripts/RGraph.svg.scatter.js +58 -1261
  61. data/vendor/assets/javascripts/RGraph.svg.semicircularprogress.js +28 -865
  62. data/vendor/assets/javascripts/RGraph.svg.waterfall.js +45 -1252
  63. data/vendor/assets/javascripts/RGraph.thermometer.js +63 -1136
  64. data/vendor/assets/javascripts/RGraph.vprogress.js +83 -1470
  65. data/vendor/assets/javascripts/RGraph.waterfall.js +83 -1347
  66. metadata +5 -4
  67. data/vendor/assets/javascripts/financial-data.js +0 -1067
@@ -1,866 +1,29 @@
1
- // version: 2017-05-08
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 licensed under the Open Source MIT license. That means that it's |
9
- * | totally free to use! |
10
- * o--------------------------------------------------------------------------------o
11
- */
12
1
 
13
- RGraph = window.RGraph || {isRGraph: true};
14
- RGraph.SVG = RGraph.SVG || {};
15
-
16
- // Module pattern
17
- (function (win, doc, undefined)
18
- {
19
- var RG = RGraph,
20
- ua = navigator.userAgent,
21
- ma = Math,
22
- win = window,
23
- doc = document;
24
-
25
-
26
-
27
- RG.SVG.SemiCircularProgress = function (conf)
28
- {
29
- //
30
- // A setter that the constructor uses (at the end)
31
- // to set all of the properties
32
- //
33
- // @param string name The name of the property to set
34
- // @param string value The value to set the property to
35
- //
36
- this.set = function (name, value)
37
- {
38
- if (arguments.length === 1 && typeof name === 'object') {
39
- for (i in arguments[0]) {
40
- if (typeof i === 'string') {
41
-
42
- var ret = RG.SVG.commonSetter({
43
- object: this,
44
- name: i,
45
- value: arguments[0][i]
46
- });
47
-
48
- name = ret.name;
49
- value = ret.value;
50
-
51
- this.set(name, value);
52
- }
53
- }
54
- } else {
55
-
56
-
57
- var ret = RG.SVG.commonSetter({
58
- object: this,
59
- name: name,
60
- value: value
61
- });
62
-
63
- name = ret.name;
64
- value = ret.value;
65
-
66
- this.properties[name] = value;
67
- }
68
-
69
- return this;
70
- };
71
-
72
-
73
-
74
-
75
-
76
-
77
-
78
-
79
- this.min = RG.SVG.stringsToNumbers(conf.min);
80
- this.max = RG.SVG.stringsToNumbers(conf.max);
81
- this.value = RG.SVG.stringsToNumbers(conf.value);
82
- this.id = conf.id;
83
- this.uid = RG.SVG.createUID();
84
- this.container = document.getElementById(this.id);
85
- this.svg = RG.SVG.createSVG({container: this.container});
86
- this.isRGraph = true;
87
- this.width = Number(this.svg.getAttribute('width'));
88
- this.height = Number(this.svg.getAttribute('height'));
89
- this.data = conf.data;
90
- this.type = 'semicircularprogress';
91
- this.angles = [];
92
- this.colorsParsed = false;
93
- this.originalColors = {};
94
- this.gradientCounter = 1;
95
- this.nodes = [];
96
- this.shadowNodes = [];
97
-
98
- // Add this object to the ObjectRegistry
99
- RG.SVG.OR.add(this);
100
-
101
- // Set the DIV container to be inline-block
102
- this.container.style.display = 'inline-block';
103
-
104
- this.properties =
105
- {
106
- centerx: null,
107
- centery: null,
108
- radius: null,
109
-
110
- width: 60,
111
-
112
- gutterLeft: 35,
113
- gutterRight: 35,
114
- gutterTop: 35,
115
- gutterBottom: 35,
116
-
117
- backgroundStrokeLinewidth: 0.25,
118
- backgroundStroke: 'gray',
119
- backgroundFill: 'Gradient(white:#aaa)',
120
- backgroundFillOpacity: 0.25,
121
-
122
- colors: ['#0c0'],
123
- strokestyle: '#666',
124
-
125
- textColor: 'gray',
126
- textFont: 'sans-serif',
127
- textSize: 10,
128
- textBold: false,
129
- textItalic: false,
130
- unitsPre: '',
131
- unitsPost: '',
132
- scalePoint: '.',
133
- scaleThousand: ',',
134
- scaleDecimals: 0,
135
- scaleFormatter: null,
136
-
137
- labelsMin: true,
138
- labelsMinSpecific: null,
139
- labelsMinPoint: null,
140
- labelsMinThousand: null,
141
- labelsMinFormatter: null,
142
- labelsMinFont: null,
143
- labelsMinSize: null,
144
- labelsMinBold: null,
145
- labelsMinItalic: null,
146
- labelsMinColor: null,
147
- labelsMinDecimals: null,
148
- labelsMinUnitsPre: null,
149
- labelsMinUnitsPost: null,
150
-
151
- labelsMax: true,
152
- labelsMaxSpecific: null,
153
- labelsMaxPoint: null,
154
- labelsMaxThousand: null,
155
- labelsMaxFormatter: null,
156
- labelsMaxFont: null,
157
- labelsMaxSize: null,
158
- labelsMaxBold: null,
159
- labelsMaxItalic: null,
160
- labelsMaxColor: null,
161
- labelsMaxDecimals: null,
162
- labelsMaxUnitsPre: null,
163
- labelsMaxUnitsPost: null,
164
-
165
- labelsCenter: true,
166
- labelsCenterSpecific: null,
167
- labelsCenterPoint: null,
168
- labelsCenterThousand: null,
169
- labelsCenterFormatter: null,
170
- labelsCenterFont: null,
171
- labelsCenterSize: 40,
172
- labelsCenterBold: true,
173
- labelsCenterItalic: null,
174
- labelsCenterColor: '#666',
175
- labelsCenterDecimals: null,
176
- labelsCenterUnitsPre: null,
177
- labelsCenterUnitsPost: null,
178
-
179
- linewidth: 0,
180
-
181
- tooltips: null,
182
- tooltipsOverride: null,
183
- tooltipsEffect: 'fade',
184
- tooltipsCssClass: 'RGraph_tooltip',
185
- tooltipsEvent: 'click',
186
-
187
- highlightStroke: 'rgba(0,0,0,0)',
188
- highlightFill: 'rgba(255,255,255,0.7)',
189
- highlightLinewidth: 1,
190
-
191
- title: '',
192
- titleSize: 16,
193
- titleX: null,
194
- titleY: null,
195
- titleHalign: 'center',
196
- titleValign: null,
197
- titleColor: 'black',
198
- titleFont: null,
199
- titleBold: false,
200
- titleItalic: false,
201
-
202
- titleSubtitle: '',
203
- titleSubtitleSize: 10,
204
- titleSubtitleX: null,
205
- titleSubtitleY: null,
206
- titleSubtitleHalign: 'center',
207
- titleSubtitleValign: null,
208
- titleSubtitleColor: '#aaa',
209
- titleSubtitleFont: null,
210
- titleSubtitleBold: false,
211
- titleSubtitleItalic: false,
212
-
213
- attribution: true,
214
- attributionX: null,
215
- attributionY: null,
216
- attributionHref: null,// Default is set in RGraph.svg.common.core.js
217
- attributionHalign: 'right',
218
- attributionValign: 'bottom',
219
- attributionSize: 7,
220
- attributionColor: 'gray',
221
- attributionFont: 'sans-serif',
222
- attributionItalic: false,
223
- attributionBold: false
224
-
225
- //shadow: false,
226
- //shadowOffsetx: 2,
227
- //shadowOffsety: 2,
228
- //shadowBlur: 2,
229
- //shadowOpacity: 0.25
230
- };
231
-
232
-
233
-
234
-
235
-
236
- /**
237
- * "Decorate" the object with the generic effects if the effects library has been included
238
- */
239
- if (RG.SVG.FX && typeof RG.SVG.FX.decorate === 'function') {
240
- RG.SVG.FX.decorate(this);
241
- }
242
-
243
-
244
-
245
-
246
- var prop = this.properties;
247
-
248
-
249
-
250
-
251
-
252
-
253
-
254
-
255
- //
256
- // The draw method draws the Bar chart
257
- //
258
- this.draw = function ()
259
- {
260
- // Fire the beforedraw event
261
- RG.SVG.fireCustomEvent(this, 'onbeforedraw');
262
-
263
-
264
-
265
-
266
- // Create the defs tag if necessary
267
- RG.SVG.createDefs(this);
268
-
269
-
270
-
271
- // Add these
272
- this.graphWidth = this.width - prop.gutterLeft - prop.gutterRight;
273
- this.graphHeight = this.height - prop.gutterTop - prop.gutterBottom;
274
-
275
-
276
-
277
- // Work out the center point
278
- this.centerx = (this.graphWidth / 2) + prop.gutterLeft;
279
- this.centery = this.height - prop.gutterBottom;
280
- this.radius = ma.min(this.graphWidth / 2, this.graphHeight);
281
-
282
-
283
-
284
- // Allow the user to override the calculated centerx/y/radius
285
- this.centerx = typeof prop.centerx === 'number' ? prop.centerx : this.centerx;
286
- this.centery = typeof prop.centery === 'number' ? prop.centery : this.centery;
287
- this.radius = typeof prop.radius === 'number' ? prop.radius : this.radius;
288
-
289
- //
290
- // Allow the centerx/centery/radius to be a plus/minus
291
- //
292
- if (typeof prop.radius === 'string' && prop.radius.match(/^\+|-\d+$/) ) this.radius += parseFloat(prop.radius);
293
- if (typeof prop.centerx === 'string' && prop.centerx.match(/^\+|-\d+$/) ) this.centery += parseFloat(prop.centerx);
294
- if (typeof prop.centery === 'string' && prop.centery.match(/^\+|-\d+$/) ) this.centerx += parseFloat(prop.centery);
295
-
296
- // Set the width of the meter
297
- this.progressWidth = prop.width || (this.radius / 3);
298
-
299
-
300
-
301
- // Parse the colors for gradients
302
- RG.SVG.resetColorsToOriginalValues({object:this});
303
- this.parseColors();
304
-
305
-
306
-
307
-
308
-
309
- // Draw the segments
310
- this.path = this.drawMeter();
311
-
312
-
313
-
314
- // Draw the title and subtitle
315
- RG.SVG.drawTitle(this);
316
-
317
-
318
-
319
- // Draw the labels
320
- this.drawLabels();
321
-
322
-
323
-
324
-
325
-
326
- // Add the attribution link. If you're adding this elsewhere on your page/site
327
- // and you don't want it displayed then there are options available to not
328
- // show it.
329
- RG.SVG.attribution(this);
330
-
331
-
332
-
333
- // Add the tooltip event listener
334
- if (!RG.SVG.isNull(prop.tooltips) && prop.tooltips[0]) {
335
-
336
- var obj = this;
337
-
338
- //
339
- // Add tooltip event listeners
340
- //
341
- this.path.addEventListener(prop.tooltipsEvent, function (e)
342
- {
343
- obj.removeHighlight();
344
-
345
- // Show the tooltip
346
- RG.SVG.tooltip({
347
- object: obj,
348
- index: 0,
349
- group: null,
350
- sequentialIndex: 0,
351
- text: prop.tooltips[0],
352
- event: e
353
- });
354
-
355
- // Highlight the rect that has been clicked on
356
- obj.highlight(e.target);
357
- }, false);
358
-
359
- this.path.addEventListener('mousemove', function (e)
360
- {
361
- e.target.style.cursor = 'pointer'
362
- }, false);
363
- }
364
-
365
-
366
- // Add the event listener that clears the highlight if
367
- // there is any. Must be MOUSEDOWN (ie before the click event)
368
- var obj = this;
369
- doc.body.addEventListener('mousedown', function (e)
370
- {
371
- obj.removeHighlight();
372
- }, false);
373
-
374
-
375
-
376
- // Fire the draw event
377
- RG.SVG.fireCustomEvent(this, 'ondraw');
378
-
379
-
380
-
381
- return this;
382
- };
383
-
384
-
385
-
386
-
387
-
388
-
389
-
390
-
391
- //
392
- // Draws the meter
393
- //
394
- this.drawMeter = function ()
395
- {
396
- //
397
- // Draw the background to the meter
398
- //
399
- var path = RG.SVG.TRIG.getArcPath({
400
- cx: this.centerx,
401
- cy: this.centery,
402
- r: this.radius,
403
- start: RG.SVG.TRIG.PI + RG.SVG.TRIG.HALFPI,
404
- end: RG.SVG.TRIG.HALFPI,
405
- anticlockwise: false
406
- });
407
-
408
- var path2 = RG.SVG.TRIG.getArcPath({
409
- cx: this.centerx,
410
- cy: this.centery,
411
- r: this.radius - this.progressWidth,
412
- end: RG.SVG.TRIG.PI + RG.SVG.TRIG.HALFPI,
413
- start: RG.SVG.TRIG.HALFPI,
414
- anticlockwise: true,
415
- moveto: false
416
- });
417
-
418
- RG.SVG.create({
419
- svg: this.svg,
420
- type: 'path',
421
- parent: this.svg.all,
422
- attr: {
423
- d: path + " L " + (this.centerx + this.radius - this.progressWidth) + " " + this.centery + path2 + " L " + (this.centerx - this.radius) + " " + this.centery,
424
- fill: prop.backgroundFill || prop.colors[0],
425
- stroke: prop.backgroundStroke,
426
- 'stroke-width': prop.backgroundStrokeLinewidth,
427
- 'fill-opacity': prop.backgroundFillOpacity
428
- }
429
- });
430
-
431
-
432
-
433
- //
434
- // This draws the bar that indicates the value
435
- //
436
- var angle = ((this.value - this.min) / (this.max - this.min)) * RG.SVG.TRIG.PI; // Because the Meter is always a semi-circle
437
-
438
- // Take off half a pi because our origin is the noth axis
439
- angle -= RG.SVG.TRIG.HALFPI;
440
-
441
-
442
- // Now get the path of the inner indicator bar
443
- var path = RG.SVG.TRIG.getArcPath({
444
- cx: this.centerx,
445
- cy: this.centery,
446
- r: this.radius,
447
- start: RG.SVG.TRIG.PI + RG.SVG.TRIG.HALFPI,
448
- end: angle,
449
- anticlockwise: false
450
- });
451
-
452
- var path2 = RG.SVG.TRIG.getArcPath({
453
- cx: this.centerx,
454
- cy: this.centery,
455
- r: this.radius - this.progressWidth,
456
- start: angle,
457
- end: angle,
458
- anticlockwise: false,
459
- array: true
460
- });
461
-
462
- var path3 = RG.SVG.TRIG.getArcPath({
463
- cx: this.centerx,
464
- cy: this.centery,
465
- r: this.radius - this.progressWidth,
466
- start: angle,
467
- end: RG.SVG.TRIG.PI + RG.SVG.TRIG.HALFPI,
468
- anticlockwise: true,
469
- moveto: false
470
- });
471
-
472
-
473
- // Now draw the path
474
- var path = RG.SVG.create({
475
- svg: this.svg,
476
- type: 'path',
477
- parent: this.svg.all,
478
- attr: {
479
- d: path + " L{1} {2} ".format(
480
- path2[1],
481
- path2[2]
482
- ) + path3 + ' z',
483
- fill: prop.colors[0],
484
- stroke: 'black',
485
- 'stroke-width': prop.linewidth
486
- }
487
- });
488
-
489
- return path;
490
- };
491
-
492
-
493
-
494
-
495
-
496
-
497
-
498
-
499
- //
500
- // Draw the labels
501
- //
502
- this.drawLabels = function ()
503
- {
504
- // Draw the min label
505
- if (prop.labelsMin) {
506
-
507
- var min = RG.SVG.numberFormat({
508
- object: this,
509
- num: this.min.toFixed(typeof prop.labelsMinDecimals === 'number' ? prop.labelsMinDecimals : prop.scaleDecimals),
510
- prepend: typeof prop.labelsMinUnitsPre === 'string' ? prop.labelsMinUnitsPre : prop.unitsPre,
511
- append: typeof prop.labelsMinUnitsPost === 'string' ? prop.labelsMinUnitsPost : prop.unitsPost,
512
- point: typeof prop.labelsMinPoint === 'string' ? prop.labelsMinPoint : prop.scalePoint,
513
- thousand: typeof prop.labelsMinThousand === 'string' ? prop.labelsMinThousand : prop.scaleThousand,
514
- formatter: typeof prop.labelsMinFormatter === 'function' ? prop.labelsMinFormatter : prop.scaleFormatter
515
- });
516
-
517
- RG.SVG.text({
518
- object: this,
519
- parent: this.svg.all,
520
- text: typeof prop.labelsMinSpecific === 'string' ? prop.labelsMinSpecific : min,
521
- x: this.centerx - this.radius + (this.progressWidth / 2),
522
- y: this.height - prop.gutterBottom + 5,
523
- valign: 'top',
524
- halign: 'center',
525
- font: prop.labelsMinFont || prop.textFont,
526
- size: prop.labelsMinSize || prop.textSize,
527
- bold: typeof prop.labelsMinBold === 'boolean' ? prop.labelsMinBold : prop.textBold,
528
- italic: typeof prop.labelsMinItalic === 'boolean' ? prop.labelsMinItalic : prop.textItalic,
529
- color: prop.labelsMinColor || prop.textColor
530
- });
531
-
532
- }
533
-
534
-
535
-
536
-
537
-
538
-
539
-
540
- // Draw the max label
541
- if (prop.labelsMax) {
542
-
543
- var max = RG.SVG.numberFormat({
544
- object: this,
545
- num: this.max.toFixed(typeof prop.labelsMaxDecimals === 'number' ? prop.labelsMaxDecimals : prop.scaleDecimals),
546
- prepend: typeof prop.labelsMaxUnitsPre === 'string' ? prop.labelsMaxUnitsPre : prop.unitsPre,
547
- append: typeof prop.labelsMaxUnitsPost === 'string' ? prop.labelsMaxUnitsPost : prop.unitsPost,
548
- point: typeof prop.labelsMaxPoint === 'string' ? prop.labelsMaxPoint : prop.scalePoint,
549
- thousand: typeof prop.labelsMaxThousand === 'string' ? prop.labelsMaxThousand : prop.scaleThousand,
550
- formatter: typeof prop.labelsMaxFormatter === 'function' ? prop.labelsMaxFormatter : prop.scaleFormatter
551
- });
552
-
553
- RG.SVG.text({
554
- object: this,
555
- parent: this.svg.all,
556
- text: typeof prop.labelsMaxSpecific === 'string' ? prop.labelsMaxSpecific : max,
557
- x: this.centerx + this.radius - (this.progressWidth / 2),
558
- y: this.height - prop.gutterBottom + 5,
559
- valign: 'top',
560
- halign: 'center',
561
- font: prop.labelsMaxFont || prop.textFont,
562
- size: prop.labelsMaxSize || prop.textSize,
563
- bold: typeof prop.labelsMaxBold === 'boolean' ? prop.labelsMaxBold : prop.textBold,
564
- italic: typeof prop.labelsMaxItalic === 'boolean' ? prop.labelsMaxItalic : prop.textItalic,
565
- color: prop.labelsMaxColor || prop.textColor
566
- });
567
- }
568
-
569
-
570
-
571
-
572
-
573
-
574
-
575
- // Draw the center label
576
- if (prop.labelsCenter) {
577
-
578
- var center = RG.SVG.numberFormat({
579
- object: this,
580
- num: this.value.toFixed(typeof prop.labelsCenterDecimals === 'number' ? prop.labelsCenterDecimals : prop.scaleDecimals),
581
- prepend: typeof prop.labelsCenterUnitsPre === 'string' ? prop.labelsCenterUnitsPre : prop.unitsPre,
582
- append: typeof prop.labelsCenterUnitsPost === 'string' ? prop.labelsCenterUnitsPost : prop.unitsPost,
583
- point: typeof prop.labelsCenterPoint === 'string' ? prop.labelsCenterPoint : prop.scalePoint,
584
- thousand: typeof prop.labelsCenterThousand === 'string' ? prop.labelsCenterThousand : prop.scaleThousand,
585
- formatter: typeof prop.labelsCenterFormatter === 'function' ? prop.labelsCenterFormatter : prop.scaleFormatter
586
- });
587
-
588
- RG.SVG.text({
589
- object: this,
590
- parent: this.svg.all,
591
- text: typeof prop.labelsCenterSpecific === 'string' ? prop.labelsCenterSpecific : center,
592
- x: this.centerx,
593
- y: this.centery,
594
- valign: 'bottom',
595
- halign: 'center',
596
- font: prop.labelsCenterFont || prop.textFont,
597
- size: prop.labelsCenterSize || prop.textSize,
598
- bold: typeof prop.labelsCenterBold === 'boolean' ? prop.labelsCenterBold : prop.textBold,
599
- italic: typeof prop.labelsCenterItalic === 'boolean' ? prop.labelsCenterItalic : prop.textItalic,
600
- color: prop.labelsCenterColor || prop.textColor
601
- });
602
- }
603
- };
604
-
605
-
606
-
607
-
608
-
609
-
610
-
611
-
612
- /**
613
- * This function can be used to highlight a segment on the chart
614
- *
615
- * @param object segment The segment to highlight
616
- */
617
- this.highlight = function (segment)
618
- {
619
- // Remove any highlight that's already been
620
- // installed
621
- this.removeHighlight();
622
-
623
- var highlight = RG.SVG.create({
624
- svg: this.svg,
625
- type: 'path',
626
- parent: this.svg.all,
627
- attr: {
628
- d: this.path.getAttribute('d'),
629
- fill: prop.highlightFill,
630
- stroke: prop.highlightStroke,
631
- 'stroke-width': prop.highlightLinewidth
632
- }
633
- });
634
-
635
- // Store the highlight node in the registry
636
- RG.SVG.REG.set('highlight', highlight);
637
-
638
- // Add the event listener that clears the highlight path if
639
- // there is any. Must be MOUSEDOWN (ie before the click event)
640
- var obj = this;
641
- doc.body.addEventListener('mousedown', function (e)
642
- {
643
- obj.removeHighlight();
644
-
645
- }, false);
646
- };
647
-
648
-
649
-
650
-
651
-
652
-
653
-
654
-
655
- /**
656
- * This function can be used to remove the highlight that is added
657
- * by tooltips
658
- */
659
- this.removeHighlight = function ()
660
- {
661
- var highlight = RG.SVG.REG.get('highlight');
662
-
663
- if (highlight) {
664
- highlight.parentNode.removeChild(highlight);
665
- highlight = null;
666
- }
667
- };
668
-
669
-
670
-
671
-
672
-
673
-
674
-
675
-
676
- /**
677
- * This allows for easy specification of gradients
678
- */
679
- this.parseColors = function ()
680
- {
681
- // Save the original colors so that they can be restored when the canvas is reset
682
- if (!Object.keys(this.originalColors).length) {
683
- this.originalColors = {
684
- colors: RG.SVG.arrayClone(prop.colors),
685
- highlightFill: RG.SVG.arrayClone(prop.highlightFill),
686
- backgroundColor: RG.SVG.arrayClone(prop.backgroundColor)
687
- }
688
- }
689
-
690
-
691
- // colors
692
- var colors = prop.colors;
693
-
694
- if (colors) {
695
- for (var i=0; i<colors.length; ++i) {
696
- colors[i] = RG.SVG.parseColorLinear({
697
- object: this,
698
- color: colors[i],
699
- start: this.centerx - this.radius,
700
- end: this.centerx + this.radius,
701
- direction: 'horizontal'
702
- });
703
- }
704
- }
705
-
706
- // Highlight fill
707
- prop.highlightFill = RG.SVG.parseColorLinear({
708
- object: this,
709
- color: prop.highlightFill,
710
- start: prop.gutterLeft,
711
- end: this.width - prop.gutterRight,
712
- direction: 'horizontal'
713
- });
714
-
715
- // Background color
716
-
717
- // Background color
718
- prop.backgroundColor = RG.SVG.parseColorLinear({
719
- object: this,
720
- color: prop.backgroundColor,
721
- start: prop.gutterLeft,
722
- end: this.width - prop.gutterRight,
723
- direction: 'horizontal'
724
- });
725
- };
726
-
727
-
728
-
729
-
730
-
731
-
732
-
733
-
734
- //
735
- // The Bar chart grow effect
736
- //
737
- this.grow = function ()
738
- {
739
- var opt = arguments[0] || {},
740
- frames = opt.frames || 30,
741
- frame = 0,
742
- obj = this,
743
- value = opt.value;
744
-
745
- //
746
- // Copy the data
747
- //
748
- value = this.value;
749
-
750
- this.draw();
751
-
752
- var iterate = function ()
753
- {
754
- var multiplier = frame / frames
755
- * RG.SVG.FX.getEasingMultiplier(frames, frame)
756
- * RG.SVG.FX.getEasingMultiplier(frames, frame);
757
-
758
- obj.value = value * multiplier;
759
-
760
- RG.SVG.redraw();
761
-
762
- if (frame++ < frames) {
763
- RG.SVG.FX.update(iterate);
764
- } else if (opt.callback) {
765
- obj.value = value;
766
- RG.SVG.redraw();
767
- (opt.callback)(obj);
768
- }
769
- };
770
-
771
- iterate();
772
-
773
- return this;
774
- };
775
-
776
-
777
-
778
-
779
-
780
-
781
-
782
-
783
- /**
784
- * Using a function to add events makes it easier to facilitate method
785
- * chaining
786
- *
787
- * @param string type The type of even to add
788
- * @param function func
789
- */
790
- this.on = function (type, func)
791
- {
792
- if (type.substr(0,2) !== 'on') {
793
- type = 'on' + type;
794
- }
795
-
796
- RG.SVG.addCustomEventListener(this, type, func);
797
-
798
- return this;
799
- };
800
-
801
-
802
-
803
-
804
-
805
-
806
-
807
-
808
- //
809
- // Used in chaining. Runs a function there and then - not waiting for
810
- // the events to fire (eg the onbeforedraw event)
811
- //
812
- // @param function func The function to execute
813
- //
814
- this.exec = function (func)
815
- {
816
- func(this);
817
-
818
- return this;
819
- };
820
-
821
-
822
-
823
-
824
-
825
-
826
-
827
-
828
- //
829
- // Remove highlight from the chart (tooltips)
830
- //
831
- this.removeHighlight = function ()
832
- {
833
- var highlight = RG.SVG.REG.get('highlight');
834
- if (highlight && highlight.parentNode) {
835
- highlight.parentNode.removeChild(highlight);
836
- }
837
-
838
- RG.SVG.REG.set('highlight', null);
839
- };
840
-
841
-
842
-
843
-
844
-
845
-
846
-
847
-
848
- //
849
- // Set the options that the user has provided
850
- //
851
- for (i in conf.options) {
852
- if (typeof i === 'string') {
853
- this.set(i, conf.options[i]);
854
- }
855
- }
856
- };
857
-
858
-
859
-
860
- return this;
861
-
862
-
863
-
864
-
865
- // End module pattern
866
- })(window, document);
2
+ RGraph=window.RGraph||{isRGraph:true};RGraph.SVG=RGraph.SVG||{};(function(win,doc,undefined)
3
+ {var RG=RGraph,ua=navigator.userAgent,ma=Math,win=window,doc=document;RG.SVG.SemiCircularProgress=function(conf)
4
+ {this.set=function(name,value)
5
+ {if(arguments.length===1&&typeof name==='object'){for(i in arguments[0]){if(typeof i==='string'){var ret=RG.SVG.commonSetter({object:this,name:i,value:arguments[0][i]});name=ret.name;value=ret.value;this.set(name,value);}}}else{var ret=RG.SVG.commonSetter({object:this,name:name,value:value});name=ret.name;value=ret.value;this.properties[name]=value;if(name==='colors'){this.originalColors=RG.SVG.arrayClone(value);this.colorsParsed=false;}}
6
+ return this;};this.min=RG.SVG.stringsToNumbers(conf.min);this.max=RG.SVG.stringsToNumbers(conf.max);this.value=RG.SVG.stringsToNumbers(conf.value);this.id=conf.id;this.uid=RG.SVG.createUID();this.container=document.getElementById(this.id);this.layers={};this.svg=RG.SVG.createSVG({object:this,container:this.container});this.isRGraph=true;this.width=Number(this.svg.getAttribute('width'));this.height=Number(this.svg.getAttribute('height'));this.data=conf.data;this.type='semicircularprogress';this.angles=[];this.colorsParsed=false;this.originalColors={};this.gradientCounter=1;this.nodes=[];this.shadowNodes=[];RG.SVG.OR.add(this);this.container.style.display='inline-block';this.properties={centerx:null,centery:null,radius:null,width:60,gutterLeft:35,gutterRight:35,gutterTop:35,gutterBottom:35,backgroundStrokeLinewidth:0.25,backgroundStroke:'gray',backgroundFill:'Gradient(white:#aaa)',backgroundFillOpacity:0.25,colors:['#0c0'],strokestyle:'#666',textColor:'gray',textFont:'sans-serif',textSize:10,textBold:false,textItalic:false,unitsPre:'',unitsPost:'',scalePoint:'.',scaleThousand:',',scaleDecimals:0,scaleFormatter:null,labelsMin:true,labelsMinSpecific:null,labelsMinPoint:null,labelsMinThousand:null,labelsMinFormatter:null,labelsMinFont:null,labelsMinSize:null,labelsMinBold:null,labelsMinItalic:null,labelsMinColor:null,labelsMinDecimals:null,labelsMinUnitsPre:null,labelsMinUnitsPost:null,labelsMax:true,labelsMaxSpecific:null,labelsMaxPoint:null,labelsMaxThousand:null,labelsMaxFormatter:null,labelsMaxFont:null,labelsMaxSize:null,labelsMaxBold:null,labelsMaxItalic:null,labelsMaxColor:null,labelsMaxDecimals:null,labelsMaxUnitsPre:null,labelsMaxUnitsPost:null,labelsCenter:true,labelsCenterSpecific:null,labelsCenterPoint:null,labelsCenterThousand:null,labelsCenterFormatter:null,labelsCenterFont:null,labelsCenterSize:40,labelsCenterBold:true,labelsCenterItalic:null,labelsCenterColor:'#666',labelsCenterDecimals:null,labelsCenterUnitsPre:null,labelsCenterUnitsPost:null,linewidth:0,tooltips:null,tooltipsOverride:null,tooltipsEffect:'fade',tooltipsCssClass:'RGraph_tooltip',tooltipsEvent:'click',highlightStroke:'rgba(0,0,0,0)',highlightFill:'rgba(255,255,255,0.7)',highlightLinewidth:1,title:'',titleSize:16,titleX:null,titleY:null,titleHalign:'center',titleValign:null,titleColor:'black',titleFont:null,titleBold:false,titleItalic:false,titleSubtitle:'',titleSubtitleSize:10,titleSubtitleX:null,titleSubtitleY:null,titleSubtitleHalign:'center',titleSubtitleValign:null,titleSubtitleColor:'#aaa',titleSubtitleFont:null,titleSubtitleBold:false,titleSubtitleItalic:false};RG.SVG.getGlobals(this);if(RG.SVG.FX&&typeof RG.SVG.FX.decorate==='function'){RG.SVG.FX.decorate(this);}
7
+ var prop=this.properties;this.draw=function()
8
+ {RG.SVG.fireCustomEvent(this,'onbeforedraw');RG.SVG.createDefs(this);this.graphWidth=this.width-prop.gutterLeft-prop.gutterRight;this.graphHeight=this.height-prop.gutterTop-prop.gutterBottom;this.centerx=(this.graphWidth/2)+prop.gutterLeft;this.centery=this.height-prop.gutterBottom;this.radius=ma.min(this.graphWidth/2,this.graphHeight);this.centerx=typeof prop.centerx==='number'?prop.centerx:this.centerx;this.centery=typeof prop.centery==='number'?prop.centery:this.centery;this.radius=typeof prop.radius==='number'?prop.radius:this.radius;if(typeof prop.radius==='string'&&prop.radius.match(/^\+|-\d+$/))this.radius+=parseFloat(prop.radius);if(typeof prop.centerx==='string'&&prop.centerx.match(/^\+|-\d+$/))this.centery+=parseFloat(prop.centerx);if(typeof prop.centery==='string'&&prop.centery.match(/^\+|-\d+$/))this.centerx+=parseFloat(prop.centery);this.progressWidth=prop.width||(this.radius/3);RG.SVG.resetColorsToOriginalValues({object:this});this.parseColors();this.path=this.drawMeter();RG.SVG.drawTitle(this);this.drawLabels();RG.SVG.attribution(this);if(!RG.SVG.isNull(prop.tooltips)&&prop.tooltips[0]){var obj=this;this.path.addEventListener(prop.tooltipsEvent,function(e)
9
+ {obj.removeHighlight();RG.SVG.tooltip({object:obj,index:0,group:null,sequentialIndex:0,text:prop.tooltips[0],event:e});obj.highlight(e.target);},false);this.path.addEventListener('mousemove',function(e)
10
+ {e.target.style.cursor='pointer'},false);}
11
+ var obj=this;doc.body.addEventListener('mousedown',function(e)
12
+ {obj.removeHighlight();},false);RG.SVG.fireCustomEvent(this,'ondraw');return this;};this.drawMeter=function()
13
+ {var path=RG.SVG.TRIG.getArcPath({cx:this.centerx,cy:this.centery,r:this.radius,start:RG.SVG.TRIG.PI+RG.SVG.TRIG.HALFPI,end:RG.SVG.TRIG.HALFPI,anticlockwise:false});var path2=RG.SVG.TRIG.getArcPath({cx:this.centerx,cy:this.centery,r:this.radius-this.progressWidth,end:RG.SVG.TRIG.PI+RG.SVG.TRIG.HALFPI,start:RG.SVG.TRIG.HALFPI,anticlockwise:true,moveto:false});RG.SVG.create({svg:this.svg,type:'path',parent:this.svg.all,attr:{d:path+" L "+(this.centerx+this.radius-this.progressWidth)+" "+this.centery+path2+" L "+(this.centerx-this.radius)+" "+this.centery,fill:prop.backgroundFill||prop.colors[0],stroke:prop.backgroundStroke,'stroke-width':prop.backgroundStrokeLinewidth,'fill-opacity':prop.backgroundFillOpacity}});var angle=((this.value-this.min)/(this.max-this.min))*RG.SVG.TRIG.PI;angle-=RG.SVG.TRIG.HALFPI;var path=RG.SVG.TRIG.getArcPath({cx:this.centerx,cy:this.centery,r:this.radius,start:RG.SVG.TRIG.PI+RG.SVG.TRIG.HALFPI,end:angle,anticlockwise:false});var path2=RG.SVG.TRIG.getArcPath({cx:this.centerx,cy:this.centery,r:this.radius-this.progressWidth,start:angle,end:angle,anticlockwise:false,array:true});var path3=RG.SVG.TRIG.getArcPath({cx:this.centerx,cy:this.centery,r:this.radius-this.progressWidth,start:angle,end:RG.SVG.TRIG.PI+RG.SVG.TRIG.HALFPI,anticlockwise:true,moveto:false});var path=RG.SVG.create({svg:this.svg,type:'path',parent:this.svg.all,attr:{d:path+" L{1} {2} ".format(path2[1],path2[2])+path3+' z',fill:prop.colors[0],stroke:'black','stroke-width':prop.linewidth}});return path;};this.drawLabels=function()
14
+ {if(prop.labelsMin){var min=RG.SVG.numberFormat({object:this,num:this.min.toFixed(typeof prop.labelsMinDecimals==='number'?prop.labelsMinDecimals:prop.scaleDecimals),prepend:typeof prop.labelsMinUnitsPre==='string'?prop.labelsMinUnitsPre:prop.unitsPre,append:typeof prop.labelsMinUnitsPost==='string'?prop.labelsMinUnitsPost:prop.unitsPost,point:typeof prop.labelsMinPoint==='string'?prop.labelsMinPoint:prop.scalePoint,thousand:typeof prop.labelsMinThousand==='string'?prop.labelsMinThousand:prop.scaleThousand,formatter:typeof prop.labelsMinFormatter==='function'?prop.labelsMinFormatter:prop.scaleFormatter});RG.SVG.text({object:this,parent:this.svg.all,text:typeof prop.labelsMinSpecific==='string'?prop.labelsMinSpecific:min,x:this.centerx-this.radius+(this.progressWidth/2),y:this.height-prop.gutterBottom+5,valign:'top',halign:'center',font:prop.labelsMinFont||prop.textFont,size:prop.labelsMinSize||prop.textSize,bold:typeof prop.labelsMinBold==='boolean'?prop.labelsMinBold:prop.textBold,italic:typeof prop.labelsMinItalic==='boolean'?prop.labelsMinItalic:prop.textItalic,color:prop.labelsMinColor||prop.textColor});}
15
+ if(prop.labelsMax){var max=RG.SVG.numberFormat({object:this,num:this.max.toFixed(typeof prop.labelsMaxDecimals==='number'?prop.labelsMaxDecimals:prop.scaleDecimals),prepend:typeof prop.labelsMaxUnitsPre==='string'?prop.labelsMaxUnitsPre:prop.unitsPre,append:typeof prop.labelsMaxUnitsPost==='string'?prop.labelsMaxUnitsPost:prop.unitsPost,point:typeof prop.labelsMaxPoint==='string'?prop.labelsMaxPoint:prop.scalePoint,thousand:typeof prop.labelsMaxThousand==='string'?prop.labelsMaxThousand:prop.scaleThousand,formatter:typeof prop.labelsMaxFormatter==='function'?prop.labelsMaxFormatter:prop.scaleFormatter});RG.SVG.text({object:this,parent:this.svg.all,text:typeof prop.labelsMaxSpecific==='string'?prop.labelsMaxSpecific:max,x:this.centerx+this.radius-(this.progressWidth/2),y:this.height-prop.gutterBottom+5,valign:'top',halign:'center',font:prop.labelsMaxFont||prop.textFont,size:prop.labelsMaxSize||prop.textSize,bold:typeof prop.labelsMaxBold==='boolean'?prop.labelsMaxBold:prop.textBold,italic:typeof prop.labelsMaxItalic==='boolean'?prop.labelsMaxItalic:prop.textItalic,color:prop.labelsMaxColor||prop.textColor});}
16
+ if(prop.labelsCenter){var center=RG.SVG.numberFormat({object:this,num:this.value.toFixed(typeof prop.labelsCenterDecimals==='number'?prop.labelsCenterDecimals:prop.scaleDecimals),prepend:typeof prop.labelsCenterUnitsPre==='string'?prop.labelsCenterUnitsPre:prop.unitsPre,append:typeof prop.labelsCenterUnitsPost==='string'?prop.labelsCenterUnitsPost:prop.unitsPost,point:typeof prop.labelsCenterPoint==='string'?prop.labelsCenterPoint:prop.scalePoint,thousand:typeof prop.labelsCenterThousand==='string'?prop.labelsCenterThousand:prop.scaleThousand,formatter:typeof prop.labelsCenterFormatter==='function'?prop.labelsCenterFormatter:prop.scaleFormatter});RG.SVG.text({object:this,parent:this.svg.all,text:typeof prop.labelsCenterSpecific==='string'?prop.labelsCenterSpecific:center,x:this.centerx,y:this.centery,valign:'bottom',halign:'center',font:prop.labelsCenterFont||prop.textFont,size:prop.labelsCenterSize||prop.textSize,bold:typeof prop.labelsCenterBold==='boolean'?prop.labelsCenterBold:prop.textBold,italic:typeof prop.labelsCenterItalic==='boolean'?prop.labelsCenterItalic:prop.textItalic,color:prop.labelsCenterColor||prop.textColor});}};this.highlight=function(segment)
17
+ {this.removeHighlight();var highlight=RG.SVG.create({svg:this.svg,type:'path',parent:this.svg.all,attr:{d:this.path.getAttribute('d'),fill:prop.highlightFill,stroke:prop.highlightStroke,'stroke-width':prop.highlightLinewidth}});RG.SVG.REG.set('highlight',highlight);var obj=this;doc.body.addEventListener('mousedown',function(e)
18
+ {obj.removeHighlight();},false);};this.removeHighlight=function()
19
+ {var highlight=RG.SVG.REG.get('highlight');if(highlight){highlight.parentNode.removeChild(highlight);highlight=null;}};this.parseColors=function()
20
+ {if(!Object.keys(this.originalColors).length){this.originalColors={colors:RG.SVG.arrayClone(prop.colors),highlightFill:RG.SVG.arrayClone(prop.highlightFill),backgroundColor:RG.SVG.arrayClone(prop.backgroundColor)}}
21
+ var colors=prop.colors;if(colors){for(var i=0;i<colors.length;++i){colors[i]=RG.SVG.parseColorLinear({object:this,color:colors[i],start:this.centerx-this.radius,end:this.centerx+this.radius,direction:'horizontal'});}}
22
+ prop.highlightFill=RG.SVG.parseColorLinear({object:this,color:prop.highlightFill,start:prop.gutterLeft,end:this.width-prop.gutterRight,direction:'horizontal'});prop.backgroundColor=RG.SVG.parseColorLinear({object:this,color:prop.backgroundColor,start:prop.gutterLeft,end:this.width-prop.gutterRight,direction:'horizontal'});};this.grow=function()
23
+ {var opt=arguments[0]||{},frames=opt.frames||30,frame=0,obj=this,value=opt.value;value=this.value;this.draw();var iterate=function()
24
+ {var multiplier=frame/frames*RG.SVG.FX.getEasingMultiplier(frames,frame)*RG.SVG.FX.getEasingMultiplier(frames,frame);obj.value=value*multiplier;RG.SVG.redraw();if(frame++<frames){RG.SVG.FX.update(iterate);}else if(opt.callback){obj.value=value;RG.SVG.redraw();(opt.callback)(obj);}};iterate();return this;};this.on=function(type,func)
25
+ {if(type.substr(0,2)!=='on'){type='on'+type;}
26
+ RG.SVG.addCustomEventListener(this,type,func);return this;};this.exec=function(func)
27
+ {func(this);return this;};this.removeHighlight=function()
28
+ {var highlight=RG.SVG.REG.get('highlight');if(highlight&&highlight.parentNode){highlight.parentNode.removeChild(highlight);}
29
+ RG.SVG.REG.set('highlight',null);};for(i in conf.options){if(typeof i==='string'){this.set(i,conf.options[i]);}}};return this;})(window,document);