rgraph-rails 5.00 → 6.14
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/publish-geml.yaml +46 -0
- data/.gitignore +1 -0
- data/README.md +4 -5
- data/lib/rgraph-rails/version.rb +1 -1
- data/rgraph-rails.gemspec +4 -4
- data/vendor/assets/javascripts/RGraph.activity.js +1691 -0
- data/vendor/assets/javascripts/RGraph.bar.js +4253 -236
- data/vendor/assets/javascripts/RGraph.bipolar.js +3958 -162
- data/vendor/assets/javascripts/RGraph.common.annotate.js +414 -35
- data/vendor/assets/javascripts/RGraph.common.context.js +635 -30
- data/vendor/assets/javascripts/RGraph.common.core.js +10485 -419
- data/vendor/assets/javascripts/RGraph.common.csv.js +508 -27
- data/vendor/assets/javascripts/RGraph.common.dynamic.js +1693 -90
- data/vendor/assets/javascripts/RGraph.common.effects.js +1629 -89
- data/vendor/assets/javascripts/RGraph.common.key.js +1003 -53
- data/vendor/assets/javascripts/RGraph.common.moment.js +5670 -0
- data/vendor/assets/javascripts/RGraph.common.sheets.js +541 -31
- data/vendor/assets/javascripts/RGraph.common.sheets.php +351 -0
- data/vendor/assets/javascripts/RGraph.common.starburst.js +382 -0
- data/vendor/assets/javascripts/RGraph.common.table.js +386 -0
- data/vendor/assets/javascripts/RGraph.common.tooltips.js +1433 -32
- data/vendor/assets/javascripts/RGraph.drawing.background.js +660 -35
- data/vendor/assets/javascripts/RGraph.drawing.circle.js +618 -34
- data/vendor/assets/javascripts/RGraph.drawing.image.js +857 -52
- data/vendor/assets/javascripts/RGraph.drawing.line.js +712 -0
- data/vendor/assets/javascripts/RGraph.drawing.marker1.js +760 -38
- data/vendor/assets/javascripts/RGraph.drawing.marker2.js +740 -37
- data/vendor/assets/javascripts/RGraph.drawing.marker3.js +573 -36
- data/vendor/assets/javascripts/RGraph.drawing.poly.js +667 -36
- data/vendor/assets/javascripts/RGraph.drawing.rect.js +638 -34
- data/vendor/assets/javascripts/RGraph.drawing.text.js +672 -37
- data/vendor/assets/javascripts/RGraph.drawing.xaxis.js +653 -52
- data/vendor/assets/javascripts/RGraph.drawing.yaxis.js +714 -51
- data/vendor/assets/javascripts/RGraph.fuel.js +1149 -59
- data/vendor/assets/javascripts/RGraph.funnel.js +1277 -56
- data/vendor/assets/javascripts/RGraph.gantt.js +1646 -82
- data/vendor/assets/javascripts/RGraph.gauge.js +1773 -89
- data/vendor/assets/javascripts/RGraph.hbar.js +3869 -159
- data/vendor/assets/javascripts/RGraph.horseshoe.js +970 -0
- data/vendor/assets/javascripts/RGraph.hprogress.js +1829 -81
- data/vendor/assets/javascripts/RGraph.line.js +5293 -244
- data/vendor/assets/javascripts/RGraph.meter.js +1570 -77
- data/vendor/assets/javascripts/RGraph.modaldialog.js +300 -19
- data/vendor/assets/javascripts/RGraph.odo.js +1553 -68
- data/vendor/assets/javascripts/RGraph.pie.js +3273 -129
- data/vendor/assets/javascripts/RGraph.radar.js +2333 -108
- data/vendor/assets/javascripts/RGraph.rose.js +2685 -114
- data/vendor/assets/javascripts/RGraph.rscatter.js +1920 -80
- data/vendor/assets/javascripts/RGraph.scatter.js +4215 -171
- data/vendor/assets/javascripts/RGraph.segmented.js +1006 -0
- data/vendor/assets/javascripts/RGraph.semicircularprogress.js +1980 -59
- data/vendor/assets/javascripts/RGraph.svg.activity.js +1696 -0
- data/vendor/assets/javascripts/RGraph.svg.bar.js +2575 -77
- data/vendor/assets/javascripts/RGraph.svg.bipolar.js +3533 -106
- data/vendor/assets/javascripts/RGraph.svg.common.ajax.js +240 -21
- data/vendor/assets/javascripts/RGraph.svg.common.core.js +7105 -299
- data/vendor/assets/javascripts/RGraph.svg.common.csv.js +408 -28
- data/vendor/assets/javascripts/RGraph.svg.common.fx.js +1291 -68
- data/vendor/assets/javascripts/RGraph.svg.common.key.js +451 -20
- data/vendor/assets/javascripts/RGraph.svg.common.sheets.js +543 -31
- data/vendor/assets/javascripts/RGraph.svg.common.table.js +391 -0
- data/vendor/assets/javascripts/RGraph.svg.common.tooltips.js +1072 -23
- data/vendor/assets/javascripts/RGraph.svg.funnel.js +1151 -32
- data/vendor/assets/javascripts/RGraph.svg.gauge.js +1429 -34
- data/vendor/assets/javascripts/RGraph.svg.hbar.js +2692 -65
- data/vendor/assets/javascripts/RGraph.svg.horseshoe.js +969 -0
- data/vendor/assets/javascripts/RGraph.svg.line.js +2855 -86
- data/vendor/assets/javascripts/RGraph.svg.pie.js +1630 -58
- data/vendor/assets/javascripts/RGraph.svg.radar.js +1772 -58
- data/vendor/assets/javascripts/RGraph.svg.rose.js +2419 -83
- data/vendor/assets/javascripts/RGraph.svg.scatter.js +2280 -65
- data/vendor/assets/javascripts/RGraph.svg.segmented.js +930 -0
- data/vendor/assets/javascripts/RGraph.svg.semicircularprogress.js +1612 -29
- data/vendor/assets/javascripts/RGraph.svg.waterfall.js +1525 -50
- data/vendor/assets/javascripts/RGraph.thermometer.js +1411 -64
- data/vendor/assets/javascripts/RGraph.vprogress.js +1915 -81
- data/vendor/assets/javascripts/RGraph.waterfall.js +1896 -89
- data/vendor/assets/javascripts/financial-data.js +1067 -0
- metadata +37 -16
- data/.travis.yml +0 -11
- data/vendor/assets/javascripts/RGraph.common.deprecated.js +0 -35
- data/vendor/assets/javascripts/RGraph.common.resizing.js +0 -38
- data/vendor/assets/javascripts/RGraph.common.zoom.js +0 -15
- data/vendor/assets/javascripts/RGraph.cornergauge.js +0 -71
@@ -1,24 +1,1073 @@
|
|
1
|
+
'version:2023-09-16 (6.14)';
|
2
|
+
//
|
3
|
+
// o--------------------------------------------------------------------------------o
|
4
|
+
// | This file is part of the RGraph package - you can learn more at: |
|
5
|
+
// | |
|
6
|
+
// | https://www.rgraph.net |
|
7
|
+
// | |
|
8
|
+
// | RGraph is licensed under the Open Source MIT license. That means that it's |
|
9
|
+
// | totally free to use and there are no restrictions on what you can do with it! |
|
10
|
+
// o--------------------------------------------------------------------------------o
|
1
11
|
|
2
|
-
RGraph=window.RGraph||{isRGraph:true,
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
12
|
+
RGraph = window.RGraph || {isrgraph:true,isRGraph:true,rgraph:true};
|
13
|
+
RGraph.SVG = RGraph.SVG || {};
|
14
|
+
|
15
|
+
// Module pattern
|
16
|
+
(function (win, doc, undefined)
|
17
|
+
{
|
18
|
+
//
|
19
|
+
// This is used in two functions, hence it's here
|
20
|
+
//
|
21
|
+
RGraph.SVG.tooltips = {};
|
22
|
+
RGraph.SVG.tooltips.css =
|
23
|
+
RGraph.SVG.tooltips.style = {
|
24
|
+
display: 'inline-block',
|
25
|
+
position: 'absolute',
|
26
|
+
padding: '6px',
|
27
|
+
lineHeight: 'initial',
|
28
|
+
fontFamily: 'Arial',
|
29
|
+
fontSize: '12pt',
|
30
|
+
fontWeight: 'normal',
|
31
|
+
textAlign: 'center',
|
32
|
+
left: 0,
|
33
|
+
top: 0,
|
34
|
+
backgroundColor: 'black',
|
35
|
+
color: 'white',
|
36
|
+
visibility: 'visible',
|
37
|
+
zIndex: 3,
|
38
|
+
borderRadius: '5px',
|
39
|
+
boxShadow: 'rgba(96,96,96,0.5) 0 0 5px',
|
40
|
+
transition: 'left ease-out .25s, top ease-out .25s'
|
41
|
+
};
|
42
|
+
|
43
|
+
|
44
|
+
//
|
45
|
+
// Shows a tooltip
|
46
|
+
//
|
47
|
+
// @param obj The chart object
|
48
|
+
// @param opt The options
|
49
|
+
//
|
50
|
+
RGraph.SVG.tooltip = function (opt)
|
51
|
+
{
|
52
|
+
var obj = opt.object;
|
53
|
+
var properties = obj.properties;
|
54
|
+
|
55
|
+
// Fire the beforetooltip event
|
56
|
+
RGraph.SVG.fireCustomEvent(obj, 'onbeforetooltip');
|
57
|
+
|
58
|
+
|
59
|
+
if (!opt.text || typeof opt.text === 'undefined' || RGraph.SVG.trim(opt.text).length === 0) {
|
60
|
+
if (typeof properties.tooltipsOverride !== 'function') {
|
61
|
+
return;
|
62
|
+
}
|
63
|
+
}
|
64
|
+
|
65
|
+
|
66
|
+
|
67
|
+
|
68
|
+
|
69
|
+
|
70
|
+
//
|
71
|
+
// chart.tooltip.override allows you to totally take control of rendering the tooltip yourself
|
72
|
+
//
|
73
|
+
if (RGraph.SVG.isFunction(properties.tooltipsOverride)) {
|
74
|
+
|
75
|
+
// Add the body click handler that clears the highlight if necessary
|
76
|
+
//
|
77
|
+
document.body.addEventListener('mouseup', function (e)
|
78
|
+
{
|
79
|
+
obj.removeHighlight();
|
80
|
+
}, false);
|
81
|
+
|
82
|
+
return (properties.tooltipsOverride)(obj, opt);
|
83
|
+
}
|
84
|
+
|
85
|
+
|
86
|
+
|
87
|
+
|
88
|
+
|
89
|
+
|
90
|
+
|
91
|
+
// Create the tooltip DIV element
|
92
|
+
if (!RGraph.SVG.REG.get('tooltip')) {
|
93
|
+
|
94
|
+
var tooltipObj = document.createElement('DIV');
|
95
|
+
tooltipObj.className = properties.tooltipsCssClass;
|
96
|
+
|
97
|
+
|
98
|
+
|
99
|
+
|
100
|
+
// Add the default CSS to the tooltip
|
101
|
+
for (var i in RGraph.SVG.tooltips.style) {
|
102
|
+
if (typeof i === 'string') {
|
103
|
+
tooltipObj.style[i] = substitute(RGraph.SVG.tooltips.style[i]);
|
104
|
+
}
|
105
|
+
}
|
106
|
+
|
107
|
+
for (var i in RGraph.SVG.tooltips.css) {
|
108
|
+
if (typeof i === 'string') {
|
109
|
+
tooltipObj.style[i] = substitute(RGraph.SVG.tooltips.css[i]);
|
110
|
+
}
|
111
|
+
}
|
112
|
+
|
113
|
+
//
|
114
|
+
// If the tooltipsCss property is populated the add those values
|
115
|
+
// to the tooltip
|
116
|
+
//
|
117
|
+
if (!RGraph.SVG.isNull(obj.properties.tooltipsCss)) {
|
118
|
+
for (var i in obj.properties.tooltipsCss) {
|
119
|
+
if (typeof i === 'string') {
|
120
|
+
tooltipObj.style[i] = substitute(obj.properties.tooltipsCss[i]);
|
121
|
+
}
|
122
|
+
}
|
123
|
+
}
|
124
|
+
|
125
|
+
|
126
|
+
|
127
|
+
|
128
|
+
// Reuse an existing tooltip
|
129
|
+
} else {
|
130
|
+
var tooltipObj = RGraph.SVG.REG.get('tooltip');
|
131
|
+
tooltipObj.__object__.removeHighlight();
|
132
|
+
|
133
|
+
// This prevents the object from continuously growing
|
134
|
+
tooltipObj.style.width = '';
|
135
|
+
}
|
136
|
+
|
137
|
+
|
138
|
+
|
139
|
+
|
140
|
+
if (RGraph.SVG.REG.get('tooltip-lasty')) {
|
141
|
+
tooltipObj.style.left = RGraph.SVG.REG.get('tooltip-lastx') + 'px';
|
142
|
+
tooltipObj.style.top = RGraph.SVG.REG.get('tooltip-lasty') + 'px';
|
143
|
+
}
|
144
|
+
|
145
|
+
|
146
|
+
|
147
|
+
|
148
|
+
|
149
|
+
|
150
|
+
|
151
|
+
|
152
|
+
|
153
|
+
|
154
|
+
|
155
|
+
|
156
|
+
|
157
|
+
|
158
|
+
|
159
|
+
|
160
|
+
|
161
|
+
|
162
|
+
|
163
|
+
|
164
|
+
|
165
|
+
|
166
|
+
|
167
|
+
|
168
|
+
|
169
|
+
|
170
|
+
|
171
|
+
|
172
|
+
|
173
|
+
|
174
|
+
|
175
|
+
|
176
|
+
|
177
|
+
|
178
|
+
|
179
|
+
|
180
|
+
///////////////////////////////////////
|
181
|
+
// Do tooltip text substitution here //
|
182
|
+
///////////////////////////////////////
|
183
|
+
function substitute (original)
|
184
|
+
{
|
185
|
+
// Ensure that it's a string first
|
186
|
+
original = String(original);
|
187
|
+
|
188
|
+
if (typeof opt.object.tooltipSubstitutions !== 'function') {
|
189
|
+
return original;
|
190
|
+
}
|
191
|
+
|
192
|
+
// Get hold of the indexes from the sequentialIndex that we have.
|
193
|
+
//
|
194
|
+
if (typeof opt.object.tooltipSubstitutions === 'function') {
|
195
|
+
var specific = opt.object.tooltipSubstitutions({
|
196
|
+
index: opt.sequentialIndex
|
197
|
+
});
|
198
|
+
}
|
199
|
+
|
200
|
+
|
201
|
+
// This allows for escaping the percent
|
202
|
+
var text = original.replace(/%%/g, '___--PERCENT--___')
|
203
|
+
|
204
|
+
|
205
|
+
//
|
206
|
+
// Draws the key in the tooltip
|
207
|
+
//
|
208
|
+
|
209
|
+
var keyReplacementFunction = function ()
|
210
|
+
{
|
211
|
+
if (!specific.values) {
|
212
|
+
return;
|
213
|
+
}
|
214
|
+
|
215
|
+
//
|
216
|
+
// Allow the user to specify the key colors
|
217
|
+
//
|
218
|
+
var colors = properties.tooltipsFormattedKeyColors ? properties.tooltipsFormattedKeyColors : properties.colors;
|
219
|
+
|
220
|
+
// Build up the HTML table that becomes the key
|
221
|
+
for (var i=0,str=[]; i<specific.values.length; ++i) {
|
222
|
+
|
223
|
+
var value = (typeof specific.values === 'object' && typeof specific.values[i] === 'number') ? specific.values[i] : 0;
|
224
|
+
var color = colors[i];
|
225
|
+
var label = ( (typeof properties.tooltipsFormattedKeyLabels === 'object' && typeof properties.tooltipsFormattedKeyLabels[i] === 'string') ? properties.tooltipsFormattedKeyLabels[i] : '');
|
226
|
+
|
227
|
+
|
228
|
+
|
229
|
+
// Chart specific customisations -------------------------
|
230
|
+
if (typeof opt.object.tooltipsFormattedCustom === 'function') {
|
231
|
+
|
232
|
+
// The index/group/sequential index
|
233
|
+
// The index
|
234
|
+
// The colors
|
235
|
+
var ret = opt.object.tooltipsFormattedCustom(
|
236
|
+
specific,
|
237
|
+
i,
|
238
|
+
colors
|
239
|
+
);
|
240
|
+
|
241
|
+
if (ret.continue) {continue;};
|
242
|
+
|
243
|
+
if (typeof ret.label === 'string') {label = ret.label;};
|
244
|
+
if (ret.color) {color = ret.color;};
|
245
|
+
if (typeof ret.value === 'number') {value = ret.value;};
|
246
|
+
}
|
247
|
+
|
248
|
+
|
249
|
+
|
250
|
+
|
251
|
+
|
252
|
+
|
253
|
+
|
254
|
+
|
255
|
+
value = RGraph.SVG.numberFormat({
|
256
|
+
object: opt.object,
|
257
|
+
num: value.toFixed(opt.object.properties.tooltipsFormattedDecimals),
|
258
|
+
thousand: opt.object.properties.tooltipsFormattedThousand || ',',
|
259
|
+
point: opt.object.properties.tooltipsFormattedPoint || '.',
|
260
|
+
prepend: opt.object.properties.tooltipsFormattedUnitsPre || '',
|
261
|
+
append: opt.object.properties.tooltipsFormattedUnitsPost || ''
|
262
|
+
});
|
263
|
+
|
264
|
+
// If the tooltipsFormattedKeyColorsShape property is set to circle then add
|
265
|
+
// some border-radius to the DIV tag
|
266
|
+
//
|
267
|
+
var borderRadius = 0;
|
268
|
+
|
269
|
+
if ( typeof opt.object.properties.tooltipsFormattedKeyColorsShape === 'string'
|
270
|
+
&& opt.object.properties.tooltipsFormattedKeyColorsShape === 'circle') {
|
271
|
+
|
272
|
+
borderRadius = '100px';
|
273
|
+
}
|
274
|
+
|
275
|
+
// Facilitate the property that allows CSS to be added to
|
276
|
+
// the tooltip key color blob
|
277
|
+
var tooltipsFormattedKeyColorsCss = '';
|
278
|
+
if (properties.tooltipsFormattedKeyColorsCss) {
|
279
|
+
for(property in properties.tooltipsFormattedKeyColorsCss) {
|
280
|
+
if (typeof property === 'string') {
|
281
|
+
tooltipsFormattedKeyColorsCss += '{1}: {2};'.format(property.replace(/[A-Z]/, function (match)
|
282
|
+
{
|
283
|
+
return '-' + match.toLowerCase();
|
284
|
+
}), String(properties.tooltipsFormattedKeyColorsCss[property]));
|
285
|
+
}
|
286
|
+
}
|
287
|
+
}
|
288
|
+
|
289
|
+
str[i] = '<tr><td><div class="RGraph_tooltipsFormattedKeyColor" id="RGraph_tooltipsFormattedKeyColor_' + i + '" '
|
290
|
+
+ '>Ml</div></td><td>'
|
291
|
+
+ '<span id="RGraph_tooltipsFormattedKeyLabel_' + i + '">' + label + '</span>'
|
292
|
+
+ ' ' + value + '</td></tr>';
|
293
|
+
|
294
|
+
// Now that styles can't be applied inline
|
295
|
+
// (due to the CSP header) then apply them with
|
296
|
+
// JavaScript after a small delay.
|
297
|
+
(function (index, color, borderRadius)
|
298
|
+
{
|
299
|
+
setTimeout(function ()
|
300
|
+
{
|
301
|
+
// Align the label left
|
302
|
+
var node = document.getElementById('RGraph_tooltipsFormattedKeyLabel_' + index);
|
303
|
+
if (node) {
|
304
|
+
node.style.textAlign = 'left'
|
305
|
+
}
|
306
|
+
|
307
|
+
// Add some styles to the color blob
|
308
|
+
var colorBlob = document.getElementById('RGraph_tooltipsFormattedKeyColor_' + index);
|
309
|
+
|
310
|
+
if (colorBlob) {
|
311
|
+
colorBlob.style.textAlign = 'left';
|
312
|
+
colorBlob.style.backgroundColor = color;
|
313
|
+
colorBlob.style.color = 'transparent';
|
314
|
+
colorBlob.style.pointerEvents = 'none';
|
315
|
+
colorBlob.style.borderRadius = borderRadius;
|
316
|
+
|
317
|
+
// Add user specified styles from the
|
318
|
+
// tooltipsFormattedKeyColorsCss property
|
319
|
+
for (var property in tooltipsFormattedKeyColorsCss) {
|
320
|
+
if (typeof property === 'string') {
|
321
|
+
colorBlob.style[property] = tooltipsFormattedKeyColorsCss[property];
|
322
|
+
}
|
323
|
+
}
|
324
|
+
}
|
325
|
+
|
326
|
+
// Set the default color for the table to inherit
|
327
|
+
var node = document.getElementById('RGraph_tooltipsFormattedKey_table')
|
328
|
+
if (node) {
|
329
|
+
node.style.color = 'inherit';
|
330
|
+
}
|
331
|
+
|
332
|
+
}, 1);
|
333
|
+
})(i, color, borderRadius);
|
334
|
+
}
|
335
|
+
str = str.join('');
|
336
|
+
|
337
|
+
// Add the key to the tooltip text - replacing the placeholder
|
338
|
+
text = text.replace('%{key}', '<table id="RGraph_tooltipsFormattedKey_table">' + str + '</table>');
|
339
|
+
};
|
340
|
+
|
341
|
+
keyReplacementFunction();
|
342
|
+
|
343
|
+
|
344
|
+
|
345
|
+
|
346
|
+
|
347
|
+
|
348
|
+
|
349
|
+
|
350
|
+
|
351
|
+
|
352
|
+
|
353
|
+
|
354
|
+
|
355
|
+
// Replace the index of the tooltip
|
356
|
+
text = text.replace(/%{index}/g, specific.index);
|
357
|
+
|
358
|
+
// Replace the dataset/group of the tooltip
|
359
|
+
text = text.replace(/%{dataset2}/g, specific.dataset2); // Used by the Bipolar
|
360
|
+
text = text.replace(/%{dataset}/g, specific.dataset);
|
361
|
+
text = text.replace(/%{group2}/g, specific.dataset2); // Used by the Bipolar
|
362
|
+
text = text.replace(/%{group}/g, specific.dataset);
|
363
|
+
|
364
|
+
// Replace the sequentialIndex of the tooltip
|
365
|
+
text = text.replace(/%{sequential_index}/g, specific.sequentialIndex);
|
366
|
+
text = text.replace(/%{seq}/g, specific.sequentialIndex);
|
367
|
+
|
368
|
+
|
369
|
+
|
370
|
+
|
371
|
+
|
372
|
+
|
373
|
+
|
374
|
+
|
375
|
+
|
376
|
+
|
377
|
+
|
378
|
+
|
379
|
+
|
380
|
+
|
381
|
+
|
382
|
+
|
383
|
+
//Do %{list} sunstitution
|
384
|
+
if (text.indexOf('%{list}') !== -1) {
|
385
|
+
(function ()
|
386
|
+
{
|
387
|
+
if (properties.tooltipsFormattedListType === 'unordered') properties.tooltipsFormattedListType = 'ul';
|
388
|
+
if (properties.tooltipsFormattedListType === '<ul>') properties.tooltipsFormattedListType = 'ul';
|
389
|
+
if (properties.tooltipsFormattedListType === 'ordered') properties.tooltipsFormattedListType = 'ol';
|
390
|
+
if (properties.tooltipsFormattedListType === '<ol>') properties.tooltipsFormattedListType = 'ol';
|
391
|
+
|
392
|
+
var str = properties.tooltipsFormattedListType === 'ol' ? '<ol id="rgraph_formatted_tooltips_list">' : '<ul id="rgraph_formatted_tooltips_list">';
|
393
|
+
var items = properties.tooltipsFormattedListItems[specific.sequentialIndex];
|
394
|
+
|
395
|
+
if (items && items.length) {
|
396
|
+
for (var i=0; i<items.length; ++i) {
|
397
|
+
str += '<li>' + items[i] + '</li>';
|
398
|
+
}
|
399
|
+
}
|
400
|
+
|
401
|
+
str += properties.tooltipsFormattedListType === 'ol' ? '</ol>' : '</ul>';
|
402
|
+
|
403
|
+
// Add the list to the tooltip
|
404
|
+
text = text.replace(/%{list}/, str);
|
405
|
+
|
406
|
+
})();
|
407
|
+
}
|
408
|
+
|
409
|
+
|
410
|
+
|
411
|
+
|
412
|
+
|
413
|
+
|
414
|
+
|
415
|
+
|
416
|
+
|
417
|
+
|
418
|
+
|
419
|
+
|
420
|
+
// Do table substitution (ie %{table} )
|
421
|
+
if (text.indexOf('%{table}') !== -1) {
|
422
|
+
(function ()
|
423
|
+
{
|
424
|
+
var str = '<table>';
|
425
|
+
|
426
|
+
// Add the headers if they're defined
|
427
|
+
if (properties.tooltipsFormattedTableHeaders && properties.tooltipsFormattedTableHeaders.length) {
|
428
|
+
str += '<thead><tr>';
|
429
|
+
for (var i=0; i<properties.tooltipsFormattedTableHeaders.length; ++i) {
|
430
|
+
str += '<th>' + properties.tooltipsFormattedTableHeaders[i] + '</th>';
|
431
|
+
}
|
432
|
+
str += '</tr></thead>';
|
433
|
+
}
|
434
|
+
|
435
|
+
|
436
|
+
|
437
|
+
|
438
|
+
|
439
|
+
// Add each row of data
|
440
|
+
if (typeof properties.tooltipsFormattedTableData === 'object' && !RGraph.SVG.isNull(properties.tooltipsFormattedTableData)) {
|
441
|
+
str += '<tbody>';
|
442
|
+
for (var i=0; i<properties.tooltipsFormattedTableData[specific.sequentialIndex].length; ++i) {
|
443
|
+
str += '<tr>';
|
444
|
+
for (var j=0; j<properties.tooltipsFormattedTableData[specific.sequentialIndex][i].length; ++j) {
|
445
|
+
str += '<td>' + String(properties.tooltipsFormattedTableData[specific.sequentialIndex][i][j]) + '</td>';
|
446
|
+
}
|
447
|
+
str += '</tr>';
|
448
|
+
}
|
449
|
+
|
450
|
+
str += '</tbody>';
|
451
|
+
}
|
452
|
+
|
453
|
+
// Close the table
|
454
|
+
str += '</table>';
|
455
|
+
|
456
|
+
text = text.replace(/%{table}/g, str);
|
457
|
+
})();
|
458
|
+
}
|
459
|
+
|
460
|
+
|
461
|
+
|
462
|
+
|
463
|
+
|
464
|
+
|
465
|
+
|
466
|
+
|
467
|
+
|
468
|
+
|
469
|
+
|
470
|
+
|
471
|
+
|
472
|
+
// Do property substitution when there's an index to
|
473
|
+
// the property
|
474
|
+
var reg = /%{pr?o?p?(?:erty)?:([_a-z0-9]+)\[([0-9]+)\]}/i;
|
475
|
+
|
476
|
+
while (text.match(reg)) {
|
477
|
+
|
478
|
+
var property = RegExp.$1;
|
479
|
+
var index = parseInt(RegExp.$2);
|
480
|
+
|
481
|
+
if (opt.object.properties[property]) {
|
482
|
+
text = text.replace(
|
483
|
+
reg,
|
484
|
+
opt.object.properties[property][index] || ''
|
485
|
+
);
|
486
|
+
|
487
|
+
// Get rid of the text
|
488
|
+
} else {
|
489
|
+
text = text.replace(reg,'');
|
490
|
+
}
|
491
|
+
|
492
|
+
RegExp.lastIndex = null;
|
493
|
+
}
|
494
|
+
|
495
|
+
|
496
|
+
|
497
|
+
|
498
|
+
// Third, replace this: %{property:xxx} (but there's no index to the property)
|
499
|
+
while (text.match(/%{property:([_a-z0-9]+)}/i)) {
|
500
|
+
var str = '%{property:' + RegExp.$1 + '}';
|
501
|
+
text = text.replace(str, opt.object.properties[RegExp.$1]);
|
502
|
+
}
|
503
|
+
|
504
|
+
|
505
|
+
|
506
|
+
|
507
|
+
// Fourth, replace this: %%prop:xxx%%
|
508
|
+
while (text.match(/%{prop:([_a-z0-9]+)}/i)) {
|
509
|
+
var str = '%{prop:' + RegExp.$1 + '}';
|
510
|
+
text = text.replace(str, opt.object.properties[RegExp.$1]);
|
511
|
+
}
|
512
|
+
|
513
|
+
|
514
|
+
|
515
|
+
|
516
|
+
// Fourth, replace this: %%p:xxx%%
|
517
|
+
while (text.match(/%{p:([_a-z0-9]+)}/i)) {
|
518
|
+
var str = '%{p:' + RegExp.$1 + '}';
|
519
|
+
text = text.replace(str, opt.object.properties[RegExp.$1]);
|
520
|
+
}
|
521
|
+
|
522
|
+
|
523
|
+
|
524
|
+
|
525
|
+
// THIS IS ONLY FOR A NON-EQUI-ANGULAR ROSE CHART
|
526
|
+
//
|
527
|
+
// Replace this: %{value2}
|
528
|
+
if (opt.object.type === 'rose' && opt.object.properties.variant === 'non-equi-angular') {
|
529
|
+
while (text.match(/%{value2}/i)) {
|
530
|
+
text = text.replace('%{value2}', specific.value2);
|
531
|
+
}
|
532
|
+
}
|
533
|
+
|
534
|
+
|
535
|
+
|
536
|
+
|
537
|
+
// Fifth and sixth, replace this: %{value} and this: %{value_formatted}
|
538
|
+
while (text.match(/%{value(?:_formatted)?}/i)) {
|
539
|
+
|
540
|
+
var value = specific.value;
|
541
|
+
|
542
|
+
//
|
543
|
+
// Special case for the Waterfall chart and mid totals
|
544
|
+
//
|
545
|
+
if (opt.object.type === 'waterfall' && specific.index != opt.object.data.length - 1 && RGraph.SVG.isNull(value)) {
|
546
|
+
|
547
|
+
for (var i=0,tot=0; i<specific.index; ++i) {
|
548
|
+
tot += opt.object.data[i];
|
549
|
+
}
|
550
|
+
value = tot;
|
551
|
+
}
|
552
|
+
|
553
|
+
if (text.match(/%{value_formatted}/i)) {
|
554
|
+
text = text.replace(
|
555
|
+
'%{value_formatted}',
|
556
|
+
typeof value === 'number' ? RGraph.SVG.numberFormat({
|
557
|
+
object: opt.object,
|
558
|
+
num: value.toFixed(opt.object.properties.tooltipsFormattedDecimals),
|
559
|
+
thousand: opt.object.properties.tooltipsFormattedThousand || ',',
|
560
|
+
point: opt.object.properties.tooltipsFormattedPoint || '.',
|
561
|
+
prepend: opt.object.properties.tooltipsFormattedUnitsPre || '',
|
562
|
+
append: opt.object.properties.tooltipsFormattedUnitsPost || ''
|
563
|
+
}) : null
|
564
|
+
);
|
565
|
+
} else {
|
566
|
+
text = text.replace('%{value}', value);
|
567
|
+
}
|
568
|
+
}
|
569
|
+
|
570
|
+
|
571
|
+
|
572
|
+
|
573
|
+
|
574
|
+
|
575
|
+
|
576
|
+
|
577
|
+
|
578
|
+
|
579
|
+
|
580
|
+
|
581
|
+
|
582
|
+
|
583
|
+
|
584
|
+
|
585
|
+
////////////////////////////////////////////////////////////////
|
586
|
+
// Do global substitution when there's an index to the global //
|
587
|
+
////////////////////////////////////////////////////////////////
|
588
|
+
var reg = /%{global:([_a-z0-9.]+)\[([0-9]+)\]}/i;
|
589
|
+
|
590
|
+
while (text.match(reg)) {
|
591
|
+
|
592
|
+
var name = RegExp.$1,
|
593
|
+
index = parseInt(RegExp.$2);
|
594
|
+
|
595
|
+
if (eval(name)) {
|
596
|
+
text = text.replace(
|
597
|
+
reg,
|
598
|
+
eval(name)[index] || ''
|
599
|
+
);
|
600
|
+
|
601
|
+
// Get rid of the text if there was nothing to replace the template bit with
|
602
|
+
} else {
|
603
|
+
text = text.replace(reg,'');
|
604
|
+
}
|
605
|
+
|
606
|
+
RegExp.lastIndex = null;
|
607
|
+
}
|
608
|
+
|
609
|
+
|
610
|
+
|
611
|
+
|
612
|
+
|
613
|
+
|
614
|
+
|
615
|
+
|
616
|
+
|
617
|
+
|
618
|
+
|
619
|
+
|
620
|
+
|
621
|
+
|
622
|
+
|
623
|
+
|
624
|
+
//////////////////////////////////////////////////
|
625
|
+
// Do global substitution when there's no index //
|
626
|
+
//////////////////////////////////////////////////
|
627
|
+
var reg = /%{global:([_a-z0-9.]+)}/i;
|
628
|
+
|
629
|
+
while (text.match(reg)) {
|
630
|
+
|
631
|
+
var name = RegExp.$1;
|
632
|
+
|
633
|
+
if (eval(name)) {
|
634
|
+
text = text.replace(
|
635
|
+
reg,
|
636
|
+
eval(name) || ''
|
637
|
+
);
|
638
|
+
|
639
|
+
// Get rid of the text if there was nothing to replace the template bit with
|
640
|
+
} else {
|
641
|
+
text = text.replace(reg,'');
|
642
|
+
}
|
643
|
+
|
644
|
+
RegExp.lastIndex = null;
|
645
|
+
}
|
646
|
+
|
647
|
+
|
648
|
+
|
649
|
+
|
650
|
+
|
651
|
+
|
652
|
+
|
653
|
+
|
654
|
+
|
655
|
+
|
656
|
+
|
657
|
+
|
658
|
+
|
659
|
+
|
660
|
+
|
661
|
+
|
662
|
+
// And lastly - call any functions
|
663
|
+
// MUST be last
|
664
|
+
var regexp = /%{function:([_A-Za-z0-9]+)\((.*?)\)}/;
|
665
|
+
|
666
|
+
// Temporarily replace carriage returns and line feeds with CR and LF
|
667
|
+
// so the the s option is not needed
|
668
|
+
text = text.replace(/\r/,'|CR|');
|
669
|
+
text = text.replace(/\n/,'|LF|');
|
670
|
+
|
671
|
+
while (text.match(regexp)) {
|
672
|
+
|
673
|
+
var str = RegExp.$1 + '(' + RegExp.$2 + ')';
|
674
|
+
|
675
|
+
for (var i=0,len=str.length; i<len; ++i) {
|
676
|
+
str = str.replace(/\r?\n/, "\\n");
|
677
|
+
}
|
678
|
+
|
679
|
+
RGraph.SVG.REG.set('tooltip-templates-function-object', opt.object);
|
680
|
+
|
681
|
+
var func = new Function ('return ' + str);
|
682
|
+
var ret = func();
|
683
|
+
|
684
|
+
text = text.replace(regexp, ret)
|
685
|
+
}
|
686
|
+
|
687
|
+
|
688
|
+
|
689
|
+
|
690
|
+
|
691
|
+
|
692
|
+
|
693
|
+
|
694
|
+
|
695
|
+
|
696
|
+
// Do color blob replacement
|
697
|
+
text = text.replace(/%{color\:([^}]+)}/g, '<div style="display: inline-block; background-color: $1; scale: 0.9;color: transparent">Mj</div>');
|
698
|
+
|
699
|
+
|
700
|
+
|
701
|
+
|
702
|
+
|
703
|
+
|
704
|
+
|
705
|
+
|
706
|
+
|
707
|
+
|
708
|
+
|
709
|
+
|
710
|
+
// Replace CR and LF with a space
|
711
|
+
text = text.replace(/\|CR\|/, ' ');
|
712
|
+
text = text.replace(/\|LF\|/, ' ');
|
713
|
+
|
714
|
+
|
715
|
+
|
716
|
+
|
717
|
+
|
718
|
+
|
719
|
+
|
720
|
+
|
721
|
+
// Replace line returns with br tags
|
722
|
+
text = text.replace(/\r?\n/g, '<br />');
|
723
|
+
text = text.replace(/___--PERCENT--___/g, '%')
|
724
|
+
|
725
|
+
|
726
|
+
return text.toString();
|
727
|
+
}
|
728
|
+
|
729
|
+
// Save the original text on the tooltip
|
730
|
+
tooltipObj.__original_text__ = opt.text;
|
731
|
+
|
732
|
+
opt.text = substitute(opt.text);
|
733
|
+
|
734
|
+
|
735
|
+
// Add the pointer if requested. The background color is updated to match the
|
736
|
+
// tooltip a further down.
|
737
|
+
if (opt.object.properties.tooltipsPointer) {
|
738
|
+
opt.text += '<div id="RGraph_tooltipsPointer"></div>';
|
739
|
+
}
|
740
|
+
|
741
|
+
|
742
|
+
|
743
|
+
|
744
|
+
|
745
|
+
|
746
|
+
|
747
|
+
|
748
|
+
|
749
|
+
|
750
|
+
|
751
|
+
|
752
|
+
|
753
|
+
|
754
|
+
|
755
|
+
|
756
|
+
|
757
|
+
|
758
|
+
|
759
|
+
tooltipObj.innerHTML = opt.text;
|
760
|
+
tooltipObj.__text__ = opt.text; // This is set because the innerHTML can change when it's set
|
761
|
+
tooltipObj.id = '__rgraph_tooltip_' + obj.id + '_' + obj.uid + '_'+ opt.index;
|
762
|
+
tooltipObj.__event__ = properties.tooltipsEvent || 'click';
|
763
|
+
tooltipObj.__object__ = obj;
|
764
|
+
|
765
|
+
|
766
|
+
|
767
|
+
|
768
|
+
|
769
|
+
|
770
|
+
|
771
|
+
|
772
|
+
|
773
|
+
|
774
|
+
|
775
|
+
|
776
|
+
// Add the index
|
777
|
+
if (typeof opt.index === 'number') {
|
778
|
+
tooltipObj.__index__ = opt.index;
|
779
|
+
}
|
780
|
+
|
781
|
+
// Add the dataset
|
782
|
+
if (typeof opt.dataset === 'number') {
|
783
|
+
tooltipObj.__dataset__ = opt.dataset;
|
784
|
+
}
|
785
|
+
|
786
|
+
// Add the group
|
787
|
+
if (typeof opt.group === 'number' || RGraph.SVG.isNull(opt.group)) {
|
788
|
+
tooltipObj.__group__ = opt.group;
|
789
|
+
}
|
790
|
+
|
791
|
+
// Add the sequentialIndex
|
792
|
+
if (typeof opt.sequentialIndex === 'number') {
|
793
|
+
tooltipObj.__sequentialIndex__ = opt.sequentialIndex;
|
794
|
+
}
|
795
|
+
|
796
|
+
|
797
|
+
|
798
|
+
|
799
|
+
// Add the tooltip to the document
|
800
|
+
document.body.appendChild(tooltipObj);
|
801
|
+
|
802
|
+
|
803
|
+
|
804
|
+
|
805
|
+
|
806
|
+
|
807
|
+
|
808
|
+
|
809
|
+
|
810
|
+
// Set styles on the pointer. It's done this way
|
811
|
+
// (not adding the style to the HTML above) to
|
812
|
+
// prevent an error bein thrown should a
|
813
|
+
// Content-Security-Policy header using style-src
|
814
|
+
// be in place
|
815
|
+
var pointerObj = document.getElementById('RGraph_tooltipsPointer');
|
816
|
+
if (pointerObj) {
|
817
|
+
var styles = window.getComputedStyle(tooltipObj, false);
|
818
|
+
|
819
|
+
pointerObj.style.backgroundColor = styles.backgroundColor;
|
820
|
+
pointerObj.style.color = 'transparent';
|
821
|
+
pointerObj.style.position = 'absolute';
|
822
|
+
pointerObj.style.bottom = -5 + (RGraph.SVG.isNumber(obj.properties.tooltipsPointerOffsety) ? obj.properties.tooltipsPointerOffsety : 0) + 'px';
|
823
|
+
pointerObj.style.left = 'calc(50% + ' + (RGraph.SVG.isNumber(obj.properties.tooltipsPointerOffsetx) ? obj.properties.tooltipsPointerOffsetx : 0) + 'px)';
|
824
|
+
pointerObj.style.transform = 'translateX(-50%) rotate(45deg)';
|
825
|
+
pointerObj.style.width = '10px';
|
826
|
+
pointerObj.style.height = '10px';
|
827
|
+
}
|
828
|
+
|
829
|
+
var width = tooltipObj.offsetWidth,
|
830
|
+
height = tooltipObj.offsetHeight;
|
831
|
+
|
832
|
+
|
833
|
+
|
834
|
+
// Set these properties to 0 (ie an integer) in case chart libraries are missing
|
835
|
+
// default values for them
|
836
|
+
obj.properties.tooltipsOffsetx = obj.properties.tooltipsOffsetx || 0;
|
837
|
+
obj.properties.tooltipsOffsety = obj.properties.tooltipsOffsety || 0;
|
838
|
+
|
839
|
+
// Move the tooltip into position
|
840
|
+
tooltipObj.style.left = opt.event.pageX - (width / 2) + obj.properties.tooltipsOffsetx + 'px';
|
841
|
+
|
842
|
+
// Prevent the top of the tooltip from being placed off the top of the page
|
843
|
+
var y = opt.event.pageY - height - 15;
|
844
|
+
|
845
|
+
if (y < 0) {
|
846
|
+
y = 5;
|
847
|
+
}
|
848
|
+
|
849
|
+
tooltipObj.style.top = y + obj.properties.tooltipsOffsety + 'px';
|
850
|
+
|
851
|
+
|
852
|
+
|
853
|
+
|
854
|
+
//
|
855
|
+
// Set the width on the tooltip so it doesn't resize if the window is resized
|
856
|
+
//
|
857
|
+
tooltipObj.style.width = width + 'px';
|
858
|
+
|
859
|
+
|
860
|
+
//
|
861
|
+
// Now that the tooltip pointer has been added, determine the background-color and update
|
862
|
+
// the color of the pointer
|
863
|
+
if (opt.object.properties.tooltipsPointer) {
|
864
|
+
|
865
|
+
var styles = window.getComputedStyle(tooltipObj, false);
|
866
|
+
var pointer = document.getElementById('RGraph_tooltipsPointer');
|
867
|
+
|
868
|
+
pointer.style.backgroundColor = styles.backgroundColor;
|
869
|
+
|
870
|
+
// Add the pointer to the tooltip as a property
|
871
|
+
tooltipObj.__pointer__ = pointer;
|
872
|
+
|
873
|
+
// Facilitate the property that allows CSS to be added to
|
874
|
+
// the tooltip key color blob
|
875
|
+
var tooltipsPointerCss = '';
|
876
|
+
|
877
|
+
if (opt.object.properties.tooltipsPointerCss) {
|
878
|
+
|
879
|
+
var pointerDiv = document.getElementById('RGraph_tooltipsPointer');
|
880
|
+
|
881
|
+
for(property in opt.object.properties.tooltipsPointerCss) {
|
882
|
+
if (typeof property === 'string') {
|
883
|
+
pointerDiv.style[property] = opt.object.properties.tooltipsPointerCss[property];
|
884
|
+
}
|
885
|
+
}
|
886
|
+
}
|
887
|
+
}
|
888
|
+
|
889
|
+
// Fade the tooltip in if the tooltip is the first view
|
890
|
+
//if (!RGraph.SVG.REG.get('tooltip-lastx')) {
|
891
|
+
// for (var i=0; i<=30; ++i) {
|
892
|
+
// (function (idx)
|
893
|
+
// {
|
894
|
+
// setTimeout(function ()
|
895
|
+
// {
|
896
|
+
// tooltipObj.style.opacity = (idx / 30) * 1;
|
897
|
+
// }, (idx / 30) * 200);
|
898
|
+
// })(i);
|
899
|
+
// }
|
900
|
+
//}
|
901
|
+
|
902
|
+
|
903
|
+
|
904
|
+
|
905
|
+
// If the left is less than zero - set it to 5
|
906
|
+
if (parseFloat(tooltipObj.style.left) <= 5) {
|
907
|
+
tooltipObj.style.left = 5 + obj.properties.tooltipsOffsetx + 'px';
|
908
|
+
}
|
909
|
+
|
910
|
+
// If the tooltip goes over the right hand edge then
|
911
|
+
// adjust the positioning
|
912
|
+
if (parseFloat(tooltipObj.style.left) + parseFloat(tooltipObj.style.width) > window.innerWidth) {
|
913
|
+
tooltipObj.style.left = ''
|
914
|
+
tooltipObj.style.right = 5 + obj.properties.tooltipsOffsety + 'px'
|
915
|
+
}
|
916
|
+
|
917
|
+
|
918
|
+
|
919
|
+
|
920
|
+
|
921
|
+
|
922
|
+
|
923
|
+
|
924
|
+
|
925
|
+
|
926
|
+
|
927
|
+
|
928
|
+
//
|
929
|
+
// Allow for static positioning.
|
930
|
+
//
|
931
|
+
if (opt.object.properties.tooltipsPositionStatic && RGraph.SVG.isFunction(opt.object.positionTooltipStatic)) {
|
932
|
+
|
933
|
+
opt.object.positionTooltipStatic({
|
934
|
+
object: opt.object,
|
935
|
+
event: opt.event,
|
936
|
+
tooltip: tooltipObj,
|
937
|
+
index: tooltipObj.__sequentialIndex__
|
938
|
+
});
|
939
|
+
|
940
|
+
// Allow for offsetting the position
|
941
|
+
tooltipObj.style.left = parseFloat(tooltipObj.style.left) + obj.properties.tooltipsOffsetx + 'px';
|
942
|
+
tooltipObj.style.top = parseFloat(tooltipObj.style.top) + obj.properties.tooltipsOffsety + 'px';
|
943
|
+
}
|
944
|
+
|
945
|
+
|
946
|
+
|
947
|
+
|
948
|
+
|
949
|
+
|
950
|
+
|
951
|
+
|
952
|
+
|
953
|
+
|
954
|
+
|
955
|
+
|
956
|
+
|
957
|
+
|
958
|
+
|
959
|
+
|
960
|
+
|
961
|
+
|
962
|
+
|
963
|
+
//
|
964
|
+
// Move the tooltip and its pointer ifthey're off-screen LHS
|
965
|
+
//
|
966
|
+
if (parseInt(tooltipObj.style.left) < 0) {
|
967
|
+
var left = parseInt(tooltipObj.style.left);
|
968
|
+
var width = parseInt(tooltipObj.style.width)
|
969
|
+
|
970
|
+
left = left + (width * 0.1 * 4);
|
971
|
+
|
972
|
+
tooltipObj.style.left = left + 'px';
|
973
|
+
var pointer = document.getElementById('RGraph_tooltipsPointer');
|
974
|
+
|
975
|
+
if (pointer) {
|
976
|
+
(function (pointer)
|
977
|
+
{
|
978
|
+
setTimeout(function ()
|
979
|
+
{
|
980
|
+
pointer.style.left = 'calc(10% + 5px)';
|
981
|
+
}, 1);
|
982
|
+
})(pointer);
|
983
|
+
}
|
984
|
+
|
985
|
+
|
986
|
+
//
|
987
|
+
// Move the tooltip and its pointer ifthey're off-screen RHS
|
988
|
+
//
|
989
|
+
} else if ( (parseInt(tooltipObj.style.left) + parseInt(tooltipObj.offsetWidth)) > document.body.offsetWidth) {
|
990
|
+
var left = parseInt(tooltipObj.style.left);
|
991
|
+
var width = parseInt(tooltipObj.style.width)
|
992
|
+
|
993
|
+
left = left - (width * 0.1 * 4);
|
994
|
+
|
995
|
+
tooltipObj.style.left = left + 'px';
|
996
|
+
var pointer = document.getElementById('RGraph_tooltipsPointer');
|
997
|
+
|
998
|
+
(function (pointer)
|
999
|
+
{
|
1000
|
+
setTimeout(function ()
|
1001
|
+
{
|
1002
|
+
if (pointer) {
|
1003
|
+
pointer.style.left = 'calc(90% - 5px)';
|
1004
|
+
}
|
1005
|
+
}, 1);
|
1006
|
+
})(pointer);
|
1007
|
+
}
|
1008
|
+
|
1009
|
+
|
1010
|
+
|
1011
|
+
|
1012
|
+
|
1013
|
+
|
1014
|
+
|
1015
|
+
// If the canvas has fixed positioning then set the tooltip position to
|
1016
|
+
// fixed too
|
1017
|
+
if (RGraph.SVG.isFixed(obj.svg)) {
|
1018
|
+
var scrollTop = window.scrollY || document.documentElement.scrollTop;
|
1019
|
+
|
1020
|
+
tooltipObj.style.position = 'fixed';
|
1021
|
+
tooltipObj.style.top = opt.event.pageY - scrollTop - height - 10 + obj.properties.tooltipsOffsety + 'px';
|
1022
|
+
}
|
1023
|
+
|
1024
|
+
|
1025
|
+
|
1026
|
+
// Cancel the mousedown event
|
1027
|
+
tooltipObj.onmousedown = function (e)
|
1028
|
+
{
|
1029
|
+
e.stopPropagation();
|
1030
|
+
};
|
1031
|
+
|
1032
|
+
// Cancel the mouseup event
|
1033
|
+
tooltipObj.onmouseup = function (e)
|
1034
|
+
{
|
1035
|
+
e.stopPropagation();
|
1036
|
+
};
|
1037
|
+
|
1038
|
+
// Cancel the click event
|
1039
|
+
tooltipObj.onclick = function (e)
|
1040
|
+
{
|
1041
|
+
if (e.button == 0) {
|
1042
|
+
e.stopPropagation();
|
1043
|
+
}
|
1044
|
+
};
|
1045
|
+
|
1046
|
+
// Add the body click handler that clears the tooltip
|
1047
|
+
document.body.addEventListener('mouseup', function (e)
|
1048
|
+
{
|
1049
|
+
RGraph.SVG.hideTooltip();
|
1050
|
+
}, false);
|
1051
|
+
|
1052
|
+
|
1053
|
+
|
1054
|
+
|
1055
|
+
|
1056
|
+
//
|
1057
|
+
// Keep a reference to the tooltip in the registry
|
1058
|
+
//
|
1059
|
+
RGraph.SVG.REG.set('tooltip', tooltipObj);
|
1060
|
+
RGraph.SVG.REG.set('tooltip-lastx', parseFloat(tooltipObj.style.left));
|
1061
|
+
RGraph.SVG.REG.set('tooltip-lasty', parseFloat(tooltipObj.style.top));
|
1062
|
+
|
1063
|
+
|
1064
|
+
//
|
1065
|
+
// Fire the tooltip event
|
1066
|
+
//
|
1067
|
+
RGraph.SVG.fireCustomEvent(obj, 'ontooltip');
|
1068
|
+
};
|
1069
|
+
|
1070
|
+
|
1071
|
+
|
1072
|
+
// End module pattern
|
1073
|
+
})(window, document);
|