rgraph-rails 1.0.1

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 (74) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +9 -0
  3. data/.rspec +2 -0
  4. data/.travis.yml +4 -0
  5. data/CODE_OF_CONDUCT.md +13 -0
  6. data/Gemfile +4 -0
  7. data/README.md +73 -0
  8. data/Rakefile +6 -0
  9. data/bin/console +14 -0
  10. data/bin/setup +7 -0
  11. data/lib/rgraph-rails/version.rb +3 -0
  12. data/lib/rgraph-rails.rb +8 -0
  13. data/license.txt +19 -0
  14. data/rgraph-rails.gemspec +26 -0
  15. data/vendor/assets/images/bg.png +0 -0
  16. data/vendor/assets/images/bullet.png +0 -0
  17. data/vendor/assets/images/facebook-large.png +0 -0
  18. data/vendor/assets/images/google-plus-large.png +0 -0
  19. data/vendor/assets/images/logo.png +0 -0
  20. data/vendor/assets/images/meter-image-sd-needle.png +0 -0
  21. data/vendor/assets/images/meter-image-sd.png +0 -0
  22. data/vendor/assets/images/meter-sketch-needle.png +0 -0
  23. data/vendor/assets/images/meter-sketch.png +0 -0
  24. data/vendor/assets/images/odometer-background.png +0 -0
  25. data/vendor/assets/images/rgraph.jpg +0 -0
  26. data/vendor/assets/images/title.png +0 -0
  27. data/vendor/assets/images/twitter-large.png +0 -0
  28. data/vendor/assets/javascripts/RGraph.bar.js +3246 -0
  29. data/vendor/assets/javascripts/RGraph.bipolar.js +2003 -0
  30. data/vendor/assets/javascripts/RGraph.common.annotate.js +399 -0
  31. data/vendor/assets/javascripts/RGraph.common.context.js +600 -0
  32. data/vendor/assets/javascripts/RGraph.common.core.js +4751 -0
  33. data/vendor/assets/javascripts/RGraph.common.csv.js +275 -0
  34. data/vendor/assets/javascripts/RGraph.common.deprecated.js +454 -0
  35. data/vendor/assets/javascripts/RGraph.common.dynamic.js +1194 -0
  36. data/vendor/assets/javascripts/RGraph.common.effects.js +1524 -0
  37. data/vendor/assets/javascripts/RGraph.common.key.js +735 -0
  38. data/vendor/assets/javascripts/RGraph.common.resizing.js +550 -0
  39. data/vendor/assets/javascripts/RGraph.common.tooltips.js +605 -0
  40. data/vendor/assets/javascripts/RGraph.common.zoom.js +223 -0
  41. data/vendor/assets/javascripts/RGraph.drawing.background.js +636 -0
  42. data/vendor/assets/javascripts/RGraph.drawing.circle.js +579 -0
  43. data/vendor/assets/javascripts/RGraph.drawing.image.js +810 -0
  44. data/vendor/assets/javascripts/RGraph.drawing.marker1.js +710 -0
  45. data/vendor/assets/javascripts/RGraph.drawing.marker2.js +672 -0
  46. data/vendor/assets/javascripts/RGraph.drawing.marker3.js +568 -0
  47. data/vendor/assets/javascripts/RGraph.drawing.poly.js +623 -0
  48. data/vendor/assets/javascripts/RGraph.drawing.rect.js +603 -0
  49. data/vendor/assets/javascripts/RGraph.drawing.text.js +648 -0
  50. data/vendor/assets/javascripts/RGraph.drawing.xaxis.js +815 -0
  51. data/vendor/assets/javascripts/RGraph.drawing.yaxis.js +860 -0
  52. data/vendor/assets/javascripts/RGraph.fuel.js +965 -0
  53. data/vendor/assets/javascripts/RGraph.funnel.js +988 -0
  54. data/vendor/assets/javascripts/RGraph.gantt.js +1242 -0
  55. data/vendor/assets/javascripts/RGraph.gauge.js +1391 -0
  56. data/vendor/assets/javascripts/RGraph.hbar.js +1794 -0
  57. data/vendor/assets/javascripts/RGraph.hprogress.js +1307 -0
  58. data/vendor/assets/javascripts/RGraph.line.js +3940 -0
  59. data/vendor/assets/javascripts/RGraph.meter.js +1242 -0
  60. data/vendor/assets/javascripts/RGraph.modaldialog.js +292 -0
  61. data/vendor/assets/javascripts/RGraph.odo.js +1265 -0
  62. data/vendor/assets/javascripts/RGraph.pie.js +1979 -0
  63. data/vendor/assets/javascripts/RGraph.radar.js +1840 -0
  64. data/vendor/assets/javascripts/RGraph.rose.js +1860 -0
  65. data/vendor/assets/javascripts/RGraph.rscatter.js +1332 -0
  66. data/vendor/assets/javascripts/RGraph.scatter.js +3029 -0
  67. data/vendor/assets/javascripts/RGraph.thermometer.js +1131 -0
  68. data/vendor/assets/javascripts/RGraph.vprogress.js +1326 -0
  69. data/vendor/assets/javascripts/RGraph.waterfall.js +1252 -0
  70. data/vendor/assets/javascripts/financial-data.js +1067 -0
  71. data/vendor/assets/stylesheets/ModalDialog.css +90 -0
  72. data/vendor/assets/stylesheets/animations.css +3347 -0
  73. data/vendor/assets/stylesheets/website.css +402 -0
  74. metadata +175 -0
@@ -0,0 +1,710 @@
1
+ // version: 2015-11-02
2
+ /**
3
+ * o--------------------------------------------------------------------------------o
4
+ * | This file is part of the RGraph package - you can learn more at: |
5
+ * | |
6
+ * | http://www.rgraph.net |
7
+ * | |
8
+ * | RGraph is 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
+
16
+ /**
17
+ * Having this here means that the RGraph libraries can be included in any order, instead of you having
18
+ * to include the common core library first.
19
+ */
20
+
21
+ // Define the RGraph global variable
22
+ RGraph = window.RGraph || {isRGraph: true};
23
+ RGraph.Drawing = RGraph.Drawing || {};
24
+
25
+ /**
26
+ * The constructor. This function sets up the object. It takes the ID (the HTML attribute) of the canvas as the
27
+ * first argument and the data as the second. If you need to change this, you can.
28
+ *
29
+ * @param string id The canvas tag ID
30
+ * @param number x The X position of the label
31
+ * @param number y The Y position of the label
32
+ * @param number text The text used - should be a single character (unless you've significantly increased
33
+ * the size of the marker.
34
+ */
35
+ RGraph.Drawing.Marker1 = function (conf)
36
+ {
37
+ /**
38
+ * Allow for object config style
39
+ */
40
+ if ( typeof conf === 'object'
41
+ && typeof conf.x === 'number'
42
+ && typeof conf.y === 'number'
43
+ && typeof conf.radius == 'number'
44
+ && typeof conf.id === 'string'
45
+ && typeof conf.text === 'string') {
46
+
47
+ var id = conf.id
48
+ var canvas = document.getElementById(id);
49
+ var x = conf.x;
50
+ var y = conf.y;
51
+ var radius = conf.radius;
52
+ var text = conf.text;
53
+ var parseConfObjectForOptions = true; // Set this so the config is parsed (at the end of the constructor)
54
+
55
+ } else {
56
+
57
+ var id = conf;
58
+ var canvas = document.getElementById(id);
59
+ var x = arguments[1];
60
+ var y = arguments[2];
61
+ var radius = arguments[3];
62
+ var text = arguments[4];
63
+ }
64
+
65
+
66
+
67
+
68
+ // id, x, y, radius, text)
69
+ this.id = id;
70
+ this.canvas = canvas;
71
+ this.context = this.canvas.getContext("2d");
72
+ this.colorsParsed = false;
73
+ this.canvas.__object__ = this;
74
+ this.original_colors = [];
75
+ this.firstDraw = true; // After the first draw this will be false
76
+
77
+
78
+ /**
79
+ * Store the properties
80
+ */
81
+ this.centerx = x;
82
+ this.centery = y;
83
+ this.radius = radius;
84
+ this.text = text;
85
+
86
+
87
+ /**
88
+ * This defines the type of this shape
89
+ */
90
+ this.type = 'drawing.marker1';
91
+
92
+
93
+ /**
94
+ * This facilitates easy object identification, and should always be true
95
+ */
96
+ this.isRGraph = true;
97
+
98
+
99
+ /**
100
+ * This adds a uid to the object that you can use for identification purposes
101
+ */
102
+ this.uid = RGraph.CreateUID();
103
+
104
+
105
+ /**
106
+ * This adds a UID to the canvas for identification purposes
107
+ */
108
+ this.canvas.uid = this.canvas.uid ? this.canvas.uid : RGraph.CreateUID();
109
+
110
+
111
+ /**
112
+ * Some example background properties
113
+ */
114
+ this.properties =
115
+ {
116
+ 'chart.strokestyle': 'black',
117
+ 'chart.fillstyle': 'white',
118
+ 'chart.linewidth': 2,
119
+ 'chart.text.color': 'black',
120
+ 'chart.text.size': 12,
121
+ 'chart.text.font': 'Arial',
122
+ 'chart.events.click': null,
123
+ 'chart.events.mousemove': null,
124
+ 'chart.shadow': true,
125
+ 'chart.shadow.color': '#aaa',
126
+ 'chart.shadow.offsetx': 0,
127
+ 'chart.shadow.offsety': 0,
128
+ 'chart.shadow.blur': 15,
129
+ 'chart.highlight.stroke': 'rgba(0,0,0,0)',
130
+ 'chart.highlight.fill': 'rgba(255,0,0,0.7)',
131
+ 'chart.tooltips': null,
132
+ 'chart.tooltips.highlight': true,
133
+ 'chart.tooltips.event': 'onclick',
134
+ 'chart.align': 'center'
135
+ }
136
+
137
+ /**
138
+ * A simple check that the browser has canvas support
139
+ */
140
+ if (!this.canvas) {
141
+ alert('[DRAWING.MARKER1] No canvas support');
142
+ return;
143
+ }
144
+
145
+
146
+ /**
147
+ * Create the dollar object so that functions can be added to them
148
+ */
149
+ this.$0 = {};
150
+
151
+
152
+ /**
153
+ * Arrays that store the coordinates
154
+ */
155
+ this.coords = [];
156
+ this.coordsText = [];
157
+
158
+
159
+
160
+ /**
161
+ * Translate half a pixel for antialiasing purposes - but only if it hasn't beeen
162
+ * done already
163
+ */
164
+ if (!this.canvas.__rgraph_aa_translated__) {
165
+ this.context.translate(0.5,0.5);
166
+
167
+ this.canvas.__rgraph_aa_translated__ = true;
168
+ }
169
+
170
+
171
+
172
+
173
+
174
+ // Short variable names
175
+ var RG = RGraph,
176
+ ca = this.canvas,
177
+ co = ca.getContext('2d'),
178
+ prop = this.properties,
179
+ pa = RG.Path,
180
+ pa2 = RG.path2,
181
+ win = window,
182
+ doc = document,
183
+ ma = Math
184
+
185
+
186
+
187
+ /**
188
+ * "Decorate" the object with the generic effects if the effects library has been included
189
+ */
190
+ if (RG.Effects && typeof RG.Effects.decorate === 'function') {
191
+ RG.Effects.decorate(this);
192
+ }
193
+
194
+
195
+
196
+
197
+ /**
198
+ * A setter method for setting graph properties. It can be used like this: obj.Set('chart.strokestyle', '#666');
199
+ *
200
+ * @param name string The name of the property to set
201
+ * @param value mixed The value of the property
202
+ */
203
+ this.set =
204
+ this.Set = function (name)
205
+ {
206
+ var value = typeof arguments[1] === 'undefined' ? null : arguments[1];
207
+
208
+ /**
209
+ * the number of arguments is only one and it's an
210
+ * object - parse it for configuration data and return.
211
+ */
212
+ if (arguments.length === 1 && typeof name === 'object') {
213
+ RG.parseObjectStyleConfig(this, name);
214
+ return this;
215
+ }
216
+
217
+
218
+
219
+
220
+
221
+ /**
222
+ * This should be done first - prepend the propertyy name with "chart." if necessary
223
+ */
224
+ if (name.substr(0,6) != 'chart.') {
225
+ name = 'chart.' + name;
226
+ }
227
+
228
+
229
+
230
+
231
+ // Convert uppercase letters to dot+lower case letter
232
+ name = name.replace(/([A-Z])/g, function (str)
233
+ {
234
+ return '.' + String(RegExp.$1).toLowerCase();
235
+ });
236
+
237
+
238
+
239
+
240
+
241
+
242
+ prop[name] = value;
243
+
244
+ return this;
245
+ };
246
+
247
+
248
+
249
+
250
+ /**
251
+ * A getter method for retrieving graph properties. It can be used like this: obj.Get('chart.strokestyle');
252
+ *
253
+ * @param name string The name of the property to get
254
+ */
255
+ this.get =
256
+ this.Get = function (name)
257
+ {
258
+ /**
259
+ * This should be done first - prepend the property name with "chart." if necessary
260
+ */
261
+ if (name.substr(0,6) != 'chart.') {
262
+ name = 'chart.' + name;
263
+ }
264
+
265
+ // Convert uppercase letters to dot+lower case letter
266
+ name = name.replace(/([A-Z])/g, function (str)
267
+ {
268
+ return '.' + String(RegExp.$1).toLowerCase()
269
+ });
270
+
271
+ return prop[name.toLowerCase()];
272
+ };
273
+
274
+
275
+
276
+
277
+ /**
278
+ * Draws the circle
279
+ */
280
+ this.draw =
281
+ this.Draw = function ()
282
+ {
283
+ /**
284
+ * Fire the onbeforedraw event
285
+ */
286
+ RG.FireCustomEvent(this, 'onbeforedraw');
287
+
288
+ var r = this.radius;
289
+
290
+ if (prop['chart.align'] == 'left') {
291
+
292
+ this.markerCenterx = this.centerx - r - r - 3;
293
+ this.markerCentery = this.centery - r - r - 3;
294
+
295
+ } else if (prop['chart.align'] == 'right') {
296
+
297
+ this.markerCenterx = this.centerx + r + r + 3;
298
+ this.markerCentery = this.centery - r - r - 3;
299
+
300
+ } else {
301
+
302
+ this.markerCenterx = this.centerx;
303
+ this.markerCentery = this.centery - r - r - 3;
304
+ }
305
+
306
+ /**
307
+ * Parse the colors. This allows for simple gradient syntax
308
+ */
309
+ if (!this.colorsParsed) {
310
+
311
+ this.parseColors();
312
+
313
+ // Don't want to do this again
314
+ this.colorsParsed = true;
315
+ }
316
+
317
+
318
+
319
+ /**
320
+ * Stop this growing uncontrollably
321
+ */
322
+ this.coordsText = [];
323
+
324
+
325
+
326
+
327
+ /**
328
+ * DRAW THE MARKER HERE
329
+ */
330
+ pa(co, ['b','lw',prop['chart.linewidth']]);
331
+
332
+ if (prop['chart.shadow']) {
333
+ RG.SetShadow(this, prop['chart.shadow.color'], prop['chart.shadow.offsetx'], prop['chart.shadow.offsety'], prop['chart.shadow.blur']);
334
+ }
335
+ this.DrawMarker();
336
+
337
+ pa(co, ['c','s',prop['chart.strokestyle'],'f',prop['chart.fillstyle']]);
338
+
339
+
340
+
341
+
342
+ // Turn the shadow off
343
+ RG.NoShadow(this);
344
+
345
+
346
+
347
+
348
+ // Now draw the text on the marker
349
+ co.fillStyle = prop['chart.text.color'];
350
+
351
+ // Draw the text on the marker
352
+ RG.Text2(this, {'font':prop['chart.text.font'],
353
+ 'size':prop['chart.text.size'],
354
+ 'x':this.coords[0][0] - 1,
355
+ 'y':this.coords[0][1] - 1,
356
+ 'text':this.text,
357
+ 'valign':'center',
358
+ 'halign':'center',
359
+ 'tag': 'labels'
360
+ });
361
+
362
+ /**
363
+ * This installs the event listeners
364
+ */
365
+ RG.InstallEventListeners(this);
366
+
367
+
368
+ /**
369
+ * Fire the onfirstdraw event
370
+ */
371
+ if (this.firstDraw) {
372
+ RG.fireCustomEvent(this, 'onfirstdraw');
373
+ this.firstDraw = false;
374
+ this.firstDrawFunc();
375
+ }
376
+
377
+
378
+
379
+
380
+ /**
381
+ * Fire the ondraw event
382
+ */
383
+ RG.FireCustomEvent(this, 'ondraw');
384
+
385
+ return this;
386
+ };
387
+
388
+
389
+
390
+ /**
391
+ * Used in chaining. Runs a function there and then - not waiting for
392
+ * the events to fire (eg the onbeforedraw event)
393
+ *
394
+ * @param function func The function to execute
395
+ */
396
+ this.exec = function (func)
397
+ {
398
+ func(this);
399
+
400
+ return this;
401
+ };
402
+
403
+
404
+
405
+
406
+ /**
407
+ * The getObjectByXY() worker method
408
+ */
409
+ this.getObjectByXY = function (e)
410
+ {
411
+ if (this.getShape(e)) {
412
+ return this;
413
+ }
414
+ };
415
+
416
+
417
+
418
+
419
+ /**
420
+ * Not used by the class during creating the shape, but is used by event handlers
421
+ * to get the coordinates (if any) of the selected bar
422
+ *
423
+ * @param object e The event object
424
+ * @param object OPTIONAL You can pass in the bar object instead of the
425
+ * function using "this"
426
+ */
427
+ this.getShape = function (e)
428
+ {
429
+ var mouseXY = RG.getMouseXY(e);
430
+ var mouseX = mouseXY[0];
431
+ var mouseY = mouseXY[1];
432
+
433
+ /**
434
+ * Path the marker but DON'T STROKE OR FILL it
435
+ */
436
+ co.beginPath();
437
+ this.DrawMarker();
438
+
439
+ if (co.isPointInPath(mouseXY[0], mouseXY[1])) {
440
+
441
+ return {
442
+ 0: this, 1: this.coords[0][0], 2: this.coords[0][1], 3: this.coords[0][2], 4: 0,
443
+ 'object': this, 'x': this.coords[0][0], 'y': this.coords[0][1], 'radius': this.coords[0][2], 'index': 0, 'tooltip': prop['chart.tooltips'] ? prop['chart.tooltips'][0] : null
444
+ };
445
+ }
446
+
447
+ return null;
448
+ };
449
+
450
+
451
+
452
+
453
+ /**
454
+ * This function positions a tooltip when it is displayed
455
+ *
456
+ * @param obj object The chart object
457
+ * @param int x The X coordinate specified for the tooltip
458
+ * @param int y The Y coordinate specified for the tooltip
459
+ * @param object tooltip The tooltips DIV element
460
+ * @param number idx The index of the tooltip
461
+ */
462
+ this.positionTooltip = function (obj, x, y, tooltip, idx)
463
+ {
464
+ var canvasXY = RG.getCanvasXY(obj.canvas);
465
+ var width = tooltip.offsetWidth;
466
+ var height = tooltip.offsetHeight;
467
+
468
+ // Set the top position
469
+ tooltip.style.left = 0;
470
+ tooltip.style.top = canvasXY[1] + this.coords[0][1] - (height / 2) - this.radius + 'px';
471
+
472
+ // By default any overflow is hidden
473
+ tooltip.style.overflow = '';
474
+
475
+ // The arrow
476
+ var img = new Image();
477
+ img.src = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABEAAAAFCAYAAACjKgd3AAAARUlEQVQYV2NkQAN79+797+RkhC4M5+/bd47B2dmZEVkBCgcmgcsgbAaA9GA1BCSBbhAuA/AagmwQPgMIGgIzCD0M0AMMAEFVIAa6UQgcAAAAAElFTkSuQmCC';
478
+ img.style.position = 'absolute';
479
+ img.id = '__rgraph_tooltip_pointer__';
480
+ img.style.top = (tooltip.offsetHeight - 2) + 'px';
481
+ tooltip.appendChild(img);
482
+
483
+ // Reposition the tooltip if at the edges:
484
+
485
+ // LEFT edge
486
+ if ((canvasXY[0] + obj.coords[0][0] + (obj.coords[0][2] / 2) - (width / 2)) < 10) {
487
+ tooltip.style.left = canvasXY[0] + this.markerCenterx - (width * 0.1) + 'px';
488
+ img.style.left = ((width * 0.1) - 8.5) + 'px';
489
+
490
+ // RIGHT edge
491
+ } else if ((canvasXY[0] + this.coords[0][0] + (this.coords[0][2] / 2) + (width / 2)) > doc.body.offsetWidth) {
492
+ tooltip.style.left = canvasXY[0] + this.markerCenterx - (width * 0.9) + 'px';
493
+ img.style.left = ((width * 0.9) - 8.5) + 'px';
494
+
495
+ // Default positioning - CENTERED
496
+ } else {
497
+ tooltip.style.left = (canvasXY[0] + this.markerCenterx - (width * 0.5)) + 'px';
498
+ img.style.left = ((width * 0.5) - 8.5) + 'px';
499
+ }
500
+ };
501
+
502
+
503
+
504
+
505
+ /**
506
+ * Each object type has its own Highlight() function which highlights the appropriate shape
507
+ *
508
+ * @param object shape The shape to highlight
509
+ */
510
+ this.highlight =
511
+ this.Highlight = function (shape)
512
+ {
513
+ if (prop['chart.tooltips.highlight']) {
514
+ pa(this, ['b','fu',function (obj){obj.DrawMarker();},'c','s',prop['chart.highlight.stroke'],'f',prop['chart.highlight.fill']]);
515
+ }
516
+ };
517
+
518
+
519
+
520
+
521
+ /**
522
+ * This function is used to encapsulate the actual drawing of the marker. It
523
+ * intentional does not start a path or set colors.
524
+ */
525
+ this.drawMarker =
526
+ this.DrawMarker = function ()
527
+ {
528
+ var r = this.radius;
529
+
530
+ if (prop['chart.align'] == 'left') {
531
+
532
+ var x = this.markerCenterx;
533
+ var y = this.markerCentery;
534
+
535
+ pa(co, ['a',x,y,r,RG.HALFPI,RG.TWOPI,false]);
536
+
537
+ // special case for MSIE 7/8
538
+ if (RG.ISOLD) {
539
+ pa(co,['m',x + r + r,y+r+r,'qc',x + r,y + r,x + r + 1,y,'m',x + r + r,y+r+r]);
540
+ } else {
541
+ pa(co, ['qc',x + r,y + r,x + r + r,y + r + r]);
542
+ }
543
+
544
+ pa(co, ['qc',x + r,y + r,x,y + r + (RG.ISOLD ? 1 : 0)]);
545
+
546
+ } else if (prop['chart.align'] == 'right') {
547
+
548
+ var x = this.markerCenterx;
549
+ var y = this.markerCentery;
550
+
551
+ pa(co, ['a',x,y,r,RG.HALFPI,RG.PI,true]);
552
+
553
+ // special case for MSIE 7/8
554
+ if (RG.ISOLD) {
555
+ pa(co, ['m',x - r - r,y+r+r,'qc',x - r,y + r,x - r - 1,y,'m',x - r - r,y+r+r]);
556
+ } else {
557
+ pa(co, ['qc',x - r,y + r,x - r - r,y + r + r]);
558
+ }
559
+
560
+ pa(co, ['qc',x - r, y + r, x, y + r + (RG.ISOLD ? 1 : 0)]);
561
+
562
+ // Default is center
563
+ } else {
564
+
565
+ var x = this.markerCenterx;
566
+ var y = this.markerCentery;
567
+
568
+ pa(co, ['a',x, y, r, RG.HALFPI / 2, RG.PI - (RG.HALFPI / 2), true]);
569
+ //co.arc(x, y, r, HALFPI / 2, PI - (HALFPI / 2), true);
570
+
571
+ // special case for MSIE 7/8
572
+ if (RG.ISOLD) {
573
+ pa(co, ['m',x,y+r+r-2,'qc',x,y + r + (r / 4),x - (Math.cos(RG.HALFPI / 2) * r),y + (Math.sin(RG.HALFPI / 2) * r),'m',x, y+r+r-2]);
574
+ } else {
575
+ pa(co, ['qc',x,y + r + (r / 4),x,y + r + r - 2]);
576
+ }
577
+
578
+ pa(co, ['qc',x,y + r + (r / 4),x + (Math.cos(RG.HALFPI / 2) * r),y + (Math.sin(RG.HALFPI / 2) * r)]);
579
+ }
580
+
581
+ this.coords[0] = [x, y, r];
582
+ };
583
+
584
+
585
+
586
+
587
+ /**
588
+ * This allows for easy specification of gradients
589
+ */
590
+ this.parseColors = function ()
591
+ {
592
+
593
+ // Save the original colors so that they can be restored when the canvas is reset
594
+ if (this.original_colors.length === 0) {
595
+ this.original_colors['chart.fillstyle'] = RG.array_clone(prop['chart.fillstyle']);
596
+ this.original_colors['chart.strokestyle'] = RG.array_clone(prop['chart.strokestyle']);
597
+ this.original_colors['chart.highlight.fill'] = RG.array_clone(prop['chart.highlight.fill']);
598
+ this.original_colors['chart.highlight.stroke'] = RG.array_clone(prop['chart.highlight.stroke']);
599
+ this.original_colors['chart.text.color'] = RG.array_clone(prop['chart.text.color']);
600
+ }
601
+
602
+
603
+
604
+
605
+ /**
606
+ * Parse various properties for colors
607
+ */
608
+ prop['chart.fillstyle'] = this.parseSingleColorForGradient(prop['chart.fillstyle']);
609
+ prop['chart.strokestyle'] = this.parseSingleColorForGradient(prop['chart.strokestyle']);
610
+ prop['chart.highlight.stroke'] = this.parseSingleColorForGradient(prop['chart.highlight.stroke']);
611
+ prop['chart.highlight.fill'] = this.parseSingleColorForGradient(prop['chart.highlight.fill']);
612
+ prop['chart.text.color'] = this.parseSingleColorForGradient(prop['chart.text.color']);
613
+ };
614
+
615
+
616
+
617
+
618
+ /**
619
+ * Use this function to reset the object to the post-constructor state. Eg reset colors if
620
+ * need be etc
621
+ */
622
+ this.reset = function ()
623
+ {
624
+ };
625
+
626
+
627
+
628
+
629
+ /**
630
+ * This parses a single color value
631
+ */
632
+ this.parseSingleColorForGradient = function (color)
633
+ {
634
+ if (!color || typeof(color) != 'string') {
635
+ return color;
636
+ }
637
+
638
+ if (color.match(/^gradient\((.*)\)$/i)) {
639
+
640
+ var parts = RegExp.$1.split(':');
641
+
642
+ // Create the gradient
643
+ var grad = co.createRadialGradient(this.markerCenterx, this.markerCentery, 0, this.markerCenterx, this.markerCentery, this.radius);
644
+
645
+ var diff = 1 / (parts.length - 1);
646
+
647
+ grad.addColorStop(0, RG.trim(parts[0]));
648
+
649
+ for (var j=1; j<parts.length; ++j) {
650
+ grad.addColorStop(j * diff, RG.trim(parts[j]));
651
+ }
652
+ }
653
+
654
+ return grad ? grad : color;
655
+ };
656
+
657
+
658
+
659
+
660
+ /**
661
+ * Using a function to add events makes it easier to facilitate method chaining
662
+ *
663
+ * @param string type The type of even to add
664
+ * @param function func
665
+ */
666
+ this.on = function (type, func)
667
+ {
668
+ if (type.substr(0,2) !== 'on') {
669
+ type = 'on' + type;
670
+ }
671
+
672
+ this[type] = func;
673
+
674
+ return this;
675
+ };
676
+
677
+
678
+
679
+
680
+ /**
681
+ * This function runs once only
682
+ * (put at the end of the file (before any effects))
683
+ */
684
+ this.firstDrawFunc = function ()
685
+ {
686
+ };
687
+
688
+
689
+
690
+
691
+ RG.att(ca);
692
+
693
+
694
+
695
+ /**
696
+ * Objects are now always registered so that the chart is redrawn if need be.
697
+ */
698
+ RG.Register(this);
699
+
700
+
701
+
702
+
703
+ /**
704
+ * This is the 'end' of the constructor so if the first argument
705
+ * contains configuration data - handle that.
706
+ */
707
+ if (parseConfObjectForOptions) {
708
+ RG.parseObjectStyleConfig(this, conf.options);
709
+ }
710
+ };