rgraph-rails 4.62 → 4.64

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.
Files changed (67) hide show
  1. checksums.yaml +5 -5
  2. data/README.md +3 -4
  3. data/lib/rgraph-rails/version.rb +1 -1
  4. data/vendor/assets/javascripts/RGraph.bar.js +240 -3742
  5. data/vendor/assets/javascripts/RGraph.bipolar.js +165 -2005
  6. data/vendor/assets/javascripts/RGraph.common.annotate.js +35 -395
  7. data/vendor/assets/javascripts/RGraph.common.context.js +30 -595
  8. data/vendor/assets/javascripts/RGraph.common.core.js +418 -5359
  9. data/vendor/assets/javascripts/RGraph.common.csv.js +20 -276
  10. data/vendor/assets/javascripts/RGraph.common.deprecated.js +35 -450
  11. data/vendor/assets/javascripts/RGraph.common.dynamic.js +88 -1395
  12. data/vendor/assets/javascripts/RGraph.common.effects.js +90 -1545
  13. data/vendor/assets/javascripts/RGraph.common.key.js +52 -753
  14. data/vendor/assets/javascripts/RGraph.common.resizing.js +37 -563
  15. data/vendor/assets/javascripts/RGraph.common.sheets.js +29 -352
  16. data/vendor/assets/javascripts/RGraph.common.tooltips.js +32 -450
  17. data/vendor/assets/javascripts/RGraph.common.zoom.js +14 -219
  18. data/vendor/assets/javascripts/RGraph.cornergauge.js +71 -0
  19. data/vendor/assets/javascripts/RGraph.drawing.background.js +34 -570
  20. data/vendor/assets/javascripts/RGraph.drawing.circle.js +33 -544
  21. data/vendor/assets/javascripts/RGraph.drawing.image.js +51 -755
  22. data/vendor/assets/javascripts/RGraph.drawing.marker1.js +37 -645
  23. data/vendor/assets/javascripts/RGraph.drawing.marker2.js +36 -633
  24. data/vendor/assets/javascripts/RGraph.drawing.marker3.js +35 -514
  25. data/vendor/assets/javascripts/RGraph.drawing.poly.js +37 -559
  26. data/vendor/assets/javascripts/RGraph.drawing.rect.js +33 -548
  27. data/vendor/assets/javascripts/RGraph.drawing.text.js +36 -664
  28. data/vendor/assets/javascripts/RGraph.drawing.xaxis.js +50 -812
  29. data/vendor/assets/javascripts/RGraph.drawing.yaxis.js +51 -856
  30. data/vendor/assets/javascripts/RGraph.fuel.js +58 -964
  31. data/vendor/assets/javascripts/RGraph.funnel.js +55 -984
  32. data/vendor/assets/javascripts/RGraph.gantt.js +77 -1354
  33. data/vendor/assets/javascripts/RGraph.gauge.js +85 -1421
  34. data/vendor/assets/javascripts/RGraph.hbar.js +162 -2788
  35. data/vendor/assets/javascripts/RGraph.hprogress.js +80 -1401
  36. data/vendor/assets/javascripts/RGraph.line.js +249 -4248
  37. data/vendor/assets/javascripts/RGraph.meter.js +74 -1280
  38. data/vendor/assets/javascripts/RGraph.modaldialog.js +19 -301
  39. data/vendor/assets/javascripts/RGraph.odo.js +71 -1264
  40. data/vendor/assets/javascripts/RGraph.pie.js +137 -2288
  41. data/vendor/assets/javascripts/RGraph.radar.js +110 -1847
  42. data/vendor/assets/javascripts/RGraph.rose.js +108 -1977
  43. data/vendor/assets/javascripts/RGraph.rscatter.js +80 -1432
  44. data/vendor/assets/javascripts/RGraph.scatter.js +172 -3163
  45. data/vendor/assets/javascripts/RGraph.semicircularprogress.js +60 -1120
  46. data/vendor/assets/javascripts/RGraph.svg.bar.js +66 -1735
  47. data/vendor/assets/javascripts/RGraph.svg.common.ajax.js +21 -246
  48. data/vendor/assets/javascripts/RGraph.svg.common.core.js +255 -3937
  49. data/vendor/assets/javascripts/RGraph.svg.common.csv.js +20 -276
  50. data/vendor/assets/javascripts/RGraph.svg.common.fx.js +68 -1303
  51. data/vendor/assets/javascripts/RGraph.svg.common.key.js +19 -205
  52. data/vendor/assets/javascripts/RGraph.svg.common.sheets.js +29 -352
  53. data/vendor/assets/javascripts/RGraph.svg.common.tooltips.js +22 -273
  54. data/vendor/assets/javascripts/RGraph.svg.funnel.js +32 -0
  55. data/vendor/assets/javascripts/RGraph.svg.hbar.js +59 -1400
  56. data/vendor/assets/javascripts/RGraph.svg.line.js +70 -1580
  57. data/vendor/assets/javascripts/RGraph.svg.pie.js +55 -1131
  58. data/vendor/assets/javascripts/RGraph.svg.radar.js +57 -1502
  59. data/vendor/assets/javascripts/RGraph.svg.rose.js +66 -1817
  60. data/vendor/assets/javascripts/RGraph.svg.scatter.js +58 -1261
  61. data/vendor/assets/javascripts/RGraph.svg.semicircularprogress.js +28 -865
  62. data/vendor/assets/javascripts/RGraph.svg.waterfall.js +45 -1252
  63. data/vendor/assets/javascripts/RGraph.thermometer.js +63 -1136
  64. data/vendor/assets/javascripts/RGraph.vprogress.js +83 -1470
  65. data/vendor/assets/javascripts/RGraph.waterfall.js +83 -1347
  66. metadata +5 -4
  67. data/vendor/assets/javascripts/financial-data.js +0 -1067
@@ -1,353 +1,30 @@
1
- // version: 2017-05-08
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
1
 
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
- //$('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.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.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.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);
2
+ RGraph=window.RGraph||{isRGraph:true};(function(win,doc,undefined)
3
+ {RGraph.Sheets=function(key)
4
+ {var worksheet,callback,letters='ABCDEFGHIJKLMNOPQRSTUVWXYZ';if(arguments.length===3){worksheet=Number(arguments[1]);callback=arguments[2];}else{worksheet=1;callback=arguments[1];}
5
+ 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);this.load=function(url,userCallback)
6
+ {var obj=this;__rgraph_JSONPCallback=function(json)
7
+ {obj.json=json;var grid=[],row=0,col=0;for(var i=0;i<json.feed.entry.length;++i){row=json.feed.entry[i].gs$cell.row-1;col=json.feed.entry[i].gs$cell.col-1;if(!grid[row]){grid[row]=[];}
8
+ grid[row][col]=json.feed.entry[i].content.$t;}
9
+ var maxcols=0;for(var i=0;i<grid.length;++i){maxcols=grid[i]?Math.max(maxcols,grid[i].length):maxcols;}
10
+ for(var i=0;i<grid.length;++i){if(typeof grid[i]==='undefined'){grid[i]=new Array(maxcols);}
11
+ for(var j=0;j<maxcols;j++){if(typeof grid[i][j]==='undefined'){grid[i][j]='';}
12
+ if(grid[i][j].match(/^[0-9]+$/)){grid[i][j]=parseInt(grid[i][j]);}else if(grid[i][j].match(/^[0-9.]+$/)){grid[i][j]=parseFloat(grid[i][j]);}}}
13
+ obj.data=grid;userCallback(obj);};var scriptNode=document.createElement('script');scriptNode.src=url;document.body.appendChild(scriptNode);};this.row=function(index,start)
14
+ {var opt={},row;start=start||1;if(arguments&&typeof arguments[2]==='object'&&typeof arguments[2].trim==='boolean'){opt.trim=arguments[2].trim;}else{opt.trim=true;}
15
+ row=this.data[index-1].slice(start-1);if(opt.trim){row=RGraph.arrayTrim(row);}
16
+ return row;};this.col=function(index,start)
17
+ {var opt={},col=[];start=start||1;if(arguments&&typeof arguments[2]==='object'&&typeof arguments[2].trim==='boolean'){opt.trim=arguments[2].trim;}else{opt.trim=true;}
18
+ for(var i=0;i<this.data.length;++i){col.push(this.data[i][index-1]);}
19
+ if(opt.trim){col=RGraph.arrayTrim(col);}
20
+ col=col.slice(start-1);return col;};this.getIndexOfLetters=function(l)
21
+ {var parts=l.split('');if(parts.length===1){return letters.indexOf(l)+1;}else if(parts.length===2){var idx=((letters.indexOf(parts[0])+1)*26)+(letters.indexOf(parts[1])+1);return idx;}}
22
+ this.get=function(str)
23
+ {str=str.toUpperCase();if(str.match(/^[a-z]+$/i)){if(str.length===1){var index=letters.indexOf(str)+1;return this.col(index,1,arguments[1]);}else if(str.length===2){var index=((letters.indexOf(str[0])+1)*26)+letters.indexOf(str[1])+1;return this.col(index,1,arguments[1]);}}
24
+ if(str.match(/^[0-9]+$/i)){return this.row(str,null,arguments[1]);}
25
+ if(str.match(/^([a-z]{1,2})([0-9]+)$/i)){var letter=RegExp.$1,number=RegExp.$2,col=this.get(letter,{trim:false});return col[number-1];}
26
+ if(str.match(/^([a-z]{1,2})([0-9]+):([a-z]{1,2})([0-9]+)$/i)){var letter1=RegExp.$1,number1=RegExp.$2,letter2=RegExp.$3,number2=RegExp.$4
27
+ if(letter1===letter2){var cells=[],index=this.getIndexOfLetters(letter1),col=this.col(index,null,{trim:false});for(var i=(number1-1);i<=(number2-1);++i){cells.push(col[i]);}}else if(number1===number2){var cells=[],row=this.row(number1,null,{trim:false}),index1=this.getIndexOfLetters(letter1),index2=this.getIndexOfLetters(letter2)
28
+ for(var i=(index1-1);i<=(index2-1);++i){cells.push(row[i]);}}
29
+ if(arguments[1]&&arguments[1].trim===false){}else{cells=RGraph.arrayTrim(cells);}
30
+ return cells;}};this.load(url,callback);};})(window,document);
@@ -1,451 +1,33 @@
1
- // version: 2017-05-08
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
1
 
13
- RGraph = window.RGraph || {isRGraph: true};
14
-
15
-
16
-
17
-
18
- // Module pattern
19
- (function (win, doc, undefined)
20
- {
21
- var RG = RGraph,
22
- ua = navigator.userAgent,
23
- ma = Math;
24
-
25
-
26
-
27
-
28
- /**
29
- * This is used in two functions, hence it's here
30
- */
31
- RG.tooltips = {};
32
- RG.tooltips.style = {
33
- display: 'inline-block',
34
- position: 'absolute',
35
- padding: '6px',
36
- fontFamily: 'Arial',
37
- fontSize: '10pt',
38
- fontWeight: 'normal',
39
- textAlign: 'center',
40
- left: 0,
41
- top: 0,
42
- backgroundColor: 'rgb(255,255,239)',
43
- color: 'black',
44
- visibility: 'visible',
45
- zIndex: 3,
46
- borderRadius: '5px',
47
- boxShadow: 'rgba(96,96,96,0.5) 0 0 5px',
48
- opacity: 0
49
- };
50
-
51
-
52
-
53
- /**
54
- * Shows a tooltip next to the mouse pointer
55
- *
56
- * @param canvas object The canvas element object
57
- * @param text string The tooltip text
58
- * @param int x The X position that the tooltip should appear at. Combined with the canvases offsetLeft
59
- * gives the absolute X position
60
- * @param int y The Y position the tooltip should appear at. Combined with the canvases offsetTop
61
- * gives the absolute Y position
62
- * @param int idx The index of the tooltip in the graph objects tooltip array
63
- * @param object e The event object
64
- */
65
- RG.tooltip =
66
- RG.Tooltip = function (obj, text, x, y, idx, e)
67
- {
68
- if (RG.trim(text).length === 0) {
69
- return;
70
- }
71
-
72
-
73
-
74
- /**
75
- * Fire the beforetooltip event
76
- */
77
- RG.fireCustomEvent(obj, 'onbeforetooltip');
78
-
79
-
80
-
81
- /**
82
- * chart.tooltip.override allows you to totally take control of rendering the tooltip yourself
83
- */
84
- if (typeof(obj.get('chart.tooltips.override')) == 'function') {
85
- return obj.get('chart.tooltips.override')(obj, text, x, y, idx);
86
- }
87
-
88
-
89
-
90
-
91
- /**
92
- * Save the X/Y coords
93
- */
94
- var originalX = x;
95
- var originalY = y;
96
-
97
- /**
98
- * This facilitates the "id:xxx" format
99
- */
100
- text = RG.getTooltipTextFromDIV(text);
101
-
102
- /**
103
- * First clear any exising timers
104
- */
105
- var timers = RG.Registry.Get('chart.tooltip.timers');
106
-
107
- if (timers && timers.length) {
108
- for (i=0; i<timers.length; ++i) {
109
- clearTimeout(timers[i]);
110
- }
111
- }
112
- RG.Registry.Set('chart.tooltip.timers', []);
113
-
114
- /**
115
- * Hide the context menu if it's currently shown
116
- */
117
- if (obj.get('chart.contextmenu')) {
118
- RG.hideContext();
119
- }
120
-
121
-
122
-
123
- /**
124
- * Show a tool tip
125
- */
126
- var tooltipObj = document.createElement('DIV');
127
- tooltipObj.className = obj.get('chart.tooltips.css.class');
128
-
129
- // Add the default CSS to the tooltip
130
- for (var i in RGraph.tooltips.style) {
131
- if (typeof i === 'string') {
132
- tooltipObj.style[i] = RGraph.tooltips.style[i];
133
- }
134
- }
135
-
136
- tooltipObj.innerHTML = text;
137
- tooltipObj.__text__ = text; // This is set because the innerHTML can change when it's set
138
- tooltipObj.__canvas__ = obj.canvas;
139
- tooltipObj.id = '__rgraph_tooltip_' + obj.canvas.id + '_' + obj.uid + '_'+ idx;
140
- tooltipObj.__event__ = obj.Get('chart.tooltips.event') || 'click';
141
- tooltipObj.__object__ = obj;
142
-
143
- if (typeof idx === 'number') {
144
- tooltipObj.__index__ = idx;
145
- origIdx = idx;
146
- }
147
-
148
- if (obj.type === 'line' || obj.type === 'radar') {
149
- for (var ds=0; ds<obj.data.length; ++ds) {
150
- if (idx >= obj.data[ds].length) {
151
- idx -= obj.data[ds].length;
152
- } else {
153
- break;
154
- }
155
- }
156
-
157
- tooltipObj.__dataset__ = ds;
158
- tooltipObj.__index2__ = idx;
159
- }
160
-
161
- document.body.appendChild(tooltipObj);
162
- //obj.canvas.parentNode.appendChild(tooltipObj);
163
-
164
- var width = tooltipObj.offsetWidth;
165
- var height = tooltipObj.offsetHeight;
166
-
167
-
168
- /**
169
- * Set the width on the tooltip so it doesn't resize if the window is resized
170
- */
171
- tooltipObj.style.width = width + 'px';
172
-
173
-
174
-
175
-
176
-
177
-
178
-
179
-
180
-
181
- //
182
- // position the tooltip on the mouse pointers position
183
- //
184
- var mouseXY = RG.getMouseXY(e);
185
- var canvasXY = RG.getCanvasXY(obj.canvas);
186
-
187
- // Position based on the mouse pointer coords on the page
188
- tooltipObj.style.left = e.pageX - (parseFloat(tooltipObj.style.paddingLeft) + (width / 2)) + 'px';
189
- tooltipObj.style.top = e.pageY - height - 10 + 'px';
190
-
191
- // If the left is less than zero - set it to 5
192
- if (parseFloat(tooltipObj.style.left) <= 5) {
193
- tooltipObj.style.left = '5px';
194
- }
195
-
196
- // If the tooltip goes over the right hand edge then
197
- // adjust the positioning
198
- if (parseFloat(tooltipObj.style.left) + parseFloat(tooltipObj.style.width) > window.innerWidth) {
199
- tooltipObj.style.left = ''
200
- tooltipObj.style.right = '5px'
201
- }
202
-
203
- // If the canvas has fixed positioning then set the tooltip position to
204
- // fixed too
205
- if (RG.isFixed(obj.canvas)) {
206
- var scrollTop = window.scrollY || document.documentElement.scrollTop;
207
-
208
- tooltipObj.style.position = 'fixed';
209
- tooltipObj.style.top = e.pageY - scrollTop - height - 10 + 'px';
210
- }
211
-
212
-
213
-
214
-
215
-
216
-
217
- // If the effect is fade:
218
- // Increase the opacity from its default 0 up to 1 - fading the tooltip in
219
- if (obj.get('chart.tooltips.effect') === 'fade') {
220
- for (var i=1; i<=10; ++i) {
221
- (function (index)
222
- {
223
- setTimeout(function ()
224
- {
225
- tooltipObj.style.opacity = index / 10;
226
- }, index * 25);
227
- })(i);
228
- }
229
- } else {
230
- tooltipObj.style.opacity = 1;
231
- }
232
-
233
-
234
-
235
-
236
-
237
-
238
-
239
-
240
-
241
-
242
-
243
- /**
244
- * If the tooltip it self is clicked, cancel it
245
- */
246
- tooltipObj.onmousedown = function (e){e.stopPropagation();}
247
- tooltipObj.onmouseup = function (e){e.stopPropagation();}
248
- tooltipObj.onclick = function (e){if (e.button == 0) {e.stopPropagation();}}
249
-
250
-
251
-
252
-
253
-
254
-
255
-
256
- /**
257
- * Keep a reference to the tooltip in the registry
258
- */
259
- RG.Registry.Set('chart.tooltip', tooltipObj);
260
-
261
- /**
262
- * Fire the tooltip event
263
- */
264
- RG.fireCustomEvent(obj, 'ontooltip');
265
- };
266
-
267
-
268
-
269
-
270
- /**
271
- *
272
- */
273
- RG.getTooltipTextFromDIV = function (text)
274
- {
275
- // This regex is duplicated firher down on roughly line 888
276
- var result = /^id:(.*)/.exec(text);
277
-
278
- if (result && result[1] && document.getElementById(result[1])) {
279
- text = document.getElementById(result[1]).innerHTML;
280
- } else if (result && result[1]) {
281
- text = '';
282
- }
283
-
284
- return text;
285
- };
286
-
287
-
288
-
289
-
290
- /**
291
- *
292
- */
293
- RG.getTooltipWidth = function (text, obj)
294
- {
295
- var div = document.createElement('DIV');
296
- div.className = obj.Get('chart.tooltips.css.class');
297
- div.style.paddingLeft = RG.tooltips.padding;
298
- div.style.paddingRight = RG.tooltips.padding;
299
- div.style.fontFamily = RG.tooltips.font_face;
300
- div.style.fontSize = RG.tooltips.font_size;
301
- div.style.visibility = 'hidden';
302
- div.style.position = 'absolute';
303
- div.style.top = '300px';
304
- div.style.left = 0;
305
- div.style.display = 'inline';
306
- div.innerHTML = RG.getTooltipTextFromDIV(text);
307
- document.body.appendChild(div);
308
-
309
- return div.offsetWidth;
310
- };
311
-
312
-
313
-
314
-
315
- /**
316
- * Hides the currently shown tooltip
317
- */
318
- RG.hideTooltip =
319
- RG.HideTooltip = function ()
320
- {
321
- var tooltip = RG.Registry.Get('chart.tooltip');
322
- var uid = arguments[0] && arguments[0].uid ? arguments[0].uid : null;
323
-
324
- if (tooltip && tooltip.parentNode && (!uid || uid == tooltip.__canvas__.uid)) {
325
- tooltip.parentNode.removeChild(tooltip);
326
- tooltip.style.display = 'none';
327
- tooltip.style.visibility = 'hidden';
328
- RG.Registry.Set('chart.tooltip', null);
329
- }
330
- };
331
-
332
-
333
-
334
-
335
- /**
336
- * This (as the name suggests preloads any images it can find in the tooltip text
337
- *
338
- * @param object obj The chart object
339
- */
340
- RG.preLoadTooltipImages =
341
- RG.PreLoadTooltipImages = function (obj)
342
- {
343
- var tooltips = obj.Get('chart.tooltips');
344
-
345
- if (RG.hasTooltips(obj)) {
346
-
347
- if (obj.type == 'rscatter') {
348
- tooltips = [];
349
- for (var i=0; i<obj.data.length; ++i) {
350
- tooltips.push(obj.data[3]);
351
- }
352
- }
353
-
354
- for (var i=0; i<tooltips.length; ++i) {
355
- // Add the text to an offscreen DIV tag
356
- var div = document.createElement('DIV');
357
- div.style.position = 'absolute';
358
- div.style.opacity = 0;
359
- div.style.top = '-100px';
360
- div.style.left = '-100px';
361
- div.innerHTML = tooltips[i];
362
- document.body.appendChild(div);
363
-
364
- // Now get the IMG tags and create them
365
- var img_tags = div.getElementsByTagName('IMG');
366
-
367
- // Create the image in an off-screen image tag
368
- for (var j=0; j<img_tags.length; ++j) {
369
- if (img_tags && img_tags[i]) {
370
- var img = document.createElement('IMG');
371
- img.style.position = 'absolute';
372
- img.style.opacity = 0;
373
- img.style.top = '-100px';
374
- img.style.left = '-100px';
375
- img.src = img_tags[i].src
376
- document.body.appendChild(img);
377
-
378
- setTimeout(function () {document.body.removeChild(img);}, 250);
379
- }
380
- }
381
-
382
- // Now remove the div
383
- document.body.removeChild(div);
384
- }
385
- }
386
- };
387
-
388
-
389
-
390
-
391
- /**
392
- * This is the tooltips canvas onmousemove listener
393
- */
394
- RG.tooltips_mousemove =
395
- RG.Tooltips_mousemove = function (obj, e)
396
- {
397
- var shape = obj.getShape(e);
398
- var changeCursor_tooltips = false
399
-
400
- if ( shape
401
- && typeof(shape['index']) == 'number'
402
- && obj.Get('chart.tooltips')[shape['index']]
403
- ) {
404
-
405
- var text = RG.parseTooltipText(obj.Get('chart.tooltips'), shape['index']);
406
-
407
- if (text) {
408
-
409
- /**
410
- * Change the cursor
411
- */
412
- changeCursor_tooltips = true;
413
-
414
- if (obj.Get('chart.tooltips.event') == 'onmousemove') {
415
-
416
- // Show the tooltip if it's not the same as the one already visible
417
- if (
418
- !RG.Registry.Get('chart.tooltip')
419
- || RG.Registry.Get('chart.tooltip').__object__.uid != obj.uid
420
- || RG.Registry.Get('chart.tooltip').__index__ != shape['index']
421
- ) {
422
-
423
- RG.hideTooltip();
424
- RG.Clear(obj.canvas);
425
- RG.redraw();
426
- RG.tooltip(obj, text, e.pageX, e.pageY, shape['index']);
427
- obj.Highlight(shape);
428
- }
429
- }
430
- }
431
-
432
- /**
433
- * More highlighting
434
- */
435
- } else if (shape && typeof(shape['index']) == 'number') {
436
-
437
- var text = RG.parseTooltipText(obj.Get('chart.tooltips'), shape['index']);
438
-
439
- if (text) {
440
- changeCursor_tooltips = true
441
- }
442
- }
443
-
444
- return changeCursor_tooltips;
445
- };
446
-
447
-
448
-
449
-
450
- // End module pattern
451
- })(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);