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,672 @@
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
33
+ */
34
+ RGraph.Drawing.Marker2 = function (conf)
35
+ {
36
+ /**
37
+ * Allow for object config style
38
+ */
39
+ if ( typeof conf === 'object'
40
+ && typeof conf.x === 'number'
41
+ && typeof conf.y === 'number'
42
+ && typeof conf.id === 'string'
43
+ && typeof conf.text === 'string') {
44
+
45
+ var id = conf.id
46
+ var canvas = document.getElementById(id);
47
+ var x = conf.x;
48
+ var y = conf.y;
49
+ var text = conf.text;
50
+
51
+ var parseConfObjectForOptions = true; // Set this so the config is parsed (at the end of the constructor)
52
+
53
+ } else {
54
+
55
+ var id = conf;
56
+ var canvas = document.getElementById(id);
57
+ var x = arguments[1];
58
+ var y = arguments[2];
59
+ var text = arguments[3];
60
+ }
61
+
62
+
63
+
64
+
65
+ this.id = id;
66
+ this.canvas = document.getElementById(this.id);
67
+ this.context = this.canvas.getContext('2d')
68
+ this.colorsParsed = false;
69
+ this.canvas.__object__ = this;
70
+ this.original_colors = [];
71
+ this.firstDraw = true; // After the first draw this will be false
72
+
73
+
74
+ /**
75
+ * Store the properties
76
+ */
77
+ this.x = x;
78
+ this.y = y;
79
+ this.text = text;
80
+
81
+
82
+ /**
83
+ * This defines the type of this shape
84
+ */
85
+ this.type = 'drawing.marker2';
86
+
87
+
88
+ /**
89
+ * This facilitates easy object identification, and should always be true
90
+ */
91
+ this.isRGraph = true;
92
+
93
+
94
+ /**
95
+ * This adds a uid to the object that you can use for identification purposes
96
+ */
97
+ this.uid = RGraph.CreateUID();
98
+
99
+
100
+ /**
101
+ * This adds a UID to the canvas for identification purposes
102
+ */
103
+ this.canvas.uid = this.canvas.uid ? this.canvas.uid : RGraph.CreateUID();
104
+
105
+
106
+ /**
107
+ * Some example background properties
108
+ */
109
+ this.properties =
110
+ {
111
+ 'chart.strokestyle': 'black',
112
+ 'chart.fillstyle': 'white',
113
+ 'chart.text.color': 'black',
114
+ 'chart.text.size': 12,
115
+ 'chart.text.font': 'Arial',
116
+ 'chart.events.click': null,
117
+ 'chart.events.mousemove': null,
118
+ 'chart.shadow': true,
119
+ 'chart.shadow.color': 'gray',
120
+ 'chart.shadow.offsetx': 3,
121
+ 'chart.shadow.offsety': 3,
122
+ 'chart.shadow.blur': 5,
123
+ 'chart.highlight.stroke': 'rgba(0,0,0,0)',
124
+ 'chart.highlight.fill': 'rgba(255,255,255,0.7)',
125
+ 'chart.tooltips': null,
126
+ 'chart.tooltips.highlight': true,
127
+ 'chart.tooltips.event': 'onclick',
128
+ 'chart.voffset': 20
129
+ }
130
+
131
+ /**
132
+ * A simple check that the browser has canvas support
133
+ */
134
+ if (!this.canvas) {
135
+ alert('[DRAWING.MARKER2] No canvas support');
136
+ return;
137
+ }
138
+
139
+ /**
140
+ * These are used to store coords
141
+ */
142
+ this.coords = [];
143
+ this.coordsText = [];
144
+
145
+
146
+ /**
147
+ * Create the dollar object so that functions can be added to them
148
+ */
149
+ this.$0 = {};
150
+
151
+
152
+ /**
153
+ * Translate half a pixel for antialiasing purposes - but only if it hasn't beeen
154
+ * done already
155
+ */
156
+ if (!this.canvas.__rgraph_aa_translated__) {
157
+ this.context.translate(0.5,0.5);
158
+
159
+ this.canvas.__rgraph_aa_translated__ = true;
160
+ }
161
+
162
+
163
+
164
+
165
+ // Short variable names
166
+ var RG = RGraph,
167
+ ca = this.canvas,
168
+ co = ca.getContext('2d'),
169
+ prop = this.properties,
170
+ pa = RG.Path,
171
+ pa2 = RG.path2,
172
+ win = window,
173
+ doc = document,
174
+ ma = Math
175
+
176
+
177
+
178
+ /**
179
+ * "Decorate" the object with the generic effects if the effects library has been included
180
+ */
181
+ if (RG.Effects && typeof RG.Effects.decorate === 'function') {
182
+ RG.Effects.decorate(this);
183
+ }
184
+
185
+
186
+
187
+
188
+ /**
189
+ * A setter method for setting graph properties. It can be used like this: obj.Set('chart.strokestyle', '#666');
190
+ *
191
+
192
+ * @param name string The name of the property to set OR it can be a map
193
+ * of name/value settings like what you set in the constructor
194
+ */
195
+ this.set =
196
+ this.Set = function (name)
197
+ {
198
+ var value = typeof arguments[1] === 'undefined' ? null : arguments[1];
199
+
200
+ /**
201
+ * the number of arguments is only one and it's an
202
+ * object - parse it for configuration data and return.
203
+ */
204
+ if (arguments.length === 1 && typeof name === 'object') {
205
+ RG.parseObjectStyleConfig(this, name);
206
+ return this;
207
+ }
208
+
209
+
210
+
211
+
212
+
213
+ /**
214
+ * This should be done first - prepend the propertyy name with "chart." if necessary
215
+ */
216
+ if (name.substr(0,6) != 'chart.') {
217
+ name = 'chart.' + name;
218
+ }
219
+
220
+
221
+
222
+
223
+ // Convert uppercase letters to dot+lower case letter
224
+ name = name.replace(/([A-Z])/g, function (str)
225
+ {
226
+ return '.' + String(RegExp.$1).toLowerCase();
227
+ });
228
+
229
+
230
+
231
+
232
+
233
+
234
+ prop[name] = value;
235
+
236
+ return this;
237
+ };
238
+
239
+
240
+
241
+
242
+ /**
243
+ * A getter method for retrieving graph properties. It can be used like this: obj.Get('chart.strokestyle');
244
+ *
245
+ * @param name string The name of the property to get
246
+ */
247
+ this.get =
248
+ this.Get = function (name)
249
+ {
250
+ /**
251
+ * This should be done first - prepend the property name with "chart." if necessary
252
+ */
253
+ if (name.substr(0,6) != 'chart.') {
254
+ name = 'chart.' + name;
255
+ }
256
+
257
+ // Convert uppercase letters to dot+lower case letter
258
+ name = name.replace(/([A-Z])/g, function (str)
259
+ {
260
+ return '.' + String(RegExp.$1).toLowerCase()
261
+ });
262
+
263
+ return prop[name.toLowerCase()];
264
+ };
265
+
266
+
267
+
268
+
269
+ /**
270
+ * Draws the marker
271
+ */
272
+ this.draw =
273
+ this.Draw = function ()
274
+ {
275
+ /**
276
+ * Reset the linewidth
277
+ */
278
+ co.lineWidth = 1;
279
+
280
+ /**
281
+ * Fire the onbeforedraw event
282
+ */
283
+ RG.FireCustomEvent(this, 'onbeforedraw');
284
+
285
+
286
+ this.metrics = RG.MeasureText(this.text, prop['chart.text.bold'], prop['chart.text.font'], prop['chart.text.size']);
287
+
288
+
289
+
290
+ if (this.x + this.metrics[0] >= ca.width) {
291
+ this.alignRight = true;
292
+ }
293
+
294
+
295
+
296
+
297
+ /**
298
+ * Parse the colors. This allows for simple gradient syntax
299
+ */
300
+ if (!this.colorsParsed) {
301
+
302
+ this.parseColors();
303
+
304
+ // Don't want to do this again
305
+ this.colorsParsed = true;
306
+ }
307
+
308
+
309
+
310
+
311
+ /***************
312
+ * Draw the box *
313
+ ****************/
314
+
315
+ var x = this.alignRight ? this.x - this.metrics[0] - 6 : this.x;
316
+ var y = this.y - 6 - prop['chart.voffset'] - this.metrics[1];
317
+ var width = this.metrics[0] + 6;
318
+ var height = this.metrics[1] + 6;
319
+
320
+ // Store these coords as the coords of the label
321
+ this.coords[0] = [x, y, width, height];
322
+
323
+
324
+
325
+ /**
326
+ * Stop this growing uncntrollably
327
+ */
328
+ this.coordsText = [];
329
+
330
+
331
+ // Set the linewidth
332
+ co.lineWidth = prop['chart.linewidth'];
333
+
334
+
335
+
336
+
337
+
338
+ /**
339
+ * Draw the box that the text sits in
340
+ */
341
+
342
+ if (prop['chart.shadow']) {
343
+ RG.SetShadow(this, prop['chart.shadow.color'], prop['chart.shadow.offsetx'], prop['chart.shadow.offsety'], prop['chart.shadow.blur']);
344
+ }
345
+ co.strokeStyle = prop['chart.strokestyle'];
346
+ co.fillStyle = prop['chart.fillstyle'];
347
+
348
+ // This partcular strokeRect has 0 width and so ends up being a line
349
+ co.strokeRect(x + (this.alignRight ? width : 0), y, 0, height + prop['chart.voffset'] - 6);
350
+
351
+ co.strokeRect(x, y, width, height);
352
+ co.fillRect(x, y, width, height);
353
+
354
+ RG.NoShadow(this);
355
+
356
+ co.fillStyle = prop['chart.text.color'];
357
+
358
+ // Draw the text
359
+ RG.Text2(this, {'font':prop['chart.text.font'],
360
+ 'size':prop['chart.text.size'],
361
+ 'x': Math.round(this.x) - (this.alignRight ? this.metrics[0] + 3 : -3),
362
+ 'y':this.y - 3 - prop['chart.voffset'],
363
+ 'text':this.text,
364
+ 'valign':'bottom',
365
+ 'halign':'left',
366
+ 'tag': 'labels'
367
+ });
368
+
369
+ this.coords[0].push([x, y, width, height]);
370
+
371
+
372
+
373
+
374
+
375
+
376
+
377
+
378
+ // Must turn the shadow off
379
+ RG.NoShadow(this);
380
+
381
+
382
+
383
+ /**
384
+ * Reset the testBaseline
385
+ */
386
+ co.textBaseline = 'alphabetic';
387
+
388
+
389
+ /**
390
+ * This installs the event listeners
391
+ */
392
+ RG.InstallEventListeners(this);
393
+
394
+
395
+ /**
396
+ * Fire the onfirstdraw event
397
+ */
398
+ if (this.firstDraw) {
399
+ RG.fireCustomEvent(this, 'onfirstdraw');
400
+ this.firstDraw = false;
401
+ this.firstDrawFunc();
402
+ }
403
+
404
+
405
+
406
+
407
+ /**
408
+ * Fire the ondraw event
409
+ */
410
+ RG.FireCustomEvent(this, 'ondraw');
411
+
412
+ return this;
413
+ };
414
+
415
+
416
+
417
+ /**
418
+ * Used in chaining. Runs a function there and then - not waiting for
419
+ * the events to fire (eg the onbeforedraw event)
420
+ *
421
+ * @param function func The function to execute
422
+ */
423
+ this.exec = function (func)
424
+ {
425
+ func(this);
426
+
427
+ return this;
428
+ };
429
+
430
+
431
+
432
+
433
+ /**
434
+ * The getObjectByXY() worker method
435
+ */
436
+ this.getObjectByXY = function (e)
437
+ {
438
+ var mouseXY = RG.getMouseXY(e);
439
+
440
+ if (this.getShape(e)) {
441
+ return this;
442
+ }
443
+ };
444
+
445
+
446
+
447
+
448
+ /**
449
+ * Not used by the class during creating the shape, but is used by event handlers
450
+ * to get the coordinates (if any) of the selected bar
451
+ *
452
+ * @param object e The event object
453
+ * @param object OPTIONAL You can pass in the bar object instead of the
454
+ * function using "this"
455
+ */
456
+ this.getShape = function (e)
457
+ {
458
+ var mouseXY = RG.getMouseXY(e);
459
+ var mouseX = mouseXY[0];
460
+ var mouseY = mouseXY[1];
461
+
462
+ if ( mouseX >= this.coords[0][0] && mouseX <= (this.coords[0][0] + this.coords[0][2]) ) {
463
+
464
+ if (mouseY >= this.coords[0][1] && mouseY <= (this.coords[0][1] + this.coords[0][3])) {
465
+
466
+ return {
467
+ 0: this, 1: this.coords[0][0], 2: this.coords[0][1], 3: this.coords[0][2], 4: this.coords[0][3], 5: 0,
468
+ 'object': this, 'x': this.coords[0][0], 'y': this.coords[0][1], 'width': this.coords[0][2], 'height': this.coords[0][3], 'index': 0, 'tooltip': prop['chart.tooltips'] ? prop['chart.tooltips'][0] : null
469
+ };
470
+ }
471
+ }
472
+
473
+ return null;
474
+ };
475
+
476
+
477
+
478
+
479
+ /**
480
+ * This function positions a tooltip when it is displayed
481
+ *
482
+ * @param obj object The chart object
483
+ * @param int x The X coordinate specified for the tooltip
484
+ * @param int y The Y coordinate specified for the tooltip
485
+ * @param object tooltip The tooltips DIV element
486
+ * @param number idx The index of the tooltip
487
+ */
488
+ this.positionTooltip = function (obj, x, y, tooltip, idx)
489
+ {
490
+ var textDimensions = RG.MeasureText(this.text, false, prop['chart.text.font'], prop['chart.text.size']);
491
+
492
+ var canvasXY = RG.getCanvasXY(obj.canvas);
493
+ var width = tooltip.offsetWidth;
494
+ var height = tooltip.offsetHeight;
495
+
496
+ // Set the top position
497
+ tooltip.style.left = 0;
498
+ tooltip.style.top = canvasXY[1] + this.coords[0][1] - height - 9 + (this.coords[0][3] / 2) + 'px';
499
+
500
+ // By default any overflow is hidden
501
+ tooltip.style.overflow = '';
502
+
503
+ // The arrow
504
+ var img = new Image();
505
+ img.src = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABEAAAAFCAYAAACjKgd3AAAARUlEQVQYV2NkQAN79+797+RkhC4M5+/bd47B2dmZEVkBCgcmgcsgbAaA9GA1BCSBbhAuA/AagmwQPgMIGgIzCD0M0AMMAEFVIAa6UQgcAAAAAElFTkSuQmCC';
506
+ img.style.position = 'absolute';
507
+ img.id = '__rgraph_tooltip_pointer__';
508
+ img.style.top = (tooltip.offsetHeight - 2) + 'px';
509
+ tooltip.appendChild(img);
510
+
511
+ // Reposition the tooltip if at the edges:
512
+
513
+ // LEFT edge
514
+ if ((canvasXY[0] + obj.coords[0][0] + (obj.coords[0][2] / 2) - (width / 2)) < 10) {
515
+ tooltip.style.left = (canvasXY[0] + this.coords[0][0] + (this.coords[0][2] / 2) - (width * 0.1)) + 'px';
516
+ img.style.left = ((width * 0.1) - 8.5) + 'px';
517
+
518
+ // RIGHT edge
519
+ } else if ((canvasXY[0] + this.coords[0][0] + (this.coords[0][2] / 2) + (width / 2)) > doc.body.offsetWidth) {
520
+ tooltip.style.left = (canvasXY[0] + this.coords[0][0] + (this.coords[0][2] / 2) - (width * 0.9)) + 'px';
521
+ img.style.left = ((width * 0.9) - 8.5) + 'px';
522
+
523
+ // Default positioning - CENTERED
524
+ } else {
525
+ tooltip.style.left = (canvasXY[0] + this.coords[0][0] + (this.coords[0][2] / 2) - (width * 0.5)) + 'px';
526
+ img.style.left = ((width * 0.5) - 8.5) + 'px';
527
+ }
528
+ };
529
+
530
+
531
+
532
+
533
+ /**
534
+ * Each object type has its own Highlight() function which highlights the appropriate shape
535
+ *
536
+ * @param object shape The shape to highlight
537
+ */
538
+ this.highlight =
539
+ this.Highlight = function (shape)
540
+ {
541
+ if (prop['chart.tooltips.highlight']) {
542
+ pa(this, ['b','r',this.coords[0][0],this.coords[0][1],this.coords[0][2],this.coords[0][3],'f',prop['chart.highlight.fill'],'s',prop['chart.highlight.stroke']]);
543
+ }
544
+ };
545
+
546
+
547
+
548
+
549
+ /**
550
+ * This allows for easy specification of gradients
551
+ */
552
+ this.parseColors = function ()
553
+ {
554
+ // Save the original colors so that they can be restored when the canvas is reset
555
+ if (this.original_colors.length === 0) {
556
+ this.original_colors['chart.fillstyle'] = RG.array_clone(prop['chart.fillstyle']);
557
+ this.original_colors['chart.strokestyle'] = RG.array_clone(prop['chart.strokestyle']);
558
+ this.original_colors['chart.highlight.fill'] = RG.array_clone(prop['chart.highlight.fill']);
559
+ this.original_colors['chart.highlight.stroke'] = RG.array_clone(prop['chart.highlight.stroke']);
560
+ this.original_colors['chart.text.color'] = RG.array_clone(prop['chart.text.color']);
561
+ }
562
+
563
+
564
+
565
+
566
+ /**
567
+ * Parse various properties for colors
568
+ */
569
+ prop['chart.fillstyle'] = this.parseSingleColorForGradient(prop['chart.fillstyle']);
570
+ prop['chart.strokestyle'] = this.parseSingleColorForGradient(prop['chart.strokestyle']);
571
+ prop['chart.highlight.stroke'] = this.parseSingleColorForGradient(prop['chart.highlight.stroke']);
572
+ prop['chart.highlight.fill'] = this.parseSingleColorForGradient(prop['chart.highlight.fill']);
573
+ prop['chart.text.color'] = this.parseSingleColorForGradient(prop['chart.text.color']);
574
+ };
575
+
576
+
577
+
578
+
579
+ /**
580
+ * Use this function to reset the object to the post-constructor state. Eg reset colors if
581
+ * need be etc
582
+ */
583
+ this.reset = function ()
584
+ {
585
+ };
586
+
587
+
588
+
589
+
590
+ /**
591
+ * This parses a single color value
592
+ */
593
+ this.parseSingleColorForGradient = function (color)
594
+ {
595
+ var canvas = this.canvas;
596
+ var context = this.context;
597
+
598
+ if (!color) {
599
+ return color;
600
+ }
601
+
602
+ if (typeof color === 'string' && color.match(/^gradient\((.*)\)$/i)) {
603
+
604
+ var parts = RegExp.$1.split(':');
605
+
606
+ // Create the gradient
607
+ var grad = co.createLinearGradient(this.x, this.y, this.x + this.metrics[0], this.y);
608
+
609
+ var diff = 1 / (parts.length - 1);
610
+
611
+ grad.addColorStop(0, RG.trim(parts[0]));
612
+
613
+ for (var j=1; j<parts.length; ++j) {
614
+ grad.addColorStop(j * diff, RG.trim(parts[j]));
615
+ }
616
+ }
617
+
618
+ return grad ? grad : color;
619
+ };
620
+
621
+
622
+
623
+
624
+ /**
625
+ * Using a function to add events makes it easier to facilitate method chaining
626
+ *
627
+ * @param string type The type of even to add
628
+ * @param function func
629
+ */
630
+ this.on = function (type, func)
631
+ {
632
+ if (type.substr(0,2) !== 'on') {
633
+ type = 'on' + type;
634
+ }
635
+
636
+ this[type] = func;
637
+
638
+ return this;
639
+ };
640
+
641
+
642
+
643
+
644
+ /**
645
+ * This function runs once only
646
+ * (put at the end of the file (before any effects))
647
+ */
648
+ this.firstDrawFunc = function ()
649
+ {
650
+ };
651
+
652
+
653
+ RG.att(ca);
654
+
655
+
656
+
657
+ /**
658
+ * Objects are now always registered so that the chart is redrawn if need be.
659
+ */
660
+ RG.Register(this);
661
+
662
+
663
+
664
+
665
+ /**
666
+ * the number of arguments is only one and it's an
667
+ * object - parse it for configuration data and return.
668
+ */
669
+ if (parseConfObjectForOptions) {
670
+ RG.parseObjectStyleConfig(this, conf.options);
671
+ }
672
+ };