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,31 +1,636 @@
|
|
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
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
12
|
+
RGraph = window.RGraph || {isrgraph:true,isRGraph: true,rgraph:true};
|
13
|
+
|
14
|
+
// Module pattern
|
15
|
+
(function (win, doc, undefined)
|
16
|
+
{
|
17
|
+
var ua = navigator.userAgent;
|
18
|
+
|
19
|
+
//
|
20
|
+
// This gunction shows a context menu containing the parameters
|
21
|
+
// provided to it
|
22
|
+
//
|
23
|
+
// @param object canvas The canvas object
|
24
|
+
// @param array menuitems The context menu menuitems
|
25
|
+
// @param object e The event object
|
26
|
+
//
|
27
|
+
RGraph.contextMenu = function ()
|
28
|
+
{
|
29
|
+
var args = RGraph.getArgs(arguments, 'object,menuitems,event'),
|
30
|
+
obj = args.object,
|
31
|
+
menuitems = args.menuitems,
|
32
|
+
e = args.event,
|
33
|
+
canvas = obj.canvas;
|
34
|
+
|
35
|
+
//
|
36
|
+
// Fire the custom RGraph event onbeforecontextmenu
|
37
|
+
//
|
38
|
+
RGraph.fireCustomEvent(obj, 'onbeforecontextmenu');
|
39
|
+
|
40
|
+
//
|
41
|
+
// Hide any existing menu
|
42
|
+
//
|
43
|
+
if (RGraph.Registry.get('contextmenu')) {
|
44
|
+
RGraph.hideContext();
|
45
|
+
}
|
46
|
+
|
47
|
+
// Hide any zoomed canvas
|
48
|
+
//
|
49
|
+
// Commented out on 13th October 2019
|
50
|
+
//
|
51
|
+
//RGraph.hideZoomedCanvas();
|
52
|
+
|
53
|
+
//
|
54
|
+
// Hide the palette if necessary
|
55
|
+
//
|
56
|
+
RGraph.hidePalette();
|
57
|
+
|
58
|
+
//
|
59
|
+
// This is here to ensure annotating is OFF
|
60
|
+
//
|
61
|
+
obj.set('mousedown', false);
|
62
|
+
|
63
|
+
var x = e.pageX;
|
64
|
+
var y = e.pageY;
|
65
|
+
var div = document.createElement('div');
|
66
|
+
var bg = document.createElement('div');
|
67
|
+
|
68
|
+
div.className = 'RGraph_contextmenu';
|
69
|
+
div.__canvas__ = canvas; // Store a reference to the canvas on the contextmenu object
|
70
|
+
div.style.position = 'absolute';
|
71
|
+
div.style.left = 0;
|
72
|
+
div.style.top = 0;
|
73
|
+
div.style.border = '1px solid #666';
|
74
|
+
div.style.backgroundColor = 'white';
|
75
|
+
div.style.boxShadow = '1px 1px 3px #ddd';
|
76
|
+
div.style.MozBoxShadow = '1px 1px 3px #ddd';
|
77
|
+
div.style.WebkitBoxShadow = '1px 1px 3px #ddd';
|
78
|
+
div.style.opacity = 0;
|
79
|
+
div.style.lineHeight = 'initial';
|
80
|
+
|
81
|
+
bg.className = 'RGraph_contextmenu_background';
|
82
|
+
bg.style.position = 'absolute';
|
83
|
+
bg.style.backgroundColor = '#ccc';
|
84
|
+
bg.style.borderRight = '1px solid #aaa';
|
85
|
+
bg.style.top = 0;
|
86
|
+
bg.style.left = 0;
|
87
|
+
bg.style.width = '18px';
|
88
|
+
bg.style.height = '100%';
|
89
|
+
bg.style.opacity = 0;
|
90
|
+
|
91
|
+
|
92
|
+
div = document.body.appendChild(div);
|
93
|
+
bg = div.appendChild(bg);
|
94
|
+
|
95
|
+
|
96
|
+
//
|
97
|
+
// Now add the context menu items
|
98
|
+
//
|
99
|
+
for (i=0; i<menuitems.length; ++i) {
|
100
|
+
|
101
|
+
var menuitem = document.createElement('div');
|
102
|
+
|
103
|
+
menuitem.__object__ = obj;
|
104
|
+
menuitem.__canvas__ = canvas;
|
105
|
+
menuitem.__contextmenu__ = div;
|
106
|
+
menuitem.className = 'RGraph_contextmenu_item';
|
107
|
+
|
108
|
+
if (menuitems[i]) {
|
109
|
+
menuitem.style.padding = '2px 5px 2px 23px';
|
110
|
+
menuitem.style.fontFamily = 'Arial';
|
111
|
+
menuitem.style.fontSize = '10pt';
|
112
|
+
menuitem.style.textAlign = 'left';
|
113
|
+
menuitem.style.fontWeight = 'normal';
|
114
|
+
menuitem.innerHTML = menuitems[i][0];
|
115
|
+
|
116
|
+
if (RGraph.isArray(menuitems[i][1])) {
|
117
|
+
menuitem.style.backgroundImage = 'url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAcAAAAHCAYAAADEUlfTAAAAQUlEQVQImY3NoQ2AMABE0ZewABMyGQ6mqWODzlAclBSFO8HZl8uf0FFxCHtwYkt4Y6ChYE44cGH9/fyae2p2LAleW9oVTQuVf6gAAAAASUVORK5CYII=)';
|
118
|
+
menuitem.style.backgroundRepeat = 'no-repeat';
|
119
|
+
menuitem.style.backgroundPosition = '97% center';
|
120
|
+
}
|
121
|
+
|
122
|
+
// Add the mouseover event
|
123
|
+
if (menuitems[i][1]) {
|
124
|
+
if (menuitem.addEventListener) {
|
125
|
+
menuitem.addEventListener("mouseover", function (e) {RGraph.hideContextSubmenu(); e.target.style.backgroundColor = 'rgba(0,0,0,0.2)'; e.target.style.cursor = 'pointer';}, false);
|
126
|
+
menuitem.addEventListener("mouseout", function (e) {e.target.style.backgroundColor = 'inherit'; e.target.style.cursor = 'default';}, false);
|
127
|
+
} else {
|
128
|
+
menuitem.attachEvent("onmouseover", function () {RGraph.hideContextSubmenu();event.srcElement.style.backgroundColor = '#eee';event.srcElement.style.cursor = 'pointer';}
|
129
|
+
, false);
|
130
|
+
menuitem.attachEvent("onmouseout", function () {event.srcElement.style.backgroundColor = 'inherit'; event.srcElement.style.cursor = 'default';}, false);
|
131
|
+
}
|
132
|
+
} else {
|
133
|
+
if (menuitem.addEventListener) {
|
134
|
+
menuitem.addEventListener("mouseover", function (e) {e.target.style.cursor = 'default';}, false);
|
135
|
+
menuitem.addEventListener("mouseout", function (e) {e.target.style.cursor = 'default';}, false);
|
136
|
+
} else {
|
137
|
+
menuitem.attachEvent("onmouseover", function () {event.srcElement.style.cursor = 'default'}, false);
|
138
|
+
menuitem.attachEvent("onmouseout", function () {event.srcElement.style.cursor = 'default';}, false);
|
139
|
+
}
|
140
|
+
}
|
141
|
+
|
142
|
+
} else {
|
143
|
+
menuitem.style.borderBottom = '1px solid #ddd';
|
144
|
+
menuitem.style.marginLeft = '25px';
|
145
|
+
}
|
146
|
+
|
147
|
+
div.appendChild(menuitem);
|
148
|
+
|
149
|
+
//
|
150
|
+
// Install the event handler that calls the menuitem
|
151
|
+
//
|
152
|
+
if (menuitems[i] && menuitems[i][1] && typeof menuitems[i][1] == 'function') {
|
153
|
+
|
154
|
+
menuitem.addEventListener('click', menuitems[i][1], false);
|
155
|
+
|
156
|
+
// Submenu
|
157
|
+
} else if (menuitems[i] && menuitems[i][1] && RGraph.isArray(menuitems[i][1])) {
|
158
|
+
(function ()
|
159
|
+
{
|
160
|
+
var tmp = menuitems[i][1]; // This is here because of "references vs primitives" and how they're passed around in Javascript
|
161
|
+
|
162
|
+
// TODO This may need attention
|
163
|
+
menuitem.addEventListener('mouseover', function (e) {RGraph.contextMenu_submenu(obj, tmp, e.target);}, false);
|
164
|
+
})();
|
165
|
+
}
|
166
|
+
}
|
167
|
+
|
168
|
+
//
|
169
|
+
// Now all the menu items have been added, set the shadow width
|
170
|
+
// Shadow now handled by CSS3
|
171
|
+
//
|
172
|
+
div.style.width = (div.offsetWidth + 10) + 'px';
|
173
|
+
div.style.height = (div.offsetHeight - 2) + 'px';
|
174
|
+
|
175
|
+
// Show the menu to the left or the right (normal) of the cursor?
|
176
|
+
if (x + div.offsetWidth > document.body.offsetWidth) {
|
177
|
+
x -= div.offsetWidth;
|
178
|
+
}
|
179
|
+
|
180
|
+
// Reposition the menu (now we have the real offsetWidth)
|
181
|
+
div.style.left = x + 'px';
|
182
|
+
div.style.top = y + 'px';
|
183
|
+
|
184
|
+
//
|
185
|
+
// Do a little fade in effect
|
186
|
+
//
|
187
|
+
setTimeout("if (obj = RGraph.Registry.get('contextmenu')) obj.style.opacity = 0.2", 50);
|
188
|
+
setTimeout("if (obj = RGraph.Registry.get('contextmenu')) obj.style.opacity = 0.4", 100);
|
189
|
+
setTimeout("if (obj = RGraph.Registry.get('contextmenu')) obj.style.opacity = 0.6", 150);
|
190
|
+
setTimeout("if (obj = RGraph.Registry.get('contextmenu')) obj.style.opacity = 0.8", 200);
|
191
|
+
setTimeout("if (obj = RGraph.Registry.get('contextmenu')) obj.style.opacity = 1", 250);
|
192
|
+
|
193
|
+
// The fade in effect on the left gray bar
|
194
|
+
setTimeout("if (obj = RGraph.Registry.get('contextmenu.bg')) obj.style.opacity = 0.2", 50);
|
195
|
+
setTimeout("if (obj = RGraph.Registry.get('contextmenu.bg')) obj.style.opacity = 0.4", 100);
|
196
|
+
setTimeout("if (obj = RGraph.Registry.get('contextmenu.bg')) obj.style.opacity = 0.6", 150);
|
197
|
+
setTimeout("if (obj = RGraph.Registry.get('contextmenu.bg')) obj.style.opacity = 0.8", 200);
|
198
|
+
setTimeout("if (obj = RGraph.Registry.get('contextmenu.bg')) obj.style.opacity = 1", 250);
|
199
|
+
|
200
|
+
// Store the context menu in the registry
|
201
|
+
RGraph.Registry.set('contextmenu', div);
|
202
|
+
RGraph.Registry.set('contextmenu.bg', bg);
|
203
|
+
RGraph.Registry.get('contextmenu').oncontextmenu = function () {return false;};
|
204
|
+
RGraph.Registry.get('contextmenu.bg').oncontextmenu = function () {return false;};
|
205
|
+
|
206
|
+
//
|
207
|
+
// Install the event handlers that hide the context menu
|
208
|
+
//
|
209
|
+
canvas.addEventListener('click', function () {RGraph.hideContext();}, false);
|
210
|
+
|
211
|
+
window.addEventListener('click', function ()
|
212
|
+
{
|
213
|
+
RGraph.hideContext();
|
214
|
+
}, false);
|
215
|
+
|
216
|
+
window.addEventListener('resize', function ()
|
217
|
+
{
|
218
|
+
RGraph.hideContext();
|
219
|
+
}, false);
|
220
|
+
|
221
|
+
|
222
|
+
//
|
223
|
+
// Add the __shape__ object to the context menu
|
224
|
+
//
|
225
|
+
|
226
|
+
//
|
227
|
+
// Set the shape coords from the .getShape() method
|
228
|
+
//
|
229
|
+
if (typeof obj.getShape == 'function') {
|
230
|
+
RGraph.Registry.get('contextmenu').__shape__ = obj.getShape(e);
|
231
|
+
}
|
232
|
+
|
233
|
+
|
234
|
+
e.stopPropagation();
|
235
|
+
|
236
|
+
//
|
237
|
+
// Fire the (RGraph) oncontextmenu event
|
238
|
+
//
|
239
|
+
RGraph.fireCustomEvent(obj, 'oncontextmenu');
|
240
|
+
|
241
|
+
return false;
|
242
|
+
};
|
243
|
+
|
244
|
+
|
245
|
+
|
246
|
+
|
247
|
+
|
248
|
+
|
249
|
+
|
250
|
+
|
251
|
+
//
|
252
|
+
// Hides the context menu if it's currently visible
|
253
|
+
//
|
254
|
+
RGraph.hideContext = function ()
|
255
|
+
{
|
256
|
+
var cm = RGraph.Registry.get('contextmenu');
|
257
|
+
var cmbg = RGraph.Registry.get('contextmenu.bg');
|
258
|
+
|
259
|
+
//Hide any submenu currently being displayed
|
260
|
+
RGraph.hideContextSubmenu();
|
261
|
+
|
262
|
+
if (cm) {
|
263
|
+
cm.parentNode.removeChild(cm);
|
264
|
+
cmbg.parentNode.removeChild(cmbg);
|
265
|
+
|
266
|
+
cm.style.visibility = 'hidden';
|
267
|
+
cm.style.display = 'none';
|
268
|
+
RGraph.Registry.set('contextmenu', null);
|
269
|
+
|
270
|
+
cmbg.style.visibility = 'hidden';
|
271
|
+
cmbg.style.display = 'none';
|
272
|
+
RGraph.Registry.set('contextmenu.bg', null);
|
273
|
+
}
|
274
|
+
};
|
275
|
+
|
276
|
+
|
277
|
+
|
278
|
+
|
279
|
+
|
280
|
+
|
281
|
+
|
282
|
+
|
283
|
+
//
|
284
|
+
// Hides the context menus SUBMENU if it's currently visible
|
285
|
+
//
|
286
|
+
RGraph.hideContextSubmenu = function ()
|
287
|
+
{
|
288
|
+
var sub = RGraph.Registry.get('contextmenu.submenu');
|
289
|
+
|
290
|
+
if (sub) {
|
291
|
+
sub.style.visibility = 'none';
|
292
|
+
sub.style.display = 'none';
|
293
|
+
RGraph.Registry.set('contextmenu.submenu', null);
|
294
|
+
}
|
295
|
+
};
|
296
|
+
|
297
|
+
|
298
|
+
|
299
|
+
|
300
|
+
|
301
|
+
|
302
|
+
|
303
|
+
|
304
|
+
//
|
305
|
+
// Shows the context menu after making a few checks - not opera (doesn't support oncontextmenu,
|
306
|
+
// not safari (tempermentality), not chrome (hmmm)
|
307
|
+
//
|
308
|
+
RGraph.showContext = function ()
|
309
|
+
{
|
310
|
+
var args = RGraph.getArgs(arguments, 'object'),
|
311
|
+
obj = args.object;
|
312
|
+
|
313
|
+
RGraph.hidePalette();
|
314
|
+
|
315
|
+
if (obj.get('contextmenu') && obj.get('contextmenu').length) {
|
316
|
+
|
317
|
+
var isOpera = navigator.userAgent.indexOf('Opera') >= 0;
|
318
|
+
var isSafari = navigator.userAgent.indexOf('Safari') >= 0;
|
319
|
+
var isChrome = navigator.userAgent.indexOf('Chrome') >= 0;
|
320
|
+
var isMacFirefox = navigator.userAgent.indexOf('Firefox') > 0 && navigator.userAgent.indexOf('Mac') > 0;
|
321
|
+
var isIE9 = navigator.userAgent.indexOf('MSIE 9') >= 0;
|
322
|
+
|
323
|
+
if (((!isOpera && !isSafari) || isChrome) && !isMacFirefox) {
|
324
|
+
|
325
|
+
obj.canvas.oncontextmenu = function (e)
|
326
|
+
{
|
327
|
+
if (e.ctrlKey) return true;
|
328
|
+
|
329
|
+
RGraph.contextMenu(obj, obj.get('contextmenu'), e);
|
330
|
+
|
331
|
+
return false;
|
332
|
+
}
|
333
|
+
|
334
|
+
// Accomodate Opera and Safari - use double click event
|
335
|
+
} else {
|
336
|
+
|
337
|
+
obj.canvas.addEventListener('dblclick', function (e)
|
338
|
+
{
|
339
|
+
if (e.ctrlKey) return true;
|
340
|
+
|
341
|
+
if (!RGraph.Registry.get('contextmenu')) {
|
342
|
+
RGraph.contextMenu(obj, obj.get('contextmenu'), e);
|
343
|
+
}
|
344
|
+
}, false);
|
345
|
+
}
|
346
|
+
}
|
347
|
+
};
|
348
|
+
|
349
|
+
|
350
|
+
|
351
|
+
|
352
|
+
|
353
|
+
|
354
|
+
|
355
|
+
|
356
|
+
//
|
357
|
+
// This draws a submenu should it be necessary
|
358
|
+
//
|
359
|
+
// @param object obj The graph object
|
360
|
+
// @param object menu The context menu
|
361
|
+
//
|
362
|
+
RGraph.contextMenu_submenu = function ()
|
363
|
+
{
|
364
|
+
var args = RGraph.getArgs(arguments, 'object,menuitems,parentMenuItem'),
|
365
|
+
obj = args.object,
|
366
|
+
menuitems = args.menuitems,
|
367
|
+
parentMenuItem = args.parentMenuItem;
|
368
|
+
|
369
|
+
RGraph.hideContextSubmenu();
|
370
|
+
|
371
|
+
var canvas = obj.canvas;
|
372
|
+
var context = obj.context;
|
373
|
+
var menu = parentMenuItem.parentNode;
|
374
|
+
|
375
|
+
var subMenu = document.createElement('DIV');
|
376
|
+
subMenu.style.position = 'absolute';
|
377
|
+
subMenu.style.width = '100px';
|
378
|
+
subMenu.style.top = menu.offsetTop + parentMenuItem.offsetTop + 'px';
|
379
|
+
subMenu.style.left = (menu.offsetLeft + menu.offsetWidth - (RGraph.ISOLD ? 9 : 0)) + 'px';
|
380
|
+
subMenu.style.backgroundColor = 'white';
|
381
|
+
subMenu.style.border = '1px solid black';
|
382
|
+
subMenu.className = 'RGraph_contextmenu';
|
383
|
+
subMenu.__contextmenu__ = menu;
|
384
|
+
subMenu.style.lineHeight = 'initial';
|
385
|
+
subMenu.style.boxShadow = '3px 3px 3px rgba(96,96,96,0.5)';
|
386
|
+
subMenu.style.MozBoxShadow = '3px 3px 3px rgba(96,96,96,0.5)';
|
387
|
+
subMenu.style.WebkitBoxShadow = '3px 3px 3px rgba(96,96,96,0.5)';
|
388
|
+
subMenu.style.filter = 'progid:DXImageTransform.Microsoft.Shadow(color=#aaaaaa,direction=135)';
|
389
|
+
document.body.appendChild(subMenu);
|
390
|
+
|
391
|
+
for (var i=0; i<menuitems.length; ++i) {
|
392
|
+
|
393
|
+
var menuitem = document.createElement('DIV');
|
394
|
+
|
395
|
+
menuitem.__canvas__ = canvas;
|
396
|
+
menuitem.__contextmenu__ = menu;
|
397
|
+
menuitem.className = 'RGraph_contextmenu_item';
|
398
|
+
|
399
|
+
if (menuitems[i]) {
|
400
|
+
menuitem.style.padding = '2px 5px 2px 23px';
|
401
|
+
menuitem.style.fontFamily = 'Arial';
|
402
|
+
menuitem.style.fontSize = '10pt';
|
403
|
+
menuitem.style.fontWeight = 'normal';
|
404
|
+
menuitem.style.textAlign = 'left';
|
405
|
+
menuitem.innerHTML = menuitems[i][0];
|
406
|
+
|
407
|
+
if (menuitems[i][1]) {
|
408
|
+
if (menuitem.addEventListener) {
|
409
|
+
menuitem.addEventListener("mouseover", function (e) {e.target.style.backgroundColor = 'rgba(0,0,0,0.2)'; e.target.style.cursor = 'pointer';}, false);
|
410
|
+
menuitem.addEventListener("mouseout", function (e) {e.target.style.backgroundColor = 'inherit'; e.target.style.cursor = 'default';}, false);
|
411
|
+
} else {
|
412
|
+
menuitem.attachEvent("onmouseover", function () {event.srcElement.style.backgroundColor = 'rgba(0,0,0,0.2)'; event.srcElement.style.cursor = 'pointer'}, false);
|
413
|
+
menuitem.attachEvent("onmouseout", function () {event.srcElement.style.backgroundColor = 'inherit'; event.srcElement.style.cursor = 'default';}, false);
|
414
|
+
}
|
415
|
+
} else {
|
416
|
+
if (menuitem.addEventListener) {
|
417
|
+
menuitem.addEventListener("mouseover", function (e) {e.target.style.cursor = 'default';}, false);
|
418
|
+
menuitem.addEventListener("mouseout", function (e) {e.target.style.cursor = 'default';}, false);
|
419
|
+
} else {
|
420
|
+
menuitem.attachEvent("onmouseover", function () {event.srcElement.style.cursor = 'default'}, false);
|
421
|
+
menuitem.attachEvent("onmouseout", function () {event.srcElement.style.cursor = 'default';}, false);
|
422
|
+
}
|
423
|
+
}
|
424
|
+
} else {
|
425
|
+
menuitem.style.borderBottom = '1px solid #ddd';
|
426
|
+
menuitem.style.marginLeft = '25px';
|
427
|
+
}
|
428
|
+
|
429
|
+
subMenu.appendChild(menuitem);
|
430
|
+
|
431
|
+
if (menuitems[i] && menuitems[i][1]) {
|
432
|
+
if (document.all) {
|
433
|
+
menuitem.attachEvent('onclick', menuitems[i][1]);
|
434
|
+
} else {
|
435
|
+
menuitem.addEventListener('click', menuitems[i][1], false);
|
436
|
+
}
|
437
|
+
}
|
438
|
+
}
|
439
|
+
|
440
|
+
|
441
|
+
var bg = document.createElement('DIV');
|
442
|
+
bg.className = 'RGraph_contextmenu_background';
|
443
|
+
bg.style.position = 'absolute';
|
444
|
+
bg.style.backgroundColor = '#ccc';
|
445
|
+
bg.style.borderRight = '1px solid #aaa';
|
446
|
+
bg.style.top = 0;
|
447
|
+
bg.style.left = 0;
|
448
|
+
bg.style.width = '18px';
|
449
|
+
bg.style.height = '100%';
|
450
|
+
|
451
|
+
bg = subMenu.appendChild(bg);
|
452
|
+
|
453
|
+
RGraph.Registry.set('contextmenu.submenu', subMenu);
|
454
|
+
};
|
455
|
+
|
456
|
+
|
457
|
+
|
458
|
+
|
459
|
+
|
460
|
+
|
461
|
+
|
462
|
+
|
463
|
+
//
|
464
|
+
// A function designed to be used in conjunction with thed context menu
|
465
|
+
// to allow people to get image versions of canvases.
|
466
|
+
//
|
467
|
+
// @param canvas Optionally you can pass in the canvas, which will be used
|
468
|
+
//
|
469
|
+
RGraph.showPNG = function ()
|
470
|
+
{
|
471
|
+
if (RGraph.ISIE8) {
|
472
|
+
alert('[RGRAPH PNG] Sorry, showing a PNG is not supported on MSIE8.');
|
473
|
+
return;
|
474
|
+
}
|
475
|
+
|
476
|
+
if (arguments[0] && arguments[0].id) {
|
477
|
+
var canvas = arguments[0];
|
478
|
+
var event = arguments[1];
|
479
|
+
|
480
|
+
} else if (RGraph.Registry.get('contextmenu')) {
|
481
|
+
var canvas = RGraph.Registry.get('contextmenu').__canvas__;
|
482
|
+
|
483
|
+
} else {
|
484
|
+
alert('[RGRAPH SHOWPNG] Could not find canvas!');
|
485
|
+
}
|
486
|
+
|
487
|
+
var obj = canvas.__object__;
|
488
|
+
|
489
|
+
//
|
490
|
+
// Create the gray background DIV to cover the page
|
491
|
+
//
|
492
|
+
var bg = document.createElement('DIV');
|
493
|
+
bg.id = '__rgraph_image_bg__';
|
494
|
+
bg.style.position = 'fixed';
|
495
|
+
bg.style.top = '-10px';
|
496
|
+
bg.style.left = '-10px';
|
497
|
+
bg.style.width = '5000px';
|
498
|
+
bg.style.height = '5000px';
|
499
|
+
bg.style.backgroundColor = 'rgb(204,204,204)';
|
500
|
+
bg.style.opacity = 0;
|
501
|
+
document.body.appendChild(bg);
|
502
|
+
|
503
|
+
|
504
|
+
//
|
505
|
+
// Create the div that the graph sits in
|
506
|
+
//
|
507
|
+
var div = document.createElement('DIV');
|
508
|
+
div.style.backgroundColor = 'white';
|
509
|
+
div.style.opacity = 0;
|
510
|
+
div.style.border = '1px solid black';
|
511
|
+
div.style.position = 'fixed';
|
512
|
+
div.style.top = '20%';
|
513
|
+
div.style.width = canvas.width + 'px';
|
514
|
+
div.style.height = canvas.height + 35 + 'px';
|
515
|
+
div.style.left = (document.body.clientWidth / 2) - (canvas.width / 2) + 'px';
|
516
|
+
div.style.padding = '5px';
|
517
|
+
|
518
|
+
div.style.borderRadius = '10px';
|
519
|
+
div.style.MozBorderRadius = '10px';
|
520
|
+
div.style.WebkitBorderRadius = '10px';
|
521
|
+
|
522
|
+
div.style.boxShadow = '0 0 15px rgba(96,96,96,0.5)';
|
523
|
+
div.style.MozBoxShadow = '0 0 15px rgba(96,96,96,0.5)';
|
524
|
+
div.style.WebkitBoxShadow = 'rgba(96,96,96,0.5) 0 0 15px';
|
525
|
+
|
526
|
+
div.__canvas__ = canvas;
|
527
|
+
div.__object__ = obj;
|
528
|
+
div.id = '__rgraph_image_div__';
|
529
|
+
document.body.appendChild(div);
|
530
|
+
|
531
|
+
|
532
|
+
//
|
533
|
+
// Add the HTML text inputs
|
534
|
+
//
|
535
|
+
div.innerHTML += '<div id="rgraph_showpng_div_container"><textarea onclick="this.select()" readonly="readonly" id="__rgraph_dataurl__">' + canvas.toDataURL() + '</textarea></div>';
|
536
|
+
|
537
|
+
var nestedTextarea = document.getElementById('__rgraph_dataurl__');
|
538
|
+
nestedTextarea.style.overflow = 'hidden';
|
539
|
+
nestedTextarea.style.height = '20px';
|
540
|
+
nestedTextarea.style.width = (canvas.width - obj.marginLeft - obj.marginRight) + 'px';
|
541
|
+
nestedTextarea.style.position = 'relative';
|
542
|
+
nestedTextarea.style.left = obj.marginLeft + 'px';
|
543
|
+
|
544
|
+
var nestedDiv = document.getElementById('rgraph_showpng_div_container');
|
545
|
+
nestedDiv.style.position = 'absolute';
|
546
|
+
//nestedDiv.style.marginLeft = '10px';
|
547
|
+
nestedDiv.style.top = canvas.height + 'px';
|
548
|
+
nestedDiv.style.width = canvas.width + 'px';
|
549
|
+
nestedDiv.style.height = '25px';
|
550
|
+
|
551
|
+
|
552
|
+
|
553
|
+
//
|
554
|
+
// Create the image rendition of the graph
|
555
|
+
//
|
556
|
+
var img = document.createElement('IMG');
|
557
|
+
RGraph.Registry.set('png', img);
|
558
|
+
img.__canvas__ = canvas;
|
559
|
+
img.__object__ = obj;
|
560
|
+
img.id = '__rgraph_image_img__';
|
561
|
+
img.className = 'RGraph_png';
|
562
|
+
|
563
|
+
img.src = canvas.toDataURL();
|
564
|
+
|
565
|
+
div.appendChild(img);
|
566
|
+
|
567
|
+
setTimeout(function () {document.getElementById("__rgraph_dataurl__").select();}, 50);
|
568
|
+
|
569
|
+
window.addEventListener('resize', function (e){var img = RGraph.Registry.get('png');img.style.left = (document.body.clientWidth / 2) - (img.width / 2) + 'px';}, false);
|
570
|
+
|
571
|
+
bg.onclick = function (e)
|
572
|
+
{
|
573
|
+
var div = document.getElementById("__rgraph_image_div__");
|
574
|
+
var bg = document.getElementById("__rgraph_image_bg__");
|
575
|
+
|
576
|
+
if (div) {
|
577
|
+
div.style.opacity = 0;
|
578
|
+
|
579
|
+
div.parentNode.removeChild(div);
|
580
|
+
|
581
|
+
div.id = '';
|
582
|
+
div.style.display = 'none';
|
583
|
+
div = null;
|
584
|
+
}
|
585
|
+
|
586
|
+
if (bg) {
|
587
|
+
bg.style.opacity = 0;
|
588
|
+
|
589
|
+
bg.id = '';
|
590
|
+
bg.style.display = 'none';
|
591
|
+
bg = null;
|
592
|
+
}
|
593
|
+
}
|
594
|
+
|
595
|
+
window.addEventListener('resize', function (e) {bg.onclick(e);}, false)
|
596
|
+
|
597
|
+
//
|
598
|
+
// This sets the image BG and the DIV as global variables, circumventing repeated calls to document.getElementById()
|
599
|
+
//
|
600
|
+
RGraph.showpng_image_bg = bg;
|
601
|
+
RGraph.showpng_image_div = div;
|
602
|
+
|
603
|
+
setTimeout('RGraph.showpng_image_div.style.opacity = 0.2', 50);
|
604
|
+
setTimeout('RGraph.showpng_image_div.style.opacity = 0.4', 100);
|
605
|
+
setTimeout('RGraph.showpng_image_div.style.opacity = 0.6', 150);
|
606
|
+
setTimeout('RGraph.showpng_image_div.style.opacity = 0.8', 200);
|
607
|
+
setTimeout('RGraph.showpng_image_div.style.opacity = 1', 250);
|
608
|
+
|
609
|
+
setTimeout('RGraph.showpng_image_bg.style.opacity = 0.1', 50);
|
610
|
+
setTimeout('RGraph.showpng_image_bg.style.opacity = 0.2', 100);
|
611
|
+
setTimeout('RGraph.showpng_image_bg.style.opacity = 0.3', 150);
|
612
|
+
setTimeout('RGraph.showpng_image_bg.style.opacity = 0.4', 200);
|
613
|
+
setTimeout('RGraph.showpng_image_bg.style.opacity = 0.5', 250);
|
614
|
+
|
615
|
+
|
616
|
+
|
617
|
+
img.onclick = function (e)
|
618
|
+
{
|
619
|
+
if (e.stopPropagation) e.stopPropagation();
|
620
|
+
else event.cancelBubble = true;
|
621
|
+
}
|
622
|
+
|
623
|
+
if (event && event.stopPropagation) {
|
624
|
+
event.stopPropagation();
|
625
|
+
}
|
626
|
+
};
|
627
|
+
|
628
|
+
|
629
|
+
|
630
|
+
|
631
|
+
|
632
|
+
|
633
|
+
|
634
|
+
|
635
|
+
// End module pattern
|
636
|
+
})(window, document);
|