rgraph-rails 1.0.5 → 1.0.6

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 +8 -8
  2. data/.travis.yml +0 -1
  3. data/README.md +3 -3
  4. data/lib/rgraph-rails/version.rb +1 -1
  5. data/vendor/assets/javascripts/RGraph.bar.js +239 -3764
  6. data/vendor/assets/javascripts/RGraph.bipolar.js +115 -1986
  7. data/vendor/assets/javascripts/RGraph.common.annotate.js +35 -399
  8. data/vendor/assets/javascripts/RGraph.common.context.js +30 -600
  9. data/vendor/assets/javascripts/RGraph.common.core.js +403 -5187
  10. data/vendor/assets/javascripts/RGraph.common.csv.js +19 -275
  11. data/vendor/assets/javascripts/RGraph.common.deprecated.js +35 -454
  12. data/vendor/assets/javascripts/RGraph.common.dynamic.js +84 -1189
  13. data/vendor/assets/javascripts/RGraph.common.effects.js +90 -1548
  14. data/vendor/assets/javascripts/RGraph.common.key.js +54 -755
  15. data/vendor/assets/javascripts/RGraph.common.resizing.js +37 -567
  16. data/vendor/assets/javascripts/RGraph.common.sheets.js +29 -356
  17. data/vendor/assets/javascripts/RGraph.common.tooltips.js +32 -614
  18. data/vendor/assets/javascripts/RGraph.common.zoom.js +14 -223
  19. data/vendor/assets/javascripts/RGraph.cornergauge.js +71 -0
  20. data/vendor/assets/javascripts/RGraph.drawing.background.js +35 -620
  21. data/vendor/assets/javascripts/RGraph.drawing.circle.js +35 -576
  22. data/vendor/assets/javascripts/RGraph.drawing.image.js +52 -807
  23. data/vendor/assets/javascripts/RGraph.drawing.marker1.js +41 -717
  24. data/vendor/assets/javascripts/RGraph.drawing.marker2.js +37 -668
  25. data/vendor/assets/javascripts/RGraph.drawing.marker3.js +36 -563
  26. data/vendor/assets/javascripts/RGraph.drawing.poly.js +40 -608
  27. data/vendor/assets/javascripts/RGraph.drawing.rect.js +35 -597
  28. data/vendor/assets/javascripts/RGraph.drawing.text.js +34 -642
  29. data/vendor/assets/javascripts/RGraph.drawing.xaxis.js +50 -809
  30. data/vendor/assets/javascripts/RGraph.drawing.yaxis.js +51 -856
  31. data/vendor/assets/javascripts/RGraph.fuel.js +58 -964
  32. data/vendor/assets/javascripts/RGraph.funnel.js +55 -984
  33. data/vendor/assets/javascripts/RGraph.gantt.js +75 -1241
  34. data/vendor/assets/javascripts/RGraph.gauge.js +87 -1397
  35. data/vendor/assets/javascripts/RGraph.hbar.js +143 -2376
  36. data/vendor/assets/javascripts/RGraph.hprogress.js +80 -1397
  37. data/vendor/assets/javascripts/RGraph.line.js +241 -4162
  38. data/vendor/assets/javascripts/RGraph.meter.js +74 -1278
  39. metadata +3 -30
  40. data/vendor/assets/images/bg.png +0 -0
  41. data/vendor/assets/images/bullet.png +0 -0
  42. data/vendor/assets/images/facebook-large.png +0 -0
  43. data/vendor/assets/images/google-plus-large.png +0 -0
  44. data/vendor/assets/images/logo.png +0 -0
  45. data/vendor/assets/images/meter-image-sd-needle.png +0 -0
  46. data/vendor/assets/images/meter-image-sd.png +0 -0
  47. data/vendor/assets/images/meter-sketch-needle.png +0 -0
  48. data/vendor/assets/images/meter-sketch.png +0 -0
  49. data/vendor/assets/images/odometer-background.png +0 -0
  50. data/vendor/assets/images/rgraph.jpg +0 -0
  51. data/vendor/assets/images/title.png +0 -0
  52. data/vendor/assets/images/twitter-large.png +0 -0
  53. data/vendor/assets/javascripts/RGraph.modaldialog.js +0 -301
  54. data/vendor/assets/javascripts/RGraph.odo.js +0 -1265
  55. data/vendor/assets/javascripts/RGraph.pie.js +0 -2272
  56. data/vendor/assets/javascripts/RGraph.radar.js +0 -1847
  57. data/vendor/assets/javascripts/RGraph.rose.js +0 -1877
  58. data/vendor/assets/javascripts/RGraph.rscatter.js +0 -1425
  59. data/vendor/assets/javascripts/RGraph.scatter.js +0 -2970
  60. data/vendor/assets/javascripts/RGraph.semicircularprogress.js +0 -1015
  61. data/vendor/assets/javascripts/RGraph.thermometer.js +0 -1129
  62. data/vendor/assets/javascripts/RGraph.vprogress.js +0 -1452
  63. data/vendor/assets/javascripts/RGraph.waterfall.js +0 -1252
  64. data/vendor/assets/javascripts/financial-data.js +0 -1067
  65. data/vendor/assets/stylesheets/ModalDialog.css +0 -90
  66. data/vendor/assets/stylesheets/animations.css +0 -3347
  67. data/vendor/assets/stylesheets/website.css +0 -446
@@ -1,1279 +1,75 @@
1
- // version: 2016-06-04
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
1
 
16
- RGraph = window.RGraph || {isRGraph: true};
17
-
18
- /**
19
- * The bar chart constructor
20
- *
21
- * @param string canvas The canvas ID
22
- * @param min integer The minimum value
23
- * @param max integer The maximum value
24
- * @param value integer The indicated value
25
- */
26
- RGraph.Meter = function (conf)
27
- {
28
- /**
29
- * Allow for object config style
30
- */
31
- if ( typeof conf === 'object'
32
- && typeof conf.value !== 'undefined'
33
- && typeof conf.id === 'string') {
34
-
35
- var id = conf.id
36
- var canvas = document.getElementById(id);
37
- var min = conf.min;
38
- var max = conf.max;
39
- var value = conf.value;
40
- var parseConfObjectForOptions = true; // Set this so the config is parsed (at the end of the constructor)
41
-
42
- } else {
43
-
44
- var id = conf;
45
- var canvas = document.getElementById(id);
46
- var min = arguments[1];
47
- var max = arguments[2];
48
- var value = arguments[3];
49
- }
50
-
51
-
52
-
53
-
54
- // id, min, max, value
55
- // Get the canvas and context objects
56
- this.id = id;
57
- this.canvas = canvas;
58
- this.context = this.canvas.getContext ? this.canvas.getContext("2d", {alpha: (typeof id === 'object' && id.alpha === false) ? false : true}) : null;
59
- this.canvas.__object__ = this;
60
- this.type = 'meter';
61
- this.min = RGraph.stringsToNumbers(min);
62
- this.max = RGraph.stringsToNumbers(max);
63
- this.value = RGraph.stringsToNumbers(value);
64
- this.centerx = null;
65
- this.centery = null;
66
- this.radius = null;
67
- this.isRGraph = true;
68
- this.currentValue = null;
69
- this.uid = RGraph.CreateUID();
70
- this.canvas.uid = this.canvas.uid ? this.canvas.uid : RGraph.CreateUID();
71
- this.colorsParsed = false;
72
- this.coordsText = [];
73
- this.original_colors = [];
74
- this.firstDraw = true; // After the first draw this will be false
75
-
76
-
77
- /**
78
- * Compatibility with older browsers
79
- */
80
- //RGraph.OldBrowserCompat(this.context);
81
-
82
-
83
- // Various config type stuff
84
- this.properties =
85
- {
86
- 'chart.background.image.url': null,
87
- 'chart.background.image.offsetx': 0,
88
- 'chart.background.image.offsety': 0,
89
- 'chart.background.image.stretch': true,
90
- 'chart.background.color': 'white',
91
- 'chart.gutter.left': 15,
92
- 'chart.gutter.right': 15,
93
- 'chart.gutter.top': 15,
94
- 'chart.gutter.bottom': 20,
95
- 'chart.linewidth': 1,
96
- 'chart.linewidth.segments': 0,
97
- 'chart.strokestyle': null,
98
- 'chart.border': true,
99
- 'chart.border.color': 'black',
100
- 'chart.text.font': 'Segoe UI, Arial, Verdana, sans-serif',
101
- 'chart.text.size': 12,
102
- 'chart.text.color': 'black',
103
- 'chart.text.valign': 'center',
104
- 'chart.text.accessible': true,
105
- 'chart.text.accessible.overflow': 'visible',
106
- 'chart.text.accessible.pointerevents': false,
107
- 'chart.value.text.decimals': 0,
108
- 'chart.value.text.units.pre': '',
109
- 'chart.value.text.units.post': '',
110
- 'chart.title': '',
111
- 'chart.title.background': null,
112
- 'chart.title.hpos': null,
113
- 'chart.title.vpos': null,
114
- 'chart.title.color': 'black',
115
- 'chart.title.bold': true,
116
- 'chart.title.font': null,
117
- 'chart.title.x': null,
118
- 'chart.title.y': null,
119
- 'chart.title.halign': null,
120
- 'chart.title.valign': null,
121
- 'chart.green.start': ((this.max - this.min) * 0.35) + this.min,
122
- 'chart.green.end': this.max,
123
- 'chart.green.color': '#207A20',
124
- 'chart.yellow.start': ((this.max - this.min) * 0.1) + this.min,
125
- 'chart.yellow.end': ((this.max - this.min) * 0.35) + this.min,
126
- 'chart.yellow.color': '#D0AC41',
127
- 'chart.red.start': this.min,
128
- 'chart.red.end': ((this.max - this.min) * 0.1) + this.min,
129
- 'chart.red.color': '#9E1E1E',
130
- 'chart.colors.ranges': null,
131
- 'chart.units.pre': '',
132
- 'chart.units.post': '',
133
- 'chart.contextmenu': null,
134
- 'chart.zoom.factor': 1.5,
135
- 'chart.zoom.fade.in': true,
136
- 'chart.zoom.fade.out': true,
137
- 'chart.zoom.hdir': 'right',
138
- 'chart.zoom.vdir': 'down',
139
- 'chart.zoom.frames': 25,
140
- 'chart.zoom.delay': 16.666,
141
- 'chart.zoom.shadow': true,
142
- 'chart.zoom.background': true,
143
- 'chart.zoom.action': 'zoom',
144
- 'chart.annotatable': false,
145
- 'chart.annotate.color': 'black',
146
- 'chart.shadow': false,
147
- 'chart.shadow.color': 'rgba(0,0,0,0.5)',
148
- 'chart.shadow.blur': 3,
149
- 'chart.shadow.offsetx': 3,
150
- 'chart.shadow.offsety': 3,
151
- 'chart.resizable': false,
152
- 'chart.resize.handle.adjust': [0,0],
153
- 'chart.resize.handle.background': null,
154
- 'chart.tickmarks.small.num': 100,
155
- 'chart.tickmarks.big.num': 10,
156
- 'chart.tickmarks.small.color': '#bbb',
157
- 'chart.tickmarks.big.color': 'black',
158
- 'chart.scale.decimals': 0,
159
- 'chart.scale.point': '.',
160
- 'chart.scale.thousand': ',',
161
- 'chart.radius': null,
162
- 'chart.centerx': null,
163
- 'chart.centery': null,
164
- 'chart.labels': true,
165
- 'chart.labels.count': 10,
166
- 'chart.labels.specific': null,
167
- 'chart.segment.radius.start': 0,
168
- 'chart.needle.radius': null,
169
- 'chart.needle.tail': false,
170
- 'chart.needle.head': true,
171
- 'chart.needle.color': 'black',
172
- 'chart.needle.image.url': null,
173
- 'chart.needle.image.offsetx': 0,
174
- 'chart.needle.image.offsety': 0,
175
- 'chart.adjustable': false,
176
- 'chart.angles.start': RGraph.PI,
177
- 'chart.angles.end': RGraph.TWOPI,
178
- 'chart.centerpin.stroke': 'black',
179
- 'chart.centerpin.fill': 'white',
180
- 'chart.clearto': 'rgba(0,0,0,0)'
181
- }
182
-
183
-
184
- // Check for support
185
- if (!this.canvas) {
186
- alert('[METER] No canvas support');
187
- return;
188
- }
189
-
190
-
191
-
192
- /*
193
- * Translate half a pixel for antialiasing purposes - but only if it hasn't beeen
194
- * done already
195
- */
196
- if (!this.canvas.__rgraph_aa_translated__) {
197
- this.context.translate(0.5,0.5);
198
-
199
- this.canvas.__rgraph_aa_translated__ = true;
200
- }
201
-
202
-
203
-
204
-
205
- // Short variable names
206
- var RG = RGraph,
207
- ca = this.canvas,
208
- co = ca.getContext('2d'),
209
- prop = this.properties,
210
- pa2 = RG.path2,
211
- win = window,
212
- doc = document,
213
- ma = Math
214
-
215
-
216
-
217
- /**
218
- * "Decorate" the object with the generic effects if the effects library has been included
219
- */
220
- if (RG.Effects && typeof RG.Effects.decorate === 'function') {
221
- RG.Effects.decorate(this);
222
- }
223
-
224
-
225
-
226
- /**
227
- * A setter
228
- *
229
- * @param name string The name of the property to set
230
- * @param value mixed The value of the property
231
- */
232
- this.set =
233
- this.Set = function (name)
234
- {
235
- var value = arguments[1] || null;
236
-
237
- /**
238
- * the number of arguments is only one and it's an
239
- * object - parse it for configuration data and return.
240
- */
241
- if (arguments.length === 1 && typeof name === 'object') {
242
- RG.parseObjectStyleConfig(this, name);
243
- return this;
244
- }
245
-
246
-
247
-
248
-
249
-
250
- /**
251
- * This should be done first - prepend the propertyy name with "chart." if necessary
252
- */
253
- if (name.substr(0,6) != 'chart.') {
254
- name = 'chart.' + name;
255
- }
256
-
257
-
258
-
259
-
260
- // Convert uppercase letters to dot+lower case letter
261
- while(name.match(/([A-Z])/)) {
262
- name = name.replace(/([A-Z])/, '.' + RegExp.$1.toLowerCase());
263
- }
264
-
265
-
266
-
267
-
268
- if (name == 'chart.value') {
269
- this.value = value;
270
- return;
271
- }
272
-
273
-
274
-
275
-
276
-
277
-
278
- prop[name] = value;
279
-
280
- return this;
281
- };
282
-
283
-
284
-
285
-
286
- /**
287
- * A getter
288
- *
289
- * @param name string The name of the property to get
290
- */
291
- this.get =
292
- this.Get = function (name)
293
- {
294
- /**
295
- * This should be done first - prepend the property name with "chart." if necessary
296
- */
297
- if (name.substr(0,6) != 'chart.') {
298
- name = 'chart.' + name;
299
- }
300
-
301
- // Convert uppercase letters to dot+lower case letter
302
- name = name.replace(/([A-Z])/g, function (str)
303
- {
304
- return '.' + String(RegExp.$1).toLowerCase()
305
- });
306
-
307
- if (name == 'chart.value') {
308
- return this.value;
309
- }
310
-
311
- return prop[name];
312
- };
313
-
314
-
315
-
316
-
317
- /**
318
- * The function you call to draw the bar chart
319
- */
320
- this.draw =
321
- this.Draw = function ()
322
- {
323
- /**
324
- * Fire the onbeforedraw event
325
- */
326
- RG.FireCustomEvent(this, 'onbeforedraw');
327
-
328
- /**
329
- * Constrain the value to be within the min and max
330
- */
331
- if (this.value > this.max) this.value = this.max;
332
- if (this.value < this.min) this.value = this.min;
333
-
334
- /**
335
- * Set the current value
336
- */
337
- this.currentValue = this.value;
338
-
339
- /**
340
- * This is new in May 2011 and facilitates indiviual gutter settings,
341
- * eg chart.gutter.left
342
- */
343
- this.gutterLeft = prop['chart.gutter.left'];
344
- this.gutterRight = prop['chart.gutter.right'];
345
- this.gutterTop = prop['chart.gutter.top'];
346
- this.gutterBottom = prop['chart.gutter.bottom'];
347
-
348
- this.centerx = ((ca.width - this.gutterLeft - this.gutterRight) / 2) + this.gutterLeft;
349
- this.centery = ca.height - this.gutterBottom;
350
- this.radius = Math.min(
351
- (ca.width - this.gutterLeft - this.gutterRight) / 2,
352
- (ca.height - this.gutterTop - this.gutterBottom)
353
- );
354
-
355
- /**
356
- * Stop this growing uncontrollably
357
- */
358
- this.coordsText = [];
359
-
360
-
361
-
362
- /**
363
- * Custom centerx, centery and radius
364
- */
365
- if (typeof(prop['chart.centerx']) == 'number') this.centerx = prop['chart.centerx'];
366
- if (typeof(prop['chart.centery']) == 'number') this.centery = prop['chart.centery'];
367
- if (typeof(prop['chart.radius']) == 'number') this.radius = prop['chart.radius'];
368
-
369
-
370
- /**
371
- * Parse the colors for gradients. Its down here so that the center X/Y can be used
372
- */
373
- if (!this.colorsParsed) {
374
-
375
- this.parseColors();
376
-
377
- // Don't want to do this again
378
- this.colorsParsed = true;
379
- }
380
-
381
-
382
- this.drawBackground();
383
- this.drawLabels();
384
- this.drawNeedle();
385
- this.drawReadout();
386
-
387
- /**
388
- * Draw the title
389
- */
390
- RG.DrawTitle(this, prop['chart.title'], this.gutterTop, null, prop['chart.title.size'] ? prop['chart.title.size'] : prop['chart.text.size'] + 2);
391
-
392
- /**
393
- * Setup the context menu if required
394
- */
395
- if (prop['chart.contextmenu']) {
396
- RG.ShowContext(this);
397
- }
398
-
399
-
400
- /**
401
- * This function enables resizing
402
- */
403
- if (prop['chart.resizable']) {
404
- RG.AllowResizing(this);
405
- }
406
-
407
-
408
- /**
409
- * This installs the event listeners
410
- */
411
- RG.InstallEventListeners(this);
412
-
413
-
414
-
415
- /**
416
- * Fire the onfirstdraw event
417
- */
418
- if (this.firstDraw) {
419
- RG.fireCustomEvent(this, 'onfirstdraw');
420
- this.firstDraw = false;
421
- this.firstDrawFunc();
422
- }
423
-
424
-
425
-
426
-
427
- /**
428
- * Fire the RGraph ondraw event
429
- */
430
- RG.FireCustomEvent(this, 'ondraw');
431
-
432
-
433
-
434
- return this;
435
- };
436
-
437
-
438
-
439
- /**
440
- * Used in chaining. Runs a function there and then - not waiting for
441
- * the events to fire (eg the onbeforedraw event)
442
- *
443
- * @param function func The function to execute
444
- */
445
- this.exec = function (func)
446
- {
447
- func(this);
448
-
449
- return this;
450
- };
451
-
452
-
453
-
454
-
455
- /**
456
- * Draws the background of the chart
457
- */
458
- this.drawBackground =
459
- this.DrawBackground = function ()
460
- {
461
- /**
462
- * First draw the background image if it's defined
463
- */
464
- if (typeof prop['chart.background.image.url'] === 'string' && !this.__background_image__) {
465
-
466
- var x = 0 + prop['chart.background.image.offsetx'];
467
- var y = 0 + prop['chart.background.image.offsety'];
468
- var img = new Image();
469
-
470
- this.__background_image__ = img;
471
- img.src = prop['chart.background.image.url'];
472
-
473
- img.onload = function ()
474
- {
475
- if (prop['chart.background.image.stretch']) {
476
- co.drawImage(this, x,y,ca.width, ca.height);
477
- } else {
478
- co.drawImage(this, x,y);
479
- }
480
- RG.redraw();
481
- }
482
-
483
- } else if (this.__background_image__) {
484
-
485
- var x = 0 + prop['chart.background.image.offsetx'];
486
- var y = 0 + prop['chart.background.image.offsety'];
487
-
488
- if (prop['chart.background.image.stretch']) {
489
- co.drawImage(this.__background_image__, x,y,ca.width, ca.height);
490
- } else {
491
- co.drawImage(this.__background_image__, x,y);
492
- }
493
- }
494
-
495
-
496
-
497
- /**
498
- * Draw the white background
499
- */
500
- co.beginPath();
501
-
502
- co.fillStyle = prop['chart.background.color'];
503
-
504
- if (prop['chart.shadow']) {
505
- RG.SetShadow(this, prop['chart.shadow.color'],prop['chart.shadow.offsetx'],prop['chart.shadow.offsety'], prop['chart.shadow.blur']);
506
- }
507
- co.moveTo(this.centerx,this.centery);
508
- co.arc(this.centerx,
509
- this.centery,
510
- this.radius,
511
- prop['chart.angles.start'],
512
- prop['chart.angles.end'],
513
- false);
514
-
515
- co.fill();
516
-
517
- RG.NoShadow(this);
518
-
519
-
520
- // Draw the shadow
521
- if (prop['chart.shadow']) {
522
-
523
- co.beginPath();
524
- var r = (this.radius * 0.06) > 40 ? 40 : (this.radius * 0.06);
525
- co.arc(this.centerx, this.centery, r, 0, RG.TWOPI, 0);
526
- co.fill();
527
-
528
- RG.NoShadow(this);
529
- }
530
-
531
-
532
-
533
- // First, draw the grey tickmarks
534
- if (prop['chart.tickmarks.small.num']) {
535
- for (var i=0; i<(prop['chart.angles.end'] - prop['chart.angles.start']); i+=(RG.PI / prop['chart.tickmarks.small.num'])) {
536
- co.beginPath();
537
- co.strokeStyle = prop['chart.tickmarks.small.color'];
538
- co.arc(this.centerx, this.centery, this.radius, prop['chart.angles.start'] + i, prop['chart.angles.start'] + i + 0.00001, 0);
539
- co.arc(this.centerx, this.centery, this.radius - 5, prop['chart.angles.start'] + i, prop['chart.angles.start'] + i + 0.00001, 0);
540
- co.stroke();
541
- }
542
-
543
- // Draw the semi-circle that makes the tickmarks
544
- co.beginPath();
545
- co.fillStyle = prop['chart.background.color'];
546
- co.arc(this.centerx, this.centery, this.radius - 4, prop['chart.angles.start'], prop['chart.angles.end'], false);
547
- co.closePath();
548
- co.fill();
549
- }
550
-
551
-
552
- // Second, draw the darker tickmarks. First run draws them in white to get rid of the existing tickmark,
553
- // then the second run draws them in the requested color
554
-
555
-
556
- if (prop['chart.tickmarks.big.num']) {
557
- var colors = ['white','white',prop['chart.tickmarks.big.color']];
558
- for (var j=0; j<colors.length; ++j) {
559
- for (var i=0; i<(prop['chart.angles.end'] - prop['chart.angles.start']); i+=((prop['chart.angles.end'] - prop['chart.angles.start']) / prop['chart.tickmarks.big.num'])) {
560
- co.beginPath();
561
- co.strokeStyle = colors[j];
562
- co.arc(this.centerx, this.centery, this.radius, prop['chart.angles.start'] + i, prop['chart.angles.start'] + i + 0.001, 0);
563
- co.arc(this.centerx, this.centery, this.radius - 5, prop['chart.angles.start'] + i, prop['chart.angles.start'] + i + 0.0001, 0);
564
- co.stroke();
565
- }
566
- }
567
- }
568
-
569
- // Draw the white circle that makes the tickmarks
570
- co.beginPath();
571
- co.fillStyle = prop['chart.background.color'];
572
- co.moveTo(this.centerx, this.centery);
573
- co.arc(this.centerx, this.centery, this.radius - 7, prop['chart.angles.start'], prop['chart.angles.end'], false);
574
- co.closePath();
575
- co.fill();
576
-
577
- /**
578
- * Color ranges - either green/yellow/red or an arbitrary number of ranges
579
- */
580
- var ranges = prop['chart.colors.ranges'];
581
-
582
- if (RG.is_array(prop['chart.colors.ranges'])) {
583
-
584
- var ranges = prop['chart.colors.ranges'];
585
-
586
- for (var i=0; i<ranges.length; ++i) {
587
-
588
- co.strokeStyle = prop['chart.strokestyle'] ? prop['chart.strokestyle'] : ranges[i][2];
589
- co.fillStyle = ranges[i][2];
590
- co.lineWidth = prop['chart.linewidth.segments'];
591
-
592
- co.beginPath();
593
- co.arc(this.centerx,
594
- this.centery,
595
- this.radius * 0.85,
596
- (((ranges[i][0] - this.min) / (this.max - this.min)) * (prop['chart.angles.end'] - prop['chart.angles.start'])) + prop['chart.angles.start'],
597
- (((ranges[i][1] - this.min) / (this.max - this.min)) * (prop['chart.angles.end'] - prop['chart.angles.start'])) + prop['chart.angles.start'],
598
- false);
599
-
600
- if (prop['chart.segment.radius.start'] > 0) {
601
- co.arc(this.centerx,
602
- this.centery,
603
- prop['chart.segment.radius.start'],
604
- (((ranges[i][1] - this.min) / (this.max - this.min)) * (prop['chart.angles.end'] - prop['chart.angles.start'])) + prop['chart.angles.start'],
605
- (((ranges[i][0] - this.min) / (this.max - this.min)) * (prop['chart.angles.end'] - prop['chart.angles.start'])) + prop['chart.angles.start'],
606
- true);
607
- } else {
608
- co.lineTo(this.centerx, this.centery);
609
- }
610
-
611
- co.closePath();
612
- co.stroke();
613
- co.fill();
614
- }
615
-
616
- // Stops the last line from being changed to a big linewidth.
617
- co.beginPath();
618
-
619
- } else {
620
- co.lineWidth = prop['chart.linewidth'];
621
-
622
- // Draw the green area
623
- co.strokeStyle = prop['chart.strokestyle'] ? prop['chart.strokestyle'] : prop['chart.green.color'];
624
- co.fillStyle = prop['chart.green.color'];
625
- co.lineWidth = prop['chart.linewidth.segments'];
626
-
627
- co.beginPath();
628
- co.arc(this.centerx,
629
- this.centery,
630
- this.radius * 0.85,
631
- (((prop['chart.green.start'] - this.min) / (this.max - this.min)) * (prop['chart.angles.end'] - this.properties['chart.angles.start'])) + prop['chart.angles.start'],
632
- (((prop['chart.green.end'] - this.min) / (this.max - this.min)) * (prop['chart.angles.end'] - prop['chart.angles.start'])) + prop['chart.angles.start'],
633
- false);
634
-
635
- if (prop['chart.segment.radius.start'] > 0) {
636
-
637
- co.arc(this.centerx,
638
- this.centery,
639
- prop['chart.segment.radius.start'],
640
- (((prop['chart.green.end'] - this.min) / (this.max - this.min)) * (prop['chart.angles.end'] - prop['chart.angles.start'])) + prop['chart.angles.start'],
641
- (((prop['chart.green.start'] - this.min) / (this.max - this.min)) * (prop['chart.angles.end'] - prop['chart.angles.start'])) + prop['chart.angles.start'],
642
- true);
643
- } else {
644
- co.lineTo(this.centerx, this.centery);
645
- }
646
-
647
- co.closePath();
648
- co.stroke();
649
- co.fill();
650
-
651
- // Draw the yellow area
652
- co.strokeStyle = prop['chart.strokestyle'] ? prop['chart.strokestyle'] : prop['chart.yellow.color'];
653
- co.fillStyle = prop['chart.yellow.color'];
654
- co.lineWidth = prop['chart.linewidth.segments'];
655
- co.beginPath();
656
- co.arc(this.centerx,
657
- this.centery,
658
- this.radius * 0.85,
659
- (((prop['chart.yellow.start'] - this.min) / (this.max - this.min)) * (prop['chart.angles.end'] - prop['chart.angles.start'])) + prop['chart.angles.start'],
660
- (((prop['chart.yellow.end'] - this.min) / (this.max - this.min)) * (prop['chart.angles.end'] - prop['chart.angles.start'])) + prop['chart.angles.start'],
661
- false);
662
-
663
- if (prop['chart.segment.radius.start'] > 0) {
664
- co.arc(this.centerx,
665
- this.centery,
666
- prop['chart.segment.radius.start'],
667
- (((prop['chart.yellow.end'] - this.min) / (this.max - this.min)) * (prop['chart.angles.end'] - prop['chart.angles.start'])) + prop['chart.angles.start'],
668
- (((prop['chart.yellow.start'] - this.min) / (this.max - this.min)) * (prop['chart.angles.end'] - prop['chart.angles.start'])) + prop['chart.angles.start'],
669
- true);
670
- } else {
671
- co.lineTo(this.centerx, this.centery);
672
- }
673
-
674
- co.closePath();
675
- co.stroke();
676
- co.fill();
677
-
678
- // Draw the red area
679
- co.strokeStyle = prop['chart.strokestyle'] ? prop['chart.strokestyle'] : prop['chart.red.color'];
680
- co.fillStyle = prop['chart.red.color'];
681
- co.lineWidth = prop['chart.linewidth.segments'];
682
-
683
- co.beginPath();
684
- co.arc(this.centerx,
685
- this.centery,this.radius * 0.85,
686
- (((prop['chart.red.start'] - this.min) / (this.max - this.min)) * (prop['chart.angles.end'] - prop['chart.angles.start'])) + prop['chart.angles.start'],
687
- (((prop['chart.red.end'] - this.min) / (this.max - this.min)) * (prop['chart.angles.end'] - prop['chart.angles.start'])) + prop['chart.angles.start'],
688
- false);
689
-
690
- if (prop['chart.segment.radius.start'] > 0) {
691
- co.arc(this.centerx,
692
- this.centery,
693
- prop['chart.segment.radius.start'],
694
- (((prop['chart.red.end'] - this.min) / (this.max - this.min)) * (prop['chart.angles.end'] - prop['chart.angles.start'])) + prop['chart.angles.start'],
695
- (((prop['chart.red.start'] - this.min) / (this.max - this.min)) * (prop['chart.angles.end'] - prop['chart.angles.start'])) + prop['chart.angles.start'],
696
- true);
697
- } else {
698
- co.lineTo(this.centerx, this.centery);
699
- }
700
-
701
- co.closePath();
702
- co.stroke();
703
- co.fill();
704
-
705
- // Revert the linewidth
706
- co.lineWidth = 1;
707
- }
708
-
709
- // Draw the outline
710
- if (prop['chart.border']) {
711
- co.strokeStyle = prop['chart.border.color'];
712
- co.lineWidth = prop['chart.linewidth'];
713
-
714
- co.beginPath();
715
- co.moveTo(this.centerx, this.centery);
716
- co.arc(this.centerx,
717
- this.centery,
718
- this.radius,
719
- prop['chart.angles.start'],
720
- prop['chart.angles.end'],
721
- false);
722
- co.closePath();
723
- }
724
-
725
- co.stroke();
726
-
727
- // Reset the linewidth back to 1
728
- co.lineWidth = 1;
729
- };
730
-
731
-
732
-
733
-
734
- /**
735
- * Draws the pointer
736
- */
737
- this.drawNeedle =
738
- this.DrawNeedle = function ()
739
- {
740
- /**
741
- * The angle that the needle is at
742
- */
743
- var a = (((this.value - this.min) / (this.max - this.min)) * (prop['chart.angles.end'] - prop['chart.angles.start'])) + prop['chart.angles.start'];
744
-
745
- /**
746
- * First draw the background image if it's defined
747
- */
748
- if (typeof prop['chart.needle.image.url'] === 'string' && !this.__needle_image__) {
749
-
750
- var img = new Image();
751
-
752
- this.__needle_image__ = img;
753
- img.src = prop['chart.needle.image.url'];
754
-
755
- img.onload = function ()
756
- {
757
- co.save();
758
- RG.rotateCanvas(ca, this.centerx, this.centery, a);
759
- co.drawImage(this,
760
- this.centerx + prop['chart.needle.image.offsetx'],
761
- this.centery + prop['chart.needle.image.offsety']);
762
- co.restore();
763
-
764
- RG.redraw();
765
- }
766
-
767
- } else if (this.__needle_image__) {
768
-
769
- co.save();
770
- RG.rotateCanvas(ca, this.centerx, this.centery, a);
771
- co.drawImage(this.__needle_image__,
772
- this.centerx + prop['chart.needle.image.offsetx'],
773
- this.centery + prop['chart.needle.image.offsety']);
774
- co.restore();
775
- }
776
-
777
-
778
-
779
-
780
-
781
-
782
-
783
-
784
- // Allow customising the needle radius
785
- var needleRadius = typeof(prop['chart.needle.radius']) == 'number' ? prop['chart.needle.radius'] : this.radius * 0.7;
786
-
787
- // First draw the circle at the bottom
788
- co.fillStyle = 'black';
789
- co.lineWidth = this.radius >= 200 ? 7 : 3;
790
- co.lineCap = 'round';
791
-
792
- // Now, draw the arm of the needle
793
- co.beginPath();
794
- co.strokeStyle = prop['chart.needle.color'];
795
- if (typeof(prop['chart.needle.linewidth']) == 'number') co.lineWidth = prop['chart.needle.linewidth'];
796
-
797
-
798
- co.arc(this.centerx, this.centery, needleRadius, a, a + 0.001, false);
799
- co.lineTo(this.centerx, this.centery);
800
- co.stroke();
801
-
802
- // Draw the triangular needle head
803
- if (prop['chart.needle.head']) {
804
-
805
- co.fillStyle = prop['chart.needle.color'];
806
- co.beginPath();
807
- co.lineWidth = 1;
808
- //co.moveTo(this.centerx, this.centery);
809
- co.arc(this.centerx, this.centery, needleRadius + 15, a, a + 0.001, 0);
810
- co.arc(this.centerx, this.centery, needleRadius - 15, a + 0.087, a + 0.087999, 0);
811
- co.arc(this.centerx, this.centery, needleRadius - 15, a - 0.087, a - 0.087999, 1);
812
- co.fill();
813
- }
814
-
815
- // Draw the tail if requested
816
- if (prop['chart.needle.tail']) {
817
- co.beginPath();
818
- co.strokeStyle = prop['chart.needle.color'];
819
- if (typeof(prop['chart.needle.linewidth']) == 'number') co.lineWidth = prop['chart.needle.linewidth'];
820
-
821
- var a = ((this.value - this.min) / (this.max - this.min) * (this.properties['chart.angles.end'] - this.properties['chart.angles.start'])) + this.properties['chart.angles.start'] + RG.PI;
822
- co.arc(this.centerx, this.centery, 25, a, a + 0.001, false);
823
- co.lineTo(this.centerx, this.centery);
824
- co.stroke();
825
- }
826
-
827
- // Draw the center circle (the stroke)
828
- var r = (this.radius * 0.06) > 40 ? 40 : (this.radius * 0.06);
829
-
830
- co.beginPath();
831
- co.fillStyle = prop['chart.centerpin.stroke'];
832
- co.arc(this.centerx, this.centery, r, 0 + 0.001, RG.TWOPI, 0);
833
- co.fill();
834
-
835
-
836
-
837
-
838
-
839
-
840
-
841
-
842
-
843
-
844
-
845
-
846
-
847
-
848
- // Draw the centre bit of the circle (the fill)
849
- co.fillStyle = prop['chart.centerpin.fill'];
850
- co.beginPath();
851
- co.arc(this.centerx, this.centery, r - 2, 0 + 0.001, RG.TWOPI, 0);
852
- co.fill();
853
- };
854
-
855
-
856
-
857
-
858
- /**
859
- * Draws the labels
860
- */
861
- this.drawLabels =
862
- this.DrawLabels = function ()
863
- {
864
- if (!prop['chart.labels']) {
865
- return;
866
- }
867
-
868
- var radius = this.radius,
869
- text_size = prop['chart.text.size'],
870
- text_font = prop['chart.text.font'],
871
- units_post = prop['chart.units.post'],
872
- units_pre = prop['chart.units.pre'],
873
- centerx = this.centerx,
874
- centery = this.centery,
875
- min = this.min,
876
- max = this.max,
877
- decimals = prop['chart.scale.decimals'],
878
- numLabels = prop['chart.labels.count'],
879
- specific = prop['chart.labels.specific']
880
-
881
-
882
-
883
-
884
- //
885
- // Draw the specific labels if they're specifid
886
- //
887
- if (specific) {
888
- for (var i=0; i<specific.length; ++i) {
889
-
890
- var angle = this.getAngle(specific[i][1]),
891
- angle_degrees = angle * (180 / RG.PI),
892
- text = specific[i][0].toString(),
893
- coords = RG.getRadiusEndPoint(this.centerx, this.centery, angle, this.radius * 0.925)
894
-
895
-
896
- RG.text2(this, {
897
- 'font':text_font,
898
- 'size':text_size,
899
- 'x': coords[0],
900
- 'y': coords[1],
901
- 'text':text,
902
- 'halign':'center',
903
- 'valign':'center',
904
- 'angle':angle_degrees + 90,
905
- 'bounding': false,
906
- 'tag': 'labels-specific',
907
- color: 'black'
908
- });
909
- }
910
-
911
- return;
912
- }
913
-
914
-
915
-
916
-
917
- co.fillStyle = prop['chart.text.color'];
918
- co.lineWidth = 1;
919
-
920
- co.beginPath();
921
-
922
- for (var i=0; i<=numLabels; ++i) {
923
-
924
- var angle = ((prop['chart.angles.end'] - prop['chart.angles.start']) * (i / numLabels)) + prop['chart.angles.start'];
925
- var coords = RG.getRadiusEndPoint(centerx, centery, angle + (((i == 0 || i == numLabels) && prop['chart.border']) ? (i == 0 ? 0.05 : -0.05) : 0), (this.radius * 0.925) - (prop['chart.text.valign'] === 'bottom' ? 15 : 0));
926
-
927
- var angleStart = prop['chart.angles.start'],
928
- angleEnd = prop['chart.angles.end'],
929
- angleRange = angleEnd - angleStart,
930
- angleStart_degrees = angleStart * (180 / RG.PI),
931
- angleEnd_degrees = angleEnd * (180 / RG.PI),
932
- angleRange_degrees = angleRange * (180 / RG.PI)
933
-
934
- // Vertical alignment
935
- valign = prop['chart.text.valign'];
936
-
937
- // Horizontal alignment
938
- if (prop['chart.border']) {
939
- if (i == 0) {
940
- halign = 'left';
941
- } else if (i == numLabels) {
942
- halign = 'right';
943
- } else {
944
- halign = 'center'
945
- }
946
- } else {
947
- halign = 'center';
948
- }
949
-
950
- RG.text2(this, {
951
- 'font':text_font,
952
- 'size':text_size,
953
- 'x':coords[0],
954
- 'y':coords[1],
955
- 'text':RG.numberFormat(this, (((this.max - this.min) * (i / numLabels)) + this.min).toFixed(decimals),units_pre,units_post),
956
- 'halign':halign,
957
- 'valign':valign,
958
- 'angle':((angleRange_degrees * (1 / numLabels) * i) + angleStart_degrees) - 270,
959
- 'bounding':false,
960
- 'boundingFill':(i == 0 || i == numLabels) ? 'white': null,
961
- 'tag': 'scale'
962
- });
963
- }
964
- };
965
-
966
-
967
-
968
-
969
- /**
970
- * This function draws the text readout if specified
971
- */
972
- this.drawReadout =
973
- this.DrawReadout = function ()
974
- {
975
- if (prop['chart.value.text']) {
976
- co.beginPath();
977
- co.fillStyle = prop['chart.text.color'];
978
- RG.Text2(this, {'font':prop['chart.text.font'],
979
- 'size':prop['chart.text.size'],
980
- 'x':this.centerx,
981
- 'y':this.centery - prop['chart.text.size'] - 15,
982
- 'text': prop['chart.value.text.units.pre'] + (this.value).toFixed(prop['chart.value.text.decimals']) + prop['chart.value.text.units.post'],
983
- 'halign':'center',
984
- 'valign':'bottom',
985
- 'bounding':true,
986
- 'boundingFill':'white',
987
- 'tag': 'value.text'
988
- });
989
-
990
- co.stroke();
991
- co.fill();
992
- }
993
- };
994
-
995
-
996
-
997
-
998
- /**
999
- * A placeholder function
1000
- *
1001
- * @param object The event object
1002
- */
1003
- this.getShape = function (e) {};
1004
-
1005
-
1006
-
1007
-
1008
- /**
1009
- * This function returns the pertinent value for a particular click (or other mouse event)
1010
- *
1011
- * @param obj e The event object
1012
- */
1013
- this.getValue = function (e)
1014
- {
1015
- var mouseXY = RG.getMouseXY(e);
1016
- var angle = RG.getAngleByXY(this.centerx, this.centery, mouseXY[0], mouseXY[1]);
1017
-
1018
- // Work out the radius
1019
- var radius = RG.getHypLength(this.centerx, this.centery, mouseXY[0], mouseXY[1]);
1020
- if (radius > this.radius) {
1021
- return null;
1022
- }
1023
-
1024
-
1025
- if (angle < RG.HALFPI) {
1026
- angle += RG.TWOPI;
1027
- }
1028
-
1029
- var value = (((angle - prop['chart.angles.start']) / (prop['chart.angles.end'] - prop['chart.angles.start'])) * (this.max - this.min)) + this.min;
1030
-
1031
- value = Math.max(value, this.min);
1032
- value = Math.min(value, this.max);
1033
-
1034
- return value;
1035
- };
1036
-
1037
-
1038
-
1039
-
1040
- /**
1041
- * The getObjectByXY() worker method. Don't call this call:
1042
- *
1043
- * RGraph.ObjectRegistry.getObjectByXY(e)
1044
- *
1045
- * @param object e The event object
1046
- */
1047
- this.getObjectByXY = function (e)
1048
- {
1049
- var mouseXY = RGraph.getMouseXY(e);
1050
-
1051
- // Work out the radius
1052
- var radius = RG.getHypLength(this.centerx, this.centery, mouseXY[0], mouseXY[1]);
1053
-
1054
- if (
1055
- mouseXY[0] > (this.centerx - this.radius)
1056
- && mouseXY[0] < (this.centerx + this.radius)
1057
- && mouseXY[1] > (this.centery - this.radius)
1058
- && mouseXY[1] < (this.centery + this.radius)
1059
- && radius <= this.radius
1060
- ) {
1061
-
1062
- return this;
1063
- }
1064
- };
1065
-
1066
-
1067
-
1068
-
1069
- /**
1070
- * This method handles the adjusting calculation for when the mouse is moved
1071
- *
1072
- * @param object e The event object
1073
- */
1074
- this.adjusting_mousemove =
1075
- this.Adjusting_mousemove = function (e)
1076
- {
1077
- /**
1078
- * Handle adjusting for the Bar
1079
- */
1080
- if (prop['chart.adjustable'] && RG.Registry.Get('chart.adjusting') && RG.Registry.Get('chart.adjusting').uid == this.uid) {
1081
- this.value = this.getValue(e);
1082
- RG.clear(this.canvas);
1083
- RG.redrawCanvas(this.canvas);
1084
- RG.fireCustomEvent(this, 'onadjust');
1085
- }
1086
- };
1087
-
1088
-
1089
-
1090
-
1091
- /**
1092
- * This method returns the appropriate angle for a value
1093
- *
1094
- * @param number value The value
1095
- */
1096
- this.getAngle = function (value)
1097
- {
1098
- // Higher than max
1099
- if (value > this.max || value < this.min) {
1100
- return null;
1101
- }
1102
-
1103
- var angle = (((value - this.min) / (this.max - this.min)) * (prop['chart.angles.end'] - prop['chart.angles.start'])) + prop['chart.angles.start'];
1104
-
1105
- return angle;
1106
- };
1107
-
1108
-
1109
-
1110
-
1111
- /**
1112
- * This allows for easy specification of gradients
1113
- */
1114
- this.parseColors = function ()
1115
- {
1116
- // Save the original colors so that they can be restored when the canvas is reset
1117
- if (this.original_colors.length === 0) {
1118
- this.original_colors['chart.green.color'] = RG.array_clone(prop['chart.green.color']);
1119
- this.original_colors['chart.yellow.color'] = RG.array_clone(prop['chart.yellow.color']);
1120
- this.original_colors['chart.red.color'] = RG.array_clone(prop['chart.red.color']);
1121
- this.original_colors['chart.colors.ranges'] = RG.array_clone(prop['chart.colors.ranges']);
1122
- }
1123
-
1124
- // Parse the basic colors
1125
- prop['chart.green.color'] = this.parseSingleColorForGradient(prop['chart.green.color']);
1126
- prop['chart.yellow.color'] = this.parseSingleColorForGradient(prop['chart.yellow.color']);
1127
- prop['chart.red.color'] = this.parseSingleColorForGradient(prop['chart.red.color']);
1128
-
1129
- // Parse chart.colors.ranges
1130
- var ranges = prop['chart.colors.ranges'];
1131
- if (ranges && ranges.length) {
1132
- for (var i=0; i<ranges.length; ++i) {
1133
- ranges[i][2] = this.parseSingleColorForGradient(ranges[i][2]);
1134
- }
1135
- }
1136
- };
1137
-
1138
-
1139
-
1140
-
1141
- /**
1142
- * Use this function to reset the object to the post-constructor state. Eg reset colors if
1143
- * need be etc
1144
- */
1145
- this.reset = function ()
1146
- {
1147
- };
1148
-
1149
-
1150
-
1151
-
1152
- /**
1153
- * This parses a single color value
1154
- */
1155
- this.parseSingleColorForGradient = function (color)
1156
- {
1157
- if (!color || typeof(color) != 'string') {
1158
- return color;
1159
- }
1160
-
1161
- if (color.match(/^gradient\((.*)\)$/i)) {
1162
-
1163
- var parts = RegExp.$1.split(':');
1164
-
1165
- // Create the gradient
1166
- var grad = co.createRadialGradient(this.centerx, this.centery, prop['chart.segment.radius.start'], this.centerx, this.centery, this.radius * 0.85);
1167
-
1168
- var diff = 1 / (parts.length - 1);
1169
-
1170
- for (var j=0; j<parts.length; ++j) {
1171
- grad.addColorStop(j * diff, RG.trim(parts[j]));
1172
- }
1173
- }
1174
-
1175
- return grad ? grad : color;
1176
- };
1177
-
1178
-
1179
-
1180
-
1181
- /**
1182
- * Using a function to add events makes it easier to facilitate method chaining
1183
- *
1184
- * @param string type The type of even to add
1185
- * @param function func
1186
- */
1187
- this.on = function (type, func)
1188
- {
1189
- if (type.substr(0,2) !== 'on') {
1190
- type = 'on' + type;
1191
- }
1192
-
1193
- this[type] = func;
1194
-
1195
- return this;
1196
- };
1197
-
1198
-
1199
-
1200
-
1201
- /**
1202
- * This function runs once only
1203
- * (put at the end of the file (before any effects))
1204
- */
1205
- this.firstDrawFunc = function ()
1206
- {
1207
- };
1208
-
1209
-
1210
-
1211
-
1212
- /**
1213
- * Meter Grow
1214
- *
1215
- * This effect gradually increases the represented value
1216
- *
1217
- * @param An object of options - eg: {frames: 60}
1218
- * @param function An optional callback function
1219
- */
1220
- this.grow = function ()
1221
- {
1222
- var obj = this;
1223
-
1224
- obj.currentValue = obj.currentValue || obj.min;
1225
-
1226
- var opt = arguments[0] || {};
1227
- var frames = opt.frames || 30;
1228
- var frame = 0;
1229
- var diff = obj.value - obj.currentValue;
1230
- var step = diff / frames;
1231
- var callback = arguments[1] || function () {};
1232
- var initial = obj.currentValue;
1233
-
1234
-
1235
-
1236
- function iterator ()
1237
- {
1238
- obj.value = initial + (frame++ * step);
1239
-
1240
- RG.clear(obj.canvas);
1241
- RG.redrawCanvas(obj.canvas);
1242
-
1243
- if (frame <= frames) {
1244
- RG.Effects.updateCanvas(iterator);
1245
- } else {
1246
- callback(obj);
1247
- }
1248
- }
1249
-
1250
- iterator();
1251
-
1252
- return this;
1253
- };
1254
-
1255
-
1256
-
1257
-
1258
-
1259
- RG.att(ca);
1260
-
1261
-
1262
-
1263
-
1264
- /**
1265
- * Register the object
1266
- */
1267
- RG.register(this);
1268
-
1269
-
1270
-
1271
-
1272
- /**
1273
- * This is the 'end' of the constructor so if the first argument
1274
- * contains configuration data - handle that.
1275
- */
1276
- if (parseConfObjectForOptions) {
1277
- RG.parseObjectStyleConfig(this, conf.options);
1278
- }
1279
- };
2
+ RGraph=window.RGraph||{isRGraph:true};RGraph.Meter=function(conf)
3
+ {if(typeof conf==='object'&&typeof conf.value!=='undefined'&&typeof conf.id==='string'){var id=conf.id
4
+ var canvas=document.getElementById(id);var min=conf.min;var max=conf.max;var value=conf.value;var parseConfObjectForOptions=true;}else{var id=conf;var canvas=document.getElementById(id);var min=arguments[1];var max=arguments[2];var value=arguments[3];}
5
+ this.id=id;this.canvas=canvas;this.context=this.canvas.getContext?this.canvas.getContext("2d",{alpha:(typeof id==='object'&&id.alpha===false)?false:true}):null;this.canvas.__object__=this;this.type='meter';this.min=RGraph.stringsToNumbers(min);this.max=RGraph.stringsToNumbers(max);this.value=RGraph.stringsToNumbers(value);this.centerx=null;this.centery=null;this.radius=null;this.isRGraph=true;this.currentValue=null;this.uid=RGraph.CreateUID();this.canvas.uid=this.canvas.uid?this.canvas.uid:RGraph.CreateUID();this.colorsParsed=false;this.coordsText=[];this.original_colors=[];this.firstDraw=true;this.properties={'chart.background.image.url':null,'chart.background.image.offsetx':0,'chart.background.image.offsety':0,'chart.background.image.stretch':true,'chart.background.color':'white','chart.gutter.left':15,'chart.gutter.right':15,'chart.gutter.top':15,'chart.gutter.bottom':20,'chart.linewidth':1,'chart.linewidth.segments':0,'chart.strokestyle':null,'chart.border':true,'chart.border.color':'black','chart.text.font':'Segoe UI, Arial, Verdana, sans-serif','chart.text.size':12,'chart.text.color':'black','chart.text.valign':'center','chart.text.accessible':false,'chart.text.accessible.overflow':'visible','chart.text.accessible.pointerevents':true,'chart.value.text.decimals':0,'chart.value.text.units.pre':'','chart.value.text.units.post':'','chart.title':'','chart.title.background':null,'chart.title.hpos':null,'chart.title.vpos':null,'chart.title.color':'black','chart.title.bold':true,'chart.title.font':null,'chart.title.x':null,'chart.title.y':null,'chart.title.halign':null,'chart.title.valign':null,'chart.green.start':((this.max-this.min)*0.35)+this.min,'chart.green.end':this.max,'chart.green.color':'#207A20','chart.yellow.start':((this.max-this.min)*0.1)+this.min,'chart.yellow.end':((this.max-this.min)*0.35)+this.min,'chart.yellow.color':'#D0AC41','chart.red.start':this.min,'chart.red.end':((this.max-this.min)*0.1)+this.min,'chart.red.color':'#9E1E1E','chart.colors.ranges':null,'chart.units.pre':'','chart.units.post':'','chart.contextmenu':null,'chart.zoom.factor':1.5,'chart.zoom.fade.in':true,'chart.zoom.fade.out':true,'chart.zoom.hdir':'right','chart.zoom.vdir':'down','chart.zoom.frames':25,'chart.zoom.delay':16.666,'chart.zoom.shadow':true,'chart.zoom.background':true,'chart.zoom.action':'zoom','chart.annotatable':false,'chart.annotate.color':'black','chart.shadow':false,'chart.shadow.color':'rgba(0,0,0,0.5)','chart.shadow.blur':3,'chart.shadow.offsetx':3,'chart.shadow.offsety':3,'chart.resizable':false,'chart.resize.handle.adjust':[0,0],'chart.resize.handle.background':null,'chart.tickmarks.small.num':100,'chart.tickmarks.big.num':10,'chart.tickmarks.small.color':'#bbb','chart.tickmarks.big.color':'black','chart.scale.decimals':0,'chart.scale.point':'.','chart.scale.thousand':',','chart.radius':null,'chart.centerx':null,'chart.centery':null,'chart.labels':true,'chart.labels.count':10,'chart.labels.specific':null,'chart.segment.radius.start':0,'chart.needle.radius':null,'chart.needle.tail':false,'chart.needle.head':true,'chart.needle.color':'black','chart.needle.image.url':null,'chart.needle.image.offsetx':0,'chart.needle.image.offsety':0,'chart.adjustable':false,'chart.angles.start':RGraph.PI,'chart.angles.end':RGraph.TWOPI,'chart.centerpin.stroke':'black','chart.centerpin.fill':'white','chart.clearto':'rgba(0,0,0,0)'}
6
+ if(!this.canvas){alert('[METER] No canvas support');return;}
7
+ if(!this.canvas.__rgraph_aa_translated__){this.context.translate(0.5,0.5);this.canvas.__rgraph_aa_translated__=true;}
8
+ var RG=RGraph,ca=this.canvas,co=ca.getContext('2d'),prop=this.properties,pa2=RG.path2,win=window,doc=document,ma=Math
9
+ if(RG.Effects&&typeof RG.Effects.decorate==='function'){RG.Effects.decorate(this);}
10
+ this.set=this.Set=function(name)
11
+ {var value=arguments[1]||null;if(arguments.length===1&&typeof name==='object'){RG.parseObjectStyleConfig(this,name);return this;}
12
+ if(name.substr(0,6)!='chart.'){name='chart.'+name;}
13
+ while(name.match(/([A-Z])/)){name=name.replace(/([A-Z])/,'.'+RegExp.$1.toLowerCase());}
14
+ if(name=='chart.value'){this.value=value;return;}
15
+ prop[name]=value;return this;};this.get=this.Get=function(name)
16
+ {if(name.substr(0,6)!='chart.'){name='chart.'+name;}
17
+ while(name.match(/([A-Z])/)){name=name.replace(/([A-Z])/,'.'+RegExp.$1.toLowerCase());}
18
+ if(name=='chart.value'){return this.value;}
19
+ return prop[name];};this.draw=this.Draw=function()
20
+ {RG.FireCustomEvent(this,'onbeforedraw');if(this.value>this.max)this.value=this.max;if(this.value<this.min)this.value=this.min;this.currentValue=this.value;this.gutterLeft=prop['chart.gutter.left'];this.gutterRight=prop['chart.gutter.right'];this.gutterTop=prop['chart.gutter.top'];this.gutterBottom=prop['chart.gutter.bottom'];this.centerx=((ca.width-this.gutterLeft-this.gutterRight)/2)+this.gutterLeft;this.centery=ca.height-this.gutterBottom;this.radius=Math.min((ca.width-this.gutterLeft-this.gutterRight)/2,(ca.height-this.gutterTop-this.gutterBottom));this.coordsText=[];if(typeof(prop['chart.centerx'])=='number')this.centerx=prop['chart.centerx'];if(typeof(prop['chart.centery'])=='number')this.centery=prop['chart.centery'];if(typeof(prop['chart.radius'])=='number')this.radius=prop['chart.radius'];if(!this.colorsParsed){this.parseColors();this.colorsParsed=true;}
21
+ this.drawBackground();this.drawLabels();this.drawNeedle();this.drawReadout();RG.DrawTitle(this,prop['chart.title'],this.gutterTop,null,prop['chart.title.size']?prop['chart.title.size']:prop['chart.text.size']+2);if(prop['chart.contextmenu']){RG.ShowContext(this);}
22
+ if(prop['chart.resizable']){RG.AllowResizing(this);}
23
+ RG.InstallEventListeners(this);if(this.firstDraw){RG.fireCustomEvent(this,'onfirstdraw');this.firstDraw=false;this.firstDrawFunc();}
24
+ RG.FireCustomEvent(this,'ondraw');return this;};this.exec=function(func)
25
+ {func(this);return this;};this.drawBackground=this.DrawBackground=function()
26
+ {if(typeof prop['chart.background.image.url']==='string'&&!this.__background_image__){var x=0+prop['chart.background.image.offsetx'];var y=0+prop['chart.background.image.offsety'];var img=new Image();this.__background_image__=img;img.src=prop['chart.background.image.url'];img.onload=function()
27
+ {if(prop['chart.background.image.stretch']){co.drawImage(this,x,y,ca.width,ca.height);}else{co.drawImage(this,x,y);}
28
+ RG.redraw();}}else if(this.__background_image__){var x=0+prop['chart.background.image.offsetx'];var y=0+prop['chart.background.image.offsety'];if(prop['chart.background.image.stretch']){co.drawImage(this.__background_image__,x,y,ca.width,ca.height);}else{co.drawImage(this.__background_image__,x,y);}}
29
+ co.beginPath();co.fillStyle=prop['chart.background.color'];if(prop['chart.shadow']){RG.SetShadow(this,prop['chart.shadow.color'],prop['chart.shadow.offsetx'],prop['chart.shadow.offsety'],prop['chart.shadow.blur']);}
30
+ co.moveTo(this.centerx,this.centery);co.arc(this.centerx,this.centery,this.radius,prop['chart.angles.start'],prop['chart.angles.end'],false);co.fill();RG.NoShadow(this);if(prop['chart.shadow']){co.beginPath();var r=(this.radius*0.06)>40?40:(this.radius*0.06);co.arc(this.centerx,this.centery,r,0,RG.TWOPI,0);co.fill();RG.NoShadow(this);}
31
+ if(prop['chart.tickmarks.small.num']){for(var i=0;i<(prop['chart.angles.end']-prop['chart.angles.start']);i+=(RG.PI/prop['chart.tickmarks.small.num'])){co.beginPath();co.strokeStyle=prop['chart.tickmarks.small.color'];co.arc(this.centerx,this.centery,this.radius,prop['chart.angles.start']+i,prop['chart.angles.start']+i+0.00001,0);co.arc(this.centerx,this.centery,this.radius-5,prop['chart.angles.start']+i,prop['chart.angles.start']+i+0.00001,0);co.stroke();}
32
+ co.beginPath();co.fillStyle=prop['chart.background.color'];co.arc(this.centerx,this.centery,this.radius-4,prop['chart.angles.start'],prop['chart.angles.end'],false);co.closePath();co.fill();}
33
+ if(prop['chart.tickmarks.big.num']){var colors=['white','white',prop['chart.tickmarks.big.color']];for(var j=0;j<colors.length;++j){for(var i=0;i<(prop['chart.angles.end']-prop['chart.angles.start']);i+=((prop['chart.angles.end']-prop['chart.angles.start'])/prop['chart.tickmarks.big.num'])){co.beginPath();co.strokeStyle=colors[j];co.arc(this.centerx,this.centery,this.radius,prop['chart.angles.start']+i,prop['chart.angles.start']+i+0.001,0);co.arc(this.centerx,this.centery,this.radius-5,prop['chart.angles.start']+i,prop['chart.angles.start']+i+0.0001,0);co.stroke();}}}
34
+ co.beginPath();co.fillStyle=prop['chart.background.color'];co.moveTo(this.centerx,this.centery);co.arc(this.centerx,this.centery,this.radius-7,prop['chart.angles.start'],prop['chart.angles.end'],false);co.closePath();co.fill();var ranges=prop['chart.colors.ranges'];if(RG.is_array(prop['chart.colors.ranges'])){var ranges=prop['chart.colors.ranges'];for(var i=0;i<ranges.length;++i){co.strokeStyle=prop['chart.strokestyle']?prop['chart.strokestyle']:ranges[i][2];co.fillStyle=ranges[i][2];co.lineWidth=prop['chart.linewidth.segments'];co.beginPath();co.arc(this.centerx,this.centery,this.radius*0.85,(((ranges[i][0]-this.min)/(this.max-this.min))*(prop['chart.angles.end']-prop['chart.angles.start']))+prop['chart.angles.start'],(((ranges[i][1]-this.min)/(this.max-this.min))*(prop['chart.angles.end']-prop['chart.angles.start']))+prop['chart.angles.start'],false);if(prop['chart.segment.radius.start']>0){co.arc(this.centerx,this.centery,prop['chart.segment.radius.start'],(((ranges[i][1]-this.min)/(this.max-this.min))*(prop['chart.angles.end']-prop['chart.angles.start']))+prop['chart.angles.start'],(((ranges[i][0]-this.min)/(this.max-this.min))*(prop['chart.angles.end']-prop['chart.angles.start']))+prop['chart.angles.start'],true);}else{co.lineTo(this.centerx,this.centery);}
35
+ co.closePath();co.stroke();co.fill();}
36
+ co.beginPath();}else{co.lineWidth=prop['chart.linewidth'];co.strokeStyle=prop['chart.strokestyle']?prop['chart.strokestyle']:prop['chart.green.color'];co.fillStyle=prop['chart.green.color'];co.lineWidth=prop['chart.linewidth.segments'];co.beginPath();co.arc(this.centerx,this.centery,this.radius*0.85,(((prop['chart.green.start']-this.min)/(this.max-this.min))*(prop['chart.angles.end']-this.properties['chart.angles.start']))+prop['chart.angles.start'],(((prop['chart.green.end']-this.min)/(this.max-this.min))*(prop['chart.angles.end']-prop['chart.angles.start']))+prop['chart.angles.start'],false);if(prop['chart.segment.radius.start']>0){co.arc(this.centerx,this.centery,prop['chart.segment.radius.start'],(((prop['chart.green.end']-this.min)/(this.max-this.min))*(prop['chart.angles.end']-prop['chart.angles.start']))+prop['chart.angles.start'],(((prop['chart.green.start']-this.min)/(this.max-this.min))*(prop['chart.angles.end']-prop['chart.angles.start']))+prop['chart.angles.start'],true);}else{co.lineTo(this.centerx,this.centery);}
37
+ co.closePath();co.stroke();co.fill();co.strokeStyle=prop['chart.strokestyle']?prop['chart.strokestyle']:prop['chart.yellow.color'];co.fillStyle=prop['chart.yellow.color'];co.lineWidth=prop['chart.linewidth.segments'];co.beginPath();co.arc(this.centerx,this.centery,this.radius*0.85,(((prop['chart.yellow.start']-this.min)/(this.max-this.min))*(prop['chart.angles.end']-prop['chart.angles.start']))+prop['chart.angles.start'],(((prop['chart.yellow.end']-this.min)/(this.max-this.min))*(prop['chart.angles.end']-prop['chart.angles.start']))+prop['chart.angles.start'],false);if(prop['chart.segment.radius.start']>0){co.arc(this.centerx,this.centery,prop['chart.segment.radius.start'],(((prop['chart.yellow.end']-this.min)/(this.max-this.min))*(prop['chart.angles.end']-prop['chart.angles.start']))+prop['chart.angles.start'],(((prop['chart.yellow.start']-this.min)/(this.max-this.min))*(prop['chart.angles.end']-prop['chart.angles.start']))+prop['chart.angles.start'],true);}else{co.lineTo(this.centerx,this.centery);}
38
+ co.closePath();co.stroke();co.fill();co.strokeStyle=prop['chart.strokestyle']?prop['chart.strokestyle']:prop['chart.red.color'];co.fillStyle=prop['chart.red.color'];co.lineWidth=prop['chart.linewidth.segments'];co.beginPath();co.arc(this.centerx,this.centery,this.radius*0.85,(((prop['chart.red.start']-this.min)/(this.max-this.min))*(prop['chart.angles.end']-prop['chart.angles.start']))+prop['chart.angles.start'],(((prop['chart.red.end']-this.min)/(this.max-this.min))*(prop['chart.angles.end']-prop['chart.angles.start']))+prop['chart.angles.start'],false);if(prop['chart.segment.radius.start']>0){co.arc(this.centerx,this.centery,prop['chart.segment.radius.start'],(((prop['chart.red.end']-this.min)/(this.max-this.min))*(prop['chart.angles.end']-prop['chart.angles.start']))+prop['chart.angles.start'],(((prop['chart.red.start']-this.min)/(this.max-this.min))*(prop['chart.angles.end']-prop['chart.angles.start']))+prop['chart.angles.start'],true);}else{co.lineTo(this.centerx,this.centery);}
39
+ co.closePath();co.stroke();co.fill();co.lineWidth=1;}
40
+ if(prop['chart.border']){co.strokeStyle=prop['chart.border.color'];co.lineWidth=prop['chart.linewidth'];co.beginPath();co.moveTo(this.centerx,this.centery);co.arc(this.centerx,this.centery,this.radius,prop['chart.angles.start'],prop['chart.angles.end'],false);co.closePath();}
41
+ co.stroke();co.lineWidth=1;};this.drawNeedle=this.DrawNeedle=function()
42
+ {var a=(((this.value-this.min)/(this.max-this.min))*(prop['chart.angles.end']-prop['chart.angles.start']))+prop['chart.angles.start'];if(typeof prop['chart.needle.image.url']==='string'&&!this.__needle_image__){var img=new Image();this.__needle_image__=img;img.src=prop['chart.needle.image.url'];img.onload=function()
43
+ {co.save();RG.rotateCanvas(ca,this.centerx,this.centery,a);co.drawImage(this,this.centerx+prop['chart.needle.image.offsetx'],this.centery+prop['chart.needle.image.offsety']);co.restore();RG.redraw();}}else if(this.__needle_image__){co.save();RG.rotateCanvas(ca,this.centerx,this.centery,a);co.drawImage(this.__needle_image__,this.centerx+prop['chart.needle.image.offsetx'],this.centery+prop['chart.needle.image.offsety']);co.restore();}
44
+ var needleRadius=typeof(prop['chart.needle.radius'])=='number'?prop['chart.needle.radius']:this.radius*0.7;co.fillStyle='black';co.lineWidth=this.radius>=200?7:3;co.lineCap='round';co.beginPath();co.strokeStyle=prop['chart.needle.color'];if(typeof(prop['chart.needle.linewidth'])=='number')co.lineWidth=prop['chart.needle.linewidth'];co.arc(this.centerx,this.centery,needleRadius,a,a+0.001,false);co.lineTo(this.centerx,this.centery);co.stroke();if(prop['chart.needle.head']){co.fillStyle=prop['chart.needle.color'];co.beginPath();co.lineWidth=1;co.arc(this.centerx,this.centery,needleRadius+15,a,a+0.001,0);co.arc(this.centerx,this.centery,needleRadius-15,a+0.087,a+0.087999,0);co.arc(this.centerx,this.centery,needleRadius-15,a-0.087,a-0.087999,1);co.fill();}
45
+ if(prop['chart.needle.tail']){co.beginPath();co.strokeStyle=prop['chart.needle.color'];if(typeof(prop['chart.needle.linewidth'])=='number')co.lineWidth=prop['chart.needle.linewidth'];var a=((this.value-this.min)/(this.max-this.min)*(this.properties['chart.angles.end']-this.properties['chart.angles.start']))+this.properties['chart.angles.start']+RG.PI;co.arc(this.centerx,this.centery,25,a,a+0.001,false);co.lineTo(this.centerx,this.centery);co.stroke();}
46
+ var r=(this.radius*0.06)>40?40:(this.radius*0.06);co.beginPath();co.fillStyle=prop['chart.centerpin.stroke'];co.arc(this.centerx,this.centery,r,0+0.001,RG.TWOPI,0);co.fill();co.fillStyle=prop['chart.centerpin.fill'];co.beginPath();co.arc(this.centerx,this.centery,r-2,0+0.001,RG.TWOPI,0);co.fill();};this.drawLabels=this.DrawLabels=function()
47
+ {if(!prop['chart.labels']){return;}
48
+ var radius=this.radius,text_size=prop['chart.text.size'],text_font=prop['chart.text.font'],units_post=prop['chart.units.post'],units_pre=prop['chart.units.pre'],centerx=this.centerx,centery=this.centery,min=this.min,max=this.max,decimals=prop['chart.scale.decimals'],numLabels=prop['chart.labels.count'],specific=prop['chart.labels.specific']
49
+ if(specific){for(var i=0;i<specific.length;++i){var angle=this.getAngle(specific[i][1]),angle_degrees=angle*(180/RG.PI),text=specific[i][0].toString(),coords=RG.getRadiusEndPoint(this.centerx,this.centery,angle,this.radius*0.925)
50
+ RG.text2(this,{'font':text_font,'size':text_size,'x':coords[0],'y':coords[1],'text':text,'halign':'center','valign':'center','angle':angle_degrees+90,'bounding':false,'tag':'labels-specific',color:'black'});}
51
+ return;}
52
+ co.fillStyle=prop['chart.text.color'];co.lineWidth=1;co.beginPath();for(var i=0;i<=numLabels;++i){var angle=((prop['chart.angles.end']-prop['chart.angles.start'])*(i/numLabels))+prop['chart.angles.start'];var coords=RG.getRadiusEndPoint(centerx,centery,angle+(((i==0||i==numLabels)&&prop['chart.border'])?(i==0?0.05:-0.05):0),(this.radius*0.925)-(prop['chart.text.valign']==='bottom'?15:0));var angleStart=prop['chart.angles.start'],angleEnd=prop['chart.angles.end'],angleRange=angleEnd-angleStart,angleStart_degrees=angleStart*(180/RG.PI),angleEnd_degrees=angleEnd*(180/RG.PI),angleRange_degrees=angleRange*(180/RG.PI)
53
+ valign=prop['chart.text.valign'];if(prop['chart.border']){if(i==0){halign='left';}else if(i==numLabels){halign='right';}else{halign='center'}}else{halign='center';}
54
+ var value=((this.max-this.min)*(i/numLabels))+this.min;RG.text2(this,{'font':text_font,'size':text_size,'x':coords[0],'y':coords[1],'text':RG.numberFormat(this,(value).toFixed(value===0?0:decimals),units_pre,units_post),'halign':halign,'valign':valign,'angle':((angleRange_degrees*(1/numLabels)*i)+angleStart_degrees)-270,'bounding':false,'boundingFill':(i==0||i==numLabels)?'white':null,'tag':'scale'});}};this.drawReadout=this.DrawReadout=function()
55
+ {if(prop['chart.value.text']){co.beginPath();co.fillStyle=prop['chart.text.color'];RG.Text2(this,{'font':prop['chart.text.font'],'size':prop['chart.text.size'],'x':this.centerx,'y':this.centery-prop['chart.text.size']-15,'text':prop['chart.value.text.units.pre']+(this.value).toFixed(prop['chart.value.text.decimals'])+prop['chart.value.text.units.post'],'halign':'center','valign':'bottom','bounding':true,'boundingFill':'white','tag':'value.text'});co.stroke();co.fill();}};this.getShape=function(e){};this.getValue=function(e)
56
+ {var mouseXY=RG.getMouseXY(e);var angle=RG.getAngleByXY(this.centerx,this.centery,mouseXY[0],mouseXY[1]);var radius=RG.getHypLength(this.centerx,this.centery,mouseXY[0],mouseXY[1]);if(radius>this.radius){return null;}
57
+ if(angle<RG.HALFPI){angle+=RG.TWOPI;}
58
+ var value=(((angle-prop['chart.angles.start'])/(prop['chart.angles.end']-prop['chart.angles.start']))*(this.max-this.min))+this.min;value=Math.max(value,this.min);value=Math.min(value,this.max);return value;};this.getObjectByXY=function(e)
59
+ {var mouseXY=RGraph.getMouseXY(e);var radius=RG.getHypLength(this.centerx,this.centery,mouseXY[0],mouseXY[1]);if(mouseXY[0]>(this.centerx-this.radius)&&mouseXY[0]<(this.centerx+this.radius)&&mouseXY[1]>(this.centery-this.radius)&&mouseXY[1]<(this.centery+this.radius)&&radius<=this.radius){return this;}};this.adjusting_mousemove=this.Adjusting_mousemove=function(e)
60
+ {if(prop['chart.adjustable']&&RG.Registry.Get('chart.adjusting')&&RG.Registry.Get('chart.adjusting').uid==this.uid){this.value=this.getValue(e);RG.clear(this.canvas);RG.redrawCanvas(this.canvas);RG.fireCustomEvent(this,'onadjust');}};this.getAngle=function(value)
61
+ {if(value>this.max||value<this.min){return null;}
62
+ var angle=(((value-this.min)/(this.max-this.min))*(prop['chart.angles.end']-prop['chart.angles.start']))+prop['chart.angles.start'];return angle;};this.parseColors=function()
63
+ {if(this.original_colors.length===0){this.original_colors['chart.green.color']=RG.array_clone(prop['chart.green.color']);this.original_colors['chart.yellow.color']=RG.array_clone(prop['chart.yellow.color']);this.original_colors['chart.red.color']=RG.array_clone(prop['chart.red.color']);this.original_colors['chart.colors.ranges']=RG.array_clone(prop['chart.colors.ranges']);}
64
+ prop['chart.green.color']=this.parseSingleColorForGradient(prop['chart.green.color']);prop['chart.yellow.color']=this.parseSingleColorForGradient(prop['chart.yellow.color']);prop['chart.red.color']=this.parseSingleColorForGradient(prop['chart.red.color']);var ranges=prop['chart.colors.ranges'];if(ranges&&ranges.length){for(var i=0;i<ranges.length;++i){ranges[i][2]=this.parseSingleColorForGradient(ranges[i][2]);}}};this.reset=function()
65
+ {};this.parseSingleColorForGradient=function(color)
66
+ {if(!color||typeof(color)!='string'){return color;}
67
+ if(color.match(/^gradient\((.*)\)$/i)){var parts=RegExp.$1.split(':');var grad=co.createRadialGradient(this.centerx,this.centery,prop['chart.segment.radius.start'],this.centerx,this.centery,this.radius*0.85);var diff=1/(parts.length-1);for(var j=0;j<parts.length;++j){grad.addColorStop(j*diff,RG.trim(parts[j]));}}
68
+ return grad?grad:color;};this.on=function(type,func)
69
+ {if(type.substr(0,2)!=='on'){type='on'+type;}
70
+ if(typeof this[type]!=='function'){this[type]=func;}else{RG.addCustomEventListener(this,type,func);}
71
+ return this;};this.firstDrawFunc=function()
72
+ {};this.grow=function()
73
+ {var obj=this;obj.currentValue=obj.currentValue||obj.min;var opt=arguments[0]||{};var frames=opt.frames||30;var frame=0;var diff=obj.value-obj.currentValue;var step=diff/frames;var callback=arguments[1]||function(){};var initial=obj.currentValue;function iterator()
74
+ {obj.value=initial+(frame++ *step);RG.clear(obj.canvas);RG.redrawCanvas(obj.canvas);if(frame<=frames){RG.Effects.updateCanvas(iterator);}else{callback(obj);}}
75
+ iterator();return this;};RG.att(ca);RG.register(this);if(parseConfObjectForOptions){RG.parseObjectStyleConfig(this,conf.options);}};