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,615 +1,33 @@
|
|
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
|
-
* gives the absolute X position
|
50
|
-
* @param int y The Y position the tooltip should appear at. Combined with the canvases offsetTop
|
51
|
-
* gives the absolute Y position
|
52
|
-
* @param int idx The index of the tooltip in the graph objects tooltip array
|
53
|
-
* @param object e The event object
|
54
|
-
*/
|
55
|
-
RG.tooltip =
|
56
|
-
RG.Tooltip = function (obj, text, x, y, idx, e)
|
57
|
-
{
|
58
|
-
/**
|
59
|
-
* chart.tooltip.override allows you to totally take control of rendering the tooltip yourself
|
60
|
-
*/
|
61
|
-
if (typeof(obj.get('chart.tooltips.override')) == 'function') {
|
62
|
-
return obj.get('chart.tooltips.override')(obj, text, x, y, idx);
|
63
|
-
}
|
64
|
-
|
65
|
-
|
66
|
-
/**
|
67
|
-
* Fire the beforetooltip event
|
68
|
-
*/
|
69
|
-
RG.fireCustomEvent(obj, 'onbeforetooltip');
|
70
|
-
|
71
|
-
|
72
|
-
/**
|
73
|
-
* Save the X/Y coords
|
74
|
-
*/
|
75
|
-
var originalX = x;
|
76
|
-
var originalY = y;
|
77
|
-
|
78
|
-
/**
|
79
|
-
* This facilitates the "id:xxx" format
|
80
|
-
*/
|
81
|
-
text = RG.getTooltipTextFromDIV(text);
|
82
|
-
|
83
|
-
/**
|
84
|
-
* First clear any exising timers
|
85
|
-
*/
|
86
|
-
var timers = RG.Registry.Get('chart.tooltip.timers');
|
87
|
-
|
88
|
-
if (timers && timers.length) {
|
89
|
-
for (i=0; i<timers.length; ++i) {
|
90
|
-
clearTimeout(timers[i]);
|
91
|
-
}
|
92
|
-
}
|
93
|
-
RG.Registry.Set('chart.tooltip.timers', []);
|
94
|
-
|
95
|
-
/**
|
96
|
-
* Hide the context menu if it's currently shown
|
97
|
-
*/
|
98
|
-
if (obj.Get('chart.contextmenu')) {
|
99
|
-
RG.hideContext();
|
100
|
-
}
|
101
|
-
|
102
|
-
var effect = obj.Get('chart.tooltips.effect') ? obj.Get('chart.tooltips.effect').toLowerCase() : 'fade';
|
103
|
-
|
104
|
-
|
105
|
-
/**
|
106
|
-
* Show a tool tip
|
107
|
-
*/
|
108
|
-
var tooltipObj = document.createElement('DIV');
|
109
|
-
tooltipObj.className = obj.Get('chart.tooltips.css.class');
|
110
|
-
tooltipObj.style.display = 'none';
|
111
|
-
tooltipObj.style.position = RG.isFixed(obj.canvas) ? 'fixed' : 'absolute';
|
112
|
-
tooltipObj.style.left = 0;
|
113
|
-
tooltipObj.style.top = 0;
|
114
|
-
tooltipObj.style.backgroundColor = 'rgb(255,255,239)';
|
115
|
-
tooltipObj.style.color = 'black';
|
116
|
-
if (!document.all) tooltipObj.style.border = '';
|
117
|
-
tooltipObj.style.visibility = 'visible';
|
118
|
-
tooltipObj.style.paddingLeft = RG.tooltips.padding;
|
119
|
-
tooltipObj.style.paddingRight = RG.tooltips.padding;
|
120
|
-
tooltipObj.style.fontFamily = RG.tooltips.font_face;
|
121
|
-
tooltipObj.style.fontSize = RG.tooltips.font_size;
|
122
|
-
tooltipObj.style.zIndex = 3;
|
123
|
-
|
124
|
-
tooltipObj.style.borderRadius = '5px';
|
125
|
-
tooltipObj.style.MozBorderRadius = '5px';
|
126
|
-
tooltipObj.style.WebkitBorderRadius = '5px';
|
127
|
-
tooltipObj.style.WebkitBoxShadow = 'rgba(96,96,96,0.5) 0 0 5px';
|
128
|
-
tooltipObj.style.MozBoxShadow = 'rgba(96,96,96,0.5) 0 0 5px';
|
129
|
-
tooltipObj.style.boxShadow = 'rgba(96,96,96,0.5) 0 0 5px';
|
130
|
-
tooltipObj.style.filter = 'progid:DXImageTransform.Microsoft.Shadow(color=#666666,direction=135)';
|
131
|
-
tooltipObj.style.opacity = 0;
|
132
|
-
//tooltipObj.style.overflow = 'hidden';
|
133
|
-
tooltipObj.innerHTML = text;
|
134
|
-
tooltipObj.__text__ = text; // This is set because the innerHTML can change when it's set
|
135
|
-
tooltipObj.__canvas__ = obj.canvas;
|
136
|
-
tooltipObj.style.display = 'inline';
|
137
|
-
tooltipObj.id = '__rgraph_tooltip_' + obj.canvas.id + '_' + obj.uid + '_'+ idx;
|
138
|
-
tooltipObj.__event__ = obj.Get('chart.tooltips.event') || 'click';
|
139
|
-
tooltipObj.__object__ = obj;
|
140
|
-
|
141
|
-
if (typeof(idx) == 'number') {
|
142
|
-
tooltipObj.__index__ = idx;
|
143
|
-
origIdx = idx;
|
144
|
-
}
|
145
|
-
|
146
|
-
if (obj.type == 'line' || obj.type == 'radar') {
|
147
|
-
for (var ds=0; ds<obj.data.length; ++ds) {
|
148
|
-
if (idx >= obj.data[ds].length) {
|
149
|
-
idx -= obj.data[ds].length;
|
150
|
-
} else {
|
151
|
-
break;
|
152
|
-
}
|
153
|
-
}
|
154
|
-
|
155
|
-
tooltipObj.__dataset__ = ds;
|
156
|
-
tooltipObj.__index2__ = idx;
|
157
|
-
}
|
158
|
-
|
159
|
-
document.body.appendChild(tooltipObj);
|
160
|
-
|
161
|
-
var width = tooltipObj.offsetWidth;
|
162
|
-
var height = tooltipObj.offsetHeight;
|
163
|
-
|
164
|
-
|
165
|
-
/**
|
166
|
-
* Set the width on the tooltip so it doesn't resize if the window is resized
|
167
|
-
*/
|
168
|
-
tooltipObj.style.width = width + 'px';
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
tooltipObj.style.top = window.event.pageY - height - 5 + 'px';
|
173
|
-
|
174
|
-
/**
|
175
|
-
* If the function exists call the object specific tooltip positioning function
|
176
|
-
*/
|
177
|
-
|
178
|
-
if (typeof(obj.positionTooltip) == 'function') {
|
179
|
-
if (tooltipObj.innerHTML.length > 0) {
|
180
|
-
|
181
|
-
obj.positionTooltip(obj, x, y, tooltipObj, origIdx ? origIdx : idx);
|
182
|
-
|
183
|
-
if (obj.Get('chart.tooltips.coords.page')) {
|
184
|
-
|
185
|
-
tooltipObj.style.left = e.pageX - (width / 2) - 4.25 + 'px';
|
186
|
-
tooltipObj.style.top = e.pageY - height - 5 + 'px';
|
187
|
-
|
188
|
-
// In case the value is negative - this positions the tooltip
|
189
|
-
// underneath the click
|
190
|
-
//if (obj.type === 'bar' && obj.data_arr[idx] < 0) {
|
191
|
-
//tooltipObj.style.top = e.pageY + 10 + 'px';
|
192
|
-
//}
|
193
|
-
|
194
|
-
//document.getElementById('__rgraph_tooltip_pointer__').style.left = (parseInt(tooltipObj.offsetWidth) / 2) - 8.5 + 'px';
|
195
|
-
}
|
196
|
-
}
|
197
|
-
} else {
|
198
|
-
tooltipObj.style.left = e.pageX - (width / 2) - 4.25 + 'px';
|
199
|
-
tooltipObj.style.top = e.pageY - height - 7 + 'px';
|
200
|
-
}
|
201
|
-
|
202
|
-
|
203
|
-
if (effect == 'fade' || effect == 'expand' || effect == 'contract' || effect == 'snap') {
|
204
|
-
setTimeout(function () {tooltipObj.style.opacity = 0.1;}, 25);
|
205
|
-
setTimeout(function () {tooltipObj.style.opacity = 0.2;}, 50);
|
206
|
-
setTimeout(function () {tooltipObj.style.opacity = 0.3;}, 75);
|
207
|
-
setTimeout(function () {tooltipObj.style.opacity = 0.4;}, 100);
|
208
|
-
setTimeout(function () {tooltipObj.style.opacity = 0.5;}, 125);
|
209
|
-
setTimeout(function () {tooltipObj.style.opacity = 0.6;}, 150);
|
210
|
-
setTimeout(function () {tooltipObj.style.opacity = 0.7;}, 175);
|
211
|
-
setTimeout(function () {tooltipObj.style.opacity = 0.8;}, 200);
|
212
|
-
setTimeout(function () {tooltipObj.style.opacity = 0.9;}, 225);
|
213
|
-
|
214
|
-
if (effect == 'expand' || effect == 'contract' || effect == 'snap') {
|
215
|
-
console.log('[RGRAPH] The snap, expand and contract tooltip effects are deprecated. Available effects now are fade and none');
|
216
|
-
}
|
217
|
-
}
|
218
|
-
|
219
|
-
setTimeout("if (RGraph.Registry.Get('chart.tooltip')) { RGraph.Registry.Get('chart.tooltip').style.opacity = 1;}", effect == 'none' ? 50 : 250);
|
220
|
-
|
221
|
-
/**
|
222
|
-
* If the tooltip it self is clicked, cancel it
|
223
|
-
*/
|
224
|
-
tooltipObj.onmousedown = function (e){e.stopPropagation();}
|
225
|
-
tooltipObj.onmouseup = function (e){e.stopPropagation();}
|
226
|
-
tooltipObj.onclick = function (e){if (e.button == 0) {e.stopPropagation();}}
|
227
|
-
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
/**
|
235
|
-
* Keep a reference to the tooltip in the registry
|
236
|
-
*/
|
237
|
-
RG.Registry.Set('chart.tooltip', tooltipObj);
|
238
|
-
|
239
|
-
/**
|
240
|
-
* Fire the tooltip event
|
241
|
-
*/
|
242
|
-
RG.FireCustomEvent(obj, 'ontooltip');
|
243
|
-
};
|
244
|
-
|
245
|
-
|
246
|
-
|
247
|
-
|
248
|
-
|
249
|
-
/**
|
250
|
-
*
|
251
|
-
*/
|
252
|
-
RG.getTooltipTextFromDIV = function (text)
|
253
|
-
{
|
254
|
-
// This regex is duplicated firher down on roughly line 888
|
255
|
-
var result = /^id:(.*)/.exec(text);
|
256
|
-
|
257
|
-
if (result && result[1] && document.getElementById(result[1])) {
|
258
|
-
text = document.getElementById(result[1]).innerHTML;
|
259
|
-
} else if (result && result[1]) {
|
260
|
-
text = '';
|
261
|
-
}
|
262
|
-
|
263
|
-
return text;
|
264
|
-
};
|
265
|
-
|
266
|
-
|
267
|
-
/**
|
268
|
-
*
|
269
|
-
*/
|
270
|
-
RG.getTooltipWidth = function (text, obj)
|
271
|
-
{
|
272
|
-
var div = document.createElement('DIV');
|
273
|
-
div.className = obj.Get('chart.tooltips.css.class');
|
274
|
-
div.style.paddingLeft = RG.tooltips.padding;
|
275
|
-
div.style.paddingRight = RG.tooltips.padding;
|
276
|
-
div.style.fontFamily = RG.tooltips.font_face;
|
277
|
-
div.style.fontSize = RG.tooltips.font_size;
|
278
|
-
div.style.visibility = 'hidden';
|
279
|
-
div.style.position = 'absolute';
|
280
|
-
div.style.top = '300px';
|
281
|
-
div.style.left = 0;
|
282
|
-
div.style.display = 'inline';
|
283
|
-
div.innerHTML = RG.getTooltipTextFromDIV(text);
|
284
|
-
document.body.appendChild(div);
|
285
|
-
|
286
|
-
return div.offsetWidth;
|
287
|
-
};
|
288
|
-
|
289
|
-
|
290
|
-
/**
|
291
|
-
* Hides the currently shown tooltip
|
292
|
-
*/
|
293
|
-
RG.hideTooltip =
|
294
|
-
RG.HideTooltip = function ()
|
295
|
-
{
|
296
|
-
var tooltip = RG.Registry.Get('chart.tooltip');
|
297
|
-
var uid = arguments[0] && arguments[0].uid ? arguments[0].uid : null;
|
298
|
-
|
299
|
-
if (tooltip && tooltip.parentNode && (!uid || uid == tooltip.__canvas__.uid)) {
|
300
|
-
tooltip.parentNode.removeChild(tooltip);
|
301
|
-
tooltip.style.display = 'none';
|
302
|
-
tooltip.style.visibility = 'hidden';
|
303
|
-
RG.Registry.Set('chart.tooltip', null);
|
304
|
-
}
|
305
|
-
};
|
306
|
-
|
307
|
-
|
308
|
-
|
309
|
-
/**
|
310
|
-
* This installs the window mousedown event listener. It clears any highlight that may
|
311
|
-
* be present.
|
312
|
-
*
|
313
|
-
* @param object obj The chart object
|
314
|
-
*
|
315
|
-
RGraph.InstallWindowMousedownTooltipListener = function (obj)
|
316
|
-
{
|
317
|
-
if (RGraph.Registry.Get('__rgraph_event_listeners__')['window_mousedown']) {
|
318
|
-
return;
|
319
|
-
}
|
320
|
-
|
321
|
-
// When the canvas is cleared, reset this flag so that the event listener is installed again
|
322
|
-
RGraph.AddCustomEventListener(obj, 'onclear', function (obj) {RGraph.Registry.Get('__rgraph_event_listeners__')['window_mousedown'] = false;})
|
323
|
-
|
324
|
-
// NOTE: Global on purpose
|
325
|
-
rgraph_window_mousedown = function (e)
|
326
|
-
{
|
327
|
-
if (RGraph.Registry.Get('chart.tooltip')) {
|
328
|
-
|
329
|
-
var obj = RGraph.Registry.Get('chart.tooltip').__object__;
|
330
|
-
var canvas = obj.canvas;
|
331
|
-
|
332
|
-
/**
|
333
|
-
* Get rid of the tooltip and redraw all canvases on the page
|
334
|
-
*
|
335
|
-
RGraph.HideTooltip();
|
336
|
-
|
337
|
-
/**
|
338
|
-
* No need to clear if highlighting is disabled
|
339
|
-
*
|
340
|
-
* TODO Really, need to check ALL of the pertinent objects that
|
341
|
-
* are drawing on the canvas using the ObjectRegistry -
|
342
|
-
* ie RGraph.ObjectRegistry.getObjectsByCanvasID()
|
343
|
-
*
|
344
|
-
if (obj.Get('chart.tooltips.highlight')) {
|
345
|
-
RGraph.RedrawCanvas(canvas);
|
346
|
-
}
|
347
|
-
}
|
348
|
-
}
|
349
|
-
window.addEventListener('mousedown', rgraph_window_mousedown, false);
|
350
|
-
RGraph.AddEventListener('window_' + obj.id, 'mousedown', rgraph_window_mousedown);
|
351
|
-
}
|
352
|
-
*/
|
353
|
-
|
354
|
-
|
355
|
-
/**
|
356
|
-
* This installs the canvas mouseup event listener. This is the function that
|
357
|
-
* actually shows the appropriate (if any) tooltip.
|
358
|
-
*
|
359
|
-
* @param object obj The chart object
|
360
|
-
*
|
361
|
-
RGraph.InstallCanvasMouseupTooltipListener = function (obj)
|
362
|
-
{
|
363
|
-
if (RGraph.Registry.Get('__rgraph_event_listeners__')[obj.canvas.id + '_mouseup']) {
|
364
|
-
return;
|
365
|
-
}
|
366
|
-
RGraph.Registry.Get('__rgraph_event_listeners__')[obj.canvas.id + '_mouseup'] = true;
|
367
|
-
|
368
|
-
// When the canvas is cleared, reset this flag so that the event listener is installed again
|
369
|
-
RGraph.AddCustomEventListener(obj, 'onclear', function (obj) {RGraph.Registry.Get('__rgraph_event_listeners__')[obj.canvas.id + '_mouseup'] = false});
|
370
|
-
|
371
|
-
// Install the onclick event handler for the tooltips
|
372
|
-
//
|
373
|
-
// // NOTE: Global on purpose
|
374
|
-
rgraph_canvas_mouseup_func = function (e)
|
375
|
-
{
|
376
|
-
var x = arguments[1] ? arguments[1] : e.pageX;
|
377
|
-
var y = arguments[2] ? arguments[2] : e.pageY;
|
378
|
-
|
379
|
-
var objects = RGraph.ObjectRegistry.getObjectsByCanvasID(e.target.id);
|
380
|
-
|
381
|
-
// It's important to go backwards through the array so that the front charts
|
382
|
-
// are checked first, then the charts at the back
|
383
|
-
for (var i=(objects.length - 1); i>=0; --i) {
|
384
|
-
|
385
|
-
var shape = objects[i].getShape(e);
|
386
|
-
|
387
|
-
if (shape && shape['object'] && !RGraph.Registry.Get('chart.tooltip')) {
|
388
|
-
|
389
|
-
/**
|
390
|
-
* This allows the Scatter chart funky tooltips style
|
391
|
-
*
|
392
|
-
if (objects[i].type == 'scatter' && shape['dataset'] > 0) {
|
393
|
-
for (var j=0; j<(objects[i].data.length - 1); ++j) {
|
394
|
-
shape['index'] += objects[i].data[j].length;
|
395
|
-
}
|
396
|
-
}
|
397
|
-
|
398
|
-
var text = RGraph.parseTooltipText(objects[i].Get('chart.tooltips'), shape['index']);
|
399
|
-
|
400
|
-
if (text) {
|
401
|
-
|
402
|
-
if (shape['object'].Get('chart.tooltips.hotspot.xonly')) {
|
403
|
-
var canvasXY = RGraph.getCanvasXY(objects[i].canvas);
|
404
|
-
x = canvasXY[0] + shape[1];
|
405
|
-
y = canvasXY[1] + shape[2];
|
406
|
-
}
|
407
|
-
|
408
|
-
RGraph.Tooltip(objects[i], text, x, y, shape['index']);
|
409
|
-
objects[i].Highlight(shape);
|
410
|
-
|
411
|
-
e.stopPropagation();
|
412
|
-
e.cancelBubble = true;
|
413
|
-
return false;
|
414
|
-
}
|
415
|
-
}
|
416
|
-
}
|
417
|
-
}
|
418
|
-
obj.canvas.addEventListener('mouseup', rgraph_canvas_mouseup_func, false);
|
419
|
-
RGraph.AddEventListener(obj.id, 'mouseup', rgraph_canvas_mouseup_func);
|
420
|
-
}
|
421
|
-
*/
|
422
|
-
|
423
|
-
|
424
|
-
|
425
|
-
/**
|
426
|
-
* This installs the canvas mousemove event listener. This is the function that
|
427
|
-
* changes the mouse pointer if need be.
|
428
|
-
*
|
429
|
-
* @param object obj The chart object
|
430
|
-
*
|
431
|
-
RGraph.InstallCanvasMousemoveTooltipListener = function (obj)
|
432
|
-
{
|
433
|
-
if (RGraph.Registry.Get('__rgraph_event_listeners__')[obj.canvas.id + '_mousemove']) {
|
434
|
-
return;
|
435
|
-
}
|
436
|
-
RGraph.Registry.Get('__rgraph_event_listeners__')[obj.canvas.id + '_mousemove'] = true;
|
437
|
-
|
438
|
-
// When the canvas is cleared, reset this flag so that the event listener is installed again
|
439
|
-
RGraph.AddCustomEventListener(obj, 'onclear', function (obj) {RGraph.Registry.Get('__rgraph_event_listeners__')[obj.canvas.id + '_mousemove'] = false})
|
440
|
-
|
441
|
-
// Install the mousemove event handler for the tooltips
|
442
|
-
//
|
443
|
-
// NOTE: Global on purpose
|
444
|
-
rgraph_canvas_mousemove_func = function (e)
|
445
|
-
{
|
446
|
-
var objects = RGraph.ObjectRegistry.getObjectsByCanvasID(e.target.id);
|
447
|
-
|
448
|
-
for (var i=0; i<objects.length; ++i) {
|
449
|
-
|
450
|
-
var shape = objects[i].getShape(e);
|
451
|
-
|
452
|
-
if (shape && shape['object']) {
|
453
|
-
|
454
|
-
/**
|
455
|
-
* This allows the Scatter chart funky tooltips style
|
456
|
-
*
|
457
|
-
if (objects[i].type == 'scatter' && shape['dataset'] > 0) {
|
458
|
-
for (var j=0; j<(objects[i].data.length - 1); ++j) {
|
459
|
-
shape['index'] += objects[i].data[j].length;
|
460
|
-
}
|
461
|
-
}
|
462
|
-
|
463
|
-
var text = RGraph.parseTooltipText(objects[i].Get('chart.tooltips'), shape['index']);
|
464
|
-
|
465
|
-
|
466
|
-
if (text) {
|
467
|
-
|
468
|
-
e.target.style.cursor = 'pointer';
|
469
|
-
|
470
|
-
/**
|
471
|
-
* This facilitates the event triggering the tooltips being mousemove
|
472
|
-
*
|
473
|
-
|
474
|
-
if ( typeof(objects[i].Get('chart.tooltips.event')) == 'string'
|
475
|
-
&& objects[i].Get('chart.tooltips.event') == 'onmousemove'
|
476
|
-
&& (!RGraph.Registry.Get('chart.tooltip') || shape['index'] != RGraph.Registry.Get('chart.tooltip').__index__ || shape['object'].uid != RGraph.Registry.Get('chart.tooltip').__object__.uid)
|
477
|
-
) {
|
478
|
-
|
479
|
-
// Hide any current tooltip
|
480
|
-
rgraph_window_mousedown(e);
|
481
|
-
|
482
|
-
rgraph_canvas_mouseup_func(e);
|
483
|
-
}
|
484
|
-
}
|
485
|
-
}
|
486
|
-
}
|
487
|
-
}
|
488
|
-
obj.canvas.addEventListener('mousemove', rgraph_canvas_mousemove_func, false);
|
489
|
-
RGraph.AddEventListener(obj.id, 'mousemove', rgraph_canvas_mousemove_func);
|
490
|
-
}
|
491
|
-
*/
|
492
|
-
|
493
|
-
|
494
|
-
|
495
|
-
|
496
|
-
|
497
|
-
|
498
|
-
|
499
|
-
/**
|
500
|
-
* This (as the name suggests preloads any images it can find in the tooltip text
|
501
|
-
*
|
502
|
-
* @param object obj The chart object
|
503
|
-
*/
|
504
|
-
RG.preLoadTooltipImages =
|
505
|
-
RG.PreLoadTooltipImages = function (obj)
|
506
|
-
{
|
507
|
-
var tooltips = obj.Get('chart.tooltips');
|
508
|
-
|
509
|
-
if (RG.hasTooltips(obj)) {
|
510
|
-
|
511
|
-
if (obj.type == 'rscatter') {
|
512
|
-
tooltips = [];
|
513
|
-
for (var i=0; i<obj.data.length; ++i) {
|
514
|
-
tooltips.push(obj.data[3]);
|
515
|
-
}
|
516
|
-
}
|
517
|
-
|
518
|
-
for (var i=0; i<tooltips.length; ++i) {
|
519
|
-
// Add the text to an offscreen DIV tag
|
520
|
-
var div = document.createElement('DIV');
|
521
|
-
div.style.position = 'absolute';
|
522
|
-
div.style.opacity = 0;
|
523
|
-
div.style.top = '-100px';
|
524
|
-
div.style.left = '-100px';
|
525
|
-
div.innerHTML = tooltips[i];
|
526
|
-
document.body.appendChild(div);
|
527
|
-
|
528
|
-
// Now get the IMG tags and create them
|
529
|
-
var img_tags = div.getElementsByTagName('IMG');
|
530
|
-
|
531
|
-
// Create the image in an off-screen image tag
|
532
|
-
for (var j=0; j<img_tags.length; ++j) {
|
533
|
-
if (img_tags && img_tags[i]) {
|
534
|
-
var img = document.createElement('IMG');
|
535
|
-
img.style.position = 'absolute';
|
536
|
-
img.style.opacity = 0;
|
537
|
-
img.style.top = '-100px';
|
538
|
-
img.style.left = '-100px';
|
539
|
-
img.src = img_tags[i].src
|
540
|
-
document.body.appendChild(img);
|
541
|
-
|
542
|
-
setTimeout(function () {document.body.removeChild(img);}, 250);
|
543
|
-
}
|
544
|
-
}
|
545
|
-
|
546
|
-
// Now remove the div
|
547
|
-
document.body.removeChild(div);
|
548
|
-
}
|
549
|
-
}
|
550
|
-
};
|
551
|
-
|
552
|
-
|
553
|
-
|
554
|
-
|
555
|
-
/**
|
556
|
-
* This is the tooltips canvas onmousemove listener
|
557
|
-
*/
|
558
|
-
RG.tooltips_mousemove =
|
559
|
-
RG.Tooltips_mousemove = function (obj, e)
|
560
|
-
{
|
561
|
-
var shape = obj.getShape(e);
|
562
|
-
var changeCursor_tooltips = false
|
563
|
-
|
564
|
-
if ( shape
|
565
|
-
&& typeof(shape['index']) == 'number'
|
566
|
-
&& obj.Get('chart.tooltips')[shape['index']]
|
567
|
-
) {
|
568
|
-
|
569
|
-
var text = RG.parseTooltipText(obj.Get('chart.tooltips'), shape['index']);
|
570
|
-
|
571
|
-
if (text) {
|
572
|
-
|
573
|
-
/**
|
574
|
-
* Change the cursor
|
575
|
-
*/
|
576
|
-
changeCursor_tooltips = true;
|
577
|
-
|
578
|
-
if (obj.Get('chart.tooltips.event') == 'onmousemove') {
|
579
|
-
|
580
|
-
// Show the tooltip if it's not the same as the one already visible
|
581
|
-
if (
|
582
|
-
!RG.Registry.Get('chart.tooltip')
|
583
|
-
|| RG.Registry.Get('chart.tooltip').__object__.uid != obj.uid
|
584
|
-
|| RG.Registry.Get('chart.tooltip').__index__ != shape['index']
|
585
|
-
) {
|
586
|
-
|
587
|
-
RG.hideTooltip();
|
588
|
-
RG.Clear(obj.canvas);
|
589
|
-
RG.redraw();
|
590
|
-
RG.tooltip(obj, text, e.pageX, e.pageY, shape['index']);
|
591
|
-
obj.Highlight(shape);
|
592
|
-
}
|
593
|
-
}
|
594
|
-
}
|
595
|
-
|
596
|
-
/**
|
597
|
-
* More highlighting
|
598
|
-
*/
|
599
|
-
} else if (shape && typeof(shape['index']) == 'number') {
|
600
|
-
|
601
|
-
var text = RG.parseTooltipText(obj.Get('chart.tooltips'), shape['index']);
|
602
|
-
|
603
|
-
if (text) {
|
604
|
-
changeCursor_tooltips = true
|
605
|
-
}
|
606
|
-
}
|
607
|
-
|
608
|
-
return changeCursor_tooltips;
|
609
|
-
};
|
610
|
-
|
611
|
-
|
612
|
-
|
613
|
-
|
614
|
-
// End module pattern
|
615
|
-
})(window, document);
|
2
|
+
RGraph=window.RGraph||{isRGraph:true};(function(win,doc,undefined)
|
3
|
+
{var RG=RGraph,ua=navigator.userAgent,ma=Math;RG.tooltips={};RG.tooltips.style={display:'inline-block',position:'absolute',padding:'6px',fontFamily:'Arial',fontSize:'10pt',fontWeight:'normal',textAlign:'center',left:0,top:0,backgroundColor:'rgb(255,255,239)',color:'black',visibility:'visible',zIndex:3,borderRadius:'5px',boxShadow:'rgba(96,96,96,0.5) 0 0 5px',opacity:0};RG.tooltip=RG.Tooltip=function(obj,text,x,y,idx,e)
|
4
|
+
{if(RG.trim(text).length===0){return;}
|
5
|
+
RG.fireCustomEvent(obj,'onbeforetooltip');if(typeof(obj.get('chart.tooltips.override'))=='function'){return obj.get('chart.tooltips.override')(obj,text,x,y,idx);}
|
6
|
+
var originalX=x;var originalY=y;text=RG.getTooltipTextFromDIV(text);var timers=RG.Registry.Get('chart.tooltip.timers');if(timers&&timers.length){for(i=0;i<timers.length;++i){clearTimeout(timers[i]);}}
|
7
|
+
RG.Registry.Set('chart.tooltip.timers',[]);if(obj.get('chart.contextmenu')){RG.hideContext();}
|
8
|
+
var tooltipObj=document.createElement('DIV');tooltipObj.className=obj.get('chart.tooltips.css.class');for(var i in RGraph.tooltips.style){if(typeof i==='string'){tooltipObj.style[i]=RGraph.tooltips.style[i];}}
|
9
|
+
tooltipObj.innerHTML=text;tooltipObj.__text__=text;tooltipObj.__canvas__=obj.canvas;tooltipObj.id='__rgraph_tooltip_'+obj.canvas.id+'_'+obj.uid+'_'+idx;tooltipObj.__event__=obj.Get('chart.tooltips.event')||'click';tooltipObj.__object__=obj;if(typeof idx==='number'){tooltipObj.__index__=idx;origIdx=idx;}
|
10
|
+
if(obj.type==='line'||obj.type==='radar'){for(var ds=0;ds<obj.data.length;++ds){if(idx>=obj.data[ds].length){idx-=obj.data[ds].length;}else{break;}}
|
11
|
+
tooltipObj.__dataset__=ds;tooltipObj.__index2__=idx;}
|
12
|
+
document.body.appendChild(tooltipObj);var width=tooltipObj.offsetWidth;var height=tooltipObj.offsetHeight;tooltipObj.style.width=width+'px';var mouseXY=RG.getMouseXY(e);var canvasXY=RG.getCanvasXY(obj.canvas);tooltipObj.style.left=e.pageX-(parseFloat(tooltipObj.style.paddingLeft)+(width/2))+'px';tooltipObj.style.top=e.pageY-height-10+'px';if(parseFloat(tooltipObj.style.left)<=5){tooltipObj.style.left='5px';}
|
13
|
+
if(parseFloat(tooltipObj.style.left)+parseFloat(tooltipObj.style.width)>window.innerWidth){tooltipObj.style.left=''
|
14
|
+
tooltipObj.style.right='5px'}
|
15
|
+
if(RG.isFixed(obj.canvas)){var scrollTop=window.scrollY||document.documentElement.scrollTop;tooltipObj.style.position='fixed';tooltipObj.style.top=e.pageY-scrollTop-height-10+'px';}
|
16
|
+
if(obj.get('chart.tooltips.effect')==='fade'){for(var i=1;i<=10;++i){(function(index)
|
17
|
+
{setTimeout(function()
|
18
|
+
{tooltipObj.style.opacity=index/10;},index*25);})(i);}}else{tooltipObj.style.opacity=1;}
|
19
|
+
tooltipObj.onmousedown=function(e){e.stopPropagation();}
|
20
|
+
tooltipObj.onmouseup=function(e){e.stopPropagation();}
|
21
|
+
tooltipObj.onclick=function(e){if(e.button==0){e.stopPropagation();}}
|
22
|
+
RG.Registry.Set('chart.tooltip',tooltipObj);RG.fireCustomEvent(obj,'ontooltip');};RG.getTooltipTextFromDIV=function(text)
|
23
|
+
{var result=/^id:(.*)/.exec(text);if(result&&result[1]&&document.getElementById(result[1])){text=document.getElementById(result[1]).innerHTML;}else if(result&&result[1]){text='';}
|
24
|
+
return text;};RG.getTooltipWidth=function(text,obj)
|
25
|
+
{var div=document.createElement('DIV');div.className=obj.Get('chart.tooltips.css.class');div.style.paddingLeft=RG.tooltips.padding;div.style.paddingRight=RG.tooltips.padding;div.style.fontFamily=RG.tooltips.font_face;div.style.fontSize=RG.tooltips.font_size;div.style.visibility='hidden';div.style.position='absolute';div.style.top='300px';div.style.left=0;div.style.display='inline';div.innerHTML=RG.getTooltipTextFromDIV(text);document.body.appendChild(div);return div.offsetWidth;};RG.hideTooltip=RG.HideTooltip=function()
|
26
|
+
{var tooltip=RG.Registry.Get('chart.tooltip');var uid=arguments[0]&&arguments[0].uid?arguments[0].uid:null;if(tooltip&&tooltip.parentNode&&(!uid||uid==tooltip.__canvas__.uid)){tooltip.parentNode.removeChild(tooltip);tooltip.style.display='none';tooltip.style.visibility='hidden';RG.Registry.Set('chart.tooltip',null);}};RG.preLoadTooltipImages=RG.PreLoadTooltipImages=function(obj)
|
27
|
+
{var tooltips=obj.Get('chart.tooltips');if(RG.hasTooltips(obj)){if(obj.type=='rscatter'){tooltips=[];for(var i=0;i<obj.data.length;++i){tooltips.push(obj.data[3]);}}
|
28
|
+
for(var i=0;i<tooltips.length;++i){var div=document.createElement('DIV');div.style.position='absolute';div.style.opacity=0;div.style.top='-100px';div.style.left='-100px';div.innerHTML=tooltips[i];document.body.appendChild(div);var img_tags=div.getElementsByTagName('IMG');for(var j=0;j<img_tags.length;++j){if(img_tags&&img_tags[i]){var img=document.createElement('IMG');img.style.position='absolute';img.style.opacity=0;img.style.top='-100px';img.style.left='-100px';img.src=img_tags[i].src
|
29
|
+
document.body.appendChild(img);setTimeout(function(){document.body.removeChild(img);},250);}}
|
30
|
+
document.body.removeChild(div);}}};RG.tooltips_mousemove=RG.Tooltips_mousemove=function(obj,e)
|
31
|
+
{var shape=obj.getShape(e);var changeCursor_tooltips=false
|
32
|
+
if(shape&&typeof(shape['index'])=='number'&&obj.Get('chart.tooltips')[shape['index']]){var text=RG.parseTooltipText(obj.Get('chart.tooltips'),shape['index']);if(text){changeCursor_tooltips=true;if(obj.Get('chart.tooltips.event')=='onmousemove'){if(!RG.Registry.Get('chart.tooltip')||RG.Registry.Get('chart.tooltip').__object__.uid!=obj.uid||RG.Registry.Get('chart.tooltip').__index__!=shape['index']){RG.hideTooltip();RG.Clear(obj.canvas);RG.redraw();RG.tooltip(obj,text,e.pageX,e.pageY,shape['index']);obj.Highlight(shape);}}}}else if(shape&&typeof(shape['index'])=='number'){var text=RG.parseTooltipText(obj.Get('chart.tooltips'),shape['index']);if(text){changeCursor_tooltips=true}}
|
33
|
+
return changeCursor_tooltips;};})(window,document);
|