rgraph-rails 1.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +9 -0
- data/.rspec +2 -0
- data/.travis.yml +4 -0
- data/CODE_OF_CONDUCT.md +13 -0
- data/Gemfile +4 -0
- data/README.md +73 -0
- data/Rakefile +6 -0
- data/bin/console +14 -0
- data/bin/setup +7 -0
- data/lib/rgraph-rails/version.rb +3 -0
- data/lib/rgraph-rails.rb +8 -0
- data/license.txt +19 -0
- data/rgraph-rails.gemspec +26 -0
- data/vendor/assets/images/bg.png +0 -0
- data/vendor/assets/images/bullet.png +0 -0
- data/vendor/assets/images/facebook-large.png +0 -0
- data/vendor/assets/images/google-plus-large.png +0 -0
- data/vendor/assets/images/logo.png +0 -0
- data/vendor/assets/images/meter-image-sd-needle.png +0 -0
- data/vendor/assets/images/meter-image-sd.png +0 -0
- data/vendor/assets/images/meter-sketch-needle.png +0 -0
- data/vendor/assets/images/meter-sketch.png +0 -0
- data/vendor/assets/images/odometer-background.png +0 -0
- data/vendor/assets/images/rgraph.jpg +0 -0
- data/vendor/assets/images/title.png +0 -0
- data/vendor/assets/images/twitter-large.png +0 -0
- data/vendor/assets/javascripts/RGraph.bar.js +3246 -0
- data/vendor/assets/javascripts/RGraph.bipolar.js +2003 -0
- data/vendor/assets/javascripts/RGraph.common.annotate.js +399 -0
- data/vendor/assets/javascripts/RGraph.common.context.js +600 -0
- data/vendor/assets/javascripts/RGraph.common.core.js +4751 -0
- data/vendor/assets/javascripts/RGraph.common.csv.js +275 -0
- data/vendor/assets/javascripts/RGraph.common.deprecated.js +454 -0
- data/vendor/assets/javascripts/RGraph.common.dynamic.js +1194 -0
- data/vendor/assets/javascripts/RGraph.common.effects.js +1524 -0
- data/vendor/assets/javascripts/RGraph.common.key.js +735 -0
- data/vendor/assets/javascripts/RGraph.common.resizing.js +550 -0
- data/vendor/assets/javascripts/RGraph.common.tooltips.js +605 -0
- data/vendor/assets/javascripts/RGraph.common.zoom.js +223 -0
- data/vendor/assets/javascripts/RGraph.drawing.background.js +636 -0
- data/vendor/assets/javascripts/RGraph.drawing.circle.js +579 -0
- data/vendor/assets/javascripts/RGraph.drawing.image.js +810 -0
- data/vendor/assets/javascripts/RGraph.drawing.marker1.js +710 -0
- data/vendor/assets/javascripts/RGraph.drawing.marker2.js +672 -0
- data/vendor/assets/javascripts/RGraph.drawing.marker3.js +568 -0
- data/vendor/assets/javascripts/RGraph.drawing.poly.js +623 -0
- data/vendor/assets/javascripts/RGraph.drawing.rect.js +603 -0
- data/vendor/assets/javascripts/RGraph.drawing.text.js +648 -0
- data/vendor/assets/javascripts/RGraph.drawing.xaxis.js +815 -0
- data/vendor/assets/javascripts/RGraph.drawing.yaxis.js +860 -0
- data/vendor/assets/javascripts/RGraph.fuel.js +965 -0
- data/vendor/assets/javascripts/RGraph.funnel.js +988 -0
- data/vendor/assets/javascripts/RGraph.gantt.js +1242 -0
- data/vendor/assets/javascripts/RGraph.gauge.js +1391 -0
- data/vendor/assets/javascripts/RGraph.hbar.js +1794 -0
- data/vendor/assets/javascripts/RGraph.hprogress.js +1307 -0
- data/vendor/assets/javascripts/RGraph.line.js +3940 -0
- data/vendor/assets/javascripts/RGraph.meter.js +1242 -0
- data/vendor/assets/javascripts/RGraph.modaldialog.js +292 -0
- data/vendor/assets/javascripts/RGraph.odo.js +1265 -0
- data/vendor/assets/javascripts/RGraph.pie.js +1979 -0
- data/vendor/assets/javascripts/RGraph.radar.js +1840 -0
- data/vendor/assets/javascripts/RGraph.rose.js +1860 -0
- data/vendor/assets/javascripts/RGraph.rscatter.js +1332 -0
- data/vendor/assets/javascripts/RGraph.scatter.js +3029 -0
- data/vendor/assets/javascripts/RGraph.thermometer.js +1131 -0
- data/vendor/assets/javascripts/RGraph.vprogress.js +1326 -0
- data/vendor/assets/javascripts/RGraph.waterfall.js +1252 -0
- data/vendor/assets/javascripts/financial-data.js +1067 -0
- data/vendor/assets/stylesheets/ModalDialog.css +90 -0
- data/vendor/assets/stylesheets/animations.css +3347 -0
- data/vendor/assets/stylesheets/website.css +402 -0
- metadata +175 -0
@@ -0,0 +1,568 @@
|
|
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. Alternatively it can take
|
28
|
+
* a single JSON-style configuration object
|
29
|
+
*
|
30
|
+
* @param string id The canvas tag ID
|
31
|
+
* @param number x The X position of the marker
|
32
|
+
* @param number y The Y position of the marker
|
33
|
+
* @param number text The max radius of the pulsing circle
|
34
|
+
*/
|
35
|
+
RGraph.Drawing.Marker3 = function (conf)
|
36
|
+
{
|
37
|
+
/**
|
38
|
+
* Allow for object config style
|
39
|
+
*/
|
40
|
+
if ( typeof conf === 'object'
|
41
|
+
&& typeof conf.x === 'number'
|
42
|
+
&& typeof conf.y === 'number'
|
43
|
+
&& typeof conf.id === 'string'
|
44
|
+
&& typeof conf.radius === 'number') {
|
45
|
+
|
46
|
+
var id = conf.id
|
47
|
+
var canvas = document.getElementById(id);
|
48
|
+
var x = conf.x;
|
49
|
+
var y = conf.y;
|
50
|
+
var radius = conf.radius;
|
51
|
+
|
52
|
+
var parseConfObjectForOptions = true; // Set this so the config is parsed (at the end of the constructor)
|
53
|
+
|
54
|
+
} else {
|
55
|
+
|
56
|
+
var id = conf;
|
57
|
+
var canvas = document.getElementById(id);
|
58
|
+
var x = arguments[1];
|
59
|
+
var y = arguments[2];
|
60
|
+
var radius = arguments[3];
|
61
|
+
}
|
62
|
+
|
63
|
+
|
64
|
+
|
65
|
+
|
66
|
+
this.id = id;
|
67
|
+
this.canvas = document.getElementById(this.id);
|
68
|
+
this.context = this.canvas.getContext('2d')
|
69
|
+
this.colorsParsed = false;
|
70
|
+
this.canvas.__object__ = this;
|
71
|
+
this.original_colors = [];
|
72
|
+
this.firstDraw = true; // After the first draw this will be false
|
73
|
+
|
74
|
+
// The actual radius is what is used to draw the marker - the other radius is the maximum target radius
|
75
|
+
// that the marker grows to
|
76
|
+
this.actualRadius = 0;
|
77
|
+
|
78
|
+
// This is the alpha value that is used to fade out the pulsing marker
|
79
|
+
this.alpha = 1;
|
80
|
+
|
81
|
+
|
82
|
+
/**
|
83
|
+
* Store the properties
|
84
|
+
*/
|
85
|
+
this.centerx = x;
|
86
|
+
this.centery = y;
|
87
|
+
this.radius = radius;
|
88
|
+
|
89
|
+
|
90
|
+
/**
|
91
|
+
* This defines the type of this shape
|
92
|
+
*/
|
93
|
+
this.type = 'drawing.marker3';
|
94
|
+
|
95
|
+
|
96
|
+
/**
|
97
|
+
* This facilitates easy object identification, and should always be true
|
98
|
+
*/
|
99
|
+
this.isRGraph = true;
|
100
|
+
|
101
|
+
|
102
|
+
/**
|
103
|
+
* This adds a uid to the object that you can use for identification purposes
|
104
|
+
*/
|
105
|
+
this.uid = RGraph.CreateUID();
|
106
|
+
|
107
|
+
|
108
|
+
/**
|
109
|
+
* This adds a UID to the canvas for identification purposes
|
110
|
+
*/
|
111
|
+
this.canvas.uid = this.canvas.uid ? this.canvas.uid : RGraph.CreateUID();
|
112
|
+
|
113
|
+
|
114
|
+
/**
|
115
|
+
* Some example background properties
|
116
|
+
*/
|
117
|
+
this.properties =
|
118
|
+
{
|
119
|
+
'chart.fillstyle': 'rgba(255,255,255,1)',
|
120
|
+
'chart.delay': 50,
|
121
|
+
'chart.events.click': null,
|
122
|
+
'chart.events.mousemove': null,
|
123
|
+
'chart.highlight.fill': 'rgba(255,0,0,1.0)',
|
124
|
+
'chart.tooltips': null,
|
125
|
+
'chart.tooltips.highlight': true,
|
126
|
+
'chart.tooltips.event': 'onclick'
|
127
|
+
}
|
128
|
+
|
129
|
+
/**
|
130
|
+
* A simple check that the browser has canvas support
|
131
|
+
*/
|
132
|
+
if (!this.canvas) {
|
133
|
+
alert('[DRAWING.MARKER3] No canvas support');
|
134
|
+
return;
|
135
|
+
}
|
136
|
+
|
137
|
+
/**
|
138
|
+
* These are used to store coords
|
139
|
+
*/
|
140
|
+
this.coords = [];
|
141
|
+
this.coordsText = [];
|
142
|
+
|
143
|
+
|
144
|
+
/**
|
145
|
+
* Create the dollar object so that functions can be added to them
|
146
|
+
*/
|
147
|
+
this.$0 = {};
|
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
|
+
|
157
|
+
this.canvas.__rgraph_aa_translated__ = true;
|
158
|
+
}
|
159
|
+
|
160
|
+
|
161
|
+
|
162
|
+
|
163
|
+
// Short variable names
|
164
|
+
var RG = RGraph,
|
165
|
+
ca = this.canvas,
|
166
|
+
co = ca.getContext('2d'),
|
167
|
+
prop = this.properties,
|
168
|
+
pa = RG.Path,
|
169
|
+
pa2 = RG.path2,
|
170
|
+
win = window,
|
171
|
+
doc = document,
|
172
|
+
ma = Math
|
173
|
+
|
174
|
+
|
175
|
+
|
176
|
+
/**
|
177
|
+
* "Decorate" the object with the generic effects if the effects library has been included
|
178
|
+
*/
|
179
|
+
if (RG.Effects && typeof RG.Effects.decorate === 'function') {
|
180
|
+
RG.Effects.decorate(this);
|
181
|
+
}
|
182
|
+
|
183
|
+
|
184
|
+
|
185
|
+
|
186
|
+
/**
|
187
|
+
* A setter method for setting graph properties. It can be used like this: obj.Set('chart.strokestyle', '#666');
|
188
|
+
*
|
189
|
+
|
190
|
+
* @param name string The name of the property to set OR it can be a map
|
191
|
+
* of name/value settings like what you set in the constructor
|
192
|
+
*/
|
193
|
+
this.set =
|
194
|
+
this.Set = function (name)
|
195
|
+
{
|
196
|
+
var value = typeof arguments[1] === 'undefined' ? null : arguments[1];
|
197
|
+
|
198
|
+
/**
|
199
|
+
* the number of arguments is only one and it's an
|
200
|
+
* object - parse it for configuration data and return.
|
201
|
+
*/
|
202
|
+
if (arguments.length === 1 && typeof name === 'object') {
|
203
|
+
RG.parseObjectStyleConfig(this, name);
|
204
|
+
return this;
|
205
|
+
}
|
206
|
+
|
207
|
+
|
208
|
+
|
209
|
+
|
210
|
+
|
211
|
+
/**
|
212
|
+
* This should be done first - prepend the propertyy name with "chart." if necessary
|
213
|
+
*/
|
214
|
+
if (name.substr(0,6) != 'chart.') {
|
215
|
+
name = 'chart.' + name;
|
216
|
+
}
|
217
|
+
|
218
|
+
|
219
|
+
|
220
|
+
|
221
|
+
// Convert uppercase letters to dot+lower case letter
|
222
|
+
name = name.replace(/([A-Z])/g, function (str)
|
223
|
+
{
|
224
|
+
return '.' + String(RegExp.$1).toLowerCase();
|
225
|
+
});
|
226
|
+
|
227
|
+
|
228
|
+
|
229
|
+
|
230
|
+
|
231
|
+
|
232
|
+
prop[name] = value;
|
233
|
+
|
234
|
+
return this;
|
235
|
+
};
|
236
|
+
|
237
|
+
|
238
|
+
|
239
|
+
|
240
|
+
/**
|
241
|
+
* A getter method for retrieving graph properties. It can be used like this: obj.Get('chart.strokestyle');
|
242
|
+
*
|
243
|
+
* @param name string The name of the property to get
|
244
|
+
*/
|
245
|
+
this.get =
|
246
|
+
this.Get = function (name)
|
247
|
+
{
|
248
|
+
/**
|
249
|
+
* This should be done first - prepend the property name with "chart." if necessary
|
250
|
+
*/
|
251
|
+
if (name.substr(0,6) != 'chart.') {
|
252
|
+
name = 'chart.' + name;
|
253
|
+
}
|
254
|
+
|
255
|
+
// Convert uppercase letters to dot+lower case letter
|
256
|
+
name = name.replace(/([A-Z])/g, function (str)
|
257
|
+
{
|
258
|
+
return '.' + String(RegExp.$1).toLowerCase()
|
259
|
+
});
|
260
|
+
|
261
|
+
return prop[name.toLowerCase()];
|
262
|
+
};
|
263
|
+
|
264
|
+
|
265
|
+
|
266
|
+
|
267
|
+
/**
|
268
|
+
* Draws the marker
|
269
|
+
*/
|
270
|
+
this.draw =
|
271
|
+
this.Draw = function ()
|
272
|
+
{
|
273
|
+
// Draw a circle to start with
|
274
|
+
co.globalAlpha = this.alpha;
|
275
|
+
pa(this, [
|
276
|
+
'b',
|
277
|
+
'a', this.centerx, this.centery, this.actualRadius, 0, 2 * Math.PI,false,
|
278
|
+
'a', this.centerx, this.centery, ma.max(this.actualRadius - 8, 0), 2 * Math.PI,0, true,
|
279
|
+
'f', prop['chart.fillstyle']]
|
280
|
+
);
|
281
|
+
this.alpha = this.actualRadius ? 1 - ( (this.actualRadius * 0.75) / this.radius) : 1;
|
282
|
+
co.globalAlpha = 1;
|
283
|
+
|
284
|
+
|
285
|
+
if (this.actualRadius < this.radius) {
|
286
|
+
this.actualRadius += 2;
|
287
|
+
} else if (this.actualRadius >= this.radius) {
|
288
|
+
this.actualRadius = 0;
|
289
|
+
this.alpha = 1;
|
290
|
+
}
|
291
|
+
|
292
|
+
var obj = this;
|
293
|
+
setTimeout(function ()
|
294
|
+
{
|
295
|
+
RG.redrawCanvas(ca);
|
296
|
+
}, prop['chart.delay']);
|
297
|
+
|
298
|
+
|
299
|
+
|
300
|
+
|
301
|
+
/**
|
302
|
+
* This installs the event listeners
|
303
|
+
*/
|
304
|
+
RG.InstallEventListeners(this);
|
305
|
+
|
306
|
+
|
307
|
+
/**
|
308
|
+
* Fire the onfirstdraw event
|
309
|
+
*/
|
310
|
+
if (this.firstDraw) {
|
311
|
+
RG.fireCustomEvent(this, 'onfirstdraw');
|
312
|
+
this.firstDraw = false;
|
313
|
+
this.firstDrawFunc();
|
314
|
+
}
|
315
|
+
|
316
|
+
|
317
|
+
|
318
|
+
|
319
|
+
/**
|
320
|
+
* Fire the ondraw event
|
321
|
+
*/
|
322
|
+
RG.fireCustomEvent(this, 'ondraw');
|
323
|
+
|
324
|
+
return this;
|
325
|
+
};
|
326
|
+
|
327
|
+
|
328
|
+
|
329
|
+
/**
|
330
|
+
* Used in chaining. Runs a function there and then - not waiting for
|
331
|
+
* the events to fire (eg the onbeforedraw event)
|
332
|
+
*
|
333
|
+
* @param function func The function to execute
|
334
|
+
*/
|
335
|
+
this.exec = function (func)
|
336
|
+
{
|
337
|
+
func(this);
|
338
|
+
|
339
|
+
return this;
|
340
|
+
};
|
341
|
+
|
342
|
+
|
343
|
+
|
344
|
+
|
345
|
+
/**
|
346
|
+
* The getObjectByXY() worker method
|
347
|
+
*/
|
348
|
+
this.getObjectByXY = function (e)
|
349
|
+
{
|
350
|
+
if (this.getShape(e)) {
|
351
|
+
return this;
|
352
|
+
}
|
353
|
+
};
|
354
|
+
|
355
|
+
|
356
|
+
|
357
|
+
|
358
|
+
/**
|
359
|
+
* Not used by the class during creating the shape, but is used by event handlers
|
360
|
+
* to get the coordinates (if any) of the selected bar
|
361
|
+
*
|
362
|
+
* @param object e The event object
|
363
|
+
*/
|
364
|
+
this.getShape = function (e)
|
365
|
+
{
|
366
|
+
var mouseXY = RGraph.getMouseXY(e);
|
367
|
+
var mouseX = mouseXY[0];
|
368
|
+
var mouseY = mouseXY[1];
|
369
|
+
|
370
|
+
if (RG.getHypLength(this.centerx, this.centery, mouseXY[0], mouseXY[1]) <= this.radius) {
|
371
|
+
|
372
|
+
return {
|
373
|
+
0: this, 1: this.centerx, 2: this.centery, 3: this.radius, 4: null, 5: 0,
|
374
|
+
'object': this, 'x': this.centerx, 'y': this.centery, 'radius': this.radius, 'index': 0, 'tooltip': prop['chart.tooltips'] ? prop['chart.tooltips'][0] : null
|
375
|
+
};
|
376
|
+
}
|
377
|
+
|
378
|
+
return null;
|
379
|
+
};
|
380
|
+
|
381
|
+
|
382
|
+
|
383
|
+
|
384
|
+
/**
|
385
|
+
* This function positions a tooltip when it is displayed
|
386
|
+
*
|
387
|
+
* @param obj object The chart object
|
388
|
+
* @param int x The X coordinate specified for the tooltip
|
389
|
+
* @param int y The Y coordinate specified for the tooltip
|
390
|
+
* @param object tooltip The tooltips DIV element
|
391
|
+
* @param number idx The index of the tooltip
|
392
|
+
*/
|
393
|
+
this.positionTooltip = function (obj, x, y, tooltip, idx)
|
394
|
+
{
|
395
|
+
var canvasXY = RG.getCanvasXY(obj.canvas);
|
396
|
+
var width = tooltip.offsetWidth;
|
397
|
+
var height = tooltip.offsetHeight;
|
398
|
+
var radius = this.radius;
|
399
|
+
|
400
|
+
// Set the top position
|
401
|
+
tooltip.style.left = 0;
|
402
|
+
tooltip.style.top = canvasXY[1] + obj.centery - height - 7 + 'px';
|
403
|
+
|
404
|
+
// By default any overflow is hidden
|
405
|
+
tooltip.style.overflow = '';
|
406
|
+
|
407
|
+
// The arrow
|
408
|
+
var img = new Image();
|
409
|
+
img.src = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABEAAAAFCAYAAACjKgd3AAAARUlEQVQYV2NkQAN79+797+RkhC4M5+/bd47B2dmZEVkBCgcmgcsgbAaA9GA1BCSBbhAuA/AagmwQPgMIGgIzCD0M0AMMAEFVIAa6UQgcAAAAAElFTkSuQmCC';
|
410
|
+
img.style.position = 'absolute';
|
411
|
+
img.id = '__rgraph_tooltip_pointer__';
|
412
|
+
img.style.top = (tooltip.offsetHeight - 2) + 'px';
|
413
|
+
tooltip.appendChild(img);
|
414
|
+
|
415
|
+
// Reposition the tooltip if at the edges:
|
416
|
+
|
417
|
+
// LEFT edge
|
418
|
+
if ((canvasXY[0] + obj.centerx - (width / 2)) < 10) {
|
419
|
+
tooltip.style.left = (canvasXY[0] + this.centerx - (width * 0.1)) + 'px';
|
420
|
+
img.style.left = ((width * 0.1) - 8.5) + 'px';
|
421
|
+
|
422
|
+
// RIGHT edge
|
423
|
+
} else if ((canvasXY[0] + obj.centerx + (width / 2)) > doc.body.offsetWidth) {
|
424
|
+
tooltip.style.left = canvasXY[0] + this.centerx - (width * 0.9) + 'px';
|
425
|
+
img.style.left = ((width * 0.9) - 8.5) + 'px';
|
426
|
+
|
427
|
+
// Default positioning - CENTERED
|
428
|
+
} else {
|
429
|
+
tooltip.style.left = (canvasXY[0] + this.centerx - (width * 0.5)) + 'px';
|
430
|
+
img.style.left = ((width * 0.5) - 8.5) + 'px';
|
431
|
+
}
|
432
|
+
};
|
433
|
+
|
434
|
+
|
435
|
+
|
436
|
+
/**
|
437
|
+
* Each object type has its own Highlight() function which highlights the appropriate shape
|
438
|
+
*
|
439
|
+
* @param object shape The shape to highlight
|
440
|
+
*/
|
441
|
+
this.highlight =
|
442
|
+
this.Highlight = function (shape)
|
443
|
+
{
|
444
|
+
if (prop['chart.tooltips.highlight']) {
|
445
|
+
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']]);
|
446
|
+
}
|
447
|
+
};
|
448
|
+
|
449
|
+
|
450
|
+
|
451
|
+
|
452
|
+
/**
|
453
|
+
* This allows for easy specification of gradients
|
454
|
+
*/
|
455
|
+
this.parseColors = function ()
|
456
|
+
{
|
457
|
+
// Save the original colors so that they can be restored when the canvas is reset
|
458
|
+
if (this.original_colors.length === 0) {
|
459
|
+
this.original_colors['chart.fillstyle'] = RG.array_clone(prop['chart.fillstyle']);
|
460
|
+
this.original_colors['chart.highlight.fill'] = RG.array_clone(prop['chart.highlight.fill']);
|
461
|
+
}
|
462
|
+
|
463
|
+
|
464
|
+
|
465
|
+
|
466
|
+
/**
|
467
|
+
* Parse various properties for colors
|
468
|
+
*/
|
469
|
+
prop['chart.fillstyle'] = this.parseSingleColorForGradient(prop['chart.fillstyle']);
|
470
|
+
prop['chart.highlight.fill'] = this.parseSingleColorForGradient(prop['chart.highlight.fill']);
|
471
|
+
};
|
472
|
+
|
473
|
+
|
474
|
+
|
475
|
+
|
476
|
+
/**
|
477
|
+
* Use this function to reset the object to the post-constructor state. Eg reset colors if
|
478
|
+
* need be etc
|
479
|
+
*/
|
480
|
+
this.reset = function ()
|
481
|
+
{
|
482
|
+
};
|
483
|
+
|
484
|
+
|
485
|
+
|
486
|
+
|
487
|
+
/**
|
488
|
+
* This parses a single color value
|
489
|
+
*/
|
490
|
+
this.parseSingleColorForGradient = function (color)
|
491
|
+
{
|
492
|
+
var canvas = this.canvas;
|
493
|
+
var context = this.context;
|
494
|
+
|
495
|
+
if (!color) {
|
496
|
+
return color;
|
497
|
+
}
|
498
|
+
|
499
|
+
if (typeof color === 'string' && color.match(/^gradient\((.*)\)$/i)) {
|
500
|
+
|
501
|
+
var parts = RegExp.$1.split(':');
|
502
|
+
|
503
|
+
// Create the gradient
|
504
|
+
var grad = co.createRadialGradient(this.centerx, this.centery, 0, this.centerx, this.centery, this.radius);
|
505
|
+
|
506
|
+
var diff = 1 / (parts.length - 1);
|
507
|
+
|
508
|
+
//grad.addColorStop(0, RG.trim(parts[0]));
|
509
|
+
|
510
|
+
for (var j=0; j<parts.length; j+=1) {
|
511
|
+
grad.addColorStop(j * diff, RG.trim(parts[j]));
|
512
|
+
}
|
513
|
+
}
|
514
|
+
|
515
|
+
return grad ? grad : color;
|
516
|
+
};
|
517
|
+
|
518
|
+
|
519
|
+
|
520
|
+
|
521
|
+
/**
|
522
|
+
* Using a function to add events makes it easier to facilitate method chaining
|
523
|
+
*
|
524
|
+
* @param string type The type of even to add
|
525
|
+
* @param function func
|
526
|
+
*/
|
527
|
+
this.on = function (type, func)
|
528
|
+
{
|
529
|
+
if (type.substr(0,2) !== 'on') {
|
530
|
+
type = 'on' + type;
|
531
|
+
}
|
532
|
+
|
533
|
+
this[type] = func;
|
534
|
+
|
535
|
+
return this;
|
536
|
+
};
|
537
|
+
|
538
|
+
|
539
|
+
|
540
|
+
|
541
|
+
/**
|
542
|
+
* This function runs once only
|
543
|
+
* (put at the end of the file (before any effects))
|
544
|
+
*/
|
545
|
+
this.firstDrawFunc = function ()
|
546
|
+
{
|
547
|
+
};
|
548
|
+
|
549
|
+
|
550
|
+
RG.att(ca);
|
551
|
+
|
552
|
+
|
553
|
+
/**
|
554
|
+
* Objects are now always registered so that the chart is redrawn if need be.
|
555
|
+
*/
|
556
|
+
RG.Register(this);
|
557
|
+
|
558
|
+
|
559
|
+
|
560
|
+
|
561
|
+
/**
|
562
|
+
* the number of arguments is only one and it's an
|
563
|
+
* object - parse it for configuration data and return.
|
564
|
+
*/
|
565
|
+
if (parseConfObjectForOptions) {
|
566
|
+
RG.parseObjectStyleConfig(this, conf.options);
|
567
|
+
}
|
568
|
+
};
|