rgraph-rails 1.0.7 → 1.0.8

Sign up to get free protection for your applications and to get access to all the features.
Files changed (61) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +3 -3
  3. data/lib/rgraph-rails/version.rb +1 -1
  4. data/license.txt +4 -16
  5. data/vendor/assets/javascripts/RGraph.bar.js +3734 -241
  6. data/vendor/assets/javascripts/RGraph.bipolar.js +2005 -115
  7. data/vendor/assets/javascripts/RGraph.common.annotate.js +395 -35
  8. data/vendor/assets/javascripts/RGraph.common.context.js +595 -30
  9. data/vendor/assets/javascripts/RGraph.common.core.js +5282 -405
  10. data/vendor/assets/javascripts/RGraph.common.csv.js +276 -19
  11. data/vendor/assets/javascripts/RGraph.common.deprecated.js +450 -35
  12. data/vendor/assets/javascripts/RGraph.common.dynamic.js +1395 -86
  13. data/vendor/assets/javascripts/RGraph.common.effects.js +1545 -90
  14. data/vendor/assets/javascripts/RGraph.common.key.js +753 -54
  15. data/vendor/assets/javascripts/RGraph.common.resizing.js +563 -37
  16. data/vendor/assets/javascripts/RGraph.common.sheets.js +352 -29
  17. data/vendor/assets/javascripts/RGraph.common.tooltips.js +450 -32
  18. data/vendor/assets/javascripts/RGraph.common.zoom.js +219 -14
  19. data/vendor/assets/javascripts/RGraph.drawing.background.js +570 -35
  20. data/vendor/assets/javascripts/RGraph.drawing.circle.js +544 -35
  21. data/vendor/assets/javascripts/RGraph.drawing.image.js +755 -52
  22. data/vendor/assets/javascripts/RGraph.drawing.marker1.js +645 -41
  23. data/vendor/assets/javascripts/RGraph.drawing.marker2.js +633 -37
  24. data/vendor/assets/javascripts/RGraph.drawing.marker3.js +514 -36
  25. data/vendor/assets/javascripts/RGraph.drawing.poly.js +559 -39
  26. data/vendor/assets/javascripts/RGraph.drawing.rect.js +548 -35
  27. data/vendor/assets/javascripts/RGraph.drawing.text.js +664 -36
  28. data/vendor/assets/javascripts/RGraph.drawing.xaxis.js +812 -50
  29. data/vendor/assets/javascripts/RGraph.drawing.yaxis.js +856 -51
  30. data/vendor/assets/javascripts/RGraph.fuel.js +964 -58
  31. data/vendor/assets/javascripts/RGraph.funnel.js +984 -55
  32. data/vendor/assets/javascripts/RGraph.gantt.js +1354 -77
  33. data/vendor/assets/javascripts/RGraph.gauge.js +1421 -87
  34. data/vendor/assets/javascripts/RGraph.hbar.js +2562 -146
  35. data/vendor/assets/javascripts/RGraph.hprogress.js +1401 -80
  36. data/vendor/assets/javascripts/RGraph.line.js +4226 -244
  37. data/vendor/assets/javascripts/RGraph.meter.js +1280 -74
  38. data/vendor/assets/javascripts/RGraph.modaldialog.js +301 -19
  39. data/vendor/assets/javascripts/RGraph.odo.js +1264 -71
  40. data/vendor/assets/javascripts/RGraph.pie.js +2288 -137
  41. data/vendor/assets/javascripts/RGraph.radar.js +1847 -110
  42. data/vendor/assets/javascripts/RGraph.rose.js +1977 -108
  43. data/vendor/assets/javascripts/RGraph.rscatter.js +1432 -80
  44. data/vendor/assets/javascripts/RGraph.scatter.js +3036 -168
  45. data/vendor/assets/javascripts/RGraph.semicircularprogress.js +1120 -60
  46. data/vendor/assets/javascripts/RGraph.svg.bar.js +1067 -0
  47. data/vendor/assets/javascripts/RGraph.svg.common.ajax.js +247 -0
  48. data/vendor/assets/javascripts/RGraph.svg.common.core.js +3363 -0
  49. data/vendor/assets/javascripts/RGraph.svg.common.csv.js +277 -0
  50. data/vendor/assets/javascripts/RGraph.svg.common.fx.js +1304 -0
  51. data/vendor/assets/javascripts/RGraph.svg.common.sheets.js +353 -0
  52. data/vendor/assets/javascripts/RGraph.svg.common.tooltips.js +233 -0
  53. data/vendor/assets/javascripts/RGraph.svg.hbar.js +1141 -0
  54. data/vendor/assets/javascripts/RGraph.svg.line.js +1486 -0
  55. data/vendor/assets/javascripts/RGraph.svg.pie.js +781 -0
  56. data/vendor/assets/javascripts/RGraph.svg.radar.js +1326 -0
  57. data/vendor/assets/javascripts/RGraph.svg.semicircularprogress.js +817 -0
  58. data/vendor/assets/javascripts/RGraph.thermometer.js +1135 -62
  59. data/vendor/assets/javascripts/RGraph.vprogress.js +1470 -83
  60. data/vendor/assets/javascripts/RGraph.waterfall.js +1347 -80
  61. metadata +15 -3
@@ -1,36 +1,545 @@
1
+ // version: 2017-01-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 licensed under the Open Source MIT license. That means that it's |
9
+ * | totally free to use! |
10
+ * o--------------------------------------------------------------------------------o
11
+ */
12
+
13
+ /**
14
+ * Having this here means that the RGraph libraries can be included in any order, instead of you having
15
+ * to include the common core library first.
16
+ */
1
17
 
2
- RGraph=window.RGraph||{isRGraph:true};RGraph.Drawing=RGraph.Drawing||{};RGraph.Drawing.Circle=function(conf)
3
- {if(typeof conf==='object'&&typeof conf.x==='number'&&typeof conf.y==='number'&&typeof conf.radius==='number'&&typeof conf.id==='string'){var id=conf.id
4
- var canvas=document.getElementById(id);var x=conf.x;var y=conf.y;var radius=conf.radius;var parseConfObjectForOptions=true;}else{var id=conf;var canvas=document.getElementById(id);var x=arguments[1];var y=arguments[2];var radius=arguments[3];}
5
- this.id=id;this.canvas=document.getElementById(this.id);this.context=this.canvas.getContext('2d');this.canvas.__object__=this;this.original_colors=[];this.firstDraw=true;this.centerx=x;this.centery=y;this.radius=radius;this.type='drawing.circle';this.isRGraph=true;this.uid=RGraph.CreateUID();this.canvas.uid=this.canvas.uid?this.canvas.uid:RGraph.CreateUID();this.properties={'chart.strokestyle':'rgba(0,0,0,0)','chart.fillstyle':'red','chart.events.click':null,'chart.events.mousemove':null,'chart.shadow':false,'chart.shadow.color':'gray','chart.shadow.offsetx':3,'chart.shadow.offsety':3,'chart.shadow.blur':5,'chart.highlight.stroke':'black','chart.highlight.fill':'rgba(255,255,255,0.7)','chart.tooltips':null,'chart.tooltips.highlight':true,'chart.tooltips.event':'onclick','chart.linewidth':2,'chart.clearto':'rgba(0,0,0,0)'}
6
- if(!this.canvas){alert('[DRAWING.CIRCLE] No canvas support');return;}
7
- this.coords=[[this.centerx,this.centery,this.radius]];this.$0={};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
- prop[name]=value;return this;};this.get=this.Get=function(name)
15
- {if(name.substr(0,6)!='chart.'){name='chart.'+name;}
16
- while(name.match(/([A-Z])/)){name=name.replace(/([A-Z])/,'.'+RegExp.$1.toLowerCase());}
17
- return prop[name.toLowerCase()];};this.draw=this.Draw=function()
18
- {RG.FireCustomEvent(this,'onbeforedraw');if(!this.colorsParsed){this.parseColors();this.colorsParsed=true;}
19
- pa2(co,['b','lw',prop['chart.linewidth']]);if(prop['chart.shadow']){RG.SetShadow(this,prop['chart.shadow.color'],prop['chart.shadow.offsetx'],prop['chart.shadow.offsety'],prop['chart.shadow.blur']);}
20
- pa2(co,['a',this.coords[0][0],this.coords[0][1],this.radius,0,RGraph.TWOPI,false,'f',prop['chart.fillstyle'],'s',prop['chart.strokestyle']]);RG.NoShadow(this);RG.InstallEventListeners(this);if(this.firstDraw){RG.fireCustomEvent(this,'onfirstdraw');this.firstDraw=false;this.firstDrawFunc();}
21
- RG.FireCustomEvent(this,'ondraw');return this;};this.exec=function(func)
22
- {func(this);return this;};this.getObjectByXY=function(e)
23
- {if(this.getShape(e)){return this;}};this.getShape=function(e)
24
- {var mouseXY=RGraph.getMouseXY(e);var mouseX=mouseXY[0];var mouseY=mouseXY[1];if(RG.getHypLength(this.centerx,this.centery,mouseXY[0],mouseXY[1])<=this.radius){return{0:this,1:this.centerx,2:this.centery,3:this.radius,4:null,5:0,'object':this,'x':this.centerx,'y':this.centery,'radius':this.radius,'index':0,'tooltip':prop['chart.tooltips']?prop['chart.tooltips'][0]:null};}
25
- return null;};this.highlight=this.Highlight=function(shape)
26
- {if(prop['chart.tooltips.highlight']){if(typeof prop['chart.highlight.style']==='function'){(prop['chart.highlight.style'])(shape);}else{pa2(co,['b','a',this.centerx,this.centery,this.radius+0.5,0,RGraph.TWOPI,false,'f',prop['chart.highlight.fill'],'s',prop['chart.highlight.stroke']]);}}};this.parseColors=function()
27
- {if(this.original_colors.length===0){this.original_colors['chart.fillstyle']=RG.array_clone(prop['chart.fillstyle']);this.original_colors['chart.strokestyle']=RG.array_clone(prop['chart.strokestyle']);this.original_colors['chart.highlight.stroke']=RG.array_clone(prop['chart.highlight.stroke']);this.original_colors['chart.highlight.fill']=RG.array_clone(prop['chart.highlight.fill']);}
28
- prop['chart.fillstyle']=this.parseSingleColorForGradient(prop['chart.fillstyle']);prop['chart.strokestyle']=this.parseSingleColorForGradient(prop['chart.strokestyle']);prop['chart.highlight.stroke']=this.parseSingleColorForGradient(prop['chart.highlight.stroke']);prop['chart.highlight.fill']=this.parseSingleColorForGradient(prop['chart.highlight.fill']);};this.reset=function()
29
- {};this.parseSingleColorForGradient=function(color)
30
- {if(!color){return color;}
31
- if(typeof color==='string'&&color.match(/^gradient\((.*)\)$/i)){var parts=RegExp.$1.split(':');var grad=co.createRadialGradient(this.centerx,this.centery,0,this.centerx,this.centery,this.radius);var diff=1/(parts.length-1);for(var j=0;j<parts.length;j+=1){grad.addColorStop(j*diff,RG.trim(parts[j]));}}
32
- return grad?grad:color;};this.on=function(type,func)
33
- {if(type.substr(0,2)!=='on'){type='on'+type;}
34
- if(typeof this[type]!=='function'){this[type]=func;}else{RG.addCustomEventListener(this,type,func);}
35
- return this;};this.firstDrawFunc=function()
36
- {};RG.att(ca);RG.Register(this);if(parseConfObjectForOptions){RG.parseObjectStyleConfig(this,conf.options);}};
18
+ // Define the RGraph global variable
19
+ RGraph = window.RGraph || {isRGraph: true};
20
+ RGraph.Drawing = RGraph.Drawing || {};
21
+
22
+ /**
23
+ * The constructor. This function sets up the object. It takes the ID (the HTML attribute) of the canvas as the
24
+ * first argument and the data as the second. If you need to change this, you can.
25
+ *
26
+ * @param string id The canvas tag ID
27
+ * @param number x The X position of the circle
28
+ * @param number y The Y position of the circle
29
+ * @param number r The radius of the circle
30
+ */
31
+ RGraph.Drawing.Circle = function (conf)
32
+ {
33
+ /**
34
+ * Allow for object config style
35
+ */
36
+ if ( typeof conf === 'object'
37
+ && typeof conf.x === 'number'
38
+ && typeof conf.y === 'number'
39
+ && typeof conf.radius === 'number'
40
+ && typeof conf.id === 'string') {
41
+
42
+ var id = conf.id,
43
+ canvas = document.getElementById(id),
44
+ x = conf.x,
45
+ y = conf.y,
46
+ radius = conf.radius,
47
+ parseConfObjectForOptions = true; // Set this so the config is parsed (at the end of the constructor)
48
+
49
+ } else {
50
+
51
+ var id = conf,
52
+ canvas = document.getElementById(id),
53
+ x = arguments[1],
54
+ y = arguments[2],
55
+ radius = arguments[3];
56
+ }
57
+
58
+
59
+
60
+
61
+ this.id = id;
62
+ this.canvas = document.getElementById(this.id);
63
+ this.context = this.canvas.getContext('2d');
64
+ this.canvas.__object__ = this;
65
+ this.original_colors = [];
66
+ this.firstDraw = true; // After the first draw this will be false
67
+
68
+
69
+ /**
70
+ * Store the properties
71
+ */
72
+ this.centerx = x;
73
+ this.centery = y;
74
+ this.radius = radius;
75
+
76
+ /**
77
+ * This defines the type of this shape
78
+ */
79
+ this.type = 'drawing.circle';
80
+
81
+
82
+ /**
83
+ * This facilitates easy object identification, and should always be true
84
+ */
85
+ this.isRGraph = true;
86
+
87
+
88
+ /**
89
+ * This adds a uid to the object that you can use for identification purposes
90
+ */
91
+ this.uid = RGraph.createUID();
92
+
93
+
94
+ /**
95
+ * This adds a UID to the canvas for identification purposes
96
+ */
97
+ this.canvas.uid = this.canvas.uid ? this.canvas.uid : RGraph.createUID();
98
+
99
+
100
+
101
+
102
+ /**
103
+ * Some example background properties
104
+ */
105
+ this.properties =
106
+ {
107
+ 'chart.strokestyle': 'rgba(0,0,0,0)',
108
+ 'chart.fillstyle': 'red',
109
+ 'chart.events.click': null,
110
+ 'chart.events.mousemove': null,
111
+ 'chart.shadow': false,
112
+ 'chart.shadow.color': 'gray',
113
+ 'chart.shadow.offsetx': 3,
114
+ 'chart.shadow.offsety': 3,
115
+ 'chart.shadow.blur': 5,
116
+ 'chart.highlight.stroke': 'black',
117
+ 'chart.highlight.fill': 'rgba(255,255,255,0.7)',
118
+ 'chart.tooltips': null,
119
+ 'chart.tooltips.highlight': true,
120
+ 'chart.tooltips.event': 'onclick',
121
+ 'chart.linewidth': 2,
122
+ 'chart.clearto': 'rgba(0,0,0,0)'
123
+ }
124
+
125
+ /**
126
+ * A simple check that the browser has canvas support
127
+ */
128
+ if (!this.canvas) {
129
+ alert('[DRAWING.CIRCLE] No canvas support');
130
+ return;
131
+ }
132
+
133
+ /**
134
+ * This can be used to store the coordinates of shapes on the graph
135
+ */
136
+ this.coords = [[
137
+ this.centerx,
138
+ this.centery,
139
+ this.radius
140
+ ]];
141
+
142
+
143
+ /**
144
+ * Create the dollar object so that functions can be added to them
145
+ */
146
+ this.$0 = {};
147
+
148
+
149
+
150
+ /**
151
+ * Translate half a pixel for antialiasing purposes - but only if it hasn't beeen
152
+ * done already
153
+ */
154
+ if (!this.canvas.__rgraph_aa_translated__) {
155
+ this.context.translate(0.5,0.5);
156
+ this.canvas.__rgraph_aa_translated__ = true;
157
+ }
158
+
159
+
160
+
161
+
162
+ // Short variable names
163
+ var RG = RGraph,
164
+ ca = this.canvas,
165
+ co = ca.getContext('2d'),
166
+ prop = this.properties,
167
+ pa2 = RG.path2,
168
+ win = window,
169
+ doc = document,
170
+ ma = Math;
171
+
172
+
173
+
174
+ /**
175
+ * "Decorate" the object with the generic effects if the effects library has been included
176
+ */
177
+ if (RG.Effects && typeof RG.Effects.decorate === 'function') {
178
+ RG.Effects.decorate(this);
179
+ }
180
+
181
+
182
+
183
+
184
+ /**
185
+ * A setter method for setting graph properties. It can be used like this: obj.Set('chart.strokestyle', '#666');
186
+ *
187
+ * @param name string The name of the property to set OR it can be a map
188
+ * of name/value settings like what you set in the constructor
189
+ */
190
+ this.set =
191
+ this.Set = function (name)
192
+ {
193
+ var value = typeof arguments[1] === 'undefined' ? null : arguments[1];
194
+
195
+ /**
196
+ * the number of arguments is only one and it's an
197
+ * object - parse it for configuration data and return.
198
+ */
199
+ if (arguments.length === 1 && typeof name === 'object') {
200
+ RG.parseObjectStyleConfig(this, name);
201
+ return this;
202
+ }
203
+
204
+
205
+
206
+
207
+
208
+ /**
209
+ * This should be done first - prepend the property name with "chart." if necessary
210
+ */
211
+ if (name.substr(0,6) != 'chart.') {
212
+ name = 'chart.' + name;
213
+ }
214
+
215
+
216
+
217
+
218
+ // Convert uppercase letters to dot+lower case letter
219
+ while(name.match(/([A-Z])/)) {
220
+ name = name.replace(/([A-Z])/, '.' + RegExp.$1.toLowerCase());
221
+ }
222
+
223
+
224
+
225
+
226
+
227
+
228
+ prop[name] = value;
229
+
230
+ return this;
231
+ };
232
+
233
+
234
+
235
+
236
+ /**
237
+ * A getter method for retrieving graph properties. It can be used like this: obj.Get('chart.strokestyle');
238
+ *
239
+ * @param name string The name of the property to get
240
+ */
241
+ this.get =
242
+ this.Get = function (name)
243
+ {
244
+ /**
245
+ * This should be done first - prepend the property name with "chart." if necessary
246
+ */
247
+ if (name.substr(0,6) != 'chart.') {
248
+ name = 'chart.' + name;
249
+ }
250
+
251
+ // Convert uppercase letters to dot+lower case letter
252
+ while(name.match(/([A-Z])/)) {
253
+ name = name.replace(/([A-Z])/, '.' + RegExp.$1.toLowerCase());
254
+ }
255
+
256
+ return prop[name.toLowerCase()];
257
+ };
258
+
259
+
260
+
261
+
262
+ /**
263
+ * Draws the circle
264
+ */
265
+ this.draw =
266
+ this.Draw = function ()
267
+ {
268
+ /**
269
+ * Fire the onbeforedraw event
270
+ */
271
+ RG.fireCustomEvent(this, 'onbeforedraw');
272
+
273
+
274
+ /**
275
+ * Parse the colors. This allows for simple gradient syntax
276
+ */
277
+ if (!this.colorsParsed) {
278
+
279
+ this.parseColors();
280
+
281
+ // Don't want to do this again
282
+ this.colorsParsed = true;
283
+ }
284
+
285
+ pa2(co, 'b lw %',prop['chart.linewidth']);
286
+
287
+ if (prop['chart.shadow']) {
288
+ RG.setShadow(
289
+ this,
290
+ prop['chart.shadow.color'],
291
+ prop['chart.shadow.offsetx'],
292
+ prop['chart.shadow.offsety'],
293
+ prop['chart.shadow.blur']
294
+ );
295
+ }
296
+
297
+ pa2(co,
298
+ 'b a % % % % % % f % s %',
299
+ this.coords[0][0],
300
+ this.coords[0][1],
301
+ this.radius, 0,
302
+ RG.TWOPI,
303
+ false,
304
+ prop['chart.fillstyle'],
305
+ prop['chart.strokestyle'
306
+ ]);
307
+
308
+ // Must turn the shadow off before the fill is done
309
+ RG.noShadow(this);
310
+
311
+
312
+ /**
313
+ * This installs the event listeners
314
+ */
315
+ RG.installEventListeners(this);
316
+
317
+
318
+ /**
319
+ * Fire the onfirstdraw event
320
+ */
321
+ if (this.firstDraw) {
322
+ RG.fireCustomEvent(this, 'onfirstdraw');
323
+ this.firstDraw = false;
324
+ this.firstDrawFunc();
325
+ }
326
+
327
+
328
+
329
+ /**
330
+ * Fire the ondraw event
331
+ */
332
+ RG.fireCustomEvent(this, 'ondraw');
333
+
334
+ return this;
335
+ };
336
+
337
+
338
+
339
+ /**
340
+ * Used in chaining. Runs a function there and then - not waiting for
341
+ * the events to fire (eg the onbeforedraw event)
342
+ *
343
+ * @param function func The function to execute
344
+ */
345
+ this.exec = function (func)
346
+ {
347
+ func(this);
348
+
349
+ return this;
350
+ };
351
+
352
+
353
+
354
+
355
+ /**
356
+ * The getObjectByXY() worker method
357
+ */
358
+ this.getObjectByXY = function (e)
359
+ {
360
+ if (this.getShape(e)) {
361
+ return this;
362
+ }
363
+ };
364
+
365
+
366
+
367
+
368
+ /**
369
+ * Not used by the class during creating the shape, but is used by event handlers
370
+ * to get the coordinates (if any) of the selected bar
371
+ *
372
+ * @param object e The event object
373
+ * @param object OPTIONAL You can pass in the bar object instead of the
374
+ * function using "this"
375
+ */
376
+ this.getShape = function (e)
377
+ {
378
+ var mouseXY = RG.getMouseXY(e),
379
+ mouseX = mouseXY[0],
380
+ mouseY = mouseXY[1];
381
+
382
+ if (RG.getHypLength(this.centerx, this.centery, mouseXY[0], mouseXY[1]) <= this.radius) {
383
+
384
+ return {
385
+ 0: this, 1: this.centerx, 2: this.centery, 3: this.radius, 4: null, 5: 0,
386
+ 'object': this, 'x': this.centerx, 'y': this.centery, 'radius': this.radius, 'index': 0, 'tooltip': prop['chart.tooltips'] ? prop['chart.tooltips'][0] : null
387
+ };
388
+ }
389
+
390
+ return null;
391
+ };
392
+
393
+
394
+
395
+
396
+ /**
397
+ * Each object type has its own Highlight() function which highlights the appropriate shape
398
+ *
399
+ * @param object shape The shape to highlight
400
+ */
401
+ this.highlight =
402
+ this.Highlight = function (shape)
403
+ {
404
+ if (prop['chart.tooltips.highlight']) {
405
+ if (typeof prop['chart.highlight.style'] === 'function') {
406
+ (prop['chart.highlight.style'])(shape);
407
+ } else {
408
+ //pa2(co, ['b','a',this.centerx, this.centery, this.radius + 0.5, 0, RGraph.TWOPI, false,'f',prop['chart.highlight.fill'],'s',prop['chart.highlight.stroke']]);
409
+ pa2(co,
410
+ 'b a % % % % % % f % s %',
411
+ this.centerx,
412
+ this.centery,
413
+ this.radius + 0.5,
414
+ 0,
415
+ RG.TWOPI,
416
+ false,
417
+ prop['chart.highlight.fill'],
418
+ prop['chart.highlight.stroke']
419
+ );
420
+ }
421
+ }
422
+ };
423
+
424
+
425
+
426
+
427
+ /**
428
+ * This allows for easy specification of gradients
429
+ */
430
+ this.parseColors = function ()
431
+ {
432
+ // Save the original colors so that they can be restored when the canvas is reset
433
+ if (this.original_colors.length === 0) {
434
+ this.original_colors['chart.fillstyle'] = RG.array_clone(prop['chart.fillstyle']);
435
+ this.original_colors['chart.strokestyle'] = RG.array_clone(prop['chart.strokestyle']);
436
+ this.original_colors['chart.highlight.stroke'] = RG.array_clone(prop['chart.highlight.stroke']);
437
+ this.original_colors['chart.highlight.fill'] = RG.array_clone(prop['chart.highlight.fill']);
438
+ }
439
+
440
+
441
+
442
+
443
+ /**
444
+ * Parse various properties for colors
445
+ */
446
+ prop['chart.fillstyle'] = this.parseSingleColorForGradient(prop['chart.fillstyle']);
447
+ prop['chart.strokestyle'] = this.parseSingleColorForGradient(prop['chart.strokestyle']);
448
+ prop['chart.highlight.stroke'] = this.parseSingleColorForGradient(prop['chart.highlight.stroke']);
449
+ prop['chart.highlight.fill'] = this.parseSingleColorForGradient(prop['chart.highlight.fill']);
450
+ };
451
+
452
+
453
+
454
+
455
+ /**
456
+ * Use this function to reset the object to the post-constructor state. Eg reset colors if
457
+ * need be etc
458
+ */
459
+ this.reset = function ()
460
+ {
461
+ };
462
+
463
+
464
+
465
+
466
+ /**
467
+ * This parses a single color value
468
+ */
469
+ this.parseSingleColorForGradient = function (color)
470
+ {
471
+ if (!color) {
472
+ return color;
473
+ }
474
+
475
+ if (typeof color === 'string' && color.match(/^gradient\((.*)\)$/i)) {
476
+
477
+ var parts = RegExp.$1.split(':');
478
+
479
+ // Create the gradient
480
+ var grad = co.createRadialGradient(this.centerx, this.centery, 0, this.centerx, this.centery, this.radius),
481
+ diff = 1 / (parts.length - 1);
482
+
483
+
484
+ for (var j=0; j<parts.length; j+=1) {
485
+ grad.addColorStop(j * diff, RG.trim(parts[j]));
486
+ }
487
+ }
488
+
489
+ return grad ? grad : color;
490
+ };
491
+
492
+
493
+
494
+
495
+ /**
496
+ * Using a function to add events makes it easier to facilitate method chaining
497
+ *
498
+ * @param string type The type of even to add
499
+ * @param function func
500
+ */
501
+ this.on = function (type, func)
502
+ {
503
+ if (type.substr(0,2) !== 'on') {
504
+ type = 'on' + type;
505
+ }
506
+
507
+ if (typeof this[type] !== 'function') {
508
+ this[type] = func;
509
+ } else {
510
+ RG.addCustomEventListener(this, type, func);
511
+ }
512
+
513
+ return this;
514
+ };
515
+
516
+
517
+
518
+
519
+ /**
520
+ * This function runs once only
521
+ * (put at the end of the file (before any effects))
522
+ */
523
+ this.firstDrawFunc = function ()
524
+ {
525
+ };
526
+
527
+
528
+
529
+
530
+ /**
531
+ * Objects are now always registered so that the chart is redrawn if need be.
532
+ */
533
+ RG.register(this);
534
+
535
+
536
+
537
+
538
+ /**
539
+ * This is the 'end' of the constructor so if the first argument
540
+ * contains configuration data - handle that.
541
+ */
542
+ if (parseConfObjectForOptions) {
543
+ RG.parseObjectStyleConfig(this, conf.options);
544
+ }
545
+ };