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