rgraph-rails 4.62 → 4.64
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/README.md +3 -4
- data/lib/rgraph-rails/version.rb +1 -1
- data/vendor/assets/javascripts/RGraph.bar.js +240 -3742
- data/vendor/assets/javascripts/RGraph.bipolar.js +165 -2005
- data/vendor/assets/javascripts/RGraph.common.annotate.js +35 -395
- data/vendor/assets/javascripts/RGraph.common.context.js +30 -595
- data/vendor/assets/javascripts/RGraph.common.core.js +418 -5359
- data/vendor/assets/javascripts/RGraph.common.csv.js +20 -276
- data/vendor/assets/javascripts/RGraph.common.deprecated.js +35 -450
- data/vendor/assets/javascripts/RGraph.common.dynamic.js +88 -1395
- data/vendor/assets/javascripts/RGraph.common.effects.js +90 -1545
- data/vendor/assets/javascripts/RGraph.common.key.js +52 -753
- data/vendor/assets/javascripts/RGraph.common.resizing.js +37 -563
- data/vendor/assets/javascripts/RGraph.common.sheets.js +29 -352
- data/vendor/assets/javascripts/RGraph.common.tooltips.js +32 -450
- data/vendor/assets/javascripts/RGraph.common.zoom.js +14 -219
- data/vendor/assets/javascripts/RGraph.cornergauge.js +71 -0
- data/vendor/assets/javascripts/RGraph.drawing.background.js +34 -570
- data/vendor/assets/javascripts/RGraph.drawing.circle.js +33 -544
- data/vendor/assets/javascripts/RGraph.drawing.image.js +51 -755
- data/vendor/assets/javascripts/RGraph.drawing.marker1.js +37 -645
- data/vendor/assets/javascripts/RGraph.drawing.marker2.js +36 -633
- data/vendor/assets/javascripts/RGraph.drawing.marker3.js +35 -514
- data/vendor/assets/javascripts/RGraph.drawing.poly.js +37 -559
- data/vendor/assets/javascripts/RGraph.drawing.rect.js +33 -548
- data/vendor/assets/javascripts/RGraph.drawing.text.js +36 -664
- data/vendor/assets/javascripts/RGraph.drawing.xaxis.js +50 -812
- data/vendor/assets/javascripts/RGraph.drawing.yaxis.js +51 -856
- data/vendor/assets/javascripts/RGraph.fuel.js +58 -964
- data/vendor/assets/javascripts/RGraph.funnel.js +55 -984
- data/vendor/assets/javascripts/RGraph.gantt.js +77 -1354
- data/vendor/assets/javascripts/RGraph.gauge.js +85 -1421
- data/vendor/assets/javascripts/RGraph.hbar.js +162 -2788
- data/vendor/assets/javascripts/RGraph.hprogress.js +80 -1401
- data/vendor/assets/javascripts/RGraph.line.js +249 -4248
- data/vendor/assets/javascripts/RGraph.meter.js +74 -1280
- data/vendor/assets/javascripts/RGraph.modaldialog.js +19 -301
- data/vendor/assets/javascripts/RGraph.odo.js +71 -1264
- data/vendor/assets/javascripts/RGraph.pie.js +137 -2288
- data/vendor/assets/javascripts/RGraph.radar.js +110 -1847
- data/vendor/assets/javascripts/RGraph.rose.js +108 -1977
- data/vendor/assets/javascripts/RGraph.rscatter.js +80 -1432
- data/vendor/assets/javascripts/RGraph.scatter.js +172 -3163
- data/vendor/assets/javascripts/RGraph.semicircularprogress.js +60 -1120
- data/vendor/assets/javascripts/RGraph.svg.bar.js +66 -1735
- data/vendor/assets/javascripts/RGraph.svg.common.ajax.js +21 -246
- data/vendor/assets/javascripts/RGraph.svg.common.core.js +255 -3937
- data/vendor/assets/javascripts/RGraph.svg.common.csv.js +20 -276
- data/vendor/assets/javascripts/RGraph.svg.common.fx.js +68 -1303
- data/vendor/assets/javascripts/RGraph.svg.common.key.js +19 -205
- data/vendor/assets/javascripts/RGraph.svg.common.sheets.js +29 -352
- data/vendor/assets/javascripts/RGraph.svg.common.tooltips.js +22 -273
- data/vendor/assets/javascripts/RGraph.svg.funnel.js +32 -0
- data/vendor/assets/javascripts/RGraph.svg.hbar.js +59 -1400
- data/vendor/assets/javascripts/RGraph.svg.line.js +70 -1580
- data/vendor/assets/javascripts/RGraph.svg.pie.js +55 -1131
- data/vendor/assets/javascripts/RGraph.svg.radar.js +57 -1502
- data/vendor/assets/javascripts/RGraph.svg.rose.js +66 -1817
- data/vendor/assets/javascripts/RGraph.svg.scatter.js +58 -1261
- data/vendor/assets/javascripts/RGraph.svg.semicircularprogress.js +28 -865
- data/vendor/assets/javascripts/RGraph.svg.waterfall.js +45 -1252
- data/vendor/assets/javascripts/RGraph.thermometer.js +63 -1136
- data/vendor/assets/javascripts/RGraph.vprogress.js +83 -1470
- data/vendor/assets/javascripts/RGraph.waterfall.js +83 -1347
- metadata +5 -4
- data/vendor/assets/javascripts/financial-data.js +0 -1067
@@ -1,646 +1,38 @@
|
|
1
|
-
// version: 2017-05-08
|
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
|
-
*/
|
17
1
|
|
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
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
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
|
-
};
|
2
|
+
RGraph=window.RGraph||{isRGraph:true};RGraph.Drawing=RGraph.Drawing||{};RGraph.Drawing.Marker1=function(conf)
|
3
|
+
{if(typeof conf==='object'&&typeof conf.x==='number'&&typeof conf.y==='number'&&typeof conf.radius=='number'&&typeof conf.id==='string'&&typeof conf.text==='string'){var id=conf.id,canvas=document.getElementById(id),x=conf.x,y=conf.y,radius=conf.radius,text=conf.text,parseConfObjectForOptions=true;}else{var id=conf,canvas=document.getElementById(id),x=arguments[1],y=arguments[2],radius=arguments[3],text=arguments[4];}
|
4
|
+
this.id=id;this.canvas=canvas;this.context=this.canvas.getContext("2d");this.colorsParsed=false;this.canvas.__object__=this;this.original_colors=[];this.firstDraw=true;this.centerx=x;this.centery=y;this.radius=radius;this.text=text;this.type='drawing.marker1';this.isRGraph=true;this.uid=RGraph.CreateUID();this.canvas.uid=this.canvas.uid?this.canvas.uid:RGraph.CreateUID();this.properties={'chart.strokestyle':'black','chart.fillstyle':'white','chart.linewidth':2,'chart.text.color':'black','chart.text.size':12,'chart.text.font':'Segoe UI, Arial, Verdana, sans-serif','chart.text.accessible':true,'chart.text.accessible.overflow':'visible','chart.text.accessible.pointerevents':true,'chart.events.click':null,'chart.events.mousemove':null,'chart.shadow':true,'chart.shadow.color':'#aaa','chart.shadow.offsetx':0,'chart.shadow.offsety':0,'chart.shadow.blur':15,'chart.highlight.stroke':'rgba(0,0,0,0)','chart.highlight.fill':'rgba(255,0,0,0.7)','chart.tooltips':null,'chart.tooltips.highlight':true,'chart.tooltips.event':'onclick','chart.align':'center','chart.clearto':'rgba(0,0,0,0)'}
|
5
|
+
if(!this.canvas){alert('[DRAWING.MARKER1] No canvas support');return;}
|
6
|
+
this.$0={};this.coords=[];this.coordsText=[];if(!this.canvas.__rgraph_aa_translated__){this.context.translate(0.5,0.5);this.canvas.__rgraph_aa_translated__=true;}
|
7
|
+
var RG=RGraph,ca=this.canvas,co=ca.getContext('2d'),prop=this.properties,pa2=RG.path2,win=window,doc=document,ma=Math
|
8
|
+
if(RG.Effects&&typeof RG.Effects.decorate==='function'){RG.Effects.decorate(this);}
|
9
|
+
this.set=this.Set=function(name)
|
10
|
+
{var value=typeof arguments[1]==='undefined'?null:arguments[1];if(arguments.length===1&&typeof name==='object'){RG.parseObjectStyleConfig(this,name);return this;}
|
11
|
+
if(name.substr(0,6)!='chart.'){name='chart.'+name;}
|
12
|
+
while(name.match(/([A-Z])/)){name=name.replace(/([A-Z])/,'.'+RegExp.$1.toLowerCase());}
|
13
|
+
prop[name]=value;return this;};this.get=this.Get=function(name)
|
14
|
+
{if(name.substr(0,6)!='chart.'){name='chart.'+name;}
|
15
|
+
while(name.match(/([A-Z])/)){name=name.replace(/([A-Z])/,'.'+RegExp.$1.toLowerCase());}
|
16
|
+
return prop[name.toLowerCase()];};this.draw=this.Draw=function()
|
17
|
+
{RG.FireCustomEvent(this,'onbeforedraw');var r=this.radius;if(prop['chart.align']=='left'){this.markerCenterx=this.centerx-r-r-3;this.markerCentery=this.centery-r-r-3;}else if(prop['chart.align']=='right'){this.markerCenterx=this.centerx+r+r+3;this.markerCentery=this.centery-r-r-3;}else{this.markerCenterx=this.centerx;this.markerCentery=this.centery-r-r-3;}
|
18
|
+
if(!this.colorsParsed){this.parseColors();this.colorsParsed=true;}
|
19
|
+
this.coordsText=[];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
|
+
this.drawMarker();pa2(co,['c','s',prop['chart.strokestyle'],'f',prop['chart.fillstyle']]);RG.noShadow(this);co.fillStyle=prop['chart.text.color'];RG.text2(this,{font:prop['chart.text.font'],size:prop['chart.text.size'],x:this.coords[0][0]-1,y:this.coords[0][1]-1,text:this.text,valign:'center',halign:'center',tag:'labels'});RG.installEventListeners(this);if(this.firstDraw){this.firstDraw=false;RG.fireCustomEvent(this,'onfirstdraw');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=RG.getMouseXY(e),mouseX=mouseXY[0],mouseY=mouseXY[1];co.beginPath();this.drawMarker();if(co.isPointInPath(mouseXY[0],mouseXY[1])){return{0:this,1:this.coords[0][0],2:this.coords[0][1],3:this.coords[0][2],4:0,'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};}
|
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{co.beginPath();co.strokeStyle=prop['chart.highlight.stroke'];co.fillStyle=prop['chart.highlight.fill'];this.drawMarker();co.closePath();co.stroke();co.fill();}}};this.drawMarker=this.DrawMarker=function()
|
27
|
+
{var r=this.radius;if(prop['chart.align']==='left'){var x=this.markerCenterx,y=this.markerCentery;pa2(co,['a',x,y,r,RG.HALFPI,RG.TWOPI,false]);pa2(co,['qc',x+r,y+r,x+r+r,y+r+r]);pa2(co,['qc',x+r,y+r,x,y+r]);}else if(prop['chart.align']==='right'){var x=this.markerCenterx,y=this.markerCentery;pa2(co,['a',x,y,r,RG.HALFPI,RG.PI,true]);pa2(co,['qc',x-r,y+r,x-r-r,y+r+r]);pa2(co,['qc',x-r,y+r,x,y+r]);}else{var x=this.markerCenterx,y=this.markerCentery;pa2(co,['a',x,y,r,RG.HALFPI/2,RG.PI-(RG.HALFPI/2),true]);pa2(co,['qc',x,y+r+(r/4),x,y+r+r-2]);pa2(co,['qc',x,y+r+(r/4),x+(ma.cos(RG.HALFPI/2)*r),y+(ma.sin(RG.HALFPI/2)*r)]);}
|
28
|
+
this.coords[0]=[x,y,r];};this.parseColors=function()
|
29
|
+
{if(this.original_colors.length===0){this.original_colors['chart.fillstyle']=RG.arrayClone(prop['chart.fillstyle']);this.original_colors['chart.strokestyle']=RG.arrayClone(prop['chart.strokestyle']);this.original_colors['chart.highlight.fill']=RG.arrayClone(prop['chart.highlight.fill']);this.original_colors['chart.highlight.stroke']=RG.arrayClone(prop['chart.highlight.stroke']);this.original_colors['chart.text.color']=RG.arrayClone(prop['chart.text.color']);}
|
30
|
+
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']);prop['chart.text.color']=this.parseSingleColorForGradient(prop['chart.text.color']);};this.reset=function()
|
31
|
+
{};this.parseSingleColorForGradient=function(color)
|
32
|
+
{if(!color||typeof(color)!='string'){return color;}
|
33
|
+
if(color.match(/^gradient\((.*)\)$/i)){var parts=RegExp.$1.split(':'),grad=co.createRadialGradient(this.markerCenterx,this.markerCentery,0,this.markerCenterx,this.markerCentery,this.radius),diff=1/(parts.length-1);grad.addColorStop(0,RG.trim(parts[0]));for(var j=1;j<parts.length;++j){grad.addColorStop(j*diff,RG.trim(parts[j]));}}
|
34
|
+
return grad?grad:color;};this.on=function(type,func)
|
35
|
+
{if(type.substr(0,2)!=='on'){type='on'+type;}
|
36
|
+
if(typeof this[type]!=='function'){this[type]=func;}else{RG.addCustomEventListener(this,type,func);}
|
37
|
+
return this;};this.firstDrawFunc=function()
|
38
|
+
{};RG.register(this);if(parseConfObjectForOptions){RG.parseObjectStyleConfig(this,conf.options);}};
|