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