rgraph-rails 1.0.5 → 1.0.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +8 -8
- data/.travis.yml +0 -1
- data/README.md +3 -3
- data/lib/rgraph-rails/version.rb +1 -1
- data/vendor/assets/javascripts/RGraph.bar.js +239 -3764
- data/vendor/assets/javascripts/RGraph.bipolar.js +115 -1986
- data/vendor/assets/javascripts/RGraph.common.annotate.js +35 -399
- data/vendor/assets/javascripts/RGraph.common.context.js +30 -600
- data/vendor/assets/javascripts/RGraph.common.core.js +403 -5187
- data/vendor/assets/javascripts/RGraph.common.csv.js +19 -275
- data/vendor/assets/javascripts/RGraph.common.deprecated.js +35 -454
- data/vendor/assets/javascripts/RGraph.common.dynamic.js +84 -1189
- data/vendor/assets/javascripts/RGraph.common.effects.js +90 -1548
- data/vendor/assets/javascripts/RGraph.common.key.js +54 -755
- data/vendor/assets/javascripts/RGraph.common.resizing.js +37 -567
- data/vendor/assets/javascripts/RGraph.common.sheets.js +29 -356
- data/vendor/assets/javascripts/RGraph.common.tooltips.js +32 -614
- data/vendor/assets/javascripts/RGraph.common.zoom.js +14 -223
- data/vendor/assets/javascripts/RGraph.cornergauge.js +71 -0
- data/vendor/assets/javascripts/RGraph.drawing.background.js +35 -620
- data/vendor/assets/javascripts/RGraph.drawing.circle.js +35 -576
- data/vendor/assets/javascripts/RGraph.drawing.image.js +52 -807
- data/vendor/assets/javascripts/RGraph.drawing.marker1.js +41 -717
- data/vendor/assets/javascripts/RGraph.drawing.marker2.js +37 -668
- data/vendor/assets/javascripts/RGraph.drawing.marker3.js +36 -563
- data/vendor/assets/javascripts/RGraph.drawing.poly.js +40 -608
- data/vendor/assets/javascripts/RGraph.drawing.rect.js +35 -597
- data/vendor/assets/javascripts/RGraph.drawing.text.js +34 -642
- data/vendor/assets/javascripts/RGraph.drawing.xaxis.js +50 -809
- 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 +75 -1241
- data/vendor/assets/javascripts/RGraph.gauge.js +87 -1397
- data/vendor/assets/javascripts/RGraph.hbar.js +143 -2376
- data/vendor/assets/javascripts/RGraph.hprogress.js +80 -1397
- data/vendor/assets/javascripts/RGraph.line.js +241 -4162
- data/vendor/assets/javascripts/RGraph.meter.js +74 -1278
- metadata +3 -30
- 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.modaldialog.js +0 -301
- data/vendor/assets/javascripts/RGraph.odo.js +0 -1265
- data/vendor/assets/javascripts/RGraph.pie.js +0 -2272
- data/vendor/assets/javascripts/RGraph.radar.js +0 -1847
- data/vendor/assets/javascripts/RGraph.rose.js +0 -1877
- data/vendor/assets/javascripts/RGraph.rscatter.js +0 -1425
- data/vendor/assets/javascripts/RGraph.scatter.js +0 -2970
- data/vendor/assets/javascripts/RGraph.semicircularprogress.js +0 -1015
- data/vendor/assets/javascripts/RGraph.thermometer.js +0 -1129
- data/vendor/assets/javascripts/RGraph.vprogress.js +0 -1452
- data/vendor/assets/javascripts/RGraph.waterfall.js +0 -1252
- data/vendor/assets/javascripts/financial-data.js +0 -1067
- data/vendor/assets/stylesheets/ModalDialog.css +0 -90
- data/vendor/assets/stylesheets/animations.css +0 -3347
- data/vendor/assets/stylesheets/website.css +0 -446
@@ -1,564 +1,37 @@
|
|
1
|
-
// version: 2016-06-04
|
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
1
|
|
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
|
-
|
56
|
-
|
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
|
-
'chart.text.accessible': true,
|
128
|
-
'chart.text.accessible.overflow': 'visible',
|
129
|
-
'chart.text.accessible.pointerevents': false,
|
130
|
-
'chart.clearto': 'rgba(0,0,0,0)'
|
131
|
-
}
|
132
|
-
|
133
|
-
/**
|
134
|
-
* A simple check that the browser has canvas support
|
135
|
-
*/
|
136
|
-
if (!this.canvas) {
|
137
|
-
alert('[DRAWING.MARKER3] No canvas support');
|
138
|
-
return;
|
139
|
-
}
|
140
|
-
|
141
|
-
/**
|
142
|
-
* These are used to store coords
|
143
|
-
*/
|
144
|
-
this.coords = [];
|
145
|
-
this.coordsText = [];
|
146
|
-
|
147
|
-
|
148
|
-
/**
|
149
|
-
* Create the dollar object so that functions can be added to them
|
150
|
-
*/
|
151
|
-
this.$0 = {};
|
152
|
-
|
153
|
-
|
154
|
-
/**
|
155
|
-
* Translate half a pixel for antialiasing purposes - but only if it hasn't beeen
|
156
|
-
* done already
|
157
|
-
*/
|
158
|
-
if (!this.canvas.__rgraph_aa_translated__) {
|
159
|
-
this.context.translate(0.5,0.5);
|
160
|
-
|
161
|
-
this.canvas.__rgraph_aa_translated__ = true;
|
162
|
-
}
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
// Short variable names
|
168
|
-
var RG = RGraph,
|
169
|
-
ca = this.canvas,
|
170
|
-
co = ca.getContext('2d'),
|
171
|
-
prop = this.properties,
|
172
|
-
pa2 = RG.path2,
|
173
|
-
win = window,
|
174
|
-
doc = document,
|
175
|
-
ma = Math
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
/**
|
180
|
-
* "Decorate" the object with the generic effects if the effects library has been included
|
181
|
-
*/
|
182
|
-
if (RG.Effects && typeof RG.Effects.decorate === 'function') {
|
183
|
-
RG.Effects.decorate(this);
|
184
|
-
}
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
/**
|
190
|
-
* A setter method for setting graph properties. It can be used like this: obj.Set('chart.strokestyle', '#666');
|
191
|
-
*
|
192
|
-
|
193
|
-
* @param name string The name of the property to set OR it can be a map
|
194
|
-
* of name/value settings like what you set in the constructor
|
195
|
-
*/
|
196
|
-
this.set =
|
197
|
-
this.Set = function (name)
|
198
|
-
{
|
199
|
-
var value = typeof arguments[1] === 'undefined' ? null : arguments[1];
|
200
|
-
|
201
|
-
/**
|
202
|
-
* the number of arguments is only one and it's an
|
203
|
-
* object - parse it for configuration data and return.
|
204
|
-
*/
|
205
|
-
if (arguments.length === 1 && typeof name === 'object') {
|
206
|
-
RG.parseObjectStyleConfig(this, name);
|
207
|
-
return this;
|
208
|
-
}
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
/**
|
215
|
-
* This should be done first - prepend the propertyy name with "chart." if necessary
|
216
|
-
*/
|
217
|
-
if (name.substr(0,6) != 'chart.') {
|
218
|
-
name = 'chart.' + name;
|
219
|
-
}
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
|
224
|
-
// Convert uppercase letters to dot+lower case letter
|
225
|
-
while(name.match(/([A-Z])/)) {
|
226
|
-
name = name.replace(/([A-Z])/, '.' + RegExp.$1.toLowerCase());
|
227
|
-
}
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
prop[name] = value;
|
235
|
-
|
236
|
-
return this;
|
237
|
-
};
|
238
|
-
|
239
|
-
|
240
|
-
|
241
|
-
|
242
|
-
/**
|
243
|
-
* A getter method for retrieving graph properties. It can be used like this: obj.Get('chart.strokestyle');
|
244
|
-
*
|
245
|
-
* @param name string The name of the property to get
|
246
|
-
*/
|
247
|
-
this.get =
|
248
|
-
this.Get = function (name)
|
249
|
-
{
|
250
|
-
/**
|
251
|
-
* This should be done first - prepend the property name with "chart." if necessary
|
252
|
-
*/
|
253
|
-
if (name.substr(0,6) != 'chart.') {
|
254
|
-
name = 'chart.' + name;
|
255
|
-
}
|
256
|
-
|
257
|
-
// Convert uppercase letters to dot+lower case letter
|
258
|
-
name = name.replace(/([A-Z])/g, function (str)
|
259
|
-
{
|
260
|
-
return '.' + String(RegExp.$1).toLowerCase()
|
261
|
-
});
|
262
|
-
|
263
|
-
return prop[name.toLowerCase()];
|
264
|
-
};
|
265
|
-
|
266
|
-
|
267
|
-
|
268
|
-
|
269
|
-
/**
|
270
|
-
* Draws the marker
|
271
|
-
*/
|
272
|
-
this.draw =
|
273
|
-
this.Draw = function ()
|
274
|
-
{
|
275
|
-
// Draw a circle to start with
|
276
|
-
co.globalAlpha = this.alpha;
|
277
|
-
pa2(co, [
|
278
|
-
'b',
|
279
|
-
'a', this.centerx, this.centery, this.actualRadius, 0, 2 * Math.PI,false,
|
280
|
-
'a', this.centerx, this.centery, ma.max(this.actualRadius - 8, 0), 2 * Math.PI,0, true,
|
281
|
-
'f', prop['chart.fillstyle']]
|
282
|
-
);
|
283
|
-
this.alpha = this.actualRadius ? 1 - ( (this.actualRadius * 0.75) / this.radius) : 1;
|
284
|
-
co.globalAlpha = 1;
|
285
|
-
|
286
|
-
|
287
|
-
if (this.actualRadius < this.radius) {
|
288
|
-
this.actualRadius += 2;
|
289
|
-
} else if (this.actualRadius >= this.radius) {
|
290
|
-
this.actualRadius = 0;
|
291
|
-
this.alpha = 1;
|
292
|
-
}
|
293
|
-
|
294
|
-
var obj = this;
|
295
|
-
setTimeout(function ()
|
296
|
-
{
|
297
|
-
RG.redrawCanvas(ca);
|
298
|
-
}, prop['chart.delay']);
|
299
|
-
|
300
|
-
|
301
|
-
|
302
|
-
|
303
|
-
/**
|
304
|
-
* This installs the event listeners
|
305
|
-
*/
|
306
|
-
RG.InstallEventListeners(this);
|
307
|
-
|
308
|
-
|
309
|
-
/**
|
310
|
-
* Fire the onfirstdraw event
|
311
|
-
*/
|
312
|
-
if (this.firstDraw) {
|
313
|
-
RG.fireCustomEvent(this, 'onfirstdraw');
|
314
|
-
this.firstDraw = false;
|
315
|
-
this.firstDrawFunc();
|
316
|
-
}
|
317
|
-
|
318
|
-
|
319
|
-
|
320
|
-
|
321
|
-
/**
|
322
|
-
* Fire the ondraw event
|
323
|
-
*/
|
324
|
-
RG.fireCustomEvent(this, 'ondraw');
|
325
|
-
|
326
|
-
return this;
|
327
|
-
};
|
328
|
-
|
329
|
-
|
330
|
-
|
331
|
-
/**
|
332
|
-
* Used in chaining. Runs a function there and then - not waiting for
|
333
|
-
* the events to fire (eg the onbeforedraw event)
|
334
|
-
*
|
335
|
-
* @param function func The function to execute
|
336
|
-
*/
|
337
|
-
this.exec = function (func)
|
338
|
-
{
|
339
|
-
func(this);
|
340
|
-
|
341
|
-
return this;
|
342
|
-
};
|
343
|
-
|
344
|
-
|
345
|
-
|
346
|
-
|
347
|
-
/**
|
348
|
-
* The getObjectByXY() worker method
|
349
|
-
*/
|
350
|
-
this.getObjectByXY = function (e)
|
351
|
-
{
|
352
|
-
if (this.getShape(e)) {
|
353
|
-
return this;
|
354
|
-
}
|
355
|
-
};
|
356
|
-
|
357
|
-
|
358
|
-
|
359
|
-
|
360
|
-
/**
|
361
|
-
* Not used by the class during creating the shape, but is used by event handlers
|
362
|
-
* to get the coordinates (if any) of the selected bar
|
363
|
-
*
|
364
|
-
* @param object e The event object
|
365
|
-
*/
|
366
|
-
this.getShape = function (e)
|
367
|
-
{
|
368
|
-
var mouseXY = RGraph.getMouseXY(e);
|
369
|
-
var mouseX = mouseXY[0];
|
370
|
-
var mouseY = mouseXY[1];
|
371
|
-
|
372
|
-
if (RG.getHypLength(this.centerx, this.centery, mouseXY[0], mouseXY[1]) <= this.radius) {
|
373
|
-
|
374
|
-
return {
|
375
|
-
0: this, 1: this.centerx, 2: this.centery, 3: this.radius, 4: null, 5: 0,
|
376
|
-
'object': this, 'x': this.centerx, 'y': this.centery, 'radius': this.radius, 'index': 0, 'tooltip': prop['chart.tooltips'] ? prop['chart.tooltips'][0] : null
|
377
|
-
};
|
378
|
-
}
|
379
|
-
|
380
|
-
return null;
|
381
|
-
};
|
382
|
-
|
383
|
-
|
384
|
-
|
385
|
-
|
386
|
-
/**
|
387
|
-
* This function positions a tooltip when it is displayed
|
388
|
-
*
|
389
|
-
* @param obj object The chart object
|
390
|
-
* @param int x The X coordinate specified for the tooltip
|
391
|
-
* @param int y The Y coordinate specified for the tooltip
|
392
|
-
* @param object tooltip The tooltips DIV element
|
393
|
-
* @param number idx The index of the tooltip
|
394
|
-
*/
|
395
|
-
this.positionTooltip = function (obj, x, y, tooltip, idx)
|
396
|
-
{
|
397
|
-
var canvasXY = RG.getCanvasXY(obj.canvas);
|
398
|
-
var mouseXY = RG.getMouseXY(window.event);
|
399
|
-
var width = tooltip.offsetWidth;
|
400
|
-
var height = tooltip.offsetHeight;
|
401
|
-
var radius = this.radius;
|
402
|
-
|
403
|
-
// Set the top position
|
404
|
-
tooltip.style.left = 0;
|
405
|
-
tooltip.style.top = window.event.pageY - height - 5 + 'px';
|
406
|
-
|
407
|
-
// By default any overflow is hidden
|
408
|
-
tooltip.style.overflow = '';
|
409
|
-
|
410
|
-
// Reposition the tooltip if at the edges:
|
411
|
-
|
412
|
-
// LEFT edge
|
413
|
-
if (canvasXY[0] + mouseXY[0] - (width / 2) < 0) {
|
414
|
-
tooltip.style.left = canvasXY[0] + mouseXY[0] - (width * 0.1) + 'px';
|
415
|
-
|
416
|
-
// RIGHT edge
|
417
|
-
} else if (canvasXY[0] + mouseXY[0] + (width / 2) > doc.body.offsetWidth) {
|
418
|
-
tooltip.style.left = canvasXY[0] + mouseXY[0] - (width * 0.9) + 'px';
|
419
|
-
|
420
|
-
// Default positioning - CENTERED
|
421
|
-
} else {
|
422
|
-
tooltip.style.left = canvasXY[0] + mouseXY[0] - (width / 2) + 'px';
|
423
|
-
}
|
424
|
-
};
|
425
|
-
|
426
|
-
|
427
|
-
|
428
|
-
/**
|
429
|
-
* Each object type has its own Highlight() function which highlights the appropriate shape
|
430
|
-
*
|
431
|
-
* @param object shape The shape to highlight
|
432
|
-
*/
|
433
|
-
this.highlight =
|
434
|
-
this.Highlight = function (shape)
|
435
|
-
{
|
436
|
-
if (prop['chart.tooltips.highlight']) {
|
437
|
-
if (typeof prop['chart.highlight.style'] === 'function') {
|
438
|
-
(prop['chart.highlight.style'])(shape);
|
439
|
-
} else {
|
440
|
-
pa2(co, ['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']]);
|
441
|
-
}
|
442
|
-
}
|
443
|
-
};
|
444
|
-
|
445
|
-
|
446
|
-
|
447
|
-
|
448
|
-
/**
|
449
|
-
* This allows for easy specification of gradients
|
450
|
-
*/
|
451
|
-
this.parseColors = function ()
|
452
|
-
{
|
453
|
-
// Save the original colors so that they can be restored when the canvas is reset
|
454
|
-
if (this.original_colors.length === 0) {
|
455
|
-
this.original_colors['chart.fillstyle'] = RG.array_clone(prop['chart.fillstyle']);
|
456
|
-
this.original_colors['chart.highlight.fill'] = RG.array_clone(prop['chart.highlight.fill']);
|
457
|
-
}
|
458
|
-
|
459
|
-
|
460
|
-
|
461
|
-
|
462
|
-
/**
|
463
|
-
* Parse various properties for colors
|
464
|
-
*/
|
465
|
-
prop['chart.fillstyle'] = this.parseSingleColorForGradient(prop['chart.fillstyle']);
|
466
|
-
prop['chart.highlight.fill'] = this.parseSingleColorForGradient(prop['chart.highlight.fill']);
|
467
|
-
};
|
468
|
-
|
469
|
-
|
470
|
-
|
471
|
-
|
472
|
-
/**
|
473
|
-
* Use this function to reset the object to the post-constructor state. Eg reset colors if
|
474
|
-
* need be etc
|
475
|
-
*/
|
476
|
-
this.reset = function ()
|
477
|
-
{
|
478
|
-
};
|
479
|
-
|
480
|
-
|
481
|
-
|
482
|
-
|
483
|
-
/**
|
484
|
-
* This parses a single color value
|
485
|
-
*/
|
486
|
-
this.parseSingleColorForGradient = function (color)
|
487
|
-
{
|
488
|
-
var canvas = this.canvas;
|
489
|
-
var context = this.context;
|
490
|
-
|
491
|
-
if (!color) {
|
492
|
-
return color;
|
493
|
-
}
|
494
|
-
|
495
|
-
if (typeof color === 'string' && color.match(/^gradient\((.*)\)$/i)) {
|
496
|
-
|
497
|
-
var parts = RegExp.$1.split(':');
|
498
|
-
|
499
|
-
// Create the gradient
|
500
|
-
var grad = co.createRadialGradient(this.centerx, this.centery, 0, this.centerx, this.centery, this.radius);
|
501
|
-
|
502
|
-
var diff = 1 / (parts.length - 1);
|
503
|
-
|
504
|
-
//grad.addColorStop(0, RG.trim(parts[0]));
|
505
|
-
|
506
|
-
for (var j=0; j<parts.length; j+=1) {
|
507
|
-
grad.addColorStop(j * diff, RG.trim(parts[j]));
|
508
|
-
}
|
509
|
-
}
|
510
|
-
|
511
|
-
return grad ? grad : color;
|
512
|
-
};
|
513
|
-
|
514
|
-
|
515
|
-
|
516
|
-
|
517
|
-
/**
|
518
|
-
* Using a function to add events makes it easier to facilitate method chaining
|
519
|
-
*
|
520
|
-
* @param string type The type of even to add
|
521
|
-
* @param function func
|
522
|
-
*/
|
523
|
-
this.on = function (type, func)
|
524
|
-
{
|
525
|
-
if (type.substr(0,2) !== 'on') {
|
526
|
-
type = 'on' + type;
|
527
|
-
}
|
528
|
-
|
529
|
-
this[type] = func;
|
530
|
-
|
531
|
-
return this;
|
532
|
-
};
|
533
|
-
|
534
|
-
|
535
|
-
|
536
|
-
|
537
|
-
/**
|
538
|
-
* This function runs once only
|
539
|
-
* (put at the end of the file (before any effects))
|
540
|
-
*/
|
541
|
-
this.firstDrawFunc = function ()
|
542
|
-
{
|
543
|
-
};
|
544
|
-
|
545
|
-
|
546
|
-
RG.att(ca);
|
547
|
-
|
548
|
-
|
549
|
-
/**
|
550
|
-
* Objects are now always registered so that the chart is redrawn if need be.
|
551
|
-
*/
|
552
|
-
RG.Register(this);
|
553
|
-
|
554
|
-
|
555
|
-
|
556
|
-
|
557
|
-
/**
|
558
|
-
* the number of arguments is only one and it's an
|
559
|
-
* object - parse it for configuration data and return.
|
560
|
-
*/
|
561
|
-
if (parseConfObjectForOptions) {
|
562
|
-
RG.parseObjectStyleConfig(this, conf.options);
|
563
|
-
}
|
564
|
-
};
|
2
|
+
RGraph=window.RGraph||{isRGraph:true};RGraph.Drawing=RGraph.Drawing||{};RGraph.Drawing.Marker3=function(conf)
|
3
|
+
{if(typeof conf==='object'&&typeof conf.x==='number'&&typeof conf.y==='number'&&typeof conf.id==='string'&&typeof conf.radius==='number'){var id=conf.id
|
4
|
+
var canvas=document.getElementById(id);var x=conf.x;var y=conf.y;var radius=conf.radius;var parseConfObjectForOptions=true;}else{var id=conf;var canvas=document.getElementById(id);var x=arguments[1];var y=arguments[2];var radius=arguments[3];}
|
5
|
+
this.id=id;this.canvas=document.getElementById(this.id);this.context=this.canvas.getContext('2d')
|
6
|
+
this.colorsParsed=false;this.canvas.__object__=this;this.original_colors=[];this.firstDraw=true;this.actualRadius=0;this.alpha=1;this.centerx=x;this.centery=y;this.radius=radius;this.type='drawing.marker3';this.isRGraph=true;this.uid=RGraph.CreateUID();this.canvas.uid=this.canvas.uid?this.canvas.uid:RGraph.CreateUID();this.properties={'chart.fillstyle':'rgba(255,255,255,1)','chart.delay':50,'chart.events.click':null,'chart.events.mousemove':null,'chart.highlight.fill':'rgba(255,0,0,1.0)','chart.tooltips':null,'chart.tooltips.highlight':true,'chart.tooltips.event':'onclick','chart.text.accessible':true,'chart.text.accessible.overflow':'visible','chart.text.accessible.pointerevents':true,'chart.clearto':'rgba(0,0,0,0)'}
|
7
|
+
if(!this.canvas){alert('[DRAWING.MARKER3] No canvas support');return;}
|
8
|
+
this.coords=[];this.coordsText=[];this.$0={};if(!this.canvas.__rgraph_aa_translated__){this.context.translate(0.5,0.5);this.canvas.__rgraph_aa_translated__=true;}
|
9
|
+
var RG=RGraph,ca=this.canvas,co=ca.getContext('2d'),prop=this.properties,pa2=RG.path2,win=window,doc=document,ma=Math
|
10
|
+
if(RG.Effects&&typeof RG.Effects.decorate==='function'){RG.Effects.decorate(this);}
|
11
|
+
this.set=this.Set=function(name)
|
12
|
+
{var value=typeof arguments[1]==='undefined'?null:arguments[1];if(arguments.length===1&&typeof name==='object'){RG.parseObjectStyleConfig(this,name);return this;}
|
13
|
+
if(name.substr(0,6)!='chart.'){name='chart.'+name;}
|
14
|
+
while(name.match(/([A-Z])/)){name=name.replace(/([A-Z])/,'.'+RegExp.$1.toLowerCase());}
|
15
|
+
prop[name]=value;return this;};this.get=this.Get=function(name)
|
16
|
+
{if(name.substr(0,6)!='chart.'){name='chart.'+name;}
|
17
|
+
while(name.match(/([A-Z])/)){name=name.replace(/([A-Z])/,'.'+RegExp.$1.toLowerCase());}
|
18
|
+
return prop[name.toLowerCase()];};this.draw=this.Draw=function()
|
19
|
+
{co.globalAlpha=this.alpha;pa2(co,['b','a',this.centerx,this.centery,this.actualRadius,0,2*Math.PI,false,'a',this.centerx,this.centery,ma.max(this.actualRadius-8,0),2*Math.PI,0,true,'f',prop['chart.fillstyle']]);this.alpha=this.actualRadius?1-((this.actualRadius*0.75)/this.radius):1;co.globalAlpha=1;if(this.actualRadius<this.radius){this.actualRadius+=2;}else if(this.actualRadius>=this.radius){this.actualRadius=0;this.alpha=1;}
|
20
|
+
var obj=this;setTimeout(function()
|
21
|
+
{RG.redrawCanvas(ca);},prop['chart.delay']);RG.InstallEventListeners(this);if(this.firstDraw){RG.fireCustomEvent(this,'onfirstdraw');this.firstDraw=false;this.firstDrawFunc();}
|
22
|
+
RG.fireCustomEvent(this,'ondraw');return this;};this.exec=function(func)
|
23
|
+
{func(this);return this;};this.getObjectByXY=function(e)
|
24
|
+
{if(this.getShape(e)){return this;}};this.getShape=function(e)
|
25
|
+
{var mouseXY=RGraph.getMouseXY(e);var mouseX=mouseXY[0];var mouseY=mouseXY[1];if(RG.getHypLength(this.centerx,this.centery,mouseXY[0],mouseXY[1])<=this.radius){return{0:this,1:this.centerx,2:this.centery,3:this.radius,4:null,5:0,'object':this,'x':this.centerx,'y':this.centery,'radius':this.radius,'index':0,'tooltip':prop['chart.tooltips']?prop['chart.tooltips'][0]:null};}
|
26
|
+
return null;};this.highlight=this.Highlight=function(shape)
|
27
|
+
{if(prop['chart.tooltips.highlight']){if(typeof prop['chart.highlight.style']==='function'){(prop['chart.highlight.style'])(shape);}else{pa2(co,['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']]);}}};this.parseColors=function()
|
28
|
+
{if(this.original_colors.length===0){this.original_colors['chart.fillstyle']=RG.array_clone(prop['chart.fillstyle']);this.original_colors['chart.highlight.fill']=RG.array_clone(prop['chart.highlight.fill']);}
|
29
|
+
prop['chart.fillstyle']=this.parseSingleColorForGradient(prop['chart.fillstyle']);prop['chart.highlight.fill']=this.parseSingleColorForGradient(prop['chart.highlight.fill']);};this.reset=function()
|
30
|
+
{};this.parseSingleColorForGradient=function(color)
|
31
|
+
{var canvas=this.canvas;var context=this.context;if(!color){return color;}
|
32
|
+
if(typeof color==='string'&&color.match(/^gradient\((.*)\)$/i)){var parts=RegExp.$1.split(':');var grad=co.createRadialGradient(this.centerx,this.centery,0,this.centerx,this.centery,this.radius);var diff=1/(parts.length-1);for(var j=0;j<parts.length;j+=1){grad.addColorStop(j*diff,RG.trim(parts[j]));}}
|
33
|
+
return grad?grad:color;};this.on=function(type,func)
|
34
|
+
{if(type.substr(0,2)!=='on'){type='on'+type;}
|
35
|
+
if(typeof this[type]!=='function'){this[type]=func;}else{RG.addCustomEventListener(this,type,func);}
|
36
|
+
return this;};this.firstDrawFunc=function()
|
37
|
+
{};RG.att(ca);RG.Register(this);if(parseConfObjectForOptions){RG.parseObjectStyleConfig(this,conf.options);}};
|