rgraph-rails 1.0.5 → 1.0.6

Sign up to get free protection for your applications and to get access to all the features.
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,1398 +1,88 @@
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 line chart constructor
20
- *
21
- * @param object canvas The canvas ID
22
- * @param array data The chart data
23
- * @param array ... Other lines to plot
24
- */
25
- RGraph.Gauge = function (conf)
26
- {
27
- /**
28
- * Allow for object config style
29
- */
30
- if ( typeof conf === 'object'
31
- && typeof conf.id === 'string') {
32
-
33
- var id = conf.id
34
- var canvas = document.getElementById(id);
35
- var min = conf.min;
36
- var max = conf.max;
37
- var value = conf.value;
38
- var parseConfObjectForOptions = true; // Set this so the config is parsed (at the end of the constructor)
39
-
40
- } else {
41
-
42
- var id = conf;
43
- var canvas = document.getElementById(id);
44
- var min = arguments[1];
45
- var max = arguments[2];
46
- var value = arguments[3];
47
- }
48
-
49
- // id, min, max, value
50
- this.id = id;
51
- this.canvas = canvas;
52
- this.context = this.canvas.getContext ? this.canvas.getContext("2d", {alpha: (typeof id === 'object' && id.alpha === false) ? false : true}) : null;
53
- this.canvas.__object__ = this;
54
- this.type = 'gauge';
55
- this.min = RGraph.stringsToNumbers(min);
56
- this.max = RGraph.stringsToNumbers(max);
57
- this.value = RGraph.stringsToNumbers(value);
58
- this.isRGraph = true;
59
- this.currentValue = null;
60
- this.uid = RGraph.CreateUID();
61
- this.canvas.uid = this.canvas.uid ? this.canvas.uid : RGraph.CreateUID();
62
- this.colorsParsed = false;
63
- this.coordsText = [];
64
- this.original_colors = [];
65
- this.firstDraw = true; // After the first draw this will be false
66
-
67
- /**
68
- * Range checking
69
- */
70
- if (typeof(this.value) == 'object') {
71
- for (var i=0; i<this.value.length; ++i) {
72
- if (this.value[i] > this.max) this.value[i] = max;
73
- if (this.value[i] < this.min) this.value[i] = min;
74
- }
75
- } else {
76
- if (this.value > this.max) this.value = max;
77
- if (this.value < this.min) this.value = min;
78
- }
79
-
80
-
81
-
82
- /**
83
- * Compatibility with older browsers
84
- */
85
- //RGraph.OldBrowserCompat(this.context);
86
-
87
-
88
- // Various config type stuff
89
- this.properties =
90
- {
91
- 'chart.angles.start': null,
92
- 'chart.angles.end': null,
93
- 'chart.centerx': null,
94
- 'chart.centery': null,
95
- 'chart.radius': null,
96
- 'chart.gutter.left': 15,
97
- 'chart.gutter.right': 15,
98
- 'chart.gutter.top': 15,
99
- 'chart.gutter.bottom': 15,
100
- 'chart.border.width': 10,
101
- 'chart.title.top': '',
102
- 'chart.title.top.font':'Segoe UI, Arial, Verdana, sans-serif',
103
- 'chart.title.top.size':14,
104
- 'chart.title.top.color':'#333',
105
- 'chart.title.top.bold':false,
106
- 'chart.title.top.pos': null,
107
- 'chart.title.bottom': '',
108
- 'chart.title.bottom.font':'Segoe UI, Arial, Verdana, sans-serif',
109
- 'chart.title.bottom.size':14,
110
- 'chart.title.bottom.color':'#333',
111
- 'chart.title.bottom.bold':false,
112
- 'chart.title.bottom.pos':null,
113
- 'chart.text.font': 'Segoe UI, Arial, Verdana, sans-serif',
114
- 'chart.text.color': '#666',
115
- 'chart.text.size': 12,
116
- 'chart.text.accessible': true,
117
- 'chart.text.accessible.overflow': 'visible',
118
- 'chart.text.accessible.pointerevents': false,
119
- 'chart.background.color': 'white',
120
- 'chart.background.gradient': false,
121
- 'chart.scale.decimals': 0,
122
- 'chart.scale.point': '.',
123
- 'chart.scale.thousand': ',',
124
- 'chart.units.pre': '',
125
- 'chart.units.post': '',
126
-
127
- 'chart.value.text': false,
128
- 'chart.value.text.y.pos': 0.5,
129
- 'chart.value.text.units.pre': null,
130
- 'chart.value.text.units.post': null,
131
- 'chart.value.text.color': 'black',
132
- 'chart.value.text.bounding': true,
133
- 'chart.value.text.bounding.fill': 'white',
134
- 'chart.value.text.bounding.stroke': 'black',
135
-
136
- 'chart.red.start': 0.9 * this.max,
137
- 'chart.red.color': '#DC3912',
138
- 'chart.red.width': 10,
139
- 'chart.yellow.color': '#FF9900',
140
- 'chart.yellow.width': 10,
141
- 'chart.green.end': 0.7 * this.max,
142
- 'chart.green.color': 'rgba(0,0,0,0)',
143
- 'chart.green.width': 10,
144
- 'chart.colors.ranges': null,
145
- 'chart.needle.size': null,
146
- 'chart.needle.tail': false,
147
- 'chart.needle.colors': ['#D5604D', 'red', 'green', 'yellow'],
148
- 'chart.needle.type': 'triangle',
149
- 'chart.needle.width': 7,
150
- 'chart.border.outer': '#ccc',
151
- 'chart.border.inner': '#f1f1f1',
152
- 'chart.border.outline': 'black',
153
- 'chart.centerpin.color': 'blue',
154
- 'chart.centerpin.radius': null,
155
- 'chart.zoom.background': true,
156
- 'chart.zoom.action': 'zoom',
157
- 'chart.tickmarks.small': 25,
158
- 'chart.tickmarks.small.color': 'black',
159
- 'chart.tickmarks.medium': 0,
160
- 'chart.tickmarks.medium.color': 'black',
161
- 'chart.tickmarks.big': 5,
162
- 'chart.tickmarks.big.color': 'black',
163
- 'chart.labels.count': 5,
164
- 'chart.labels.centered': false,
165
- 'chart.labels.offset': 0,
166
- 'chart.border.gradient': false,
167
- 'chart.adjustable': false,
168
- 'chart.shadow': true,
169
- 'chart.shadow.color': 'gray',
170
- 'chart.shadow.offsetx': 0,
171
- 'chart.shadow.offsety': 0,
172
- 'chart.shadow.blur': 15,
173
- 'chart.clearto': 'rgba(0,0,0,0)'
174
- }
175
-
176
-
177
-
178
-
179
- /*
180
- * Translate half a pixel for antialiasing purposes - but only if it hasn't beeen
181
- * done already
182
- */
183
- if (!this.canvas.__rgraph_aa_translated__) {
184
- this.context.translate(0.5,0.5);
185
-
186
- this.canvas.__rgraph_aa_translated__ = true;
187
- }
188
-
189
-
190
-
191
-
192
-
193
- // Short variable names
194
- var RG = RGraph,
195
- ca = this.canvas,
196
- co = ca.getContext('2d'),
197
- prop = this.properties,
198
- pa2 = RG.path2,
199
- win = window,
200
- doc = document,
201
- ma = Math
202
-
203
-
204
-
205
- /**
206
- * "Decorate" the object with the generic effects if the effects library has been included
207
- */
208
- if (RG.Effects && typeof RG.Effects.decorate === 'function') {
209
- RG.Effects.decorate(this);
210
- }
211
-
212
-
213
-
214
-
215
- /**
216
- * An all encompassing accessor
217
- *
218
- * @param string name The name of the property
219
- * @param mixed value The value of the property
220
- */
221
- this.set =
222
- this.Set = function (name)
223
- {
224
- var value = typeof arguments[1] === 'undefined' ? null : arguments[1];
225
-
226
- /**
227
- * the number of arguments is only one and it's an
228
- * object - parse it for configuration data and return.
229
- */
230
- if (arguments.length === 1 && typeof name === 'object') {
231
- RG.parseObjectStyleConfig(this, name);
232
- return this;
233
- }
234
-
235
-
236
-
237
-
238
-
239
- /**
240
- * This should be done first - prepend the propertyy name with "chart." if necessary
241
- */
242
- if (name.substr(0,6) != 'chart.') {
243
- name = 'chart.' + name;
244
- }
245
-
246
-
247
-
248
-
249
- // Convert uppercase letters to dot+lower case letter
250
- while(name.match(/([A-Z])/)) {
251
- name = name.replace(/([A-Z])/, '.' + RegExp.$1.toLowerCase());
252
- }
253
-
254
-
255
-
256
-
257
-
258
- /**
259
- * Title compatibility
260
- */
261
- if (name == 'chart.title') name = 'chart.title.top';
262
- if (name == 'chart.title.font') name = 'chart.title.top.font';
263
- if (name == 'chart.title.size') name = 'chart.title.top.size';
264
- if (name == 'chart.title.color') name = 'chart.title.top.color';
265
- if (name == 'chart.title.bold') name = 'chart.title.top.bold';
266
-
267
- // BC
268
- if (name == 'chart.needle.color') {
269
- name = 'chart.needle.colors';
270
- }
271
-
272
-
273
-
274
-
275
-
276
-
277
- prop[name] = value;
278
-
279
- return this;
280
- };
281
-
282
-
283
-
284
-
285
- /**
286
- * An all encompassing accessor
287
- *
288
- * @param string name The name of the property
289
- */
290
- this.get =
291
- this.Get = function (name)
292
- {
293
- /**
294
- * This should be done first - prepend the property name with "chart." if necessary
295
- */
296
- if (name.substr(0,6) != 'chart.') {
297
- name = 'chart.' + name;
298
- }
299
-
300
- // Convert uppercase letters to dot+lower case letter
301
- name = name.replace(/([A-Z])/g, function (str)
302
- {
303
- return '.' + String(RegExp.$1).toLowerCase()
304
- });
305
-
306
- // BC
307
- if (name == 'chart.needle.color') {
308
- name = 'chart.needle.colors';
309
- }
310
-
311
- return prop[name];
312
- };
313
-
314
-
315
-
316
-
317
- /**
318
- * The function you call to draw the line chart
319
- *
320
- * @param bool An optional bool used internally to ditinguish whether the
321
- * line chart is being called by the bar chart
322
- */
323
- this.draw =
324
- this.Draw = function ()
325
- {
326
- /**
327
- * Fire the onbeforedraw event
328
- */
329
- RG.FireCustomEvent(this, 'onbeforedraw');
330
-
331
-
332
-
333
- /**
334
- * Store the value (for animation primarily
335
- */
336
- this.currentValue = this.value;
337
-
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.gutterTop - this.gutterBottom) / 2) + this.gutterTop;
350
- this.radius = Math.min(
351
- ((ca.width - this.gutterLeft - this.gutterRight) / 2),
352
- ((ca.height - this.gutterTop - this.gutterBottom) / 2)
353
- );
354
- this.startAngle = prop['chart.angles.start'] ? prop['chart.angles.start'] : (RG.HALFPI / 3) + RG.HALFPI;
355
- this.endAngle = prop['chart.angles.end'] ? prop['chart.angles.end'] : RG.TWOPI + RG.HALFPI - (RG.HALFPI / 3);
356
-
357
-
358
- /**
359
- * Reset this so it doesn't keep growing
360
- */
361
- this.coordsText = [];
362
-
363
-
364
-
365
- /**
366
- * You can now override the positioning and radius if you so wish.
367
- */
368
- if (typeof(prop['chart.centerx']) == 'number') this.centerx = prop['chart.centerx'];
369
- if (typeof(prop['chart.centery']) == 'number') this.centery = prop['chart.centery'];
370
- if (typeof(prop['chart.radius']) == 'number') this.radius = prop['chart.radius'];
371
-
372
- /**
373
- * Parse the colors. This allows for simple gradient syntax
374
- */
375
- if (!this.colorsParsed) {
376
- this.parseColors();
377
-
378
- // Don't want to do this again
379
- this.colorsParsed = true;
380
- }
381
-
382
-
383
- // This has to be in the constructor
384
- this.centerpinRadius = 0.16 * this.radius;
385
-
386
- if (typeof(prop['chart.centerpin.radius']) == 'number') {
387
- this.centerpinRadius = prop['chart.centerpin.radius'];
388
- }
389
-
390
-
391
-
392
- /**
393
- * Setup the context menu if required
394
- */
395
- if (prop['chart.contextmenu']) {
396
- RG.ShowContext(this);
397
- }
398
-
399
-
400
-
401
- // DRAW THE CHART HERE
402
- this.DrawBackGround();
403
- this.DrawGradient();
404
- this.DrawColorBands();
405
- this.DrawSmallTickmarks();
406
- this.DrawMediumTickmarks();
407
- this.DrawBigTickmarks();
408
- this.DrawLabels();
409
- this.DrawTopTitle();
410
- this.DrawBottomTitle();
411
-
412
- if (typeof(this.value) == 'object') {
413
- for (var i=0; i<this.value.length; ++i) {
414
- this.DrawNeedle(this.value[i], prop['chart.needle.colors'][i], i);
415
- }
416
- } else {
417
- this.DrawNeedle(this.value, prop['chart.needle.colors'][0], 0);
418
- }
419
-
420
- this.DrawCenterpin();
421
-
422
- /**
423
- * This function enables resizing
424
- */
425
- if (prop['chart.resizable']) {
426
- RG.AllowResizing(this);
427
- }
428
-
429
-
430
- /**
431
- * This installs the event listeners
432
- */
433
- RG.InstallEventListeners(this);
434
-
435
-
436
- /**
437
- * Fire the onfirstdraw event
438
- */
439
- if (this.firstDraw) {
440
- RG.fireCustomEvent(this, 'onfirstdraw');
441
- this.firstDraw = false;
442
- this.firstDrawFunc();
443
- }
444
-
445
-
446
-
447
-
448
- /**
449
- * Fire the RGraph ondraw event
450
- */
451
- RG.FireCustomEvent(this, 'ondraw');
452
-
453
- return this;
454
- };
455
-
456
-
457
-
458
- /**
459
- * Used in chaining. Runs a function there and then - not waiting for
460
- * the events to fire (eg the onbeforedraw event)
461
- *
462
- * @param function func The function to execute
463
- */
464
- this.exec = function (func)
465
- {
466
- func(this);
467
-
468
- return this;
469
- };
470
-
471
-
472
-
473
-
474
- /**
475
- * Draw the background
476
- */
477
- this.drawBackGround =
478
- this.DrawBackGround = function ()
479
- {
480
- // Shadow //////////////////////////////////////////////
481
- if (prop['chart.shadow']) {
482
- RG.SetShadow(this, prop['chart.shadow.color'], prop['chart.shadow.offsetx'], prop['chart.shadow.offsety'], prop['chart.shadow.blur']);
483
- }
484
-
485
- co.beginPath();
486
- co.fillStyle = prop['chart.background.color'];
487
- //co.moveTo(this.centerx, this.centery)
488
- co.arc(this.centerx, this.centery, this.radius, 0, RG.TWOPI, 0);
489
- co.fill();
490
-
491
- // Turn off the shadow
492
- RG.NoShadow(this);
493
- // Shadow //////////////////////////////////////////////
494
-
495
-
496
- var grad = co.createRadialGradient(this.centerx + 50, this.centery - 50, 0, this.centerx + 50, this.centery - 50, 150);
497
- grad.addColorStop(0, '#eee');
498
- grad.addColorStop(1, 'white');
499
-
500
- var borderWidth = prop['chart.border.width'];
501
-
502
- co.beginPath();
503
- co.fillStyle = prop['chart.background.color'];
504
- co.arc(this.centerx, this.centery, this.radius, 0, RG.TWOPI, 0);
505
- co.fill();
506
-
507
- /**
508
- * Draw the gray circle
509
- */
510
- co.beginPath();
511
- co.fillStyle = prop['chart.border.outer'];
512
- co.arc(this.centerx, this.centery, this.radius, 0, RG.TWOPI, 0);
513
- co.fill();
514
-
515
- /**
516
- * Draw the light gray inner border
517
- */
518
- co.beginPath();
519
- co.fillStyle = prop['chart.border.inner'];
520
- co.arc(this.centerx, this.centery, this.radius - borderWidth, 0, RG.TWOPI, 0);
521
- co.fill();
522
-
523
-
524
-
525
- // Draw the white circle inner border
526
- co.beginPath();
527
- co.fillStyle = prop['chart.background.color'];
528
- co.arc(this.centerx, this.centery, this.radius - borderWidth - 4, 0, RG.TWOPI, 0);
529
- co.fill();
530
-
531
-
532
-
533
- // Draw the circle background. Can be any colour now.
534
- co.beginPath();
535
- co.fillStyle = prop['chart.background.color'];
536
- co.arc(this.centerx, this.centery, this.radius - borderWidth - 4, 0, RG.TWOPI, 0);
537
- co.fill();
538
-
539
- if (prop['chart.background.gradient']) {
540
-
541
- // Draw a partially transparent gradient that sits on top of the background
542
- co.beginPath();
543
- co.fillStyle = RG.RadialGradient(this,
544
- this.centerx,
545
- this.centery,
546
- 0,
547
- this.centerx,
548
- this.centery,
549
- this.radius,
550
- 'rgba(255,255,255,0.6)',
551
- 'rgba(255,255,255,0.1)');
552
- co.arc(this.centerx, this.centery, this.radius - borderWidth - 4, 0, RG.TWOPI, 0);
553
- co.fill();
554
- }
555
-
556
-
557
-
558
- // Draw a black border around the chart
559
- co.beginPath();
560
- co.strokeStyle = prop['chart.border.outline'];
561
- co.arc(this.centerx, this.centery, this.radius, 0, RG.TWOPI, 0);
562
- co.stroke();
563
- };
564
-
565
-
566
-
567
-
568
- /**
569
- * This function draws the smaller tickmarks
570
- */
571
- this.drawSmallTickmarks =
572
- this.DrawSmallTickmarks = function ()
573
- {
574
- var numTicks = prop['chart.tickmarks.small'];
575
- co.lineWidth = 1;
576
-
577
- for (var i=0; i<=numTicks; ++i) {
578
- co.beginPath();
579
- co.strokeStyle = prop['chart.tickmarks.small.color'];
580
- var a = (((this.endAngle - this.startAngle) / numTicks) * i) + this.startAngle;
581
- co.arc(this.centerx, this.centery, this.radius - prop['chart.border.width'] - 10, a, a + 0.00001, 0);
582
- co.arc(this.centerx, this.centery, this.radius - prop['chart.border.width'] - 10 - 5, a, a + 0.00001, 0);
583
- co.stroke();
584
- }
585
- };
586
-
587
-
588
-
589
-
590
- /**
591
- * This function draws the medium sized tickmarks
592
- */
593
- this.drawMediumTickmarks =
594
- this.DrawMediumTickmarks = function ()
595
- {
596
- if (prop['chart.tickmarks.medium']) {
597
-
598
- var numTicks = prop['chart.tickmarks.medium'];
599
- co.lineWidth = 3;
600
- co.lineCap = 'round';
601
- co.strokeStyle = prop['chart.tickmarks.medium.color'];
602
-
603
- for (var i=0; i<=numTicks; ++i) {
604
- co.beginPath();
605
- var a = (((this.endAngle - this.startAngle) / numTicks) * i) + this.startAngle + (((this.endAngle - this.startAngle) / (2 * numTicks)));
606
-
607
- if (a > this.startAngle && a< this.endAngle) {
608
- co.arc(this.centerx, this.centery, this.radius - prop['chart.border.width'] - 10, a, a + 0.00001, 0);
609
- co.arc(this.centerx, this.centery, this.radius - prop['chart.border.width'] - 10 - 6, a, a + 0.00001, 0);
610
- }
611
- co.stroke();
612
- }
613
- }
614
- };
615
-
616
-
617
-
618
-
619
- /**
620
- * This function draws the large, bold tickmarks
621
- */
622
- this.drawBigTickmarks =
623
- this.DrawBigTickmarks = function ()
624
- {
625
- var numTicks = prop['chart.tickmarks.big'];
626
- co.lineWidth = 3;
627
- co.lineCap = 'round';
628
-
629
- for (var i=0; i<=numTicks; ++i) {
630
- co.beginPath();
631
- co.strokeStyle = prop['chart.tickmarks.big.color'];
632
- var a = (((this.endAngle - this.startAngle) / numTicks) * i) + this.startAngle;
633
- co.arc(this.centerx, this.centery, this.radius - prop['chart.border.width'] - 10, a, a + 0.00001, 0);
634
- co.arc(this.centerx, this.centery, this.radius - prop['chart.border.width'] - 10 - 10, a, a + 0.00001, 0);
635
- co.stroke();
636
- }
637
- };
638
-
639
-
640
-
641
-
642
- /**
643
- * This function draws the centerpin
644
- */
645
- this.drawCenterpin =
646
- this.DrawCenterpin = function ()
647
- {
648
- var offset = 6;
649
-
650
- var grad = co.createRadialGradient(this.centerx + offset, this.centery - offset, 0, this.centerx + offset, this.centery - offset, 25);
651
- grad.addColorStop(0, '#ddf');
652
- grad.addColorStop(1, prop['chart.centerpin.color']);
653
-
654
- co.beginPath();
655
- co.fillStyle = grad;
656
- co.arc(this.centerx, this.centery, this.centerpinRadius, 0, RG.TWOPI, 0);
657
- co.fill();
658
- };
659
-
660
-
661
-
662
-
663
- /**
664
- * This function draws the labels
665
- */
666
- this.drawLabels =
667
- this.DrawLabels = function ()
668
- {
669
- co.fillStyle = prop['chart.text.color'];
670
- var font = prop['chart.text.font'];
671
- var size = prop['chart.text.size'];
672
- var num = prop['chart.labels.specific'] ? (prop['chart.labels.specific'].length - 1) : prop['chart.labels.count'];
673
-
674
- co.beginPath();
675
- if (num) {
676
- for (var i=0; i<=num; ++i) {
677
- var hyp = (this.radius - 25 - prop['chart.border.width']) - prop['chart.labels.offset'];
678
- var a = (this.endAngle - this.startAngle) / num
679
- a = this.startAngle + (i * a);
680
- a -= RG.HALFPI;
681
-
682
- var x = this.centerx - (ma.sin(a) * hyp);
683
- var y = this.centery + (ma.cos(a) * hyp);
684
-
685
- var hAlign = x > this.centerx ? 'right' : 'left';
686
- var vAlign = y > this.centery ? 'bottom' : 'top';
687
-
688
- // This handles the label alignment when the label is on a PI/HALFPI boundary
689
- if (a == RG.HALFPI) {
690
- vAlign = 'center';
691
- } else if (a == RG.PI) {
692
- hAlign = 'center';
693
- } else if (a == (RG.HALFPI + RG.PI) ) {
694
- vAlign = 'center';
695
- }
696
-
697
- /**
698
- * Can now force center alignment
699
- */
700
- if (prop['chart.labels.centered']) {
701
- hAlign = 'center';
702
- vAlign = 'center';
703
- }
704
-
705
-
706
- RG.Text2(this, {
707
- 'font':font,
708
- 'size':size,
709
- 'x':x,
710
- 'y':y,
711
- 'text':prop['chart.labels.specific'] ? prop['chart.labels.specific'][i] : RG.number_format(this, (((this.max - this.min) * (i / num)) + this.min).toFixed(prop['chart.scale.decimals']), prop['chart.units.pre'], prop['chart.units.post']),
712
- 'halign':hAlign,
713
- 'valign':vAlign,
714
- 'tag': prop['chart.labels.specific'] ? 'labels.specific' : 'labels'
715
- });
716
- }
717
- }
718
- co.fill();
719
-
720
-
721
- /**
722
- * Draw the textual value if requested
723
- */
724
- if (prop['chart.value.text']) {
725
-
726
- var x = this.centerx;
727
- var y = this.centery + (prop['chart.value.text.y.pos'] * this.radius);
728
-
729
- var units_pre = typeof(prop['chart.value.text.units.pre']) == 'string' ? prop['chart.value.text.units.pre'] : prop['chart.units.pre'];
730
- var units_post = typeof(prop['chart.value.text.units.post']) == 'string' ? prop['chart.value.text.units.post'] : prop['chart.units.post'];
731
- var color = prop['chart.value.text.color'];
732
- var bounding = prop['chart.value.text.bounding'];
733
- var boundingFill = prop['chart.value.text.bounding.fill'];
734
- var boundingStroke = prop['chart.value.text.bounding.stroke'];
735
-
736
- co.fillStyle = color;
737
-
738
- RG.text2(this, {
739
- 'font':font,
740
- 'size':size + 2,
741
- 'x':x,
742
- 'y':y,
743
- 'text':RG.numberFormat(this, this.value.toFixed(prop['chart.value.text.decimals']), units_pre, units_post),
744
- 'halign':'center',
745
- 'valign':'center',
746
- 'bounding':bounding,
747
- 'bounding.fill':boundingFill,
748
- 'bounding.stroke': boundingStroke,
749
- 'tag': 'value.text'
750
- });
751
- }
752
- };
753
-
754
-
755
-
756
-
757
- /**
758
- * This function draws the top title
759
- */
760
- this.drawTopTitle =
761
- this.DrawTopTitle = function ()
762
- {
763
- var x = this.centerx;
764
- var y = this.centery - 25;
765
-
766
- // Totally override the calculated positioning
767
- if (typeof(prop['chart.title.top.pos']) == 'number') {
768
- y = this.centery - (this.radius * prop['chart.title.top.pos']);
769
- }
770
-
771
- if (prop['chart.title.top']) {
772
- co.fillStyle = prop['chart.title.top.color'];
773
- RG.Text2(this, {'font':prop['chart.title.top.font'],
774
- 'size':prop['chart.title.top.size'],
775
- 'x':x,
776
- 'y':y,
777
- 'text':String(prop['chart.title.top']),
778
- 'halign':'center',
779
- 'valign':'bottom',
780
- 'bold':prop['chart.title.top.bold'],
781
- 'tag': 'title.top'
782
- });
783
- }
784
- };
785
-
786
-
787
-
788
-
789
- /**
790
- * This function draws the bottom title
791
- */
792
- this.drawBottomTitle =
793
- this.DrawBottomTitle = function ()
794
- {
795
- var x = this.centerx;
796
- var y = this.centery + this.centerpinRadius + 10;
797
-
798
- // Totally override the calculated positioning
799
- if (typeof(prop['chart.title.bottom.pos']) == 'number') {
800
- y = this.centery + (this.radius * prop['chart.title.bottom.pos']);
801
- }
802
-
803
- if (prop['chart.title.bottom']) {
804
- co.fillStyle = prop['chart.title.bottom.color'];
805
-
806
- RG.Text2(this, {'font':prop['chart.title.bottom.font'],
807
- 'size':prop['chart.title.bottom.size'],
808
- 'x':x,
809
- 'y':y,
810
- 'text':String(prop['chart.title.bottom']),
811
- 'halign':'center',
812
- 'valign':'top',
813
- 'bold':prop['chart.title.bottom.bold'],
814
- 'tag': 'title.bottom'
815
- });
816
- }
817
- };
818
-
819
-
820
-
821
-
822
- /**
823
- * This function draws the Needle
824
- *
825
- * @param number value The value to draw the needle for
826
- */
827
- this.drawNeedle =
828
- this.DrawNeedle = function (value, color, index)
829
- {
830
- var type = prop['chart.needle.type'];
831
-
832
- co.lineWidth = 0.5;
833
- co.strokeStyle = 'gray';
834
- co.fillStyle = color;
835
-
836
- var angle = (this.endAngle - this.startAngle) * ((value - this.min) / (this.max - this.min));
837
- angle += this.startAngle;
838
-
839
-
840
- // Work out the size of the needle
841
- if ( typeof(prop['chart.needle.size']) == 'object'
842
- && prop['chart.needle.size']
843
- && typeof(prop['chart.needle.size'][index]) == 'number') {
844
-
845
- var size = prop['chart.needle.size'][index];
846
-
847
- } else if (typeof(prop['chart.needle.size']) == 'number') {
848
- var size = prop['chart.needle.size'];
849
-
850
- } else {
851
- var size = this.radius - 25 - prop['chart.border.width'];
852
- }
853
-
854
-
855
-
856
- if (type == 'line') {
857
-
858
- co.beginPath();
859
-
860
- co.lineWidth = prop['chart.needle.width'];
861
- co.strokeStyle = color;
862
-
863
- co.arc(this.centerx,
864
- this.centery,
865
- size,
866
- angle,
867
- angle + 0.0001,
868
- false);
869
-
870
- co.lineTo(this.centerx, this.centery);
871
-
872
- if (prop['chart.needle.tail']) {
873
- co.arc(this.centerx, this.centery, this.radius * 0.2 , angle + RG.PI, angle + 0.00001 + RG.PI, false);
874
- }
875
-
876
- co.lineTo(this.centerx, this.centery);
877
-
878
- co.stroke();
879
- //co.fill();
880
-
881
- } else {
882
-
883
- co.beginPath();
884
- co.arc(this.centerx, this.centery, size, angle, angle + 0.00001, false);
885
- co.arc(this.centerx, this.centery, this.centerpinRadius * 0.5, angle + RG.HALFPI, angle + 0.00001 + RG.HALFPI, false);
886
-
887
- if (prop['chart.needle.tail']) {
888
- co.arc(this.centerx, this.centery, this.radius * 0.2 , angle + RG.PI, angle + 0.00001 + RG.PI, false);
889
- }
890
-
891
- co.arc(this.centerx, this.centery, this.centerpinRadius * 0.5, angle - RG.HALFPI, angle - 0.00001 - RG.HALFPI, false);
892
- co.stroke();
893
- co.fill();
894
-
895
- /**
896
- * Store the angle in an object variable
897
- */
898
- this.angle = angle;
899
- }
900
- };
901
-
902
-
903
-
904
-
905
- /**
906
- * This draws the green background to the tickmarks
907
- */
908
- this.drawColorBands =
909
- this.DrawColorBands = function ()
910
- {
911
- if (RG.is_array(prop['chart.colors.ranges'])) {
912
-
913
- var ranges = prop['chart.colors.ranges'];
914
-
915
- for (var i=0; i<ranges.length; ++i) {
916
-
917
- //co.strokeStyle = prop['chart.strokestyle'] ? prop['chart.strokestyle'] : ranges[i][2];
918
- co.fillStyle = ranges[i][2];
919
- co.lineWidth = 0;//prop['chart.linewidth.segments'];
920
-
921
- co.beginPath();
922
- co.arc(this.centerx,
923
- this.centery,
924
- this.radius - 10 - prop['chart.border.width'],
925
- (((ranges[i][0] - this.min) / (this.max - this.min)) * (this.endAngle - this.startAngle)) + this.startAngle,
926
- (((ranges[i][1] - this.min) / (this.max - this.min)) * (this.endAngle - this.startAngle)) + this.startAngle,
927
- false);
928
-
929
- co.arc(this.centerx,
930
- this.centery,
931
- this.radius - 20 - prop['chart.border.width'],
932
- (((ranges[i][1] - this.min) / (this.max - this.min)) * (this.endAngle - this.startAngle)) + this.startAngle,
933
- (((ranges[i][0] - this.min) / (this.max - this.min)) * (this.endAngle - this.startAngle)) + this.startAngle,
934
- true);
935
- co.closePath();
936
- co.fill();
937
- }
938
-
939
- return;
940
- }
941
-
942
-
943
-
944
-
945
- /**
946
- * Draw the GREEN region
947
- */
948
- co.strokeStyle = prop['chart.green.color'];
949
- co.fillStyle = prop['chart.green.color'];
950
-
951
- var greenStart = this.startAngle;
952
- var greenEnd = this.startAngle + (this.endAngle - this.startAngle) * ((prop['chart.green.end'] - this.min) / (this.max - this.min))
953
-
954
- co.beginPath();
955
- co.arc(this.centerx, this.centery, this.radius - 10 - prop['chart.border.width'], greenStart, greenEnd, false);
956
- co.arc(this.centerx, this.centery, this.radius - (10 + prop['chart.green.width']) - prop['chart.border.width'], greenEnd, greenStart, true);
957
- co.fill();
958
-
959
-
960
-
961
-
962
-
963
- /**
964
- * Draw the YELLOW region
965
- */
966
- co.strokeStyle = prop['chart.yellow.color'];
967
- co.fillStyle = prop['chart.yellow.color'];
968
-
969
- var yellowStart = greenEnd;
970
- var yellowEnd = this.startAngle + (this.endAngle - this.startAngle) * ((prop['chart.red.start'] - this.min) / (this.max - this.min))
971
-
972
- co.beginPath();
973
- co.arc(this.centerx, this.centery, this.radius - 10 - prop['chart.border.width'], yellowStart, yellowEnd, false);
974
- co.arc(this.centerx, this.centery, this.radius - (10 + prop['chart.yellow.width']) - prop['chart.border.width'], yellowEnd, yellowStart, true);
975
- co.fill();
976
-
977
-
978
-
979
-
980
-
981
- /**
982
- * Draw the RED region
983
- */
984
- co.strokeStyle = prop['chart.red.color'];
985
- co.fillStyle = prop['chart.red.color'];
986
-
987
- var redStart = yellowEnd;
988
- var redEnd = this.startAngle + (this.endAngle - this.startAngle) * ((this.max - this.min) / (this.max - this.min))
989
-
990
- co.beginPath();
991
- co.arc(this.centerx, this.centery, this.radius - 10 - prop['chart.border.width'], redStart, redEnd, false);
992
- co.arc(this.centerx, this.centery, this.radius - (10 + prop['chart.red.width']) - prop['chart.border.width'], redEnd, redStart, true);
993
- co.fill();
994
- };
995
-
996
-
997
-
998
-
999
- /**
1000
- * A placeholder function
1001
- *
1002
- * @param object The event object
1003
- */
1004
- this.getShape = function (e) {};
1005
-
1006
-
1007
-
1008
-
1009
- /**
1010
- * A getValue method
1011
- *
1012
- * @param object e An event object
1013
- */
1014
- this.getValue = function (e)
1015
- {
1016
- var mouseXY = RG.getMouseXY(e);
1017
- var mouseX = mouseXY[0];
1018
- var mouseY = mouseXY[1];
1019
-
1020
- var angle = RG.getAngleByXY(this.centerx, this.centery, mouseX, mouseY);
1021
-
1022
- if (angle >= 0 && angle <= RG.HALFPI) {
1023
- angle += RG.TWOPI;
1024
- }
1025
-
1026
- var value = ((angle - this.startAngle) / (this.endAngle - this.startAngle)) * (this.max - this.min);
1027
- value = value + this.min;
1028
-
1029
- if (value < this.min) {
1030
- value = this.min
1031
- }
1032
-
1033
- if (value > this.max) {
1034
- value = this.max
1035
- }
1036
-
1037
- return value;
1038
- };
1039
-
1040
-
1041
-
1042
-
1043
- /**
1044
- * The getObjectByXY() worker method. Don't call this call:
1045
- *
1046
- * RGraph.ObjectRegistry.getObjectByXY(e)
1047
- *
1048
- * @param object e The event object
1049
- */
1050
- this.getObjectByXY = function (e)
1051
- {
1052
- var mouseXY = RGraph.getMouseXY(e);
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
- && RG.getHypLength(this.centerx, this.centery, mouseXY[0], mouseXY[1]) <= this.radius
1060
- ) {
1061
-
1062
- return this;
1063
- }
1064
- };
1065
-
1066
-
1067
-
1068
-
1069
- /**
1070
- * This draws the gradient that goes around the Gauge chart
1071
- */
1072
- this.drawGradient =
1073
- this.DrawGradient = function ()
1074
- {
1075
- if (prop['chart.border.gradient']) {
1076
-
1077
- co.beginPath();
1078
-
1079
- var grad = co.createRadialGradient(this.centerx, this.centery, this.radius, this.centerx, this.centery, this.radius - 15);
1080
- grad.addColorStop(0, 'gray');
1081
- grad.addColorStop(1, 'white');
1082
-
1083
- co.fillStyle = grad;
1084
- co.arc(this.centerx, this.centery, this.radius, 0, RG.TWOPI, false)
1085
- co.arc(this.centerx, this.centery, this.radius - 15, RG.TWOPI,0, true)
1086
- co.fill();
1087
- }
1088
- };
1089
-
1090
-
1091
-
1092
-
1093
- /**
1094
- * This method handles the adjusting calculation for when the mouse is moved
1095
- *
1096
- * @param object e The event object
1097
- */
1098
- this.adjusting_mousemove =
1099
- this.Adjusting_mousemove = function (e)
1100
- {
1101
- /**
1102
- * Handle adjusting for the Bar
1103
- */
1104
- if (prop['chart.adjustable'] && RG.Registry.Get('chart.adjusting') && RG.Registry.Get('chart.adjusting').uid == this.uid) {
1105
- this.value = this.getValue(e);
1106
- //RG.Clear(this.canvas);
1107
- RG.redrawCanvas(this.canvas);
1108
- RG.fireCustomEvent(this, 'onadjust');
1109
- }
1110
- };
1111
-
1112
-
1113
-
1114
-
1115
- /**
1116
- * This method returns an appropriate angle for the given value (in RADIANS)
1117
- *
1118
- * @param number value The value to get the angle for
1119
- */
1120
- this.getAngle = function (value)
1121
- {
1122
- // Higher than max
1123
- if (value > this.max || value < this.min) {
1124
- return null;
1125
- }
1126
-
1127
- //var value = ((angle - this.startAngle) / (this.endAngle - this.startAngle)) * (this.max - this.min);
1128
- //value = value + this.min;
1129
-
1130
- var angle = (((value - this.min) / (this.max - this.min)) * (this.endAngle - this.startAngle)) + this.startAngle;
1131
-
1132
- return angle;
1133
- };
1134
-
1135
-
1136
-
1137
-
1138
- /**
1139
- * This allows for easy specification of gradients. Could optimise this not to repeatedly call parseSingleColors()
1140
- */
1141
- this.parseColors = function ()
1142
- {
1143
- // Save the original colors so that they can be restored when the canvas is reset
1144
- if (this.original_colors.length === 0) {
1145
- this.original_colors['chart.background.color'] = RG.array_clone(prop['chart.background.color']);
1146
- this.original_colors['chart.red.color'] = RG.array_clone(prop['chart.red.color']);
1147
- this.original_colors['chart.yellow.color'] = RG.array_clone(prop['chart.yellow.color']);
1148
- this.original_colors['chart.green.color'] = RG.array_clone(prop['chart.green.color']);
1149
- this.original_colors['chart.border.inner'] = RG.array_clone(prop['chart.border.inner']);
1150
- this.original_colors['chart.border.outer'] = RG.array_clone(prop['chart.border.outer']);
1151
- this.original_colors['chart.colors.ranges'] = RG.array_clone(prop['chart.colors.ranges']);
1152
- this.original_colors['chart.needle.colors'] = RG.array_clone(prop['chart.needle.colors']);
1153
- }
1154
-
1155
- prop['chart.background.color'] = this.parseSingleColorForGradient(prop['chart.background.color']);
1156
- prop['chart.red.color'] = this.parseSingleColorForGradient(prop['chart.red.color']);
1157
- prop['chart.yellow.color'] = this.parseSingleColorForGradient(prop['chart.yellow.color']);
1158
- prop['chart.green.color'] = this.parseSingleColorForGradient(prop['chart.green.color']);
1159
- prop['chart.border.inner'] = this.parseSingleColorForGradient(prop['chart.border.inner']);
1160
- prop['chart.border.outer'] = this.parseSingleColorForGradient(prop['chart.border.outer']);
1161
-
1162
- // Parse the chart.color.ranges value
1163
- if (prop['chart.colors.ranges']) {
1164
-
1165
- var ranges = prop['chart.colors.ranges'];
1166
-
1167
- for (var i=0; i<ranges.length; ++i) {
1168
- ranges[i][2] = this.parseSingleColorForGradient(ranges[i][2], this.radius - 30);
1169
- }
1170
- }
1171
-
1172
- // Parse the chart.needle.colors value
1173
- if (prop['chart.needle.colors']) {
1174
-
1175
- var colors = prop['chart.needle.colors'];
1176
-
1177
- for (var i=0; i<colors.length; ++i) {
1178
- colors[i] = this.parseSingleColorForGradient(colors[i]);
1179
- }
1180
- }
1181
- };
1182
-
1183
-
1184
-
1185
-
1186
- /**
1187
- * Use this function to reset the object to the post-constructor state. Eg reset colors if
1188
- * need be etc
1189
- */
1190
- this.reset = function ()
1191
- {
1192
- };
1193
-
1194
-
1195
-
1196
-
1197
- /**
1198
- * This parses a single color value
1199
- *
1200
- * @param string color The color to look for a gradient in
1201
- * @param radius OPTIONAL The start radius to start the gradient at.
1202
- * If not suppllied the centerx value is used
1203
- */
1204
- this.parseSingleColorForGradient = function (color)
1205
- {
1206
- var radiusStart = arguments[1] || 0;
1207
-
1208
- if (!color || typeof(color) != 'string') {
1209
- return color;
1210
- }
1211
-
1212
- if (color.match(/^gradient\((.*)\)$/i)) {
1213
-
1214
- var parts = RegExp.$1.split(':');
1215
-
1216
- // Create the gradient
1217
- var grad = co.createRadialGradient(this.centerx,
1218
- this.centery,
1219
- radiusStart,
1220
- this.centerx,
1221
- this.centery,
1222
- this.radius
1223
- );
1224
-
1225
- var diff = 1 / (parts.length - 1);
1226
-
1227
- grad.addColorStop(0, RG.trim(parts[0]));
1228
-
1229
- for (var j=1; j<parts.length; ++j) {
1230
- grad.addColorStop(j * diff, RG.trim(parts[j]));
1231
- }
1232
- }
1233
-
1234
- return grad ? grad : color;
1235
- };
1236
-
1237
-
1238
-
1239
-
1240
- /**
1241
- * Using a function to add events makes it easier to facilitate method chaining
1242
- *
1243
- * @param string type The type of even to add
1244
- * @param function func
1245
- */
1246
- this.on = function (type, func)
1247
- {
1248
- if (type.substr(0,2) !== 'on') {
1249
- type = 'on' + type;
1250
- }
1251
-
1252
- this[type] = func;
1253
-
1254
- return this;
1255
- };
1256
-
1257
-
1258
-
1259
-
1260
- /**
1261
- * This function runs once only
1262
- * (put at the end of the file (before any effects))
1263
- */
1264
- this.firstDrawFunc = function ()
1265
- {
1266
- };
1267
-
1268
-
1269
-
1270
-
1271
- /**
1272
- * Gauge Grow
1273
- *
1274
- * This effect gradually increases the represented value
1275
- *
1276
- * @param object Options for the effect. You can pass frames here
1277
- * @param function An optional callback function
1278
- */
1279
- this.grow = function ()
1280
- {
1281
- var obj = this;
1282
- var opt = arguments[0] ? arguments[0] : {};
1283
- var callback = arguments[1] ? arguments[1] : function () {};
1284
- var frames = opt.frames || 30;
1285
- var frame = 0;
1286
-
1287
- // Single pointer
1288
- if (typeof obj.value === 'number') {
1289
-
1290
- var origValue = Number(obj.currentValue);
1291
-
1292
- if (obj.currentValue == null) {
1293
- obj.currentValue = obj.min;
1294
- origValue = obj.min;
1295
- }
1296
-
1297
- var newValue = obj.value;
1298
- var diff = newValue - origValue;
1299
-
1300
-
1301
- var iterator = function ()
1302
- {
1303
- obj.value = ((frame / frames) * diff) + origValue;
1304
-
1305
- if (obj.value > obj.max) obj.value = obj.max;
1306
- if (obj.value < obj.min) obj.value = obj.min;
1307
-
1308
- //RGraph.clear(obj.canvas);
1309
- RG.redrawCanvas(obj.canvas);
1310
-
1311
- if (frame++ < frames) {
1312
- RG.Effects.updateCanvas(iterator);
1313
- } else {
1314
- callback(obj);
1315
- }
1316
- };
1317
-
1318
- iterator();
1319
-
1320
-
1321
-
1322
- /**
1323
- * Multiple pointers
1324
- */
1325
- } else {
1326
-
1327
- if (obj.currentValue == null) {
1328
- obj.currentValue = [];
1329
-
1330
- for (var i=0; i<obj.value.length; ++i) {
1331
- obj.currentValue[i] = obj.min;
1332
- }
1333
-
1334
- origValue = RG.array_clone(obj.currentValue);
1335
- }
1336
-
1337
- var origValue = RG.array_clone(obj.currentValue);
1338
- var newValue = RG.array_clone(obj.value);
1339
- var diff = [];
1340
-
1341
- for (var i=0,len=newValue.length; i<len; ++i) {
1342
- diff[i] = newValue[i] - Number(obj.currentValue[i]);
1343
- }
1344
-
1345
-
1346
-
1347
- var iterator = function ()
1348
- {
1349
- frame++;
1350
-
1351
- for (var i=0,len=obj.value.length; i<len; ++i) {
1352
-
1353
- obj.value[i] = ((frame / frames) * diff[i]) + origValue[i];
1354
-
1355
- if (obj.value[i] > obj.max) obj.value[i] = obj.max;
1356
- if (obj.value[i] < obj.min) obj.value[i] = obj.min;
1357
- }
1358
-
1359
- //RG.clear(obj.canvas);
1360
- RG.redrawCanvas(obj.canvas);
1361
-
1362
-
1363
- if (frame < frames) {
1364
- RG.Effects.updateCanvas(iterator);
1365
- } else {
1366
- callback(obj);
1367
- }
1368
- };
1369
-
1370
- iterator();
1371
- }
1372
-
1373
- return this;
1374
- };
1375
-
1376
-
1377
-
1378
- RG.att(ca);
1379
-
1380
-
1381
-
1382
-
1383
- /**
1384
- * Register the object
1385
- */
1386
- RG.Register(this);
1387
-
1388
-
1389
-
1390
-
1391
- /**
1392
- * This is the 'end' of the constructor so if the first argument
1393
- * contains configuration data - handle that.
1394
- */
1395
- if (parseConfObjectForOptions) {
1396
- RG.parseObjectStyleConfig(this, conf.options);
1397
- }
1398
- };
2
+ RGraph=window.RGraph||{isRGraph:true};RGraph.Gauge=function(conf)
3
+ {if(typeof conf==='object'&&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='gauge';this.min=RGraph.stringsToNumbers(min);this.max=RGraph.stringsToNumbers(max);this.value=RGraph.stringsToNumbers(value);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;if(typeof(this.value)=='object'){for(var i=0;i<this.value.length;++i){if(this.value[i]>this.max)this.value[i]=max;if(this.value[i]<this.min)this.value[i]=min;}}else{if(this.value>this.max)this.value=max;if(this.value<this.min)this.value=min;}
6
+ this.properties={'chart.angles.start':null,'chart.angles.end':null,'chart.centerx':null,'chart.centery':null,'chart.radius':null,'chart.gutter.left':15,'chart.gutter.right':15,'chart.gutter.top':15,'chart.gutter.bottom':15,'chart.border.width':10,'chart.title.top':'','chart.title.top.font':'Segoe UI, Arial, Verdana, sans-serif','chart.title.top.size':14,'chart.title.top.color':'#333','chart.title.top.bold':false,'chart.title.top.pos':null,'chart.title.bottom':'','chart.title.bottom.font':'Segoe UI, Arial, Verdana, sans-serif','chart.title.bottom.size':14,'chart.title.bottom.color':'#333','chart.title.bottom.bold':false,'chart.title.bottom.pos':null,'chart.text.font':'Segoe UI, Arial, Verdana, sans-serif','chart.text.color':'#666','chart.text.size':12,'chart.text.accessible':true,'chart.text.accessible.overflow':'visible','chart.text.accessible.pointerevents':true,'chart.background.color':'white','chart.background.gradient':false,'chart.scale.decimals':0,'chart.scale.point':'.','chart.scale.thousand':',','chart.units.pre':'','chart.units.post':'','chart.value.text':false,'chart.value.text.y.pos':0.5,'chart.value.text.units.pre':null,'chart.value.text.units.post':null,'chart.value.text.color':'black','chart.value.text.bounding':true,'chart.value.text.bounding.fill':'white','chart.value.text.bounding.stroke':'black','chart.red.start':0.9*this.max,'chart.red.color':'#DC3912','chart.red.width':10,'chart.yellow.color':'#FF9900','chart.yellow.width':10,'chart.green.end':0.7*this.max,'chart.green.color':'rgba(0,0,0,0)','chart.green.width':10,'chart.colors.ranges':null,'chart.needle.size':null,'chart.needle.tail':false,'chart.needle.colors':['#D5604D','red','green','yellow'],'chart.needle.type':'triangle','chart.needle.width':7,'chart.border.outer':'#ccc','chart.border.inner':'#f1f1f1','chart.border.outline':'black','chart.centerpin.color':'blue','chart.centerpin.radius':null,'chart.zoom.background':true,'chart.zoom.action':'zoom','chart.tickmarks.small':25,'chart.tickmarks.small.color':'black','chart.tickmarks.medium':0,'chart.tickmarks.medium.color':'black','chart.tickmarks.big':5,'chart.tickmarks.big.color':'black','chart.labels.count':5,'chart.labels.centered':false,'chart.labels.offset.radius':0,'chart.labels.offset.angle':0,'chart.labels.specific':null,'chart.labels.offsetx':0,'chart.labels.offsety':0,'chart.border.gradient':false,'chart.adjustable':false,'chart.shadow':true,'chart.shadow.color':'gray','chart.shadow.offsetx':0,'chart.shadow.offsety':0,'chart.shadow.blur':15,'chart.clearto':'rgba(0,0,0,0)'}
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=typeof arguments[1]==='undefined'?null:arguments[1];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.title')name='chart.title.top';if(name=='chart.title.font')name='chart.title.top.font';if(name=='chart.title.size')name='chart.title.top.size';if(name=='chart.title.color')name='chart.title.top.color';if(name=='chart.title.bold')name='chart.title.top.bold';if(name=='chart.needle.color'){name='chart.needle.colors';}
15
+ if(name=='chart.labels.offset'){name='chart.labels.offset.radius';}
16
+ prop[name]=value;return this;};this.get=this.Get=function(name)
17
+ {if(name.substr(0,6)!='chart.'){name='chart.'+name;}
18
+ while(name.match(/([A-Z])/)){name=name.replace(/([A-Z])/,'.'+RegExp.$1.toLowerCase());}
19
+ if(name=='chart.needle.color'){name='chart.needle.colors';}
20
+ if(name=='chart.labels.offset'){name='chart.labels.offset.radius';}
21
+ return prop[name];};this.draw=this.Draw=function()
22
+ {RG.FireCustomEvent(this,'onbeforedraw');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.gutterTop-this.gutterBottom)/2)+this.gutterTop;this.radius=Math.min(((ca.width-this.gutterLeft-this.gutterRight)/2),((ca.height-this.gutterTop-this.gutterBottom)/2));this.startAngle=prop['chart.angles.start']?prop['chart.angles.start']:(RG.HALFPI/3)+RG.HALFPI;this.endAngle=prop['chart.angles.end']?prop['chart.angles.end']:RG.TWOPI+RG.HALFPI-(RG.HALFPI/3);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;}
23
+ this.centerpinRadius=0.16*this.radius;if(typeof(prop['chart.centerpin.radius'])=='number'){this.centerpinRadius=prop['chart.centerpin.radius'];}
24
+ if(prop['chart.contextmenu']){RG.ShowContext(this);}
25
+ this.DrawBackGround();this.DrawGradient();this.DrawColorBands();this.DrawSmallTickmarks();this.DrawMediumTickmarks();this.DrawBigTickmarks();this.DrawLabels();this.DrawTopTitle();this.DrawBottomTitle();if(typeof(this.value)=='object'){for(var i=0;i<this.value.length;++i){this.DrawNeedle(this.value[i],prop['chart.needle.colors'][i],i);}}else{this.DrawNeedle(this.value,prop['chart.needle.colors'][0],0);}
26
+ this.DrawCenterpin();if(prop['chart.resizable']){RG.AllowResizing(this);}
27
+ RG.InstallEventListeners(this);if(this.firstDraw){RG.fireCustomEvent(this,'onfirstdraw');this.firstDraw=false;this.firstDrawFunc();}
28
+ RG.FireCustomEvent(this,'ondraw');return this;};this.exec=function(func)
29
+ {func(this);return this;};this.drawBackGround=this.DrawBackGround=function()
30
+ {if(prop['chart.shadow']){RG.SetShadow(this,prop['chart.shadow.color'],prop['chart.shadow.offsetx'],prop['chart.shadow.offsety'],prop['chart.shadow.blur']);}
31
+ co.beginPath();co.fillStyle=prop['chart.background.color'];co.arc(this.centerx,this.centery,this.radius,0,RG.TWOPI,0);co.fill();RG.NoShadow(this);var grad=co.createRadialGradient(this.centerx+50,this.centery-50,0,this.centerx+50,this.centery-50,150);grad.addColorStop(0,'#eee');grad.addColorStop(1,'white');var borderWidth=prop['chart.border.width'];co.beginPath();co.fillStyle=prop['chart.background.color'];co.arc(this.centerx,this.centery,this.radius,0,RG.TWOPI,0);co.fill();co.beginPath();co.fillStyle=prop['chart.border.outer'];co.arc(this.centerx,this.centery,this.radius,0,RG.TWOPI,0);co.fill();co.beginPath();co.fillStyle=prop['chart.border.inner'];co.arc(this.centerx,this.centery,this.radius-borderWidth,0,RG.TWOPI,0);co.fill();co.beginPath();co.fillStyle=prop['chart.background.color'];co.arc(this.centerx,this.centery,this.radius-borderWidth-4,0,RG.TWOPI,0);co.fill();co.beginPath();co.fillStyle=prop['chart.background.color'];co.arc(this.centerx,this.centery,this.radius-borderWidth-4,0,RG.TWOPI,0);co.fill();if(prop['chart.background.gradient']){co.beginPath();co.fillStyle=RG.RadialGradient(this,this.centerx,this.centery,0,this.centerx,this.centery,this.radius,'rgba(255,255,255,0.6)','rgba(255,255,255,0.1)');co.arc(this.centerx,this.centery,this.radius-borderWidth-4,0,RG.TWOPI,0);co.fill();}
32
+ co.beginPath();co.strokeStyle=prop['chart.border.outline'];co.arc(this.centerx,this.centery,this.radius,0,RG.TWOPI,0);co.stroke();};this.drawSmallTickmarks=this.DrawSmallTickmarks=function()
33
+ {var numTicks=prop['chart.tickmarks.small'];co.lineWidth=1;for(var i=0;i<=numTicks;++i){co.beginPath();co.strokeStyle=prop['chart.tickmarks.small.color'];var a=(((this.endAngle-this.startAngle)/numTicks)*i)+this.startAngle;co.arc(this.centerx,this.centery,this.radius-prop['chart.border.width']-10,a,a+0.00001,0);co.arc(this.centerx,this.centery,this.radius-prop['chart.border.width']-10-5,a,a+0.00001,0);co.stroke();}};this.drawMediumTickmarks=this.DrawMediumTickmarks=function()
34
+ {if(prop['chart.tickmarks.medium']){var numTicks=prop['chart.tickmarks.medium'];co.lineWidth=3;co.lineCap='round';co.strokeStyle=prop['chart.tickmarks.medium.color'];for(var i=0;i<=numTicks;++i){co.beginPath();var a=(((this.endAngle-this.startAngle)/numTicks)*i)+this.startAngle+(((this.endAngle-this.startAngle)/(2*numTicks)));if(a>this.startAngle&&a<this.endAngle){co.arc(this.centerx,this.centery,this.radius-prop['chart.border.width']-10,a,a+0.00001,0);co.arc(this.centerx,this.centery,this.radius-prop['chart.border.width']-10-6,a,a+0.00001,0);}
35
+ co.stroke();}}};this.drawBigTickmarks=this.DrawBigTickmarks=function()
36
+ {var numTicks=prop['chart.tickmarks.big'];co.lineWidth=3;co.lineCap='round';for(var i=0;i<=numTicks;++i){co.beginPath();co.strokeStyle=prop['chart.tickmarks.big.color'];var a=(((this.endAngle-this.startAngle)/numTicks)*i)+this.startAngle;co.arc(this.centerx,this.centery,this.radius-prop['chart.border.width']-10,a,a+0.00001,0);co.arc(this.centerx,this.centery,this.radius-prop['chart.border.width']-10-10,a,a+0.00001,0);co.stroke();}};this.drawCenterpin=this.DrawCenterpin=function()
37
+ {var offset=6;var grad=co.createRadialGradient(this.centerx+offset,this.centery-offset,0,this.centerx+offset,this.centery-offset,25);grad.addColorStop(0,'#ddf');grad.addColorStop(1,prop['chart.centerpin.color']);co.beginPath();co.fillStyle=grad;co.arc(this.centerx,this.centery,this.centerpinRadius,0,RG.TWOPI,0);co.fill();};this.drawLabels=this.DrawLabels=function()
38
+ {co.fillStyle=prop['chart.text.color'];var font=prop['chart.text.font'],size=prop['chart.text.size'],num=prop['chart.labels.specific']?(prop['chart.labels.specific'].length-1):prop['chart.labels.count'],offsetx=prop['chart.labels.offsetx'],offsety=prop['chart.labels.offsety'],offseta=prop['chart.labels.offset.angle']
39
+ co.beginPath();if(num){for(var i=0;i<=num;++i){var hyp=(this.radius-25-prop['chart.border.width'])-prop['chart.labels.offset.radius'];var a=(this.endAngle-this.startAngle)/num
40
+ a=this.startAngle+(i*a);a-=RG.HALFPI;a+=offseta;var x=this.centerx-(ma.sin(a)*hyp);var y=this.centery+(ma.cos(a)*hyp);var hAlign=x>this.centerx?'right':'left';var vAlign=y>this.centery?'bottom':'top';if(a==RG.HALFPI){vAlign='center';}else if(a==RG.PI){hAlign='center';}else if(a==(RG.HALFPI+RG.PI)){vAlign='center';}
41
+ if(prop['chart.labels.centered']){hAlign='center';vAlign='center';}
42
+ var value=(((this.max-this.min)*(i/num))+this.min);RG.text2(this,{'font':font,'size':size,'x':x+offsetx,'y':y+offsety,'text':prop['chart.labels.specific']?prop['chart.labels.specific'][i]:RG.numberFormat(this,value.toFixed(value===0?0:prop['chart.scale.decimals']),prop['chart.units.pre'],prop['chart.units.post']),'halign':hAlign,'valign':vAlign,'tag':prop['chart.labels.specific']?'labels.specific':'labels'});}}
43
+ co.fill();if(prop['chart.value.text']){var x=this.centerx;var y=this.centery+(prop['chart.value.text.y.pos']*this.radius);var units_pre=typeof(prop['chart.value.text.units.pre'])=='string'?prop['chart.value.text.units.pre']:prop['chart.units.pre'];var units_post=typeof(prop['chart.value.text.units.post'])=='string'?prop['chart.value.text.units.post']:prop['chart.units.post'];var color=prop['chart.value.text.color'];var bounding=prop['chart.value.text.bounding'];var boundingFill=prop['chart.value.text.bounding.fill'];var boundingStroke=prop['chart.value.text.bounding.stroke'];co.fillStyle=color;RG.text2(this,{'font':font,'size':size+2,'x':x,'y':y,'text':RG.numberFormat(this,this.value.toFixed(prop['chart.value.text.decimals']),units_pre,units_post),'halign':'center','valign':'center','bounding':bounding,'bounding.fill':boundingFill,'bounding.stroke':boundingStroke,'tag':'value.text'});}};this.drawTopTitle=this.DrawTopTitle=function()
44
+ {var x=this.centerx;var y=this.centery-25;if(typeof(prop['chart.title.top.pos'])=='number'){y=this.centery-(this.radius*prop['chart.title.top.pos']);}
45
+ if(prop['chart.title.top']){co.fillStyle=prop['chart.title.top.color'];RG.Text2(this,{'font':prop['chart.title.top.font'],'size':prop['chart.title.top.size'],'x':x,'y':y,'text':String(prop['chart.title.top']),'halign':'center','valign':'bottom','bold':prop['chart.title.top.bold'],'tag':'title.top'});}};this.drawBottomTitle=this.DrawBottomTitle=function()
46
+ {var x=this.centerx;var y=this.centery+this.centerpinRadius+10;if(typeof(prop['chart.title.bottom.pos'])=='number'){y=this.centery+(this.radius*prop['chart.title.bottom.pos']);}
47
+ if(prop['chart.title.bottom']){co.fillStyle=prop['chart.title.bottom.color'];RG.Text2(this,{'font':prop['chart.title.bottom.font'],'size':prop['chart.title.bottom.size'],'x':x,'y':y,'text':String(prop['chart.title.bottom']),'halign':'center','valign':'top','bold':prop['chart.title.bottom.bold'],'tag':'title.bottom'});}};this.drawNeedle=this.DrawNeedle=function(value,color,index)
48
+ {var type=prop['chart.needle.type'];co.lineWidth=0.5;co.strokeStyle='gray';co.fillStyle=color;var angle=(this.endAngle-this.startAngle)*((value-this.min)/(this.max-this.min));angle+=this.startAngle;if(typeof(prop['chart.needle.size'])=='object'&&prop['chart.needle.size']&&typeof(prop['chart.needle.size'][index])=='number'){var size=prop['chart.needle.size'][index];}else if(typeof(prop['chart.needle.size'])=='number'){var size=prop['chart.needle.size'];}else{var size=this.radius-25-prop['chart.border.width'];}
49
+ if(type=='line'){co.beginPath();co.lineWidth=prop['chart.needle.width'];co.strokeStyle=color;co.arc(this.centerx,this.centery,size,angle,angle+0.0001,false);co.lineTo(this.centerx,this.centery);if(prop['chart.needle.tail']){co.arc(this.centerx,this.centery,this.radius*0.2,angle+RG.PI,angle+0.00001+RG.PI,false);}
50
+ co.lineTo(this.centerx,this.centery);co.stroke();}else{co.beginPath();co.arc(this.centerx,this.centery,size,angle,angle+0.00001,false);co.arc(this.centerx,this.centery,this.centerpinRadius*0.5,angle+RG.HALFPI,angle+0.00001+RG.HALFPI,false);if(prop['chart.needle.tail']){co.arc(this.centerx,this.centery,this.radius*0.2,angle+RG.PI,angle+0.00001+RG.PI,false);}
51
+ co.arc(this.centerx,this.centery,this.centerpinRadius*0.5,angle-RG.HALFPI,angle-0.00001-RG.HALFPI,false);co.stroke();co.fill();this.angle=angle;}};this.drawColorBands=this.DrawColorBands=function()
52
+ {if(RG.is_array(prop['chart.colors.ranges'])){var ranges=prop['chart.colors.ranges'];for(var i=0;i<ranges.length;++i){co.fillStyle=ranges[i][2];co.lineWidth=0;co.beginPath();co.arc(this.centerx,this.centery,this.radius-10-prop['chart.border.width'],(((ranges[i][0]-this.min)/(this.max-this.min))*(this.endAngle-this.startAngle))+this.startAngle,(((ranges[i][1]-this.min)/(this.max-this.min))*(this.endAngle-this.startAngle))+this.startAngle,false);co.arc(this.centerx,this.centery,this.radius-20-prop['chart.border.width'],(((ranges[i][1]-this.min)/(this.max-this.min))*(this.endAngle-this.startAngle))+this.startAngle,(((ranges[i][0]-this.min)/(this.max-this.min))*(this.endAngle-this.startAngle))+this.startAngle,true);co.closePath();co.fill();}
53
+ return;}
54
+ co.strokeStyle=prop['chart.green.color'];co.fillStyle=prop['chart.green.color'];var greenStart=this.startAngle;var greenEnd=this.startAngle+(this.endAngle-this.startAngle)*((prop['chart.green.end']-this.min)/(this.max-this.min))
55
+ co.beginPath();co.arc(this.centerx,this.centery,this.radius-10-prop['chart.border.width'],greenStart,greenEnd,false);co.arc(this.centerx,this.centery,this.radius-(10+prop['chart.green.width'])-prop['chart.border.width'],greenEnd,greenStart,true);co.fill();co.strokeStyle=prop['chart.yellow.color'];co.fillStyle=prop['chart.yellow.color'];var yellowStart=greenEnd;var yellowEnd=this.startAngle+(this.endAngle-this.startAngle)*((prop['chart.red.start']-this.min)/(this.max-this.min))
56
+ co.beginPath();co.arc(this.centerx,this.centery,this.radius-10-prop['chart.border.width'],yellowStart,yellowEnd,false);co.arc(this.centerx,this.centery,this.radius-(10+prop['chart.yellow.width'])-prop['chart.border.width'],yellowEnd,yellowStart,true);co.fill();co.strokeStyle=prop['chart.red.color'];co.fillStyle=prop['chart.red.color'];var redStart=yellowEnd;var redEnd=this.startAngle+(this.endAngle-this.startAngle)*((this.max-this.min)/(this.max-this.min))
57
+ co.beginPath();co.arc(this.centerx,this.centery,this.radius-10-prop['chart.border.width'],redStart,redEnd,false);co.arc(this.centerx,this.centery,this.radius-(10+prop['chart.red.width'])-prop['chart.border.width'],redEnd,redStart,true);co.fill();};this.getShape=function(e){};this.getValue=function(e)
58
+ {var mouseXY=RG.getMouseXY(e);var mouseX=mouseXY[0];var mouseY=mouseXY[1];var angle=RG.getAngleByXY(this.centerx,this.centery,mouseX,mouseY);if(angle>=0&&angle<=RG.HALFPI){angle+=RG.TWOPI;}
59
+ var value=((angle-this.startAngle)/(this.endAngle-this.startAngle))*(this.max-this.min);value=value+this.min;if(value<this.min){value=this.min}
60
+ if(value>this.max){value=this.max}
61
+ return value;};this.getObjectByXY=function(e)
62
+ {var mouseXY=RGraph.getMouseXY(e);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)&&RG.getHypLength(this.centerx,this.centery,mouseXY[0],mouseXY[1])<=this.radius){return this;}};this.drawGradient=this.DrawGradient=function()
63
+ {if(prop['chart.border.gradient']){co.beginPath();var grad=co.createRadialGradient(this.centerx,this.centery,this.radius,this.centerx,this.centery,this.radius-15);grad.addColorStop(0,'gray');grad.addColorStop(1,'white');co.fillStyle=grad;co.arc(this.centerx,this.centery,this.radius,0,RG.TWOPI,false)
64
+ co.arc(this.centerx,this.centery,this.radius-15,RG.TWOPI,0,true)
65
+ co.fill();}};this.adjusting_mousemove=this.Adjusting_mousemove=function(e)
66
+ {if(prop['chart.adjustable']&&RG.Registry.Get('chart.adjusting')&&RG.Registry.Get('chart.adjusting').uid==this.uid){this.value=this.getValue(e);RG.redrawCanvas(this.canvas);RG.fireCustomEvent(this,'onadjust');}};this.getAngle=function(value)
67
+ {if(value>this.max||value<this.min){return null;}
68
+ var angle=(((value-this.min)/(this.max-this.min))*(this.endAngle-this.startAngle))+this.startAngle;return angle;};this.parseColors=function()
69
+ {if(this.original_colors.length===0){this.original_colors['chart.background.color']=RG.array_clone(prop['chart.background.color']);this.original_colors['chart.red.color']=RG.array_clone(prop['chart.red.color']);this.original_colors['chart.yellow.color']=RG.array_clone(prop['chart.yellow.color']);this.original_colors['chart.green.color']=RG.array_clone(prop['chart.green.color']);this.original_colors['chart.border.inner']=RG.array_clone(prop['chart.border.inner']);this.original_colors['chart.border.outer']=RG.array_clone(prop['chart.border.outer']);this.original_colors['chart.colors.ranges']=RG.array_clone(prop['chart.colors.ranges']);this.original_colors['chart.needle.colors']=RG.array_clone(prop['chart.needle.colors']);}
70
+ prop['chart.background.color']=this.parseSingleColorForGradient(prop['chart.background.color']);prop['chart.red.color']=this.parseSingleColorForGradient(prop['chart.red.color']);prop['chart.yellow.color']=this.parseSingleColorForGradient(prop['chart.yellow.color']);prop['chart.green.color']=this.parseSingleColorForGradient(prop['chart.green.color']);prop['chart.border.inner']=this.parseSingleColorForGradient(prop['chart.border.inner']);prop['chart.border.outer']=this.parseSingleColorForGradient(prop['chart.border.outer']);if(prop['chart.colors.ranges']){var ranges=prop['chart.colors.ranges'];for(var i=0;i<ranges.length;++i){ranges[i][2]=this.parseSingleColorForGradient(ranges[i][2],this.radius-30);}}
71
+ if(prop['chart.needle.colors']){var colors=prop['chart.needle.colors'];for(var i=0;i<colors.length;++i){colors[i]=this.parseSingleColorForGradient(colors[i]);}}};this.reset=function()
72
+ {};this.parseSingleColorForGradient=function(color)
73
+ {var radiusStart=arguments[1]||0;if(!color||typeof(color)!='string'){return color;}
74
+ if(color.match(/^gradient\((.*)\)$/i)){var parts=RegExp.$1.split(':');var grad=co.createRadialGradient(this.centerx,this.centery,radiusStart,this.centerx,this.centery,this.radius);var diff=1/(parts.length-1);grad.addColorStop(0,RG.trim(parts[0]));for(var j=1;j<parts.length;++j){grad.addColorStop(j*diff,RG.trim(parts[j]));}}
75
+ return grad?grad:color;};this.on=function(type,func)
76
+ {if(type.substr(0,2)!=='on'){type='on'+type;}
77
+ if(typeof this[type]!=='function'){this[type]=func;}else{RG.addCustomEventListener(this,type,func);}
78
+ return this;};this.firstDrawFunc=function()
79
+ {};this.grow=function()
80
+ {var obj=this;var opt=arguments[0]?arguments[0]:{};var callback=arguments[1]?arguments[1]:function(){};var frames=opt.frames||30;var frame=0;if(typeof obj.value==='number'){var origValue=Number(obj.currentValue);if(obj.currentValue==null){obj.currentValue=obj.min;origValue=obj.min;}
81
+ var newValue=obj.value;var diff=newValue-origValue;var iterator=function()
82
+ {obj.value=((frame/frames)*diff)+origValue;if(obj.value>obj.max)obj.value=obj.max;if(obj.value<obj.min)obj.value=obj.min;RG.redrawCanvas(obj.canvas);if(frame++<frames){RG.Effects.updateCanvas(iterator);}else{callback(obj);}};iterator();}else{if(obj.currentValue==null){obj.currentValue=[];for(var i=0;i<obj.value.length;++i){obj.currentValue[i]=obj.min;}
83
+ origValue=RG.array_clone(obj.currentValue);}
84
+ var origValue=RG.array_clone(obj.currentValue);var newValue=RG.array_clone(obj.value);var diff=[];for(var i=0,len=newValue.length;i<len;++i){diff[i]=newValue[i]-Number(obj.currentValue[i]);}
85
+ var iterator=function()
86
+ {frame++;for(var i=0,len=obj.value.length;i<len;++i){obj.value[i]=((frame/frames)*diff[i])+origValue[i];if(obj.value[i]>obj.max)obj.value[i]=obj.max;if(obj.value[i]<obj.min)obj.value[i]=obj.min;}
87
+ RG.redrawCanvas(obj.canvas);if(frame<frames){RG.Effects.updateCanvas(iterator);}else{callback(obj);}};iterator();}
88
+ return this;};RG.att(ca);RG.Register(this);if(parseConfObjectForOptions){RG.parseObjectStyleConfig(this,conf.options);}};