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,40 +1,560 @@
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.Poly=function(conf)
3
- {if(typeof conf==='object'&&typeof conf.coords==='object'&&typeof conf.id==='string'){var id=conf.id
4
- var coords=conf.coords;var parseConfObjectForOptions=true;}else{var id=conf;var coords=arguments[1];}
5
- this.id=id;this.canvas=document.getElementById(this.id);this.context=this.canvas.getContext('2d');this.colorsParsed=false;this.canvas.__object__=this;this.coords=coords;this.coordsText=[];this.original_colors=[];this.firstDraw=true;this.type='drawing.poly';this.isRGraph=true;this.uid=RGraph.CreateUID();this.canvas.uid=this.canvas.uid?this.canvas.uid:RGraph.CreateUID();this.properties={'chart.linewidth':1,'chart.strokestyle':'black','chart.fillstyle':'red','chart.events.click':null,'chart.events.mousemove':null,'chart.tooltips':null,'chart.tooltips.override':null,'chart.tooltips.effect':'fade','chart.tooltips.css.class':'RGraph_tooltip','chart.tooltips.event':'onclick','chart.tooltips.highlight':true,'chart.highlight.stroke':'rgba(0,0,0,0)','chart.highlight.fill':'rgba(255,255,255,0.7)','chart.shadow':false,'chart.shadow.color':'rgba(0,0,0,0.2)','chart.shadow.offsetx':3,'chart.shadow.offsety':3,'chart.shadow.blur':5,'chart.clearto':'rgba(0,0,0,0)'}
6
- if(!this.canvas){alert('[DRAWING.POLY] No canvas support');return;}
7
- 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
- this.coordsText=[];var obj=this;pa2(co,['b','fu',function(obj){if(prop['chart.shadow']){co.shadowColor=prop['chart.shadow.color'];co.shadowOffsetX=prop['chart.shadow.offsetx'];co.shadowOffsetY=prop['chart.shadow.offsety'];co.shadowBlur=prop['chart.shadow.blur'];}},'fu',function(obj)
20
- {co.strokeStyle=prop['chart.strokestyle'];co.fillStyle=prop['chart.fillstyle'];obj.drawPoly();},'lw',prop['chart.linewidth'],'f',prop['chart.fillstyle'],'fu',function()
21
- {RG.NoShadow(obj);},'s',prop['chart.strokestyle']]);RG.NoShadow(this)
22
- RG.InstallEventListeners(this);if(this.firstDraw){RG.fireCustomEvent(this,'onfirstdraw');this.firstDraw=false;this.firstDrawFunc();}
23
- RG.FireCustomEvent(this,'ondraw');return this;};this.exec=function(func)
24
- {func(this);return this;};this.getObjectByXY=function(e)
25
- {if(this.getShape(e)){return this;}};this.drawPoly=this.DrawPoly=function()
26
- {var coords=this.coords;pa2(co,['b','m',coords[0][0],coords[0][1]]);for(var i=1,len=coords.length;i<len;++i){co.lineTo(coords[i][0],coords[i][1]);}
27
- pa2(co,['lw',prop['chart.linewidth'],'c','f',co.fillStyle,'s',co.strokeStyle]);};this.getShape=function(e)
28
- {var coords=this.coords;var mouseXY=RGraph.getMouseXY(e);var mouseX=mouseXY[0];var mouseY=mouseXY[1];co.beginPath();co.strokeStyle='rgba(0,0,0,0)';co.fillStyle='rgba(0,0,0,0)';this.DrawPoly();if(co.isPointInPath(mouseX,mouseY)){return{0:this,1:this.coords,2:0,'object':this,'coords':this.coords,'index':0,'tooltip':prop['chart.tooltips']?prop['chart.tooltips'][0]:null};}
29
- return null;};this.highlight=this.Highlight=function(shape)
30
- {co.fillStyle=prop['chart.fillstyle'];if(prop['chart.tooltips.highlight']){if(typeof prop['chart.highlight.style']==='function'){(prop['chart.highlight.style'])(shape);}else{pa2(co,['b','fu',function(obj){obj.DrawPoly();},'f',prop['chart.highlight.fill'],'s',prop['chart.highlight.stroke']]);}}};this.parseColors=function()
31
- {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']);}
32
- var func=this.parseSingleColorForGradient;prop['chart.fillstyle']=func(prop['chart.fillstyle']);prop['chart.strokestyle']=func(prop['chart.strokestyle']);prop['chart.highlight.stroke']=func(prop['chart.highlight.stroke']);prop['chart.highlight.fill']=func(prop['chart.highlight.fill']);};this.reset=function()
33
- {};this.parseSingleColorForGradient=function(color)
34
- {if(!color){return color;}
35
- if(typeof color==='string'&&color.match(/^gradient\((.*)\)$/i)){var parts=RegExp.$1.split(':');var grad=co.createLinearGradient(0,0,ca.width,0);var diff=1/(parts.length-1);grad.addColorStop(0,RG.trim(parts[0]));for(var j=1,len=parts.length;j<len;++j){grad.addColorStop(j*diff,RG.trim(parts[j]));}}
36
- return grad?grad:color;};this.on=function(type,func)
37
- {if(type.substr(0,2)!=='on'){type='on'+type;}
38
- if(typeof this[type]!=='function'){this[type]=func;}else{RG.addCustomEventListener(this,type,func);}
39
- return this;};this.firstDrawFunc=function()
40
- {};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, then the coordinates of the coords of the shape
25
+ *
26
+ * @param string id The canvas tag ID
27
+ * @param number coords The coordinates of the shape
28
+ */
29
+ RGraph.Drawing.Poly = function (conf)
30
+ {
31
+ /**
32
+ * Allow for object config style
33
+ */
34
+ if ( typeof conf === 'object'
35
+ && typeof conf.coords === 'object'
36
+ && typeof conf.id === 'string') {
37
+
38
+ var id = conf.id,
39
+ coords = conf.coords,
40
+ parseConfObjectForOptions = true; // Set this so the config is parsed (at the end of the constructor)
41
+ } else {
42
+ var id = conf,
43
+ coords = arguments[1];
44
+ }
45
+
46
+
47
+
48
+
49
+ this.id = id;
50
+ this.canvas = document.getElementById(this.id);
51
+ this.context = this.canvas.getContext('2d');
52
+ this.colorsParsed = false;
53
+ this.canvas.__object__ = this;
54
+ this.coords = coords;
55
+ this.coordsText = [];
56
+ this.original_colors = [];
57
+ this.firstDraw = true; // After the first draw this will be false
58
+
59
+
60
+ /**
61
+ * This defines the type of this shape
62
+ */
63
+ this.type = 'drawing.poly';
64
+
65
+
66
+ /**
67
+ * This facilitates easy object identification, and should always be true
68
+ */
69
+ this.isRGraph = true;
70
+
71
+
72
+ /**
73
+ * This adds a uid to the object that you can use for identification purposes
74
+ */
75
+ this.uid = RGraph.createUID();
76
+
77
+
78
+ /**
79
+ * This adds a UID to the canvas for identification purposes
80
+ */
81
+ this.canvas.uid = this.canvas.uid ? this.canvas.uid : RGraph.createUID();
82
+
83
+
84
+
85
+
86
+ /**
87
+ * Some example background properties
88
+ */
89
+ this.properties =
90
+ {
91
+ 'chart.linewidth': 1,
92
+ 'chart.strokestyle': 'black',
93
+ 'chart.fillstyle': 'red',
94
+ 'chart.events.click': null,
95
+ 'chart.events.mousemove': null,
96
+ 'chart.tooltips': null,
97
+ 'chart.tooltips.override': null,
98
+ 'chart.tooltips.effect': 'fade',
99
+ 'chart.tooltips.css.class': 'RGraph_tooltip',
100
+ 'chart.tooltips.event': 'onclick',
101
+ 'chart.tooltips.highlight': true,
102
+ 'chart.highlight.stroke': 'rgba(0,0,0,0)',
103
+ 'chart.highlight.fill': 'rgba(255,255,255,0.7)',
104
+ 'chart.shadow': false,
105
+ 'chart.shadow.color': 'rgba(0,0,0,0.2)',
106
+ 'chart.shadow.offsetx': 3,
107
+ 'chart.shadow.offsety': 3,
108
+ 'chart.shadow.blur': 5,
109
+ 'chart.clearto': 'rgba(0,0,0,0)'
110
+ }
111
+
112
+ /**
113
+ * A simple check that the browser has canvas support
114
+ */
115
+ if (!this.canvas) {
116
+ alert('[DRAWING.POLY] No canvas support');
117
+ return;
118
+ }
119
+
120
+ /**
121
+ * Create the dollar object so that functions can be added to them
122
+ */
123
+ this.$0 = {};
124
+
125
+
126
+ /**
127
+ * Translate half a pixel for antialiasing purposes - but only if it hasn't beeen
128
+ * done already
129
+ */
130
+ if (!this.canvas.__rgraph_aa_translated__) {
131
+ this.context.translate(0.5,0.5);
132
+ this.canvas.__rgraph_aa_translated__ = true;
133
+ }
134
+
135
+
136
+
137
+
138
+ // Short variable names
139
+ var RG = RGraph,
140
+ ca = this.canvas,
141
+ co = ca.getContext('2d'),
142
+ prop = this.properties,
143
+ pa2 = RG.path2,
144
+ win = window,
145
+ doc = document,
146
+ ma = Math;
147
+
148
+
149
+
150
+ /**
151
+ * "Decorate" the object with the generic effects if the effects library has been included
152
+ */
153
+ if (RG.Effects && typeof RG.Effects.decorate === 'function') {
154
+ RG.Effects.decorate(this);
155
+ }
156
+
157
+
158
+
159
+
160
+ /**
161
+ * A setter method for setting properties.
162
+ *
163
+ * @param name string The name of the property to set OR it can be a map
164
+ * of name/value settings like what you set in the constructor
165
+ */
166
+ this.set =
167
+ this.Set = function (name)
168
+ {
169
+ var value = typeof arguments[1] === 'undefined' ? null : arguments[1];
170
+
171
+ /**
172
+ * the number of arguments is only one and it's an
173
+ * object - parse it for configuration data and return.
174
+ */
175
+ if (arguments.length === 1 && typeof name === 'object') {
176
+ RG.parseObjectStyleConfig(this, name);
177
+ return this;
178
+ }
179
+
180
+
181
+
182
+
183
+
184
+ /**
185
+ * This should be done first - prepend the property name with "chart." if necessary
186
+ */
187
+ if (name.substr(0,6) != 'chart.') {
188
+ name = 'chart.' + name;
189
+ }
190
+
191
+
192
+
193
+
194
+ // Convert uppercase letters to dot+lower case letter
195
+ while(name.match(/([A-Z])/)) {
196
+ name = name.replace(/([A-Z])/, '.' + RegExp.$1.toLowerCase());
197
+ }
198
+
199
+
200
+
201
+
202
+
203
+
204
+ prop[name] = value;
205
+
206
+ return this;
207
+ };
208
+
209
+
210
+
211
+
212
+ /**
213
+ * A getter method for retrieving graph properties. It can be used like this: obj.Get('chart.strokestyle');
214
+ *
215
+ * @param name string The name of the property to get
216
+ */
217
+ this.get =
218
+ this.Get = function (name)
219
+ {
220
+ /**
221
+ * This should be done first - prepend the property name with "chart." if necessary
222
+ */
223
+ if (name.substr(0,6) != 'chart.') {
224
+ name = 'chart.' + name;
225
+ }
226
+
227
+ // Convert uppercase letters to dot+lower case letter
228
+ while(name.match(/([A-Z])/)) {
229
+ name = name.replace(/([A-Z])/, '.' + RegExp.$1.toLowerCase());
230
+ }
231
+
232
+ return prop[name.toLowerCase()];
233
+ };
234
+
235
+
236
+
237
+
238
+ /**
239
+ * Draws the shape
240
+ */
241
+ this.draw =
242
+ this.Draw = function ()
243
+ {
244
+ /**
245
+ * Fire the onbeforedraw event
246
+ */
247
+ RG.fireCustomEvent(this, 'onbeforedraw');
248
+
249
+
250
+ /**
251
+ * Parse the colors. This allows for simple gradient syntax
252
+ */
253
+ if (!this.colorsParsed) {
254
+
255
+ this.parseColors();
256
+
257
+ // Don't want to do this again
258
+ this.colorsParsed = true;
259
+ }
260
+
261
+
262
+
263
+
264
+
265
+ /**
266
+ * Stop this growing uncntrollably
267
+ */
268
+ this.coordsText = [];
269
+
270
+
271
+
272
+
273
+
274
+ /**
275
+ * DRAW THE SHAPE HERE
276
+ */
277
+
278
+ var obj = this;
279
+ pa2(co, ['b','fu',function (obj){
280
+ if (prop['chart.shadow']) {
281
+ co.shadowColor = prop['chart.shadow.color'];
282
+ co.shadowOffsetX = prop['chart.shadow.offsetx'];
283
+ co.shadowOffsetY = prop['chart.shadow.offsety'];
284
+ co.shadowBlur = prop['chart.shadow.blur'];
285
+ }},'fu',function (obj)
286
+ {
287
+ co.strokeStyle = prop['chart.strokestyle'];
288
+ co.fillStyle = prop['chart.fillstyle'];
289
+
290
+ obj.drawPoly();
291
+ },'lw',prop['chart.linewidth'],'f',prop['chart.fillstyle'], 'fu', function ()
292
+ {
293
+ RG.noShadow(obj);
294
+ }, 's',prop['chart.strokestyle']]);
295
+
296
+
297
+
298
+ /**
299
+ * Turn off shadow again
300
+ */
301
+ RG.noShadow(this)
302
+
303
+
304
+
305
+ /**
306
+ * This installs the event listeners
307
+ */
308
+ RG.installEventListeners(this);
309
+
310
+
311
+ /**
312
+ * Fire the onfirstdraw event
313
+ */
314
+ if (this.firstDraw) {
315
+ RG.fireCustomEvent(this, 'onfirstdraw');
316
+ this.firstDraw = false;
317
+ this.firstDrawFunc();
318
+ }
319
+
320
+
321
+
322
+
323
+ /**
324
+ * Fire the ondraw event
325
+ */
326
+ RG.fireCustomEvent(this, 'ondraw');
327
+
328
+ return this;
329
+ };
330
+
331
+
332
+
333
+ /**
334
+ * Used in chaining. Runs a function there and then - not waiting for
335
+ * the events to fire (eg the onbeforedraw event)
336
+ *
337
+ * @param function func The function to execute
338
+ */
339
+ this.exec = function (func)
340
+ {
341
+ func(this);
342
+
343
+ return this;
344
+ };
345
+
346
+
347
+
348
+
349
+ /**
350
+ * The getObjectByXY() worker method
351
+ */
352
+ this.getObjectByXY = function (e)
353
+ {
354
+ if (this.getShape(e)) {
355
+ return this;
356
+ }
357
+ };
358
+
359
+
360
+
361
+
362
+ /**
363
+ * Draw the Poly but doesn't stroke or fill - that's left to other functions
364
+ */
365
+ this.drawPoly =
366
+ this.DrawPoly = function ()
367
+ {
368
+ var coords = this.coords;
369
+
370
+ pa2(co, ['b','m',coords[0][0], coords[0][1]]);
371
+
372
+ // Draw lines to subsequent coords
373
+ for (var i=1,len=coords.length; i<len; ++i) {
374
+ co.lineTo(coords[i][0],coords[i][1]);
375
+ }
376
+
377
+ // Close the path and stroke/fill it with whatever the current fill/stroke styles are
378
+ pa2(co, ['lw', prop['chart.linewidth'], 'c','f',co.fillStyle, 's',co.strokeStyle]);
379
+ };
380
+
381
+
382
+
383
+
384
+ /**
385
+ * Not used by the class during creating the graph, but is used by event handlers
386
+ * to get the coordinates (if any) of the selected bar
387
+ *
388
+ * @param object e The event object
389
+ */
390
+ this.getShape = function (e)
391
+ {
392
+ var coords = this.coords,
393
+ mouseXY = RG.getMouseXY(e),
394
+ mouseX = mouseXY[0],
395
+ mouseY = mouseXY[1];
396
+
397
+ // Should redraw the poly but not stroke or fill it and then use isPointInPath() to test it
398
+ // DON'T USE PATH OBJECT HERE
399
+ co.beginPath();
400
+ co.strokeStyle = 'rgba(0,0,0,0)';
401
+ co.fillStyle = 'rgba(0,0,0,0)';
402
+ this.drawPoly();
403
+
404
+ if (co.isPointInPath(mouseX, mouseY)) {
405
+
406
+ return {
407
+ 0: this, 1: this.coords, 2: 0,
408
+ 'object': this, 'coords': this.coords, 'index': 0, 'tooltip': prop['chart.tooltips'] ? prop['chart.tooltips'][0] : null
409
+ };
410
+ }
411
+
412
+ return null;
413
+ };
414
+
415
+
416
+
417
+
418
+ /**
419
+ * Each object type has its own Highlight() function which highlights the appropriate shape
420
+ *
421
+ * @param object shape The shape to highlight
422
+ */
423
+ this.highlight =
424
+ this.Highlight = function (shape)
425
+ {
426
+ // Evidentally this is necessary
427
+ co.fillStyle = prop['chart.fillstyle'];
428
+
429
+ // Add the new highlight
430
+ if (prop['chart.tooltips.highlight']) {
431
+ if (typeof prop['chart.highlight.style'] === 'function') {
432
+ (prop['chart.highlight.style'])(shape);
433
+ } else {
434
+ pa2(co, ['b', 'fu', function (obj){obj.DrawPoly();},'f',prop['chart.highlight.fill'],'s',prop['chart.highlight.stroke']]);
435
+ }
436
+ }
437
+ };
438
+
439
+
440
+
441
+
442
+ /**
443
+ * This allows for easy specification of gradients
444
+ */
445
+ this.parseColors = function ()
446
+ {
447
+
448
+ // Save the original colors so that they can be restored when the canvas is reset
449
+ if (this.original_colors.length === 0) {
450
+ this.original_colors['chart.fillstyle'] = RG.array_clone(prop['chart.fillstyle']);
451
+ this.original_colors['chart.strokestyle'] = RG.array_clone(prop['chart.strokestyle']);
452
+ this.original_colors['chart.highlight.stroke'] = RG.array_clone(prop['chart.highlight.stroke']);
453
+ this.original_colors['chart.highlight.fill'] = RG.array_clone(prop['chart.highlight.fill']);
454
+ }
455
+
456
+ var func = this.parseSingleColorForGradient;
457
+
458
+ /**
459
+ * Parse various properties for colors
460
+ */
461
+ prop['chart.fillstyle'] = func(prop['chart.fillstyle']);
462
+ prop['chart.strokestyle'] = func(prop['chart.strokestyle']);
463
+ prop['chart.highlight.stroke'] = func(prop['chart.highlight.stroke']);
464
+ prop['chart.highlight.fill'] = func(prop['chart.highlight.fill']);
465
+ };
466
+
467
+
468
+
469
+
470
+ /**
471
+ * Use this function to reset the object to the post-constructor state. Eg reset colors if
472
+ * need be etc
473
+ */
474
+ this.reset = function ()
475
+ {
476
+ };
477
+
478
+
479
+
480
+
481
+ /**
482
+ * This parses a single color value
483
+ */
484
+ this.parseSingleColorForGradient = function (color)
485
+ {
486
+ if (!color) {
487
+ return color;
488
+ }
489
+
490
+ if (typeof color === 'string' && color.match(/^gradient\((.*)\)$/i)) {
491
+
492
+ // Create the gradient
493
+ var parts = RegExp.$1.split(':'),
494
+ grad = co.createLinearGradient(0,0,ca.width,0),
495
+ diff = 1 / (parts.length - 1);
496
+
497
+ grad.addColorStop(0, RG.trim(parts[0]));
498
+
499
+ for (var j=1,len=parts.length; j<len; ++j) {
500
+ grad.addColorStop(j * diff, RG.trim(parts[j]));
501
+ }
502
+ }
503
+
504
+ return grad ? grad : color;
505
+ };
506
+
507
+
508
+
509
+
510
+ /**
511
+ * Using a function to add events makes it easier to facilitate method chaining
512
+ *
513
+ * @param string type The type of even to add
514
+ * @param function func
515
+ */
516
+ this.on = function (type, func)
517
+ {
518
+ if (type.substr(0,2) !== 'on') {
519
+ type = 'on' + type;
520
+ }
521
+
522
+ if (typeof this[type] !== 'function') {
523
+ this[type] = func;
524
+ } else {
525
+ RG.addCustomEventListener(this, type, func);
526
+ }
527
+
528
+ return this;
529
+ };
530
+
531
+
532
+
533
+
534
+ /**
535
+ * This function runs once only
536
+ * (put at the end of the file (before any effects))
537
+ */
538
+ this.firstDrawFunc = function ()
539
+ {
540
+ };
541
+
542
+
543
+
544
+
545
+ /**
546
+ * Objects are now always registered so that the chart is redrawn if need be.
547
+ */
548
+ RG.register(this);
549
+
550
+
551
+
552
+
553
+ /**
554
+ * This is the 'end' of the constructor so if the first argument
555
+ * contains configuration data - handle that.
556
+ */
557
+ if (parseConfObjectForOptions) {
558
+ RG.parseObjectStyleConfig(this, conf.options);
559
+ }
560
+ };