rgraph-rails 1.0.7 → 1.0.8

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