rgraph-rails 1.0.7 → 1.0.8
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 +4 -4
- data/README.md +3 -3
- data/lib/rgraph-rails/version.rb +1 -1
- data/license.txt +4 -16
- data/vendor/assets/javascripts/RGraph.bar.js +3734 -241
- data/vendor/assets/javascripts/RGraph.bipolar.js +2005 -115
- data/vendor/assets/javascripts/RGraph.common.annotate.js +395 -35
- data/vendor/assets/javascripts/RGraph.common.context.js +595 -30
- data/vendor/assets/javascripts/RGraph.common.core.js +5282 -405
- data/vendor/assets/javascripts/RGraph.common.csv.js +276 -19
- data/vendor/assets/javascripts/RGraph.common.deprecated.js +450 -35
- data/vendor/assets/javascripts/RGraph.common.dynamic.js +1395 -86
- data/vendor/assets/javascripts/RGraph.common.effects.js +1545 -90
- data/vendor/assets/javascripts/RGraph.common.key.js +753 -54
- data/vendor/assets/javascripts/RGraph.common.resizing.js +563 -37
- data/vendor/assets/javascripts/RGraph.common.sheets.js +352 -29
- data/vendor/assets/javascripts/RGraph.common.tooltips.js +450 -32
- data/vendor/assets/javascripts/RGraph.common.zoom.js +219 -14
- data/vendor/assets/javascripts/RGraph.drawing.background.js +570 -35
- data/vendor/assets/javascripts/RGraph.drawing.circle.js +544 -35
- data/vendor/assets/javascripts/RGraph.drawing.image.js +755 -52
- data/vendor/assets/javascripts/RGraph.drawing.marker1.js +645 -41
- data/vendor/assets/javascripts/RGraph.drawing.marker2.js +633 -37
- data/vendor/assets/javascripts/RGraph.drawing.marker3.js +514 -36
- data/vendor/assets/javascripts/RGraph.drawing.poly.js +559 -39
- data/vendor/assets/javascripts/RGraph.drawing.rect.js +548 -35
- data/vendor/assets/javascripts/RGraph.drawing.text.js +664 -36
- data/vendor/assets/javascripts/RGraph.drawing.xaxis.js +812 -50
- data/vendor/assets/javascripts/RGraph.drawing.yaxis.js +856 -51
- data/vendor/assets/javascripts/RGraph.fuel.js +964 -58
- data/vendor/assets/javascripts/RGraph.funnel.js +984 -55
- data/vendor/assets/javascripts/RGraph.gantt.js +1354 -77
- data/vendor/assets/javascripts/RGraph.gauge.js +1421 -87
- data/vendor/assets/javascripts/RGraph.hbar.js +2562 -146
- data/vendor/assets/javascripts/RGraph.hprogress.js +1401 -80
- data/vendor/assets/javascripts/RGraph.line.js +4226 -244
- data/vendor/assets/javascripts/RGraph.meter.js +1280 -74
- data/vendor/assets/javascripts/RGraph.modaldialog.js +301 -19
- data/vendor/assets/javascripts/RGraph.odo.js +1264 -71
- data/vendor/assets/javascripts/RGraph.pie.js +2288 -137
- data/vendor/assets/javascripts/RGraph.radar.js +1847 -110
- data/vendor/assets/javascripts/RGraph.rose.js +1977 -108
- data/vendor/assets/javascripts/RGraph.rscatter.js +1432 -80
- data/vendor/assets/javascripts/RGraph.scatter.js +3036 -168
- data/vendor/assets/javascripts/RGraph.semicircularprogress.js +1120 -60
- data/vendor/assets/javascripts/RGraph.svg.bar.js +1067 -0
- data/vendor/assets/javascripts/RGraph.svg.common.ajax.js +247 -0
- data/vendor/assets/javascripts/RGraph.svg.common.core.js +3363 -0
- data/vendor/assets/javascripts/RGraph.svg.common.csv.js +277 -0
- data/vendor/assets/javascripts/RGraph.svg.common.fx.js +1304 -0
- data/vendor/assets/javascripts/RGraph.svg.common.sheets.js +353 -0
- data/vendor/assets/javascripts/RGraph.svg.common.tooltips.js +233 -0
- data/vendor/assets/javascripts/RGraph.svg.hbar.js +1141 -0
- data/vendor/assets/javascripts/RGraph.svg.line.js +1486 -0
- data/vendor/assets/javascripts/RGraph.svg.pie.js +781 -0
- data/vendor/assets/javascripts/RGraph.svg.radar.js +1326 -0
- data/vendor/assets/javascripts/RGraph.svg.semicircularprogress.js +817 -0
- data/vendor/assets/javascripts/RGraph.thermometer.js +1135 -62
- data/vendor/assets/javascripts/RGraph.vprogress.js +1470 -83
- data/vendor/assets/javascripts/RGraph.waterfall.js +1347 -80
- metadata +15 -3
@@ -0,0 +1,353 @@
|
|
1
|
+
// version: 2017-01-02
|
2
|
+
/**
|
3
|
+
* o--------------------------------------------------------------------------------o
|
4
|
+
* | This file is part of the RGraph package - you can learn more at: |
|
5
|
+
* | |
|
6
|
+
* | http://www.rgraph.net |
|
7
|
+
* | |
|
8
|
+
* | RGraph is licensed under the Open Source MIT license. That means that it's |
|
9
|
+
* | totally free to use! |
|
10
|
+
* o--------------------------------------------------------------------------------o
|
11
|
+
*/
|
12
|
+
|
13
|
+
/**
|
14
|
+
* Initialise the various objects
|
15
|
+
*/
|
16
|
+
RGraph = window.RGraph || {isRGraph: true};
|
17
|
+
|
18
|
+
// Module pattern
|
19
|
+
(function (win, doc, undefined)
|
20
|
+
{
|
21
|
+
RGraph.Sheets = function (key)
|
22
|
+
{
|
23
|
+
var worksheet,
|
24
|
+
callback,
|
25
|
+
letters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ';
|
26
|
+
|
27
|
+
// 3 arguments
|
28
|
+
if (arguments.length === 3) {
|
29
|
+
worksheet = Number(arguments[1]);
|
30
|
+
callback = arguments[2];
|
31
|
+
|
32
|
+
// 2 arguments
|
33
|
+
} else {
|
34
|
+
worksheet = 1;
|
35
|
+
callback = arguments[1];
|
36
|
+
}
|
37
|
+
|
38
|
+
var url = 'https://spreadsheets.google.com/feeds/cells/[KEY]/[WORKSHEET]/public/full?alt=json-in-script&callback=__rgraph_JSONPCallback'.replace(/\[KEY\]/, key).replace(/\[WORKSHEET\]/, worksheet);
|
39
|
+
|
40
|
+
/*
|
41
|
+
* https://spreadsheets.google.com/feeds/cells/1q_BMjvKO_kKbAO3VjoaITSDyrLAk8f0SK5UFMmE3oRs/2/public/full?alt=json-in-script
|
42
|
+
*/
|
43
|
+
|
44
|
+
|
45
|
+
|
46
|
+
|
47
|
+
|
48
|
+
//
|
49
|
+
// Loads the spreadsheet
|
50
|
+
//
|
51
|
+
this.load = function(url, userCallback)
|
52
|
+
{
|
53
|
+
var obj = this;
|
54
|
+
|
55
|
+
// A global on purpose
|
56
|
+
__rgraph_JSONPCallback = function (json)
|
57
|
+
{
|
58
|
+
// Save the JSON on the RGraph.Sheets object
|
59
|
+
obj.json = json;
|
60
|
+
|
61
|
+
//
|
62
|
+
// Put the entries in the JSON feed into a grid
|
63
|
+
//
|
64
|
+
var grid = [], row = 0, col = 0;
|
65
|
+
|
66
|
+
for (var i=0; i<json.feed.entry.length; ++i) {
|
67
|
+
|
68
|
+
row = json.feed.entry[i].gs$cell.row - 1;
|
69
|
+
col = json.feed.entry[i].gs$cell.col - 1;
|
70
|
+
|
71
|
+
if (!grid[row]) {
|
72
|
+
grid[row] = [];
|
73
|
+
}
|
74
|
+
|
75
|
+
grid[row][col] = json.feed.entry[i].content.$t;
|
76
|
+
}
|
77
|
+
|
78
|
+
|
79
|
+
//
|
80
|
+
// Determine the longest row
|
81
|
+
//
|
82
|
+
var maxcols = 0; // The max length of the rows
|
83
|
+
|
84
|
+
for (var i=0; i<grid.length; ++i) {
|
85
|
+
maxcols = grid[i] ? Math.max(maxcols, grid[i].length) : maxcols;
|
86
|
+
}
|
87
|
+
|
88
|
+
|
89
|
+
|
90
|
+
//
|
91
|
+
// Now go through the array and fill in any blank holes.
|
92
|
+
//
|
93
|
+
for (var i=0; i<grid.length; ++i) {
|
94
|
+
|
95
|
+
if (typeof grid[i] === 'undefined') {
|
96
|
+
grid[i] = new Array(maxcols);
|
97
|
+
}
|
98
|
+
|
99
|
+
for (var j=0; j<maxcols; j++) {
|
100
|
+
if (typeof grid[i][j] === 'undefined') {
|
101
|
+
grid[i][j] = '';
|
102
|
+
}
|
103
|
+
|
104
|
+
// Convert numbers to real numbers and floats here too
|
105
|
+
if (grid[i][j].match(/^[0-9]+$/)) {
|
106
|
+
grid[i][j] = parseInt(grid[i][j]);
|
107
|
+
} else if (grid[i][j].match(/^[0-9.]+$/)) {
|
108
|
+
grid[i][j] = parseFloat(grid[i][j]);
|
109
|
+
}
|
110
|
+
}
|
111
|
+
}
|
112
|
+
|
113
|
+
//
|
114
|
+
// Save the grid on the object
|
115
|
+
//
|
116
|
+
obj.data = grid;
|
117
|
+
|
118
|
+
|
119
|
+
|
120
|
+
//
|
121
|
+
// Call the users callback function. Users can access the raw data if
|
122
|
+
// they want with the obj.data property or by using the accessor
|
123
|
+
// methods (better)
|
124
|
+
//
|
125
|
+
userCallback(obj);
|
126
|
+
};
|
127
|
+
|
128
|
+
// Add the new script tag to the document that pulls in the JSON
|
129
|
+
//
|
130
|
+
// With jQuery...
|
131
|
+
//
|
132
|
+
//jQuery('body').append("<script src='" + url + "'></script>");
|
133
|
+
//
|
134
|
+
// And without jQuery...
|
135
|
+
|
136
|
+
var scriptNode = document.createElement('SCRIPT');
|
137
|
+
scriptNode.src = url;
|
138
|
+
document.body.appendChild(scriptNode);
|
139
|
+
};
|
140
|
+
|
141
|
+
|
142
|
+
|
143
|
+
|
144
|
+
//
|
145
|
+
// Fetches a row of data and returns it
|
146
|
+
//
|
147
|
+
// @param id number The numeric index of the column to fetch (starts at 1)
|
148
|
+
// @param start number The index to start fetching/returning at. The first
|
149
|
+
// character is 1
|
150
|
+
// @param opt An option object containing options
|
151
|
+
//
|
152
|
+
this.row = function (index, start)
|
153
|
+
{
|
154
|
+
var opt = {}, row;
|
155
|
+
|
156
|
+
// Default for start is 1
|
157
|
+
start = start || 1;
|
158
|
+
|
159
|
+
//
|
160
|
+
// Parse the .trim argument
|
161
|
+
//
|
162
|
+
|
163
|
+
if (arguments && typeof arguments[2] === 'object' && typeof arguments[2].trim === 'boolean') {
|
164
|
+
opt.trim = arguments[2].trim;
|
165
|
+
} else {
|
166
|
+
opt.trim = true;
|
167
|
+
}
|
168
|
+
|
169
|
+
row = this.data[index - 1].slice(start - 1);
|
170
|
+
|
171
|
+
// Trim the array if required
|
172
|
+
if (opt.trim) {
|
173
|
+
row = RGraph.SVG.arrayTrim(row);
|
174
|
+
}
|
175
|
+
|
176
|
+
return row;
|
177
|
+
};
|
178
|
+
|
179
|
+
|
180
|
+
|
181
|
+
//
|
182
|
+
// Fetches a column of data and returns it
|
183
|
+
//
|
184
|
+
// @param id number The letter that corresponds to the column
|
185
|
+
// @param start number The index to start fetching/returning at. The first
|
186
|
+
// character is 1
|
187
|
+
// @param opt An option object containing options
|
188
|
+
//
|
189
|
+
this.col = function (index, start)
|
190
|
+
{
|
191
|
+
var opt = {},
|
192
|
+
col = [];
|
193
|
+
|
194
|
+
// Default for start is 1
|
195
|
+
start = start || 1;
|
196
|
+
|
197
|
+
if (arguments && typeof arguments[2] === 'object' && typeof arguments[2].trim === 'boolean') {
|
198
|
+
opt.trim = arguments[2].trim;
|
199
|
+
} else {
|
200
|
+
opt.trim = true;
|
201
|
+
}
|
202
|
+
|
203
|
+
for (var i=0; i<this.data.length; ++i) {
|
204
|
+
col.push(this.data[i][index - 1]);
|
205
|
+
}
|
206
|
+
|
207
|
+
// Trim the array if required
|
208
|
+
if (opt.trim) {
|
209
|
+
col = RGraph.SVG.arrayTrim(col);
|
210
|
+
}
|
211
|
+
|
212
|
+
// Now account for the start index
|
213
|
+
|
214
|
+
col = col.slice(start - 1);
|
215
|
+
|
216
|
+
return col;
|
217
|
+
};
|
218
|
+
|
219
|
+
|
220
|
+
|
221
|
+
//
|
222
|
+
// Returns the index (zero index) of the given letters
|
223
|
+
//
|
224
|
+
this.getIndexOfLetters = function (l)
|
225
|
+
{
|
226
|
+
var parts = l.split('');
|
227
|
+
|
228
|
+
if (parts.length === 1) {
|
229
|
+
return letters.indexOf(l) + 1;
|
230
|
+
} else if (parts.length === 2){
|
231
|
+
var idx = ((letters.indexOf(parts[0]) + 1) * 26) + (letters.indexOf(parts[1]) + 1);
|
232
|
+
return idx;
|
233
|
+
}
|
234
|
+
}
|
235
|
+
|
236
|
+
|
237
|
+
|
238
|
+
|
239
|
+
|
240
|
+
//
|
241
|
+
// The get method makes retrieving cells very straightforward,
|
242
|
+
// for example: obj.get('B1');
|
243
|
+
//
|
244
|
+
// @param str string The cells(s) to fetch
|
245
|
+
// @param string Optional set of options that are passed
|
246
|
+
// to the relevant row/col function
|
247
|
+
//
|
248
|
+
this.get = function (str)
|
249
|
+
{
|
250
|
+
// Uppercase letters please!
|
251
|
+
str = str.toUpperCase();
|
252
|
+
|
253
|
+
//
|
254
|
+
// Handle the style of .get('C') or .get('AA'
|
255
|
+
//
|
256
|
+
if (str.match(/^[a-z]+$/i)) {
|
257
|
+
if (str.length === 1) {
|
258
|
+
var index = letters.indexOf(str) + 1;
|
259
|
+
return this.col(index, 1, arguments[1]);
|
260
|
+
|
261
|
+
} else if (str.length === 2) {
|
262
|
+
var index = ((letters.indexOf(str[0]) + 1) * 26) + letters.indexOf(str[1]) + 1;
|
263
|
+
return this.col(index, 1, arguments[1]);
|
264
|
+
}
|
265
|
+
}
|
266
|
+
|
267
|
+
|
268
|
+
|
269
|
+
|
270
|
+
//
|
271
|
+
// Handle the style of .get('2');
|
272
|
+
//(fetching a whole row
|
273
|
+
//
|
274
|
+
if (str.match(/^[0-9]+$/i)) {
|
275
|
+
return this.row(str, null, arguments[1]);
|
276
|
+
}
|
277
|
+
|
278
|
+
|
279
|
+
|
280
|
+
|
281
|
+
//
|
282
|
+
// Handle the style of .get('E2');
|
283
|
+
//(fetching a single cell)
|
284
|
+
//
|
285
|
+
if (str.match(/^([a-z]{1,2})([0-9]+)$/i)) {
|
286
|
+
|
287
|
+
var letter = RegExp.$1,
|
288
|
+
number = RegExp.$2,
|
289
|
+
col = this.get(letter, {trim: false});
|
290
|
+
|
291
|
+
|
292
|
+
return col[number - 1];
|
293
|
+
}
|
294
|
+
|
295
|
+
|
296
|
+
|
297
|
+
|
298
|
+
//
|
299
|
+
// Handle the style of .get('B2:E2');
|
300
|
+
//(fetching the E2 cell to the E2 cell)
|
301
|
+
//
|
302
|
+
if (str.match(/^([a-z]{1,2})([0-9]+):([a-z]{1,2})([0-9]+)$/i)) {
|
303
|
+
|
304
|
+
var letter1 = RegExp.$1,
|
305
|
+
number1 = RegExp.$2,
|
306
|
+
letter2 = RegExp.$3,
|
307
|
+
number2 = RegExp.$4
|
308
|
+
|
309
|
+
|
310
|
+
if (letter1 === letter2) {
|
311
|
+
var cells = [],
|
312
|
+
index = this.getIndexOfLetters(letter1),
|
313
|
+
col = this.col(index, null, {trim: false});
|
314
|
+
|
315
|
+
for (var i=(number1 - 1); i<=(number2 - 1); ++i) {
|
316
|
+
cells.push(col[i]);
|
317
|
+
}
|
318
|
+
|
319
|
+
} else if (number1 === number2) {
|
320
|
+
|
321
|
+
var cells = [],
|
322
|
+
row = this.row(number1, null, {trim: false}),
|
323
|
+
index1 = this.getIndexOfLetters(letter1),
|
324
|
+
index2 = this.getIndexOfLetters(letter2)
|
325
|
+
|
326
|
+
for (var i=(index1 - 1); i<=(index2 - 1); ++i) {
|
327
|
+
cells.push(row[i]);
|
328
|
+
}
|
329
|
+
}
|
330
|
+
|
331
|
+
// Trim the results
|
332
|
+
if (arguments[1] && arguments[1].trim === false) {
|
333
|
+
// Nada
|
334
|
+
} else {
|
335
|
+
cells = RGraph.SVG.arrayTrim(cells);
|
336
|
+
}
|
337
|
+
|
338
|
+
return cells;
|
339
|
+
|
340
|
+
}
|
341
|
+
};
|
342
|
+
|
343
|
+
|
344
|
+
|
345
|
+
|
346
|
+
//
|
347
|
+
// Load the data
|
348
|
+
//
|
349
|
+
this.load(url, callback);
|
350
|
+
};
|
351
|
+
|
352
|
+
// End module pattern
|
353
|
+
})(window, document);
|
@@ -0,0 +1,233 @@
|
|
1
|
+
// version: 2017-01-02
|
2
|
+
/**
|
3
|
+
* o--------------------------------------------------------------------------------o
|
4
|
+
* | This file is part of the RGraph package - you can learn more at: |
|
5
|
+
* | |
|
6
|
+
* | http://www.rgraph.net |
|
7
|
+
* | |
|
8
|
+
* | RGraph is licensed under the Open Source MIT license. That means that it's |
|
9
|
+
* | totally free to use! |
|
10
|
+
* o--------------------------------------------------------------------------------o
|
11
|
+
*/
|
12
|
+
|
13
|
+
RGraph = window.RGraph || {isRGraph: true,isRGraphSVG: true};
|
14
|
+
RGraph.SVG = RGraph.SVG || {};
|
15
|
+
|
16
|
+
// Module pattern
|
17
|
+
(function (win, doc, undefined)
|
18
|
+
{
|
19
|
+
var RG = RGraph,
|
20
|
+
ua = navigator.userAgent,
|
21
|
+
ma = Math;
|
22
|
+
|
23
|
+
|
24
|
+
|
25
|
+
/**
|
26
|
+
* This is used in two functions, hence it's here
|
27
|
+
*/
|
28
|
+
RG.SVG.tooltips = {};
|
29
|
+
RG.SVG.tooltips.style = {
|
30
|
+
display: 'inline-block',
|
31
|
+
position: 'absolute',
|
32
|
+
padding: '6px',
|
33
|
+
fontFamily: 'Arial',
|
34
|
+
fontSize: '12pt',
|
35
|
+
fontWeight: 'normal',
|
36
|
+
textAlign: 'center',
|
37
|
+
left: 0,
|
38
|
+
top: 0,
|
39
|
+
backgroundColor: 'rgb(255,255,239)',
|
40
|
+
color: 'black',
|
41
|
+
visibility: 'visible',
|
42
|
+
zIndex: 3,
|
43
|
+
borderRadius: '5px',
|
44
|
+
boxShadow: 'rgba(96,96,96,0.5) 0 0 5px',
|
45
|
+
opacity: 0
|
46
|
+
};
|
47
|
+
|
48
|
+
|
49
|
+
//
|
50
|
+
// Shows a tooltip
|
51
|
+
//
|
52
|
+
// @param obj The chart object
|
53
|
+
// @param opt The options
|
54
|
+
//
|
55
|
+
RG.SVG.tooltip = function (opt)
|
56
|
+
{
|
57
|
+
var obj = opt.object;
|
58
|
+
|
59
|
+
// Fire the beforetooltip event
|
60
|
+
RG.SVG.fireCustomEvent(obj, 'onbeforetooltip');
|
61
|
+
|
62
|
+
|
63
|
+
|
64
|
+
|
65
|
+
if (RG.SVG.trim(opt.text).length === 0) {
|
66
|
+
return;
|
67
|
+
}
|
68
|
+
|
69
|
+
|
70
|
+
|
71
|
+
var prop = obj.properties;
|
72
|
+
|
73
|
+
|
74
|
+
|
75
|
+
/**
|
76
|
+
* chart.tooltip.override allows you to totally take control of rendering the tooltip yourself
|
77
|
+
*/
|
78
|
+
if (typeof prop.tooltipsOverride === 'function') {
|
79
|
+
return (prop.tooltipsOverride)(obj, opt);
|
80
|
+
}
|
81
|
+
|
82
|
+
|
83
|
+
|
84
|
+
// Create the tooltip DIV element
|
85
|
+
var tooltipObj = document.createElement('DIV');
|
86
|
+
tooltipObj.className = prop.tooltipsCssClass;
|
87
|
+
|
88
|
+
|
89
|
+
|
90
|
+
// Add the default CSS to the tooltip
|
91
|
+
for (var i in RG.SVG.tooltips.style) {
|
92
|
+
if (typeof i === 'string') {
|
93
|
+
tooltipObj.style[i] = RG.SVG.tooltips.style[i];
|
94
|
+
}
|
95
|
+
}
|
96
|
+
|
97
|
+
|
98
|
+
tooltipObj.innerHTML = opt.text;
|
99
|
+
tooltipObj.__text__ = opt.text; // This is set because the innerHTML can change when it's set
|
100
|
+
tooltipObj.id = '__rgraph_tooltip_' + obj.id + '_' + obj.uid + '_'+ opt.index;
|
101
|
+
tooltipObj.__event__ = prop.tooltipsEvent || 'click';
|
102
|
+
tooltipObj.__object__ = obj;
|
103
|
+
|
104
|
+
// Add the index
|
105
|
+
if (typeof opt.index === 'number') {
|
106
|
+
tooltipObj.__index__ = opt.index;
|
107
|
+
}
|
108
|
+
|
109
|
+
// Add the dataset
|
110
|
+
if (typeof opt.dataset === 'number') {
|
111
|
+
tooltipObj.__dataset__ = opt.dataset;
|
112
|
+
}
|
113
|
+
|
114
|
+
// Add the group
|
115
|
+
if (typeof opt.group === 'number' || RG.SVG.isNull(opt.group)) {
|
116
|
+
tooltipObj.__group__ = opt.group;
|
117
|
+
}
|
118
|
+
|
119
|
+
// Add the sequentialIndex
|
120
|
+
if (typeof opt.sequentialIndex === 'number') {
|
121
|
+
tooltipObj.__sequentialIndex__ = opt.sequentialIndex;
|
122
|
+
}
|
123
|
+
|
124
|
+
|
125
|
+
|
126
|
+
|
127
|
+
// Add the tooltip to the document
|
128
|
+
document.body.appendChild(tooltipObj);
|
129
|
+
|
130
|
+
|
131
|
+
var width = tooltipObj.offsetWidth,
|
132
|
+
height = tooltipObj.offsetHeight;
|
133
|
+
|
134
|
+
// Move the tooltip into position
|
135
|
+
tooltipObj.style.left = opt.event.pageX - (width / 2) + 'px';
|
136
|
+
tooltipObj.style.top = opt.event.pageY - height - 15 + 'px';
|
137
|
+
|
138
|
+
|
139
|
+
|
140
|
+
|
141
|
+
/**
|
142
|
+
* Set the width on the tooltip so it doesn't resize if the window is resized
|
143
|
+
*/
|
144
|
+
tooltipObj.style.width = width + 'px';
|
145
|
+
|
146
|
+
|
147
|
+
// Fade the tooltip in if the tooltip effect is "fade"
|
148
|
+
if (prop.tooltipsEffect === 'fade') {
|
149
|
+
for (var i=0; i<=30; ++i) {
|
150
|
+
(function (idx)
|
151
|
+
{
|
152
|
+
setTimeout(function ()
|
153
|
+
{
|
154
|
+
tooltipObj.style.opacity = (idx / 30) * 1;
|
155
|
+
}, (idx / 30) * 200);
|
156
|
+
})(i);
|
157
|
+
}
|
158
|
+
} else {
|
159
|
+
tooltipObj.style.opacity = 1;
|
160
|
+
tooltipObj.style.display = 'inline-block';
|
161
|
+
}
|
162
|
+
|
163
|
+
|
164
|
+
|
165
|
+
|
166
|
+
// If the left is less than zero - set it to 5
|
167
|
+
if (parseFloat(tooltipObj.style.left) <= 5) {
|
168
|
+
tooltipObj.style.left = '5px';
|
169
|
+
}
|
170
|
+
|
171
|
+
// If the tooltip goes over the right hand edge then
|
172
|
+
// adjust the positioning
|
173
|
+
if (parseFloat(tooltipObj.style.left) + parseFloat(tooltipObj.style.width) > window.innerWidth) {
|
174
|
+
tooltipObj.style.left = ''
|
175
|
+
tooltipObj.style.right = '5px'
|
176
|
+
}
|
177
|
+
|
178
|
+
|
179
|
+
|
180
|
+
|
181
|
+
// If the canvas has fixed positioning then set the tooltip position to
|
182
|
+
// fixed too
|
183
|
+
if (RG.SVG.isFixed(obj.svg)) {
|
184
|
+
var scrollTop = window.scrollY || document.documentElement.scrollTop;
|
185
|
+
|
186
|
+
tooltipObj.style.position = 'fixed';
|
187
|
+
tooltipObj.style.top = opt.event.pageY - scrollTop - height - 10 + 'px';
|
188
|
+
}
|
189
|
+
|
190
|
+
|
191
|
+
|
192
|
+
// Cancel the mousedown event
|
193
|
+
tooltipObj.onmousedown = function (e)
|
194
|
+
{
|
195
|
+
e.stopPropagation();
|
196
|
+
};
|
197
|
+
|
198
|
+
// Cancel the mouseup event
|
199
|
+
tooltipObj.onmouseup = function (e)
|
200
|
+
{
|
201
|
+
e.stopPropagation();
|
202
|
+
};
|
203
|
+
|
204
|
+
// Cancel the click event
|
205
|
+
tooltipObj.onclick = function (e)
|
206
|
+
{
|
207
|
+
if (e.button == 0) {
|
208
|
+
e.stopPropagation();
|
209
|
+
}
|
210
|
+
};
|
211
|
+
|
212
|
+
// Add the body click handler that clears the tooltip
|
213
|
+
document.body.addEventListener('mousedown', function (e)
|
214
|
+
{
|
215
|
+
RG.SVG.hideTooltip();
|
216
|
+
}, false);
|
217
|
+
|
218
|
+
|
219
|
+
/**
|
220
|
+
* Keep a reference to the tooltip in the registry
|
221
|
+
*/
|
222
|
+
RG.SVG.REG.set('tooltip', tooltipObj);
|
223
|
+
|
224
|
+
//
|
225
|
+
// Fire the tooltip event
|
226
|
+
//
|
227
|
+
RG.SVG.fireCustomEvent(obj, 'ontooltip');
|
228
|
+
};
|
229
|
+
|
230
|
+
|
231
|
+
|
232
|
+
// End module pattern
|
233
|
+
})(window, document);
|