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,1190 +1,85 @@
|
|
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 starts at just 99 GBP and |
|
11
|
-
* | you can read about it here: |
|
12
|
-
* | |
|
13
|
-
* | http://www.rgraph.net/license |
|
14
|
-
* o--------------------------------------------------------------------------------o
|
15
|
-
*/
|
16
1
|
|
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
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
}
|
102
|
-
|
103
|
-
RG.Registry.set('chart.adjusting', null);
|
104
|
-
RG.Registry.set('chart.adjusting.shape', null);
|
105
|
-
RG.Registry.set('chart.adjusting.gantt', null);
|
106
|
-
|
107
|
-
|
108
|
-
// ==============================================
|
109
|
-
// Finally, redraw the chart
|
110
|
-
// ==============================================
|
111
|
-
|
112
|
-
var tags = document.getElementsByTagName('canvas');
|
113
|
-
for (var i=0; i<tags.length; ++i) {
|
114
|
-
if (tags[i].__object__ && tags[i].__object__.isRGraph) {
|
115
|
-
if (!tags[i].__object__.get('chart.annotatable')) {
|
116
|
-
if (!tags[i].__rgraph_trace_cover__ && !noredraw) {
|
117
|
-
RG.clear(tags[i]);
|
118
|
-
} else {
|
119
|
-
var noredraw = true;
|
120
|
-
}
|
121
|
-
}
|
122
|
-
}
|
123
|
-
}
|
124
|
-
|
125
|
-
if (!noredraw) {
|
126
|
-
RG.redraw();
|
127
|
-
}
|
128
|
-
};
|
129
|
-
win.addEventListener('mouseup', RG.window_mouseup_event_listener, false);
|
130
|
-
}
|
131
|
-
};
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
/**
|
137
|
-
* This is the canvas mouseup event listener. It installs the mouseup event for the
|
138
|
-
* canvas. The mouseup event then checks the relevant object.
|
139
|
-
*
|
140
|
-
* @param object obj The chart object
|
141
|
-
*
|
142
|
-
* RGraph.window_mouseup_event_listener
|
143
|
-
*/
|
144
|
-
RG.installCanvasMouseupListener =
|
145
|
-
RG.InstallCanvasMouseupListener = function (obj)
|
146
|
-
{
|
147
|
-
if (!obj.canvas.rgraph_mouseup_event_listener) {
|
148
|
-
obj.canvas.rgraph_mouseup_event_listener = function (e)
|
149
|
-
{
|
150
|
-
/**
|
151
|
-
* For firefox add the window.event object
|
152
|
-
*/
|
153
|
-
if (navigator.userAgent.indexOf('Firefox') >= 0) window.event = e;
|
154
|
-
|
155
|
-
e = RG.fixEventObject(e);
|
156
|
-
|
157
|
-
|
158
|
-
// *************************************************************************
|
159
|
-
// Tooltips
|
160
|
-
// *************************************************************************
|
161
|
-
|
162
|
-
|
163
|
-
// This causes things at the edge of the chart area - eg line chart hotspots - not to fire because the
|
164
|
-
// cursor is out of the chart area
|
165
|
-
var objects = RG.ObjectRegistry.getObjectsByXY(e);
|
166
|
-
//var objects = RG.ObjectRegistry.getObjectsByCanvasID(e.target.id);
|
167
|
-
|
168
|
-
if (objects) {
|
169
|
-
for (var i=0,len=objects.length; i<len; i+=1) {
|
170
|
-
|
171
|
-
var obj = objects[i],
|
172
|
-
id = objects[i].id;
|
173
|
-
|
174
|
-
|
175
|
-
// =========================================================================
|
176
|
-
// The drawing API text object supports chart.link
|
177
|
-
// ========================================================================
|
178
|
-
var link = obj.Get('link');
|
179
|
-
|
180
|
-
if (obj.type == 'drawing.text' && typeof link === 'string') {
|
181
|
-
|
182
|
-
var link_target = obj.get('link.target');
|
183
|
-
var link_options = obj.get('link.options');
|
184
|
-
|
185
|
-
window.open(link, link_target ? link_target : null, link_options);
|
186
|
-
}
|
187
|
-
|
188
|
-
|
189
|
-
// ========================================================================
|
190
|
-
// Tooltips
|
191
|
-
// ========================================================================
|
192
|
-
|
193
|
-
|
194
|
-
if (!RG.isNull(obj) && RG.tooltip) {
|
195
|
-
|
196
|
-
var shape = obj.getShape(e);
|
197
|
-
|
198
|
-
if (shape && shape['tooltip']) {
|
199
|
-
|
200
|
-
var text = shape['tooltip'];
|
201
|
-
|
202
|
-
if (text) {
|
203
|
-
|
204
|
-
var type = shape['object'].type;
|
205
|
-
|
206
|
-
if ( type == 'line'
|
207
|
-
|| type == 'rscatter'
|
208
|
-
|| (type == 'scatter' && !obj.get('chart.boxplot'))
|
209
|
-
|| type == 'radar') {
|
210
|
-
|
211
|
-
var canvasXY = RG.getCanvasXY(obj.canvas);
|
212
|
-
var x = canvasXY[0] + shape['x'];
|
213
|
-
var y = canvasXY[1] + shape['y'];
|
214
|
-
|
215
|
-
} else {
|
216
|
-
var x = e.pageX;
|
217
|
-
var y = e.pageY;
|
218
|
-
}
|
219
|
-
|
220
|
-
RG.clear(obj.canvas);
|
221
|
-
RG.redraw();
|
222
|
-
RG.Registry.set('chart.tooltip.shape', shape);
|
223
|
-
RG.tooltip(obj, text, x, y, shape['index'], e);
|
224
|
-
obj.highlight(shape);
|
225
|
-
|
226
|
-
// Add the shape that triggered the tooltip
|
227
|
-
if (RG.Registry.get('chart.tooltip')) {
|
228
|
-
|
229
|
-
RG.Registry.get('chart.tooltip').__shape__ = shape;
|
230
|
-
|
231
|
-
RG.evaluateCursor(e);
|
232
|
-
}
|
233
|
-
|
234
|
-
e.cancelBubble = true;
|
235
|
-
e.stopPropagation();
|
236
|
-
return false;
|
237
|
-
}
|
238
|
-
}
|
239
|
-
}
|
240
|
-
|
241
|
-
|
242
|
-
|
243
|
-
|
244
|
-
|
245
|
-
// =========================================================================
|
246
|
-
// Adjusting
|
247
|
-
// ========================================================================
|
248
|
-
|
249
|
-
|
250
|
-
|
251
|
-
if (RG.Registry.get('chart.adjusting') || RG.Registry.get('chart.adjusting.gantt')) {
|
252
|
-
|
253
|
-
//var obj = RG.Registry.get('chart.adjusting');
|
254
|
-
|
255
|
-
// If it's a line chart update the data_arr variable
|
256
|
-
if (obj && obj.type === 'line') {
|
257
|
-
obj.data_arr = RG.arrayLinearize(obj.data);
|
258
|
-
}
|
259
|
-
|
260
|
-
RG.fireCustomEvent(RG.Registry.get('chart.adjusting'), 'onadjustend');
|
261
|
-
}
|
262
|
-
|
263
|
-
RG.Registry.set('chart.adjusting', null);
|
264
|
-
RG.Registry.set('chart.adjusting.shape', null);
|
265
|
-
RG.Registry.set('chart.adjusting.gantt', null);
|
266
|
-
|
267
|
-
/**
|
268
|
-
* If the mouse pointer is over a "front" chart this prevents charts behind it
|
269
|
-
* from firing their events.
|
270
|
-
*/
|
271
|
-
if (shape || (obj.overChartArea && obj.overChartArea(e)) ) {
|
272
|
-
break;
|
273
|
-
}
|
274
|
-
}
|
275
|
-
}
|
276
|
-
};
|
277
|
-
obj.canvas.addEventListener('mouseup', obj.canvas.rgraph_mouseup_event_listener, false);
|
278
|
-
}
|
279
|
-
};
|
280
|
-
|
281
|
-
|
282
|
-
|
283
|
-
|
284
|
-
/**
|
285
|
-
* This is the canvas mousemove event listener.
|
286
|
-
*
|
287
|
-
* @param object obj The chart object
|
288
|
-
*/
|
289
|
-
RG.installCanvasMousemoveListener =
|
290
|
-
RG.InstallCanvasMousemoveListener = function (obj)
|
291
|
-
{
|
292
|
-
if (!obj.canvas.rgraph_mousemove_event_listener) {
|
293
|
-
obj.canvas.rgraph_mousemove_event_listener = function (e)
|
294
|
-
{
|
295
|
-
/**
|
296
|
-
* For firefox add the window.event object
|
297
|
-
*/
|
298
|
-
if (navigator.userAgent.indexOf('Firefox') >= 0) window.event = e;
|
299
|
-
e = RG.fixEventObject(e);
|
300
|
-
|
301
|
-
|
302
|
-
|
303
|
-
|
304
|
-
/**
|
305
|
-
* Go through all the objects and check them to see if anything needs doing
|
306
|
-
*/
|
307
|
-
var objects = RG.ObjectRegistry.getObjectsByXY(e);
|
308
|
-
//var objects = RG.ObjectRegistry.getObjectsByCanvasID(e.target.id);
|
309
|
-
|
310
|
-
if (objects && objects.length > 0) {
|
311
|
-
for (var i=0,len=objects.length; i<len; i+=1) {
|
312
|
-
|
313
|
-
var obj = objects[i];
|
314
|
-
var id = obj.id;
|
315
|
-
|
316
|
-
if (!obj.getShape) {
|
317
|
-
continue;
|
318
|
-
}
|
319
|
-
|
320
|
-
|
321
|
-
var shape = obj.getShape(e);
|
322
|
-
|
323
|
-
|
324
|
-
|
325
|
-
|
326
|
-
|
327
|
-
|
328
|
-
|
329
|
-
//
|
330
|
-
// If the mouse is over a key element add the details
|
331
|
-
// of it to the Registry
|
332
|
-
//
|
333
|
-
if (obj.coords && obj.coords.key && obj.coords.key.length) {
|
334
|
-
|
335
|
-
var mouseXY = RG.getMouseXY(e);
|
336
|
-
|
337
|
-
for (var i=0,overkey=false; i<obj.coords.key.length; ++i) {
|
338
|
-
|
339
|
-
if (
|
340
|
-
mouseXY[0] >= obj.coords.key[i][0]
|
341
|
-
&& mouseXY[0] <= (obj.coords.key[i][0] + obj.coords.key[i][2])
|
342
|
-
&& mouseXY[1] >= obj.coords.key[i][1]
|
343
|
-
&& mouseXY[1] <= (obj.coords.key[i][1] + obj.coords.key[i][3])
|
344
|
-
) {
|
345
|
-
|
346
|
-
RG.Registry.set('key-element', obj.coords.key[i]);
|
347
|
-
overkey = true;
|
348
|
-
}
|
349
|
-
|
350
|
-
if (!overkey) {
|
351
|
-
RG.Registry.set('key-element', null);
|
352
|
-
}
|
353
|
-
}
|
354
|
-
}
|
355
|
-
|
356
|
-
|
357
|
-
|
358
|
-
|
359
|
-
// ================================================================================================ //
|
360
|
-
// This facilitates the chart.events.mousemove option
|
361
|
-
// ================================================================================================ //
|
362
|
-
|
363
|
-
var func = obj.Get('chart.events.mousemove');
|
364
|
-
|
365
|
-
if (!func && typeof obj.onmousemove == 'function') {
|
366
|
-
var func = obj.onmousemove;
|
367
|
-
}
|
368
|
-
|
369
|
-
/**
|
370
|
-
*
|
371
|
-
*/
|
372
|
-
if (shape) {
|
373
|
-
var index = shape['object'].type == 'scatter' ? shape['index_adjusted'] : shape['index'];
|
374
|
-
if (typeof(obj['$' + index]) == 'object' && typeof(obj['$' + index].onmousemove) == 'function') {
|
375
|
-
var func2 = obj['$' + index].onmousemove;
|
376
|
-
}
|
377
|
-
}
|
378
|
-
|
379
|
-
/**
|
380
|
-
* This bit saves the current pointer style if there isn't one already saved
|
381
|
-
*/
|
382
|
-
if (shape && (typeof(func) == 'function' || typeof(func2) == 'function' || typeof obj.Get('link') === 'string')) {
|
383
|
-
|
384
|
-
if (obj.Get('chart.events.mousemove.revertto') == null) {
|
385
|
-
obj.Set('chart.events.mousemove.revertto', e.target.style.cursor);
|
386
|
-
}
|
387
|
-
|
388
|
-
if (typeof(func) == 'function') RGraph.custom_events_mousemove_pointer = func(e, shape);
|
389
|
-
if (typeof(func2) == 'function') RGraph.custom_events_mousemove_pointer = RGraph.custom_events_mousemove_pointer || func2(e, shape);
|
390
|
-
|
391
|
-
|
392
|
-
//return;
|
393
|
-
|
394
|
-
} else if (typeof(obj.Get('chart.events.mousemove.revertto')) == 'string') {
|
395
|
-
|
396
|
-
RG.cursor.push('default');
|
397
|
-
obj.Set('chart.events.mousemove.revertto', null);
|
398
|
-
}
|
399
|
-
|
400
|
-
|
401
|
-
|
402
|
-
// ================================================================================================ //
|
403
|
-
// Tooltips
|
404
|
-
// ================================================================================================ //
|
405
|
-
var current_tooltip = RG.Registry.get('chart.tooltip');
|
406
|
-
var tooltips = obj.get('chart.tooltips');
|
407
|
-
var tooltips_event = obj.Get('chart.tooltips.event');
|
408
|
-
|
409
|
-
if ( shape
|
410
|
-
&& (tooltips && tooltips[shape['index']] || shape['tooltip'])
|
411
|
-
&& tooltips_event.indexOf('mousemove') > 0
|
412
|
-
&& ( RG.isNull(current_tooltip) // Is there a tooltip being shown?
|
413
|
-
|| obj.uid != current_tooltip.__object__.uid // Same object?
|
414
|
-
|| (current_tooltip.__index__ != shape['index']) // Same tooltip index?
|
415
|
-
|| (typeof shape['dataset'] === 'number' && shape['dataset'] != current_tooltip.__shape__['dataset'])
|
416
|
-
)
|
417
|
-
) {
|
418
|
-
|
419
|
-
RG.clear(obj.canvas);
|
420
|
-
RG.hideTooltip();
|
421
|
-
RG.redraw();
|
422
|
-
obj.canvas.rgraph_mouseup_event_listener(e);
|
423
|
-
|
424
|
-
return;
|
425
|
-
}
|
426
|
-
|
427
|
-
|
428
|
-
// ================================================================================================ //
|
429
|
-
// Adjusting
|
430
|
-
// ================================================================================================ //
|
431
|
-
|
432
|
-
|
433
|
-
if (obj && obj.get('chart.adjustable')) {
|
434
|
-
obj.Adjusting_mousemove(e);
|
435
|
-
}
|
436
|
-
|
437
|
-
|
438
|
-
/**
|
439
|
-
* This facilitates breaking out of the loop when a shape has been found -
|
440
|
-
* ie the cursor is over a shape an upper chart
|
441
|
-
*/
|
442
|
-
if (shape || (obj.overChartArea && obj.overChartArea(e) )) {
|
443
|
-
break;
|
444
|
-
}
|
445
|
-
}
|
446
|
-
}
|
447
|
-
|
448
|
-
// ================================================================================================ //
|
449
|
-
// Crosshairs
|
450
|
-
// ================================================================================================ //
|
451
|
-
|
452
|
-
|
453
|
-
if (e.target && e.target.__object__ && e.target.__object__.get('chart.crosshairs')) {
|
454
|
-
RG.drawCrosshairs(e, e.target.__object__);
|
455
|
-
}
|
456
|
-
|
457
|
-
|
458
|
-
// ================================================================================================ //
|
459
|
-
// Interactive key No LONGER REQUIRED
|
460
|
-
// ================================================================================================ //
|
461
|
-
|
462
|
-
|
463
|
-
//if (typeof InteractiveKey_line_mousemove == 'function') InteractiveKey_line_mousemove(e);
|
464
|
-
//if (typeof InteractiveKey_pie_mousemove == 'function') InteractiveKey_pie_mousemove(e);
|
465
|
-
|
466
|
-
|
467
|
-
// ================================================================================================ //
|
468
|
-
// Annotating
|
469
|
-
// ================================================================================================ //
|
470
|
-
|
471
|
-
|
472
|
-
if (e.target.__object__ && e.target.__object__.get('chart.annotatable') && RG.annotating_canvas_onmousemove) {
|
473
|
-
RG.annotating_canvas_onmousemove(e);
|
474
|
-
}
|
475
|
-
|
476
|
-
|
477
|
-
|
478
|
-
/**
|
479
|
-
* Determine the pointer
|
480
|
-
*/
|
481
|
-
RG.evaluateCursor(e);
|
482
|
-
};
|
483
|
-
obj.canvas.addEventListener('mousemove', obj.canvas.rgraph_mousemove_event_listener, false);
|
484
|
-
}
|
485
|
-
};
|
486
|
-
|
487
|
-
|
488
|
-
|
489
|
-
|
490
|
-
/**
|
491
|
-
* This is the canvas mousedown event listener.
|
492
|
-
*
|
493
|
-
* @param object obj The chart object
|
494
|
-
*/
|
495
|
-
RG.installCanvasMousedownListener =
|
496
|
-
RG.InstallCanvasMousedownListener = function (obj)
|
497
|
-
{
|
498
|
-
if (!obj.canvas.rgraph_mousedown_event_listener) {
|
499
|
-
obj.canvas.rgraph_mousedown_event_listener = function (e)
|
500
|
-
{
|
501
|
-
/**
|
502
|
-
* For firefox add the window.event object
|
503
|
-
*/
|
504
|
-
if (navigator.userAgent.indexOf('Firefox') >= 0) window.event = e;
|
505
|
-
|
506
|
-
e = RG.fixEventObject(e);
|
507
|
-
|
508
|
-
|
509
|
-
/**
|
510
|
-
* Annotating
|
511
|
-
*/
|
512
|
-
if (e.target.__object__ && e.target.__object__.get('chart.annotatable') && RG.annotating_canvas_onmousedown) {
|
513
|
-
RG.annotating_canvas_onmousedown(e);
|
514
|
-
return;
|
515
|
-
}
|
516
|
-
|
517
|
-
var obj = RG.ObjectRegistry.getObjectByXY(e);
|
518
|
-
|
519
|
-
if (obj) {
|
520
|
-
|
521
|
-
var id = obj.id;
|
522
|
-
|
523
|
-
|
524
|
-
|
525
|
-
/*************************************************************
|
526
|
-
* Handle adjusting for all object types
|
527
|
-
*************************************************************/
|
528
|
-
if (obj && obj.isRGraph && obj.get('chart.adjustable')) {
|
529
|
-
|
530
|
-
/**
|
531
|
-
* Check the cursor is in the correct area
|
532
|
-
*/
|
533
|
-
var obj = RG.ObjectRegistry.getObjectByXY(e);
|
534
|
-
|
535
|
-
if (obj && obj.isRGraph) {
|
536
|
-
|
537
|
-
// If applicable, get the appropriate shape and store it in the registry
|
538
|
-
switch (obj.type) {
|
539
|
-
case 'bar': var shape = obj.getShapeByX(e); break;
|
540
|
-
case 'gantt':
|
541
|
-
var shape = obj.getShape(e);
|
542
|
-
if (shape) {
|
543
|
-
var mouseXY = RG.getMouseXY(e);
|
544
|
-
RG.Registry.set('chart.adjusting.gantt', {
|
545
|
-
'index': shape['index'],
|
546
|
-
'object': obj,
|
547
|
-
'mousex': mouseXY[0],
|
548
|
-
'mousey': mouseXY[1],
|
549
|
-
'event_start': obj.data[shape['index']][0],
|
550
|
-
'event_duration': obj.data[shape['index']][1],
|
551
|
-
'mode': (mouseXY[0] > (shape['x'] + shape['width'] - 5) ? 'resize' : 'move'),
|
552
|
-
'shape': shape
|
553
|
-
});
|
554
|
-
}
|
555
|
-
break;
|
556
|
-
case 'line': var shape = obj.getShape(e); break;
|
557
|
-
default: var shape = null;
|
558
|
-
}
|
559
|
-
|
560
|
-
RG.Registry.set('chart.adjusting.shape', shape);
|
561
|
-
|
562
|
-
|
563
|
-
// Fire the onadjustbegin event
|
564
|
-
RG.fireCustomEvent(obj, 'onadjustbegin');
|
565
|
-
|
566
|
-
RG.Registry.set('chart.adjusting', obj);
|
567
|
-
|
568
|
-
|
569
|
-
// Liberally redraw the canvas
|
570
|
-
RG.clear(obj.canvas);
|
571
|
-
RG.redraw();
|
572
|
-
|
573
|
-
// Call the mousemove event listener so that the canvas
|
574
|
-
// is adjusted even though the mouse isn't moved
|
575
|
-
obj.canvas.rgraph_mousemove_event_listener(e);
|
576
|
-
}
|
577
|
-
}
|
578
|
-
|
579
|
-
|
580
|
-
RG.clear(obj.canvas);
|
581
|
-
RG.redraw();
|
582
|
-
}
|
583
|
-
};
|
584
|
-
obj.canvas.addEventListener('mousedown', obj.canvas.rgraph_mousedown_event_listener, false);
|
585
|
-
}
|
586
|
-
};
|
587
|
-
|
588
|
-
|
589
|
-
|
590
|
-
|
591
|
-
/**
|
592
|
-
* This is the canvas click event listener. Used by the pseudo event listener
|
593
|
-
*
|
594
|
-
* @param object obj The chart object
|
595
|
-
*/
|
596
|
-
RG.installCanvasClickListener =
|
597
|
-
RG.InstallCanvasClickListener = function (obj)
|
598
|
-
{
|
599
|
-
if (!obj.canvas.rgraph_click_event_listener) {
|
600
|
-
obj.canvas.rgraph_click_event_listener = function (e)
|
601
|
-
{
|
602
|
-
/**
|
603
|
-
* For firefox add the window.event object
|
604
|
-
*/
|
605
|
-
if (navigator.userAgent.indexOf('Firefox') >= 0) window.event = e;
|
606
|
-
|
607
|
-
e = RG.fixEventObject(e);
|
608
|
-
|
609
|
-
var objects = RG.ObjectRegistry.getObjectsByXY(e);
|
610
|
-
|
611
|
-
for (var i=0,len=objects.length; i<len; i+=1) {
|
612
|
-
|
613
|
-
var obj = objects[i];
|
614
|
-
var id = obj.id;
|
615
|
-
var shape = obj.getShape(e);
|
616
|
-
|
617
|
-
/**
|
618
|
-
* This bit saves the current pointer style if there isn't one already saved
|
619
|
-
*/
|
620
|
-
var func = obj.get('chart.events.click');
|
621
|
-
|
622
|
-
if (!func && typeof(obj.onclick) == 'function') {
|
623
|
-
func = obj.onclick;
|
624
|
-
}
|
625
|
-
|
626
|
-
if (shape && typeof func == 'function') {
|
627
|
-
|
628
|
-
func(e, shape);
|
629
|
-
|
630
|
-
/**
|
631
|
-
* If objects are layered on top of each other this return
|
632
|
-
* stops objects underneath from firing once the "top"
|
633
|
-
* objects user event has fired
|
634
|
-
*/
|
635
|
-
return;
|
636
|
-
}
|
637
|
-
|
638
|
-
|
639
|
-
|
640
|
-
//
|
641
|
-
// Handle the key click event
|
642
|
-
//
|
643
|
-
var key = RG.Registry.get('key-element');
|
644
|
-
if (key) {
|
645
|
-
RG.fireCustomEvent(obj, 'onkeyclick');
|
646
|
-
}
|
647
|
-
|
648
|
-
|
649
|
-
|
650
|
-
|
651
|
-
|
652
|
-
/**
|
653
|
-
* The property takes priority over this.
|
654
|
-
*/
|
655
|
-
if (shape) {
|
656
|
-
|
657
|
-
var index = shape['object'].type == 'scatter' ? shape['index_adjusted'] : shape['index'];
|
658
|
-
|
659
|
-
if (typeof(index) == 'number' && obj['$' + index]) {
|
660
|
-
|
661
|
-
var func = obj['$' + index].onclick;
|
662
|
-
|
663
|
-
if (typeof(func) == 'function') {
|
664
|
-
|
665
|
-
func(e, shape);
|
666
|
-
|
667
|
-
/**
|
668
|
-
* If objects are layered on top of each other this return
|
669
|
-
* stops objects underneath from firing once the "top"
|
670
|
-
* objects user event has fired
|
671
|
-
*/
|
672
|
-
return;
|
673
|
-
}
|
674
|
-
}
|
675
|
-
}
|
676
|
-
|
677
|
-
/**
|
678
|
-
* This facilitates breaking out of the loop when a shape has been found -
|
679
|
-
* ie the cursor is over a shape an upper chart
|
680
|
-
*/
|
681
|
-
if (shape || (obj.overChartArea && obj.overChartArea(e)) ) {
|
682
|
-
break;
|
683
|
-
}
|
684
|
-
}
|
685
|
-
};
|
686
|
-
obj.canvas.addEventListener('click', obj.canvas.rgraph_click_event_listener, false);
|
687
|
-
}
|
688
|
-
};
|
689
|
-
|
690
|
-
|
691
|
-
|
692
|
-
|
693
|
-
/**
|
694
|
-
* This function evaluates the various cursor settings and if there's one for pointer, changes it to that
|
695
|
-
*/
|
696
|
-
//RG.evaluateCursor =
|
697
|
-
RG.evaluateCursor =
|
698
|
-
RG.EvaluateCursor = function (e)
|
699
|
-
{
|
700
|
-
var obj = null;
|
701
|
-
var mouseXY = RG.getMouseXY(e);
|
702
|
-
var mouseX = mouseXY[0];
|
703
|
-
var mouseY = mouseXY[1];
|
704
|
-
var canvas = e.target;
|
705
|
-
|
706
|
-
/**
|
707
|
-
* Tooltips cause the mouse pointer to change
|
708
|
-
*/
|
709
|
-
var objects = RG.ObjectRegistry.getObjectsByCanvasID(canvas.id);
|
710
|
-
|
711
|
-
for (var i=0,len=objects.length; i<len; i+=1) {
|
712
|
-
if ((objects[i].getShape && objects[i].getShape(e)) || (objects[i].overChartArea && objects[i].overChartArea(e))) {
|
713
|
-
var obj = objects[i];
|
714
|
-
var id = obj.id;
|
715
|
-
}
|
716
|
-
}
|
717
|
-
|
718
|
-
if (!RG.isNull(obj)) {
|
719
|
-
if (obj.getShape && obj.getShape(e)) {
|
720
|
-
|
721
|
-
var shape = obj.getShape(e);
|
722
|
-
|
723
|
-
if (obj.get('chart.tooltips')) {
|
724
|
-
|
725
|
-
var text = RG.parseTooltipText(obj.get('chart.tooltips'), shape['index']);
|
726
|
-
|
727
|
-
if (!text && shape['object'].type == 'scatter' && shape['index_adjusted']) {
|
728
|
-
text = RG.parseTooltipText(obj.get('chart.tooltips'), shape['index_adjusted']);
|
729
|
-
}
|
730
|
-
|
731
|
-
/**
|
732
|
-
* This essentially makes front charts "hide" the back charts
|
733
|
-
*/
|
734
|
-
if (text) {
|
735
|
-
var pointer = true;
|
736
|
-
}
|
737
|
-
}
|
738
|
-
}
|
739
|
-
|
740
|
-
/**
|
741
|
-
* Now go through the key coords and see if it's over that.
|
742
|
-
*/
|
743
|
-
if (!RG.isNull(obj) && obj.Get('chart.key.interactive')) {
|
744
|
-
for (var j=0; j<obj.coords.key.length; ++j) {
|
745
|
-
if (mouseX > obj.coords.key[j][0] && mouseX < (obj.coords.key[j][0] + obj.coords.key[j][2]) && mouseY > obj.coords.key[j][1] && mouseY < (obj.coords.key[j][1] + obj.coords.key[j][3])) {
|
746
|
-
var pointer = true;
|
747
|
-
}
|
748
|
-
}
|
749
|
-
}
|
750
|
-
}
|
751
|
-
|
752
|
-
/**
|
753
|
-
* It can be specified in the user mousemove event - remember it can now
|
754
|
-
* be specified in THREE ways
|
755
|
-
*/
|
756
|
-
if (RGraph.custom_events_mousemove_pointer) {
|
757
|
-
var pointer = true;
|
758
|
-
RGraph.custom_events_mousemove_pointer = false;
|
759
|
-
}
|
760
|
-
/*
|
761
|
-
|
762
|
-
|
763
|
-
var index = shape['object'].type == 'scatter' ? shape['index_adjusted'] : shape['index'];
|
764
|
-
if (!RG.isNull(obj['$' + index]) && typeof(obj['$' + index].onmousemove) == 'function') {
|
765
|
-
var str = (obj['$' + index].onmousemove).toString();
|
766
|
-
if (str.match(/pointer/) && str.match(/cursor/) && str.match(/style/)) {
|
767
|
-
var pointer = true;
|
768
|
-
}
|
769
|
-
}
|
770
|
-
}
|
771
|
-
*/
|
772
|
-
|
773
|
-
/**
|
774
|
-
* Is the chart resizable? Go through all the objects again
|
775
|
-
*/
|
776
|
-
var objects = RG.ObjectRegistry.objects.byCanvasID;
|
777
|
-
|
778
|
-
for (var i=0,len=objects.length; i<len; i+=1) {
|
779
|
-
if (objects[i] && objects[i][1].Get('chart.resizable')) {
|
780
|
-
var resizable = true;
|
781
|
-
}
|
782
|
-
}
|
783
|
-
|
784
|
-
if (resizable && mouseX > (e.target.width - 32) && mouseY > (e.target.height - 16)) {
|
785
|
-
pointer = true;
|
786
|
-
}
|
787
|
-
|
788
|
-
|
789
|
-
if (pointer) {
|
790
|
-
e.target.style.cursor = 'pointer';
|
791
|
-
} else if (e.target.style.cursor == 'pointer') {
|
792
|
-
e.target.style.cursor = 'default';
|
793
|
-
} else {
|
794
|
-
e.target.style.cursor = null;
|
795
|
-
}
|
796
|
-
|
797
|
-
|
798
|
-
|
799
|
-
// =========================================================================
|
800
|
-
// Resize cursor - check mouseis in bottom left corner and if it is change it
|
801
|
-
// =========================================================================
|
802
|
-
|
803
|
-
|
804
|
-
if (resizable && mouseX >= (e.target.width - 15) && mouseY >= (e.target.height - 15)) {
|
805
|
-
e.target.style.cursor = 'move';
|
806
|
-
|
807
|
-
} else if (e.target.style.cursor === 'move') {
|
808
|
-
e.target.style.cursor = 'default';
|
809
|
-
}
|
810
|
-
|
811
|
-
|
812
|
-
// =========================================================================
|
813
|
-
// Interactive key
|
814
|
-
// =========================================================================
|
815
|
-
|
816
|
-
|
817
|
-
|
818
|
-
if (typeof mouse_over_key == 'boolean' && mouse_over_key) {
|
819
|
-
e.target.style.cursor = 'pointer';
|
820
|
-
}
|
821
|
-
|
822
|
-
|
823
|
-
// =========================================================================
|
824
|
-
// Gantt chart adjusting
|
825
|
-
// =========================================================================
|
826
|
-
|
827
|
-
//if (obj && obj.type == 'gantt' && obj.get('chart.adjustable')) {
|
828
|
-
// if (obj.getShape && obj.getShape(e)) {
|
829
|
-
// e.target.style.cursor = 'ew-resize';
|
830
|
-
// } else {
|
831
|
-
// e.target.style.cursor = 'default';
|
832
|
-
// }
|
833
|
-
//} else if (!obj || !obj.type) {
|
834
|
-
// e.target.style.cursor = cursor;
|
835
|
-
//}
|
836
|
-
|
837
|
-
|
838
|
-
// =========================================================================
|
839
|
-
// Line chart adjusting
|
840
|
-
// =========================================================================
|
841
|
-
|
842
|
-
|
843
|
-
if (obj && obj.type == 'line' && obj.get('chart.adjustable')) {
|
844
|
-
if (obj.getShape && obj.getShape(e)) {
|
845
|
-
e.target.style.cursor = 'ns-resize';
|
846
|
-
} else {
|
847
|
-
e.target.style.cursor = 'default';
|
848
|
-
}
|
849
|
-
}
|
850
|
-
|
851
|
-
|
852
|
-
// =========================================================================
|
853
|
-
// Annotatable
|
854
|
-
// =========================================================================
|
855
|
-
|
856
|
-
|
857
|
-
if (e.target.__object__ && e.target.__object__.get('chart.annotatable')) {
|
858
|
-
e.target.style.cursor = 'crosshair';
|
859
|
-
}
|
860
|
-
|
861
|
-
|
862
|
-
// =========================================================================
|
863
|
-
// Drawing API link
|
864
|
-
// =========================================================================
|
865
|
-
|
866
|
-
|
867
|
-
if (obj && obj.type === 'drawing.text' && shape && typeof obj.get('link') === 'string') {
|
868
|
-
e.target.style.cursor = 'pointer';
|
869
|
-
}
|
870
|
-
};
|
871
|
-
|
872
|
-
|
873
|
-
|
874
|
-
|
875
|
-
/**
|
876
|
-
* This function handles the tooltip text being a string, function
|
877
|
-
*
|
878
|
-
* @param mixed tooltip This could be a string or a function. If it's a function it's called and
|
879
|
-
* the return value is used as the tooltip text
|
880
|
-
* @param numbr idx The index of the tooltip.
|
881
|
-
*/
|
882
|
-
RG.parseTooltipText = function (tooltips, idx)
|
883
|
-
{
|
884
|
-
// No tooltips
|
885
|
-
if (!tooltips) {
|
886
|
-
return null;
|
887
|
-
}
|
888
|
-
|
889
|
-
// Get the tooltip text
|
890
|
-
if (typeof tooltips == 'function') {
|
891
|
-
var text = tooltips(idx);
|
892
|
-
|
893
|
-
// A single tooltip. Only supported by the Scatter chart
|
894
|
-
} else if (typeof tooltips == 'string') {
|
895
|
-
var text = tooltips;
|
896
|
-
|
897
|
-
} else if (typeof tooltips == 'object' && typeof tooltips[idx] == 'function') {
|
898
|
-
var text = tooltips[idx](idx);
|
899
|
-
|
900
|
-
} else if (typeof tooltips[idx] == 'string' && tooltips[idx]) {
|
901
|
-
var text = tooltips[idx];
|
902
|
-
|
903
|
-
} else {
|
904
|
-
var text = '';
|
905
|
-
}
|
906
|
-
|
907
|
-
if (text == 'undefined') {
|
908
|
-
text = '';
|
909
|
-
} else if (text == 'null') {
|
910
|
-
text = '';
|
911
|
-
}
|
912
|
-
|
913
|
-
// Conditional in case the tooltip file isn't included
|
914
|
-
return RG.getTooltipTextFromDIV ? RG.getTooltipTextFromDIV(text) : text;
|
915
|
-
};
|
916
|
-
|
917
|
-
|
918
|
-
|
919
|
-
|
920
|
-
/**
|
921
|
-
* Draw crosshairs if enabled
|
922
|
-
*
|
923
|
-
* @param object obj The graph object (from which we can get the context and canvas as required)
|
924
|
-
*/
|
925
|
-
RG.drawCrosshairs =
|
926
|
-
RG.DrawCrosshairs = function (e, obj)
|
927
|
-
{
|
928
|
-
var e = RG.fixEventObject(e),
|
929
|
-
width = obj.canvas.width,
|
930
|
-
height = obj.canvas.height,
|
931
|
-
mouseXY = RG.getMouseXY(e),
|
932
|
-
x = mouseXY[0],
|
933
|
-
y = mouseXY[1],
|
934
|
-
gutterLeft = obj.gutterLeft,
|
935
|
-
gutterRight = obj.gutterRight,
|
936
|
-
gutterTop = obj.gutterTop,
|
937
|
-
gutterBottom = obj.gutterBottom,
|
938
|
-
Mathround = Math.round,
|
939
|
-
prop = obj.properties,
|
940
|
-
co = obj.context,
|
941
|
-
ca = obj.canvas
|
942
|
-
|
943
|
-
RG.redrawCanvas(ca);
|
944
|
-
|
945
|
-
if ( x >= gutterLeft
|
946
|
-
&& y >= gutterTop
|
947
|
-
&& x <= (width - gutterRight)
|
948
|
-
&& y <= (height - gutterBottom)
|
949
|
-
) {
|
950
|
-
|
951
|
-
var linewidth = prop['chart.crosshairs.linewidth'] ? prop['chart.crosshairs.linewidth'] : 1;
|
952
|
-
co.lineWidth = linewidth ? linewidth : 1;
|
953
|
-
|
954
|
-
co.beginPath();
|
955
|
-
co.strokeStyle = prop['chart.crosshairs.color'];
|
956
|
-
|
957
|
-
|
958
|
-
|
959
|
-
|
960
|
-
|
961
|
-
/**
|
962
|
-
* The chart.crosshairs.snap option
|
963
|
-
*/
|
964
|
-
if (prop['chart.crosshairs.snap']) {
|
965
|
-
|
966
|
-
// Linear search for the closest point
|
967
|
-
var point = null;
|
968
|
-
var dist = null;
|
969
|
-
var len = null;
|
970
|
-
|
971
|
-
if (obj.type == 'line') {
|
972
|
-
|
973
|
-
for (var i=0; i<obj.coords.length; ++i) {
|
974
|
-
|
975
|
-
var length = RG.getHypLength(obj.coords[i][0], obj.coords[i][1], x, y);
|
976
|
-
|
977
|
-
// Check the mouse X coordinate
|
978
|
-
if (typeof dist != 'number' || length < dist) {
|
979
|
-
var point = i;
|
980
|
-
var dist = length;
|
981
|
-
}
|
982
|
-
}
|
983
|
-
|
984
|
-
x = obj.coords[point][0];
|
985
|
-
y = obj.coords[point][1];
|
986
|
-
|
987
|
-
// Get the dataset
|
988
|
-
for (var dataset=0; dataset<obj.coords2.length; ++dataset) {
|
989
|
-
for (var point=0; point<obj.coords2[dataset].length; ++point) {
|
990
|
-
if (obj.coords2[dataset][point][0] == x && obj.coords2[dataset][point][1] == y) {
|
991
|
-
ca.__crosshairs_snap_dataset__ = dataset;
|
992
|
-
ca.__crosshairs_snap_point__ = point;
|
993
|
-
}
|
994
|
-
}
|
995
|
-
}
|
996
|
-
|
997
|
-
} else {
|
998
|
-
|
999
|
-
for (var i=0; i<obj.coords.length; ++i) {
|
1000
|
-
for (var j=0; j<obj.coords[i].length; ++j) {
|
1001
|
-
|
1002
|
-
// Check the mouse X coordinate
|
1003
|
-
var len = RG.getHypLength(obj.coords[i][j][0], obj.coords[i][j][1], x, y);
|
1004
|
-
|
1005
|
-
if (typeof(dist) != 'number' || len < dist) {
|
1006
|
-
|
1007
|
-
var dataset = i;
|
1008
|
-
var point = j;
|
1009
|
-
var dist = len;
|
1010
|
-
}
|
1011
|
-
}
|
1012
|
-
|
1013
|
-
}
|
1014
|
-
ca.__crosshairs_snap_dataset__ = dataset;
|
1015
|
-
ca.__crosshairs_snap_point__ = point;
|
1016
|
-
|
1017
|
-
|
1018
|
-
x = obj.coords[dataset][point][0];
|
1019
|
-
y = obj.coords[dataset][point][1];
|
1020
|
-
}
|
1021
|
-
}
|
1022
|
-
|
1023
|
-
|
1024
|
-
|
1025
|
-
|
1026
|
-
|
1027
|
-
|
1028
|
-
// Draw a top vertical line
|
1029
|
-
if (prop['chart.crosshairs.vline']) {
|
1030
|
-
co.moveTo(Mathround(x), Mathround(gutterTop));
|
1031
|
-
co.lineTo(Mathround(x), Mathround(height - gutterBottom));
|
1032
|
-
}
|
1033
|
-
|
1034
|
-
// Draw a horizontal line
|
1035
|
-
if (prop['chart.crosshairs.hline']) {
|
1036
|
-
co.moveTo(Mathround(gutterLeft), Mathround(y));
|
1037
|
-
co.lineTo(Mathround(width - gutterRight), Mathround(y));
|
1038
|
-
}
|
1039
|
-
|
1040
|
-
co.stroke();
|
1041
|
-
|
1042
|
-
|
1043
|
-
/**
|
1044
|
-
* Need to show the coords?
|
1045
|
-
*/
|
1046
|
-
if (obj.type == 'scatter' && prop['chart.crosshairs.coords']) {
|
1047
|
-
|
1048
|
-
var xCoord = (((x - gutterLeft) / (width - gutterLeft - gutterRight)) * (prop['chart.xmax'] - prop['chart.xmin'])) + prop['chart.xmin'];
|
1049
|
-
xCoord = xCoord.toFixed(prop['chart.scale.decimals']);
|
1050
|
-
var yCoord = obj.max - (((y - prop['chart.gutter.top']) / (height - gutterTop - gutterBottom)) * obj.max);
|
1051
|
-
|
1052
|
-
if (obj.type == 'scatter' && obj.properties['chart.xaxispos'] == 'center') {
|
1053
|
-
yCoord = (yCoord - (obj.max / 2)) * 2;
|
1054
|
-
}
|
1055
|
-
|
1056
|
-
yCoord = yCoord.toFixed(prop['chart.scale.decimals']);
|
1057
|
-
|
1058
|
-
var div = RG.Registry.get('chart.coordinates.coords.div');
|
1059
|
-
var mouseXY = RG.getMouseXY(e);
|
1060
|
-
var canvasXY = RG.getCanvasXY(ca);
|
1061
|
-
|
1062
|
-
if (!div) {
|
1063
|
-
var div = document.createElement('DIV');
|
1064
|
-
div.__object__ = obj;
|
1065
|
-
div.style.position = 'absolute';
|
1066
|
-
div.style.backgroundColor = 'white';
|
1067
|
-
div.style.border = '1px solid black';
|
1068
|
-
div.style.fontFamily = 'Arial, Verdana, sans-serif';
|
1069
|
-
div.style.fontSize = '10pt'
|
1070
|
-
div.style.padding = '2px';
|
1071
|
-
div.style.opacity = 1;
|
1072
|
-
div.style.WebkitBorderRadius = '3px';
|
1073
|
-
div.style.borderRadius = '3px';
|
1074
|
-
div.style.MozBorderRadius = '3px';
|
1075
|
-
document.body.appendChild(div);
|
1076
|
-
|
1077
|
-
RG.Registry.set('chart.coordinates.coords.div', div);
|
1078
|
-
}
|
1079
|
-
|
1080
|
-
// Convert the X/Y pixel coords to correspond to the scale
|
1081
|
-
div.style.opacity = 1;
|
1082
|
-
div.style.display = 'inline';
|
1083
|
-
|
1084
|
-
if (!prop['chart.crosshairs.coords.fixed']) {
|
1085
|
-
div.style.left = ma.max(2, (e.pageX - div.offsetWidth - 3)) + 'px';
|
1086
|
-
div.style.top = ma.max(2, (e.pageY - div.offsetHeight - 3)) + 'px';
|
1087
|
-
} else {
|
1088
|
-
div.style.left = canvasXY[0] + gutterLeft + 3 + 'px';
|
1089
|
-
div.style.top = canvasXY[1] + gutterTop + 3 + 'px';
|
1090
|
-
}
|
1091
|
-
|
1092
|
-
div.innerHTML = '<span style="color: #666">' + prop['chart.crosshairs.coords.labels.x'] + ':</span> ' + xCoord + '<br><span style="color: #666">' + prop['chart.crosshairs.coords.labels.y'] + ':</span> ' + yCoord;
|
1093
|
-
|
1094
|
-
obj.canvas.addEventListener('mouseout', RG.hideCrosshairCoords, false);
|
1095
|
-
|
1096
|
-
ca.__crosshairs_labels__ = div;
|
1097
|
-
ca.__crosshairs_x__ = xCoord;
|
1098
|
-
ca.__crosshairs_y__ = yCoord;
|
1099
|
-
|
1100
|
-
} else if (prop['chart.crosshairs.coords']) {
|
1101
|
-
alert('[RGRAPH] Showing crosshair coordinates is only supported on the Scatter chart');
|
1102
|
-
}
|
1103
|
-
|
1104
|
-
/**
|
1105
|
-
* Fire the oncrosshairs custom event
|
1106
|
-
*/
|
1107
|
-
RG.fireCustomEvent(obj, 'oncrosshairs');
|
1108
|
-
|
1109
|
-
} else {
|
1110
|
-
RG.hideCrosshairCoords();
|
1111
|
-
}
|
1112
|
-
};
|
1113
|
-
|
1114
|
-
|
1115
|
-
|
1116
|
-
|
1117
|
-
//
|
1118
|
-
// Adds a mousemove event listener that highlights a segment based on th
|
1119
|
-
// mousemove event. Used in the Rose and the RScatter charts
|
1120
|
-
//
|
1121
|
-
//@param int segments The number of segments to allow
|
1122
|
-
//
|
1123
|
-
RG.allowSegmentHighlight = function (opt)
|
1124
|
-
{
|
1125
|
-
var obj = opt.object,
|
1126
|
-
count = opt.count,
|
1127
|
-
fill = opt.fill,
|
1128
|
-
stroke = opt.stroke
|
1129
|
-
|
1130
|
-
if (!RG.segmentHighlightFunction) {
|
1131
|
-
|
1132
|
-
RG.segmentHighlightFunction = function (e)
|
1133
|
-
{
|
1134
|
-
|
1135
|
-
var mouseXY = RG.getMouseXY(e);
|
1136
|
-
var angle = RG.getAngleByXY(obj.centerx, obj.centery, mouseXY[0], mouseXY[1]);
|
1137
|
-
|
1138
|
-
angle += RG.HALFPI;
|
1139
|
-
|
1140
|
-
if (angle > RG.TWOPI) {
|
1141
|
-
angle -= RG.TWOPI;
|
1142
|
-
}
|
1143
|
-
|
1144
|
-
RG.redraw();
|
1145
|
-
|
1146
|
-
var start = 0;
|
1147
|
-
var end = 0;
|
1148
|
-
var a = (ma.PI * 2) / count;
|
1149
|
-
|
1150
|
-
//
|
1151
|
-
// Radius
|
1152
|
-
//
|
1153
|
-
var r = obj.radius;
|
1154
|
-
|
1155
|
-
|
1156
|
-
(function ()
|
1157
|
-
{
|
1158
|
-
for (i=0; i<count; i+=1) {
|
1159
|
-
if (angle < (a * (i + 1))) {
|
1160
|
-
start = i * a;
|
1161
|
-
end = (i + 1) * a;
|
1162
|
-
|
1163
|
-
return;
|
1164
|
-
}
|
1165
|
-
}
|
1166
|
-
})();
|
1167
|
-
|
1168
|
-
start -= RG.HALFPI;
|
1169
|
-
end -= RG.HALFPI;
|
1170
|
-
|
1171
|
-
|
1172
|
-
RG.path2(
|
1173
|
-
obj.context,
|
1174
|
-
'b m % % a % % % % % false c s % f %',
|
1175
|
-
obj.centerx, obj.centery,
|
1176
|
-
obj.centerx,obj.centery,r,start,end,
|
1177
|
-
stroke,
|
1178
|
-
fill
|
1179
|
-
);
|
1180
|
-
|
1181
|
-
};
|
1182
|
-
obj.canvas.addEventListener('mousemove', RG.segmentHighlightFunction, false);
|
1183
|
-
}
|
1184
|
-
}
|
1185
|
-
|
1186
|
-
|
1187
|
-
|
1188
|
-
|
1189
|
-
// End module pattern
|
1190
|
-
})(window, document);
|
2
|
+
RGraph=window.RGraph||{isRGraph:true};(function(win,doc,undefined)
|
3
|
+
{var RG=RGraph,ua=navigator.userAgent,ma=Math;RG.installWindowMousedownListener=RG.InstallWindowMousedownListener=function(obj)
|
4
|
+
{if(!RG.window_mousedown_event_listener){RG.window_mousedown_event_listener=function(e)
|
5
|
+
{if(navigator.userAgent.indexOf('Firefox')>=0)win.event=e;e=RG.fixEventObject(e);if(RG.HideTooltip&&RG.Registry.Get('chart.tooltip')){RG.clear(RG.Registry.Get('chart.tooltip').__canvas__);RG.redraw();RG.hideTooltip();}};win.addEventListener('mousedown',RG.window_mousedown_event_listener,false);}};RG.installWindowMouseupListener=RG.InstallWindowMouseupListener=function(obj)
|
6
|
+
{if(!RG.window_mouseup_event_listener){RG.window_mouseup_event_listener=function(e)
|
7
|
+
{if(navigator.userAgent.indexOf('Firefox')>=0)win.event=e;e=RG.fixEventObject(e);if(RG.annotating_window_onmouseup){RG.annotating_window_onmouseup(e);return;}
|
8
|
+
if(RG.Registry.Get('chart.adjusting')||RG.Registry.Get('chart.adjusting.gantt')){var obj=RG.Registry.Get('chart.adjusting');if(obj&&obj.type==='line'){obj.data_arr=RG.arrayLinearize(obj.data);}
|
9
|
+
RG.fireCustomEvent(RG.Registry.Get('chart.adjusting'),'onadjustend');}
|
10
|
+
RG.Registry.set('chart.adjusting',null);RG.Registry.set('chart.adjusting.shape',null);RG.Registry.set('chart.adjusting.gantt',null);var tags=document.getElementsByTagName('canvas');for(var i=0;i<tags.length;++i){if(tags[i].__object__&&tags[i].__object__.isRGraph){if(!tags[i].__object__.get('chart.annotatable')){if(!tags[i].__rgraph_trace_cover__&&!noredraw){RG.clear(tags[i]);}else{var noredraw=true;}}}}
|
11
|
+
if(!noredraw){RG.redraw();}};win.addEventListener('mouseup',RG.window_mouseup_event_listener,false);}};RG.installCanvasMouseupListener=RG.InstallCanvasMouseupListener=function(obj)
|
12
|
+
{if(!obj.canvas.rgraph_mouseup_event_listener){obj.canvas.rgraph_mouseup_event_listener=function(e)
|
13
|
+
{if(navigator.userAgent.indexOf('Firefox')>=0)window.event=e;e=RG.fixEventObject(e);var objects=RG.ObjectRegistry.getObjectsByXY(e);if(objects){for(var i=0,len=objects.length;i<len;i+=1){var obj=objects[i],id=objects[i].id;var link=obj.Get('link');if(obj.type=='drawing.text'&&typeof link==='string'){var link_target=obj.get('link.target');var link_options=obj.get('link.options');window.open(link,link_target?link_target:null,link_options);}
|
14
|
+
if(!RG.isNull(obj)&&RG.tooltip){var shape=obj.getShape(e);if(shape&&shape['tooltip']){var text=shape['tooltip'];if(text){var type=shape['object'].type;RG.clear(obj.canvas);RG.redraw();RG.Registry.set('chart.tooltip.shape',shape);RG.tooltip(obj,text,0,0,shape['index'],e);obj.highlight(shape);if(RG.Registry.get('chart.tooltip')){RG.Registry.get('chart.tooltip').__shape__=shape;RG.evaluateCursor(e);}
|
15
|
+
e.cancelBubble=true;e.stopPropagation();return false;}}}
|
16
|
+
if(RG.Registry.get('chart.adjusting')||RG.Registry.get('chart.adjusting.gantt')){if(obj&&obj.type==='line'){obj.data_arr=RG.arrayLinearize(obj.data);}
|
17
|
+
RG.fireCustomEvent(RG.Registry.get('chart.adjusting'),'onadjustend');}
|
18
|
+
RG.Registry.set('chart.adjusting',null);RG.Registry.set('chart.adjusting.shape',null);RG.Registry.set('chart.adjusting.gantt',null);if(shape||(obj.overChartArea&&obj.overChartArea(e))){break;}}}};obj.canvas.addEventListener('mouseup',obj.canvas.rgraph_mouseup_event_listener,false);}};RG.installCanvasMousemoveListener=RG.InstallCanvasMousemoveListener=function(obj)
|
19
|
+
{if(!obj.canvas.rgraph_mousemove_event_listener){obj.canvas.rgraph_mousemove_event_listener=function(e)
|
20
|
+
{if(navigator.userAgent.indexOf('Firefox')>=0)window.event=e;e=RG.fixEventObject(e);var objects=RG.OR.getObjectsByXY(e);var uids=[];if(objects&&objects.length>0){for(var i=0,len=objects.length;i<len;i+=1){var obj=objects[i];var id=obj.id;uids[obj.uid]=true;if(!obj.getShape){continue;}
|
21
|
+
var shape=obj.getShape(e);if(obj.coords&&obj.coords.key&&obj.coords.key.length){var mouseXY=RG.getMouseXY(e);for(var i=0,overkey=false;i<obj.coords.key.length;++i){if(mouseXY[0]>=obj.coords.key[i][0]&&mouseXY[0]<=(obj.coords.key[i][0]+obj.coords.key[i][2])&&mouseXY[1]>=obj.coords.key[i][1]&&mouseXY[1]<=(obj.coords.key[i][1]+obj.coords.key[i][3])){RG.Registry.set('key-element',obj.coords.key[i]);overkey=true;}
|
22
|
+
if(!overkey){RG.Registry.set('key-element',null);}}}
|
23
|
+
var func=obj.get('chart.events.mousemove');if(!func&&typeof obj.onmousemove=='function'){var func=obj.onmousemove;}
|
24
|
+
if(shape){var index=shape['object'].type=='scatter'?shape['index_adjusted']:shape['index'];if(typeof(obj['$'+index])=='object'&&typeof(obj['$'+index].onmousemove)=='function'){var func2=obj['$'+index].onmousemove;}}
|
25
|
+
if(shape&&(typeof(func)=='function'||typeof(func2)=='function'||typeof obj.Get('link')==='string')){if(obj.Get('chart.events.mousemove.revertto')==null){obj.Set('chart.events.mousemove.revertto',e.target.style.cursor);}
|
26
|
+
if(typeof(func)=='function')RGraph.custom_events_mousemove_pointer=func(e,shape);if(typeof(func2)=='function')RGraph.custom_events_mousemove_pointer=RGraph.custom_events_mousemove_pointer||func2(e,shape);if(typeof RG.events==='object'&&typeof RG.events[obj.uid]==='object'){for(i in RG.events[obj.uid]){if(typeof i==='string'&&typeof RG.events[obj.uid][i]==='object'&&RG.events[obj.uid][i][1]==='onmousemove'&&typeof RG.events[obj.uid][i][2]==='function'){(RG.events[obj.uid][i][2])(obj);}}}}else if(typeof(obj.Get('chart.events.mousemove.revertto'))=='string'){RG.cursor.push('default');obj.Set('chart.events.mousemove.revertto',null);}
|
27
|
+
var func=obj.properties['chart.events.mouseover'];if(!func&&typeof obj.onmouseover==='function'){func=obj.onmouseover;}
|
28
|
+
if(shape){var index=shape['object'].type=='scatter'?shape['index_adjusted']:shape['index'];if(typeof(obj['$'+index])=='object'&&typeof(obj['$'+index].onmouseover)=='function'){var func2=obj['$'+index].onmouseover;}}else{obj.__mouseover_shape_index__=null;RG.__mouseover_objects__=[];}
|
29
|
+
if(typeof RG.__mouseover_objects__==='undefined'){RG.__mouseover_objects__=[];}
|
30
|
+
if(typeof func==='function'||typeof func2==='function'){if(shape){if((obj.__mouseover_shape_index__===shape.index)===false){obj.__mouseover_shape_index__=shape.index;RG.__mouseover_objects__.push(obj);if(func)func(e,shape);if(func2)func2(e,shape);if(typeof RG.events==='object'&&typeof RG.events[obj.uid]==='object'){for(i in RG.events[obj.uid]){if(typeof i==='string'&&typeof RG.events[obj.uid][i]==='object'&&RG.events[obj.uid][i][1]==='onmouseover'&&typeof RG.events[obj.uid][i][2]==='function'){(RG.events[obj.uid][i][2])(obj);}}}}}else{obj.__mouseover_shape_index__=null;RG.__mouseover_objects__=[];}}else{obj.__mouseover_shape_index__=null;}
|
31
|
+
var current_tooltip=RG.Registry.get('chart.tooltip');var tooltips=obj.get('chart.tooltips');var tooltips_event=obj.Get('chart.tooltips.event');if(shape&&(tooltips&&tooltips[shape['index']]||shape['tooltip'])&&tooltips_event.indexOf('mousemove')!==-1&&(RG.isNull(current_tooltip)||obj.uid!=current_tooltip.__object__.uid||(current_tooltip.__index__!=shape['index'])||(typeof shape['dataset']==='number'&&shape['dataset']!=current_tooltip.__shape__['dataset']))){RG.clear(obj.canvas);RG.hideTooltip();RG.redraw();obj.canvas.rgraph_mouseup_event_listener(e);return;}
|
32
|
+
if(obj&&obj.get('chart.adjustable')){obj.Adjusting_mousemove(e);}
|
33
|
+
if(shape||(obj.overChartArea&&obj.overChartArea(e))){break;}}
|
34
|
+
var objects=RG.OR.getObjectsByCanvasID(e.target.id);for(var i=0;i<objects.length;++i){if(!uids[objects[i].uid]){objects[i].__mouseover_shape_index__=null;}}}else{var objects=RG.OR.getObjectsByCanvasID(e.target.id);for(var i=0;i<objects.length;i++){objects[i].__mouseover_shape_index__=null;}
|
35
|
+
RG.__mouseover_objects__=[];}
|
36
|
+
if(e.target&&e.target.__object__&&e.target.__object__.get('chart.crosshairs')){RG.drawCrosshairs(e,e.target.__object__);}
|
37
|
+
if(e.target.__object__&&e.target.__object__.get('chart.annotatable')&&RG.annotating_canvas_onmousemove){RG.annotating_canvas_onmousemove(e);}
|
38
|
+
RG.evaluateCursor(e);};obj.canvas.addEventListener('mousemove',obj.canvas.rgraph_mousemove_event_listener,false);}};RG.installCanvasMousedownListener=RG.InstallCanvasMousedownListener=function(obj)
|
39
|
+
{if(!obj.canvas.rgraph_mousedown_event_listener){obj.canvas.rgraph_mousedown_event_listener=function(e)
|
40
|
+
{if(navigator.userAgent.indexOf('Firefox')>=0)window.event=e;e=RG.fixEventObject(e);if(e.target.__object__&&e.target.__object__.get('chart.annotatable')&&RG.annotating_canvas_onmousedown){RG.annotating_canvas_onmousedown(e);return;}
|
41
|
+
var obj=RG.ObjectRegistry.getObjectByXY(e);if(obj){var id=obj.id;if(obj&&obj.isRGraph&&obj.get('chart.adjustable')){var obj=RG.ObjectRegistry.getObjectByXY(e);if(obj&&obj.isRGraph){switch(obj.type){case'bar':var shape=obj.getShapeByX(e);break;case'gantt':var shape=obj.getShape(e);var data=typeof shape.subindex==='number'?obj.data[shape.index][shape.subindex]:obj.data[shape.index];if(shape){var mouseXY=RG.getMouseXY(e);RG.Registry.set('chart.adjusting.gantt',{index:shape.index,subindex:shape.subindex,object:obj,mousex:mouseXY[0],mousey:mouseXY[1],event:data,event_start:data[0],event_duration:data[1],mode:(mouseXY[0]>(shape['x']+shape['width']-5)?'resize':'move'),shape:shape});}
|
42
|
+
break;case'line':var shape=obj.getShape(e);break;case'hbar':var shape=obj.getShapeByY(e);break;default:var shape=null;}
|
43
|
+
RG.Registry.set('chart.adjusting.shape',shape);RG.fireCustomEvent(obj,'onadjustbegin');RG.Registry.set('chart.adjusting',obj);RG.clear(obj.canvas);RG.redraw();obj.canvas.rgraph_mousemove_event_listener(e);}}
|
44
|
+
RG.clear(obj.canvas);RG.redraw();}};obj.canvas.addEventListener('mousedown',obj.canvas.rgraph_mousedown_event_listener,false);}};RG.installCanvasClickListener=RG.InstallCanvasClickListener=function(obj)
|
45
|
+
{if(!obj.canvas.rgraph_click_event_listener){obj.canvas.rgraph_click_event_listener=function(e)
|
46
|
+
{if(navigator.userAgent.indexOf('Firefox')>=0)window.event=e;e=RG.fixEventObject(e);var objects=RG.ObjectRegistry.getObjectsByXY(e);for(var i=0,len=objects.length;i<len;i+=1){var obj=objects[i];var id=obj.id;var shape=obj.getShape(e);var func=obj.get('chart.events.click');if(!func&&typeof(obj.onclick)=='function'){func=obj.onclick;}
|
47
|
+
if(shape&&typeof func=='function'){func(e,shape);if(typeof RG.events==='object'&&typeof RG.events[obj.uid]==='object'){for(i in RG.events[obj.uid]){if(typeof i==='string'&&typeof RG.events[obj.uid][i]==='object'&&RG.events[obj.uid][i][1]==='onclick'&&typeof RG.events[obj.uid][i][2]==='function'){(RG.events[obj.uid][i][2])(obj);}}}
|
48
|
+
return;}
|
49
|
+
var key=RG.Registry.get('key-element');if(key){RG.fireCustomEvent(obj,'onkeyclick');}
|
50
|
+
if(shape){var index=shape['object'].type=='scatter'?shape['index_adjusted']:shape['index'];if(typeof(index)=='number'&&obj['$'+index]){var func=obj['$'+index].onclick;if(typeof(func)=='function'){func(e,shape);return;}}}
|
51
|
+
if(shape||(obj.overChartArea&&obj.overChartArea(e))){break;}}};obj.canvas.addEventListener('click',obj.canvas.rgraph_click_event_listener,false);}};RG.evaluateCursor=RG.EvaluateCursor=function(e)
|
52
|
+
{var obj=null;var mouseXY=RG.getMouseXY(e);var mouseX=mouseXY[0];var mouseY=mouseXY[1];var canvas=e.target;var objects=RG.ObjectRegistry.getObjectsByCanvasID(canvas.id);for(var i=0,len=objects.length;i<len;i+=1){if((objects[i].getShape&&objects[i].getShape(e))||(objects[i].overChartArea&&objects[i].overChartArea(e))){var obj=objects[i];var id=obj.id;}}
|
53
|
+
if(!RG.isNull(obj)){if(obj.getShape&&obj.getShape(e)){var shape=obj.getShape(e);if(obj.get('chart.tooltips')){var text=RG.parseTooltipText(obj.get('chart.tooltips'),shape['index']);if(!text&&shape['object'].type=='scatter'&&shape['index_adjusted']){text=RG.parseTooltipText(obj.get('chart.tooltips'),shape['index_adjusted']);}
|
54
|
+
if(text){var pointer=true;}}}
|
55
|
+
if(!RG.isNull(obj)&&obj.Get('chart.key.interactive')){for(var j=0;j<obj.coords.key.length;++j){if(mouseX>obj.coords.key[j][0]&&mouseX<(obj.coords.key[j][0]+obj.coords.key[j][2])&&mouseY>obj.coords.key[j][1]&&mouseY<(obj.coords.key[j][1]+obj.coords.key[j][3])){var pointer=true;}}}}
|
56
|
+
if(RGraph.custom_events_mousemove_pointer){var pointer=true;RGraph.custom_events_mousemove_pointer=false;}
|
57
|
+
var objects=RG.ObjectRegistry.objects.byCanvasID;for(var i=0,len=objects.length;i<len;i+=1){if(objects[i]&&objects[i][1].Get('chart.resizable')){var resizable=true;}}
|
58
|
+
if(resizable&&mouseX>(e.target.width-32)&&mouseY>(e.target.height-16)){pointer=true;}
|
59
|
+
if(pointer){e.target.style.cursor='pointer';}else if(e.target.style.cursor=='pointer'){e.target.style.cursor='default';}else{e.target.style.cursor=null;}
|
60
|
+
if(resizable&&mouseX>=(e.target.width-15)&&mouseY>=(e.target.height-15)){e.target.style.cursor='move';}else if(e.target.style.cursor==='move'){e.target.style.cursor='default';}
|
61
|
+
if(typeof mouse_over_key=='boolean'&&mouse_over_key){e.target.style.cursor='pointer';}
|
62
|
+
if(obj&&obj.type=='line'&&obj.get('chart.adjustable')){if(obj.getShape&&obj.getShape(e)){e.target.style.cursor='ns-resize';}else{e.target.style.cursor='default';}}
|
63
|
+
if(e.target.__object__&&e.target.__object__.get('chart.annotatable')){e.target.style.cursor='crosshair';}
|
64
|
+
if(obj&&obj.type==='drawing.text'&&shape&&typeof obj.get('link')==='string'){e.target.style.cursor='pointer';}};RG.parseTooltipText=function(tooltips,idx)
|
65
|
+
{if(!tooltips){return null;}
|
66
|
+
if(typeof tooltips=='function'){var text=tooltips(idx);}else if(typeof tooltips=='string'){var text=tooltips;}else if(typeof tooltips=='object'&&typeof tooltips[idx]=='function'){var text=tooltips[idx](idx);}else if(typeof tooltips[idx]=='string'&&tooltips[idx]){var text=tooltips[idx];}else{var text='';}
|
67
|
+
if(text=='undefined'){text='';}else if(text=='null'){text='';}
|
68
|
+
return RG.getTooltipTextFromDIV?RG.getTooltipTextFromDIV(text):text;};RG.drawCrosshairs=RG.DrawCrosshairs=function(e,obj)
|
69
|
+
{var e=RG.fixEventObject(e),width=obj.canvas.width,height=obj.canvas.height,mouseXY=RG.getMouseXY(e),x=mouseXY[0],y=mouseXY[1],gutterLeft=obj.gutterLeft,gutterRight=obj.gutterRight,gutterTop=obj.gutterTop,gutterBottom=obj.gutterBottom,Mathround=Math.round,prop=obj.properties,co=obj.context,ca=obj.canvas
|
70
|
+
RG.redrawCanvas(ca);if(x>=gutterLeft&&y>=gutterTop&&x<=(width-gutterRight)&&y<=(height-gutterBottom)){var linewidth=prop['chart.crosshairs.linewidth']?prop['chart.crosshairs.linewidth']:1;co.lineWidth=linewidth?linewidth:1;co.beginPath();co.strokeStyle=prop['chart.crosshairs.color'];if(prop['chart.crosshairs.snap']){var point=null;var dist=null;var len=null;if(obj.type=='line'){for(var i=0;i<obj.coords.length;++i){var length=RG.getHypLength(obj.coords[i][0],obj.coords[i][1],x,y);if(typeof dist!='number'||length<dist){var point=i;var dist=length;}}
|
71
|
+
x=obj.coords[point][0];y=obj.coords[point][1];for(var dataset=0;dataset<obj.coords2.length;++dataset){for(var point=0;point<obj.coords2[dataset].length;++point){if(obj.coords2[dataset][point][0]==x&&obj.coords2[dataset][point][1]==y){ca.__crosshairs_snap_dataset__=dataset;ca.__crosshairs_snap_point__=point;}}}}else{for(var i=0;i<obj.coords.length;++i){for(var j=0;j<obj.coords[i].length;++j){var len=RG.getHypLength(obj.coords[i][j][0],obj.coords[i][j][1],x,y);if(typeof(dist)!='number'||len<dist){var dataset=i;var point=j;var dist=len;}}}
|
72
|
+
ca.__crosshairs_snap_dataset__=dataset;ca.__crosshairs_snap_point__=point;x=obj.coords[dataset][point][0];y=obj.coords[dataset][point][1];}}
|
73
|
+
if(prop['chart.crosshairs.vline']){co.moveTo(Mathround(x),Mathround(gutterTop));co.lineTo(Mathround(x),Mathround(height-gutterBottom));}
|
74
|
+
if(prop['chart.crosshairs.hline']){co.moveTo(Mathround(gutterLeft),Mathround(y));co.lineTo(Mathround(width-gutterRight),Mathround(y));}
|
75
|
+
co.stroke();if(obj.type=='scatter'&&prop['chart.crosshairs.coords']){var xCoord=(((x-gutterLeft)/(width-gutterLeft-gutterRight))*(prop['chart.xmax']-prop['chart.xmin']))+prop['chart.xmin'];xCoord=xCoord.toFixed(prop['chart.scale.decimals']);var yCoord=obj.max-(((y-prop['chart.gutter.top'])/(height-gutterTop-gutterBottom))*obj.max);if(obj.type=='scatter'&&obj.properties['chart.xaxispos']=='center'){yCoord=(yCoord-(obj.max/2))*2;}
|
76
|
+
yCoord=yCoord.toFixed(prop['chart.scale.decimals']);var div=RG.Registry.get('chart.coordinates.coords.div');var mouseXY=RG.getMouseXY(e);var canvasXY=RG.getCanvasXY(ca);if(!div){var div=document.createElement('DIV');div.__object__=obj;div.style.position='absolute';div.style.backgroundColor='white';div.style.border='1px solid black';div.style.fontFamily='Arial, Verdana, sans-serif';div.style.fontSize='10pt'
|
77
|
+
div.style.padding='2px';div.style.opacity=1;div.style.WebkitBorderRadius='3px';div.style.borderRadius='3px';div.style.MozBorderRadius='3px';document.body.appendChild(div);RG.Registry.set('chart.coordinates.coords.div',div);}
|
78
|
+
div.style.opacity=1;div.style.display='inline';if(!prop['chart.crosshairs.coords.fixed']){div.style.left=ma.max(2,(e.pageX-div.offsetWidth-3))+'px';div.style.top=ma.max(2,(e.pageY-div.offsetHeight-3))+'px';}else{div.style.left=canvasXY[0]+gutterLeft+3+'px';div.style.top=canvasXY[1]+gutterTop+3+'px';}
|
79
|
+
div.innerHTML='<span style="color: #666">'+prop['chart.crosshairs.coords.labels.x']+':</span> '+xCoord+'<br><span style="color: #666">'+prop['chart.crosshairs.coords.labels.y']+':</span> '+yCoord;obj.canvas.addEventListener('mouseout',RG.hideCrosshairCoords,false);ca.__crosshairs_labels__=div;ca.__crosshairs_x__=xCoord;ca.__crosshairs_y__=yCoord;}else if(prop['chart.crosshairs.coords']){alert('[RGRAPH] Showing crosshair coordinates is only supported on the Scatter chart');}
|
80
|
+
RG.fireCustomEvent(obj,'oncrosshairs');}else{RG.hideCrosshairCoords();}};RG.allowSegmentHighlight=function(opt)
|
81
|
+
{var obj=opt.object,count=opt.count,fill=opt.fill,stroke=opt.stroke
|
82
|
+
if(!RG.segmentHighlightFunction){RG.segmentHighlightFunction=function(e)
|
83
|
+
{var mouseXY=RG.getMouseXY(e);var angle=RG.getAngleByXY(obj.centerx,obj.centery,mouseXY[0],mouseXY[1]);angle+=RG.HALFPI;if(angle>RG.TWOPI){angle-=RG.TWOPI;}
|
84
|
+
RG.redraw();var start=0;var end=0;var a=(ma.PI*2)/count;var r=obj.radius;(function()
|
85
|
+
{for(i=0;i<count;i+=1){if(angle<(a*(i+1))){start=i*a;end=(i+1)*a;return;}}})();start-=RG.HALFPI;end-=RG.HALFPI;RG.path2(obj.context,'b m % % a % % % % % false c s % f %',obj.centerx,obj.centery,obj.centerx,obj.centery,r,start,end,stroke,fill);};obj.canvas.addEventListener('mousemove',RG.segmentHighlightFunction,false);}}})(window,document);
|