rgraph-rails 1.0.5 → 1.0.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +8 -8
- data/.travis.yml +0 -1
- data/README.md +3 -3
- data/lib/rgraph-rails/version.rb +1 -1
- data/vendor/assets/javascripts/RGraph.bar.js +239 -3764
- data/vendor/assets/javascripts/RGraph.bipolar.js +115 -1986
- data/vendor/assets/javascripts/RGraph.common.annotate.js +35 -399
- data/vendor/assets/javascripts/RGraph.common.context.js +30 -600
- data/vendor/assets/javascripts/RGraph.common.core.js +403 -5187
- data/vendor/assets/javascripts/RGraph.common.csv.js +19 -275
- data/vendor/assets/javascripts/RGraph.common.deprecated.js +35 -454
- data/vendor/assets/javascripts/RGraph.common.dynamic.js +84 -1189
- data/vendor/assets/javascripts/RGraph.common.effects.js +90 -1548
- data/vendor/assets/javascripts/RGraph.common.key.js +54 -755
- data/vendor/assets/javascripts/RGraph.common.resizing.js +37 -567
- data/vendor/assets/javascripts/RGraph.common.sheets.js +29 -356
- data/vendor/assets/javascripts/RGraph.common.tooltips.js +32 -614
- data/vendor/assets/javascripts/RGraph.common.zoom.js +14 -223
- data/vendor/assets/javascripts/RGraph.cornergauge.js +71 -0
- data/vendor/assets/javascripts/RGraph.drawing.background.js +35 -620
- data/vendor/assets/javascripts/RGraph.drawing.circle.js +35 -576
- data/vendor/assets/javascripts/RGraph.drawing.image.js +52 -807
- data/vendor/assets/javascripts/RGraph.drawing.marker1.js +41 -717
- data/vendor/assets/javascripts/RGraph.drawing.marker2.js +37 -668
- data/vendor/assets/javascripts/RGraph.drawing.marker3.js +36 -563
- data/vendor/assets/javascripts/RGraph.drawing.poly.js +40 -608
- data/vendor/assets/javascripts/RGraph.drawing.rect.js +35 -597
- data/vendor/assets/javascripts/RGraph.drawing.text.js +34 -642
- data/vendor/assets/javascripts/RGraph.drawing.xaxis.js +50 -809
- data/vendor/assets/javascripts/RGraph.drawing.yaxis.js +51 -856
- data/vendor/assets/javascripts/RGraph.fuel.js +58 -964
- data/vendor/assets/javascripts/RGraph.funnel.js +55 -984
- data/vendor/assets/javascripts/RGraph.gantt.js +75 -1241
- data/vendor/assets/javascripts/RGraph.gauge.js +87 -1397
- data/vendor/assets/javascripts/RGraph.hbar.js +143 -2376
- data/vendor/assets/javascripts/RGraph.hprogress.js +80 -1397
- data/vendor/assets/javascripts/RGraph.line.js +241 -4162
- data/vendor/assets/javascripts/RGraph.meter.js +74 -1278
- metadata +3 -30
- data/vendor/assets/images/bg.png +0 -0
- data/vendor/assets/images/bullet.png +0 -0
- data/vendor/assets/images/facebook-large.png +0 -0
- data/vendor/assets/images/google-plus-large.png +0 -0
- data/vendor/assets/images/logo.png +0 -0
- data/vendor/assets/images/meter-image-sd-needle.png +0 -0
- data/vendor/assets/images/meter-image-sd.png +0 -0
- data/vendor/assets/images/meter-sketch-needle.png +0 -0
- data/vendor/assets/images/meter-sketch.png +0 -0
- data/vendor/assets/images/odometer-background.png +0 -0
- data/vendor/assets/images/rgraph.jpg +0 -0
- data/vendor/assets/images/title.png +0 -0
- data/vendor/assets/images/twitter-large.png +0 -0
- data/vendor/assets/javascripts/RGraph.modaldialog.js +0 -301
- data/vendor/assets/javascripts/RGraph.odo.js +0 -1265
- data/vendor/assets/javascripts/RGraph.pie.js +0 -2272
- data/vendor/assets/javascripts/RGraph.radar.js +0 -1847
- data/vendor/assets/javascripts/RGraph.rose.js +0 -1877
- data/vendor/assets/javascripts/RGraph.rscatter.js +0 -1425
- data/vendor/assets/javascripts/RGraph.scatter.js +0 -2970
- data/vendor/assets/javascripts/RGraph.semicircularprogress.js +0 -1015
- data/vendor/assets/javascripts/RGraph.thermometer.js +0 -1129
- data/vendor/assets/javascripts/RGraph.vprogress.js +0 -1452
- data/vendor/assets/javascripts/RGraph.waterfall.js +0 -1252
- data/vendor/assets/javascripts/financial-data.js +0 -1067
- data/vendor/assets/stylesheets/ModalDialog.css +0 -90
- data/vendor/assets/stylesheets/animations.css +0 -3347
- data/vendor/assets/stylesheets/website.css +0 -446
@@ -1,568 +1,38 @@
|
|
1
|
-
// version: 2016-06-04
|
2
|
-
/**
|
3
|
-
* o--------------------------------------------------------------------------------o
|
4
|
-
* | This file is part of the RGraph package - you can learn more at: |
|
5
|
-
* | |
|
6
|
-
* | http://www.rgraph.net |
|
7
|
-
* | |
|
8
|
-
* | RGraph is dual licensed under the Open Source GPL (General Public License) |
|
9
|
-
* | v2.0 license and a commercial license which means that you're not bound by |
|
10
|
-
* | the terms of the GPL. The commercial license starts at just 99 GBP and |
|
11
|
-
* | you can read about it here: |
|
12
|
-
* | |
|
13
|
-
* | http://www.rgraph.net/license |
|
14
|
-
* o--------------------------------------------------------------------------------o
|
15
|
-
*/
|
16
1
|
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
(
|
21
|
-
{
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
// The size of the resize handle (so '15' isn't littered throughout the code)
|
62
|
-
var resizeHandleSize = 15;
|
63
|
-
|
64
|
-
|
65
|
-
// Add the original width and height to the canvas
|
66
|
-
if ( !ca.resizing.__rgraph_original_width__
|
67
|
-
|| !ca.resizing.__rgraph_original_height__
|
68
|
-
|| !ca.resizing.__adjustX
|
69
|
-
|| !ca.resizing.__adjustY
|
70
|
-
) {
|
71
|
-
|
72
|
-
ca.resizing.__rgraph_original_width__ = ca.width;
|
73
|
-
ca.resizing.__rgraph_original_height__ = ca.height;
|
74
|
-
ca.resizing.adjustX = (typeof obj.get('chart.resize.handle.adjust') == 'object' && typeof obj.get('chart.resize.handle.adjust')[0] == 'number' ? obj.Get('chart.resize.handle.adjust')[0] : 0);
|
75
|
-
ca.resizing.adjustY = (typeof obj.get('chart.resize.handle.adjust') == 'object' && typeof obj.get('chart.resize.handle.adjust')[1] == 'number' ? obj.Get('chart.resize.handle.adjust')[1] : 0);
|
76
|
-
ca.resizing.bgcolor = obj.get('chart.resize.handle.background') || 'rgba(0,0,0,0)';
|
77
|
-
}
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
// Draw the resize handle
|
83
|
-
pa2(co,
|
84
|
-
'b m % % r % % % % f %',
|
85
|
-
ca.width - resizeHandleSize - resizeHandleSize + ca.resizing.adjustX, ca.height - resizeHandleSize,
|
86
|
-
ca.width - resizeHandleSize - resizeHandleSize + ca.resizing.adjustX, ca.height - resizeHandleSize + ca.resizing.adjustY, 2 * resizeHandleSize, resizeHandleSize,
|
87
|
-
ca.resizing.bgcolor
|
88
|
-
);
|
89
|
-
|
90
|
-
// Draw the arrows
|
91
|
-
pa2(co,
|
92
|
-
'b lw 1 m % % l % % m % % l % % s gray f transparent',
|
93
|
-
ma.round(ca.width - (resizeHandleSize / 2) + ca.resizing.adjustX), ca.height - resizeHandleSize + ca.resizing.adjustY,
|
94
|
-
ma.round(ca.width - (resizeHandleSize / 2) + ca.resizing.adjustX), ca.height + ca.resizing.adjustY,
|
95
|
-
ca.width + ca.resizing.adjustX, ma.round(ca.height - (resizeHandleSize / 2) + ca.resizing.adjustY),
|
96
|
-
ca.width - resizeHandleSize + ca.resizing.adjustX, ma.round(ca.height - (resizeHandleSize / 2) + ca.resizing.adjustY)
|
97
|
-
);
|
98
|
-
|
99
|
-
// Top arrow head
|
100
|
-
pa2(co, [ 'b', 'm', ca.width - (resizeHandleSize / 2) + ca.resizing.adjustX, ca.height - resizeHandleSize + ca.resizing.adjustY, 'l',ca.width - (resizeHandleSize / 2) + 3 + ca.resizing.adjustX, ca.height - resizeHandleSize + 3 + ca.resizing.adjustY, 'l',ca.width - (resizeHandleSize / 2) - 3 + ca.resizing.adjustX, ca.height - resizeHandleSize + 3 + ca.resizing.adjustY, 'c', 'f','gray']);
|
101
|
-
|
102
|
-
// Bottom arrow head
|
103
|
-
pa2(co, ['b','m', ca.width - (resizeHandleSize / 2) + ca.resizing.adjustX, ca.height + ca.resizing.adjustY,'l', ca.width - (resizeHandleSize / 2) + 3 + ca.resizing.adjustX, ca.height - 3 + ca.resizing.adjustY,'l', ca.width - (resizeHandleSize / 2) - 3 + ca.resizing.adjustX, ca.height - 3 + ca.resizing.adjustY,'c','f', 'gray']);
|
104
|
-
|
105
|
-
// Left arrow head
|
106
|
-
pa2(co, ['b','m', ca.width - resizeHandleSize + ca.resizing.adjustX, ca.height - (resizeHandleSize / 2) + ca.resizing.adjustY,'l', ca.width - resizeHandleSize + 3 + ca.resizing.adjustX, ca.height - (resizeHandleSize / 2) + 3 + ca.resizing.adjustY,'l', ca.width - resizeHandleSize + 3 + ca.resizing.adjustX, ca.height - (resizeHandleSize / 2) - 3 + ca.resizing.adjustY,'c','f', 'gray']);
|
107
|
-
|
108
|
-
// Right arrow head
|
109
|
-
pa2(co, ['b','m',ca.width + ca.resizing.adjustX, ca.height - (resizeHandleSize / 2) + ca.resizing.adjustY,'l',ca.width - 3 + ca.resizing.adjustX, ca.height - (resizeHandleSize / 2) + 3 + ca.resizing.adjustY,'l',ca.width - 3 + ca.resizing.adjustX, ca.height - (resizeHandleSize / 2) - 3 + ca.resizing.adjustY,'c','f', 'gray']);
|
110
|
-
|
111
|
-
// Square at the centre of the arrows
|
112
|
-
pa2(co, ['b','m',ca.width + ca.resizing.adjustX, ca.height - (resizeHandleSize / 2) + ca.resizing.adjustY,'r',ca.width - (resizeHandleSize / 2) - 2 + ca.resizing.adjustX, ca.height - (resizeHandleSize / 2) - 2 + ca.resizing.adjustY, 4, 4,'r',ca.width - (resizeHandleSize / 2) - 2 + ca.resizing.adjustX, ca.height - (resizeHandleSize / 2) - 2 + ca.resizing.adjustY, 4, 4,'s','gray','f','white']);
|
113
|
-
|
114
|
-
// Draw the "Reset" button
|
115
|
-
pa2(co, ['b','m',ma.round(ca.width - resizeHandleSize - 3 + ca.resizing.adjustX), ca.height - resizeHandleSize / 2 + ca.resizing.adjustY,'l',ma.round(ca.width - resizeHandleSize - resizeHandleSize + ca.resizing.adjustX), ca.height - (resizeHandleSize / 2) + ca.resizing.adjustY,'l',ca.width - resizeHandleSize - resizeHandleSize + 2 + ca.resizing.adjustX, ca.height - (resizeHandleSize / 2) - 2 + ca.resizing.adjustY,'l',ca.width - resizeHandleSize - resizeHandleSize + 2 + ca.resizing.adjustX, ca.height - (resizeHandleSize / 2) + 2 + ca.resizing.adjustY,'l',ca.width - resizeHandleSize - resizeHandleSize + ca.resizing.adjustX, ca.height - (resizeHandleSize / 2) + ca.resizing.adjustY,'s','gray','f','gray']);
|
116
|
-
|
117
|
-
// The vertical line at the end of the reset button
|
118
|
-
pa2(co, ['b','m', ma.round(ca.width - resizeHandleSize - resizeHandleSize - 1 + ca.resizing.adjustX), ca.height - (resizeHandleSize / 2) - 3 + ca.resizing.adjustY,'l', ma.round(ca.width - resizeHandleSize - resizeHandleSize - 1 + ca.resizing.adjustX), ca.height - (resizeHandleSize / 2) + 3 + ca.resizing.adjustY,'s','f']);
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
/**
|
127
|
-
* The code inside this if() condition only runs once due to the if() condition tests- if
|
128
|
-
* the obj.rgraphResizewrapper variable exists then the code has run
|
129
|
-
*/
|
130
|
-
if (obj.get('chart.resizable') && !ca.rgraphResizewrapper) {
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
// ** TODO ** Needs fixing
|
135
|
-
//
|
136
|
-
//
|
137
|
-
// Wrap the canvas
|
138
|
-
// ** NEEDS FIXING **
|
139
|
-
//
|
140
|
-
ca.rgraphResizewrapper = $('<div id="rgraph_resize_container_' + ca.id +'"></div>').css({
|
141
|
-
'float': ca.style.cssFloat,
|
142
|
-
position: 'relative'
|
143
|
-
}).get(0);
|
144
|
-
|
145
|
-
$(ca).wrap(ca.rgraphResizewrapper);
|
146
|
-
|
147
|
-
// TODO Might need to add more properties here (eg margin, padding etc)
|
148
|
-
ca.style.cssFloat = 'none';
|
149
|
-
ca.style.top = 0;
|
150
|
-
ca.style.left = 0;
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
var window_onmousemove = function (e)
|
155
|
-
{
|
156
|
-
var ca = active,
|
157
|
-
obj = ca ? ca.__object__ : null;
|
158
|
-
|
159
|
-
if (ca) {
|
160
|
-
|
161
|
-
e = RG.fixEventObject(e);
|
162
|
-
|
163
|
-
if (ca.resizing.mousedown) {
|
164
|
-
|
165
|
-
var newWidth = ca.width + (e.pageX - ca.resizing.originalx);
|
166
|
-
var newHeight = ca.height + (e.pageY - ca.resizing.originaly);
|
167
|
-
|
168
|
-
if ( newWidth > (ca.resizing.originalw / 2)
|
169
|
-
&& (typeof obj.get('resizableMaxwidth') === 'number' ? newWidth < obj.get('resizableMaxwidth') : true)
|
170
|
-
) {
|
171
|
-
ca.resizing.div.style.width = newWidth + 'px';
|
172
|
-
}
|
173
|
-
|
174
|
-
if (newHeight > (ca.resizing.originalh / 2) && (typeof obj.get('resizableMaxheight') === 'number' ? newHeight < obj.get('resizableMaxheight') : true) ) {
|
175
|
-
ca.resizing.div.style.height = newHeight + 'px';
|
176
|
-
}
|
177
|
-
|
178
|
-
RG.fireCustomEvent(ca.__object__, 'onresize');
|
179
|
-
}
|
180
|
-
}
|
181
|
-
}
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
// Install the function as an event listener - but only once
|
186
|
-
if (typeof ca.rgraph_resize_window_mousemove_listener_installed != 'boolean') {
|
187
|
-
window.addEventListener('mousemove', window_onmousemove, false);
|
188
|
-
ca.rgraph_resize_window_mousemove_listener_installed = true;
|
189
|
-
}
|
190
|
-
|
191
|
-
// The window onmouseup function
|
192
|
-
var MouseupFunc = function (e)
|
193
|
-
{
|
194
|
-
if (!ca.resizing || !ca.resizing.div || !ca.resizing.mousedown) {
|
195
|
-
return;
|
196
|
-
}
|
197
|
-
|
198
|
-
if (ca.resizing.div) {
|
199
|
-
|
200
|
-
var div = ca.resizing.div;
|
201
|
-
var coords = RG.getCanvasXY(ca);
|
202
|
-
|
203
|
-
var parentNode = ca.parentNode;
|
204
|
-
|
205
|
-
if (ca.style.position != 'absolute') {
|
206
|
-
|
207
|
-
// Create a DIV to go in the canvases place
|
208
|
-
var placeHolderDIV = document.createElement('DIV');
|
209
|
-
placeHolderDIV.style.width = ca.resizing.originalw + 'px';
|
210
|
-
placeHolderDIV.style.height = ca.resizing.originalh + 'px';
|
211
|
-
|
212
|
-
placeHolderDIV.style.display = 'inline-block'; // Added 5th Nov 2010
|
213
|
-
placeHolderDIV.style.position = ca.style.position;
|
214
|
-
placeHolderDIV.style.left = ca.style.left;
|
215
|
-
placeHolderDIV.style.top = ca.style.top;
|
216
|
-
placeHolderDIV.style.cssFloat = ca.style.cssFloat;
|
217
|
-
|
218
|
-
parentNode.insertBefore(placeHolderDIV, ca);
|
219
|
-
}
|
220
|
-
|
221
|
-
|
222
|
-
// Now set the canvas to be positioned absolutely
|
223
|
-
ca.style.backgroundColor = 'white';
|
224
|
-
ca.style.position = 'absolute';
|
225
|
-
ca.style.border = '1px dashed gray';
|
226
|
-
ca.style.boxShadow = '2px 2px 5px #ddd';
|
227
|
-
|
228
|
-
|
229
|
-
ca.style.left = 0;//(ca.resizing.originalCanvasX - 2) + 'px';
|
230
|
-
ca.style.top = 0;//(ca.resizing.originalCanvasY - 2) + 'px';
|
231
|
-
|
232
|
-
|
233
|
-
// Set the dimensions of the canvas using the HTML attributes
|
234
|
-
ca.width = parseInt(div.style.width);
|
235
|
-
ca.height = parseInt(div.style.height);
|
236
|
-
|
237
|
-
|
238
|
-
|
239
|
-
|
240
|
-
// Because resizing the canvas resets any tranformation - the antialias fix needs to be reapplied.
|
241
|
-
ca.getContext('2d').translate(0.5,0.5);
|
242
|
-
|
243
|
-
|
244
|
-
|
245
|
-
// Reset the gradient parsing status by setting all of the color values back to their original
|
246
|
-
// values before Draw was first called
|
247
|
-
var objects = RG.ObjectRegistry.getObjectsByCanvasID(ca.id);
|
248
|
-
for (var i=0,len=objects.length; i<len; i+=1) {
|
249
|
-
|
250
|
-
RG.resetColorsToOriginalValues(objects[i]);
|
251
|
-
if (typeof objects[i].reset === 'function') {
|
252
|
-
objects[i].reset();
|
253
|
-
}
|
254
|
-
}
|
255
|
-
|
256
|
-
|
257
|
-
|
258
|
-
|
259
|
-
// Kill the background cache
|
260
|
-
RG.cache = [];
|
261
|
-
|
262
|
-
|
263
|
-
// Fire the onresize event
|
264
|
-
RG.fireCustomEvent(ca.__object__, 'onresizebeforedraw');
|
265
|
-
|
266
|
-
RG.redrawCanvas(ca);
|
267
|
-
|
268
|
-
|
269
|
-
// Get rid of transparent semi-opaque DIV
|
270
|
-
ca.resizing.mousedown = false;
|
271
|
-
div.style.display = 'none';
|
272
|
-
document.body.removeChild(div);
|
273
|
-
}
|
274
|
-
|
275
|
-
|
276
|
-
// If there is zoom enabled in thumbnail mode, lose the zoom image
|
277
|
-
if (RG.Registry.Get('chart.zoomed.div') || RGraph.Registry.Get('chart.zoomed.img')) {
|
278
|
-
RG.Registry.Set('chart.zoomed.div', null);
|
279
|
-
RG.Registry.Set('chart.zoomed.img', null);
|
280
|
-
}
|
281
|
-
|
282
|
-
|
283
|
-
// Fire the onresize event
|
284
|
-
RG.FireCustomEvent(ca.__object__, 'onresizeend');
|
285
|
-
};
|
286
|
-
|
287
|
-
|
288
|
-
var window_onmouseup = MouseupFunc;
|
289
|
-
|
290
|
-
// Install the function as an event listener - but only once
|
291
|
-
if (typeof ca.rgraph_resize_window_mouseup_listener_installed != 'boolean') {
|
292
|
-
window.addEventListener('mouseup', window_onmouseup, false);
|
293
|
-
ca.rgraph_resize_window_mouseup_listener_installed = true;
|
294
|
-
}
|
295
|
-
|
296
|
-
|
297
|
-
|
298
|
-
|
299
|
-
|
300
|
-
|
301
|
-
|
302
|
-
|
303
|
-
|
304
|
-
|
305
|
-
|
306
|
-
|
307
|
-
|
308
|
-
|
309
|
-
|
310
|
-
|
311
|
-
|
312
|
-
|
313
|
-
|
314
|
-
|
315
|
-
|
316
|
-
|
317
|
-
|
318
|
-
|
319
|
-
|
320
|
-
|
321
|
-
|
322
|
-
|
323
|
-
var canvas_onmousemove = function (e)
|
324
|
-
{
|
325
|
-
|
326
|
-
e = RG.fixEventObject(e);
|
327
|
-
|
328
|
-
var coords = RG.getMouseXY(e);
|
329
|
-
var obj = e.target.__object__;
|
330
|
-
var ca = e.target;
|
331
|
-
var co = ca.getContext('2d');
|
332
|
-
var cursor = ca.style.cursor;
|
333
|
-
|
334
|
-
// Save the original cursor
|
335
|
-
if (!ca.resizing.original_cursor) {
|
336
|
-
ca.resizing.original_cursor = cursor;
|
337
|
-
}
|
338
|
-
|
339
|
-
if ( (coords[0] > (ca.width - resizeHandleSize)
|
340
|
-
&& coords[0] < ca.width
|
341
|
-
&& coords[1] > (ca.height - resizeHandleSize)
|
342
|
-
&& coords[1] < ca.height)) {
|
343
|
-
|
344
|
-
ca.style.cursor = 'move';
|
345
|
-
|
346
|
-
} else if ( coords[0] > (ca.width - resizeHandleSize - resizeHandleSize)
|
347
|
-
&& coords[0] < ca.width - resizeHandleSize
|
348
|
-
&& coords[1] > (ca.height - resizeHandleSize)
|
349
|
-
&& coords[1] < ca.height) {
|
350
|
-
|
351
|
-
ca.style.cursor = 'pointer';
|
352
|
-
|
353
|
-
} else {
|
354
|
-
if (ca.resizing.original_cursor) {
|
355
|
-
ca.style.cursor = ca.resizing.original_cursor;
|
356
|
-
ca.resizing.original_cursor = null;
|
357
|
-
} else {
|
358
|
-
ca.style.cursor = 'default';
|
359
|
-
}
|
360
|
-
}
|
361
|
-
};
|
362
|
-
|
363
|
-
|
364
|
-
|
365
|
-
|
366
|
-
|
367
|
-
// Install the function as an event listener - but only once
|
368
|
-
if (typeof ca.rgraph_resize_mousemove_listener_installed != 'boolean') {
|
369
|
-
ca.addEventListener('mousemove', canvas_onmousemove, false);
|
370
|
-
ca.rgraph_resize_mousemove_listener_installed = true;
|
371
|
-
}
|
372
|
-
|
373
|
-
|
374
|
-
|
375
|
-
|
376
|
-
|
377
|
-
var canvas_onmouseout = function (e)
|
378
|
-
{
|
379
|
-
e.target.style.cursor = 'default';
|
380
|
-
e.target.title = '';
|
381
|
-
};
|
382
|
-
|
383
|
-
// Install the function as an event listener - but only once
|
384
|
-
if (typeof ca.rgraph_resize_mouseout_listener_installed != 'boolean') {
|
385
|
-
ca.addEventListener('mouseout', canvas_onmouseout, false);
|
386
|
-
ca.rgraph_resize_mouseout_listener_installed = true;
|
387
|
-
}
|
388
|
-
|
389
|
-
|
390
|
-
|
391
|
-
|
392
|
-
|
393
|
-
var canvas_onmousedown = function (e)
|
394
|
-
{
|
395
|
-
e = RG.fixEventObject(e);
|
396
|
-
|
397
|
-
var coords = RG.getMouseXY(e);
|
398
|
-
var canvasXY = RG.getCanvasXY(e.target);
|
399
|
-
var ca = e.target;
|
400
|
-
|
401
|
-
/**
|
402
|
-
* Set the active variable to the last canvas that was clicked on
|
403
|
-
*/
|
404
|
-
active = ca;
|
405
|
-
|
406
|
-
|
407
|
-
|
408
|
-
|
409
|
-
|
410
|
-
|
411
|
-
if ( coords[0] > (ca.width - resizeHandleSize)
|
412
|
-
&& coords[0] < ca.width
|
413
|
-
&& coords[1] > (ca.height - resizeHandleSize)
|
414
|
-
&& coords[1] < ca.height) {
|
415
|
-
|
416
|
-
RG.fireCustomEvent(obj, 'onresizebegin');
|
417
|
-
|
418
|
-
// Save the existing border
|
419
|
-
if (ca.resizing.original_css_border == null) {
|
420
|
-
ca.resizing.original_css_border = ca.style.border;
|
421
|
-
}
|
422
|
-
|
423
|
-
// Save the existing shadow
|
424
|
-
if (ca.resizing.original_css_shadow == null) {
|
425
|
-
ca.resizing.original_css_shadow = ca.style.boxShadow;
|
426
|
-
}
|
427
|
-
|
428
|
-
ca.resizing.mousedown = true;
|
429
|
-
|
430
|
-
|
431
|
-
// Create the semi-opaque DIV
|
432
|
-
var div = document.createElement('DIV');
|
433
|
-
div.style.position = 'absolute';
|
434
|
-
div.style.left = canvasXY[0] + 'px';
|
435
|
-
div.style.top = canvasXY[1] + 'px';
|
436
|
-
div.style.width = ca.width + 'px';
|
437
|
-
div.style.height = ca.height + 'px';
|
438
|
-
div.style.border = '1px dotted black';
|
439
|
-
div.style.backgroundColor = 'gray';
|
440
|
-
div.style.opacity = 0.5;
|
441
|
-
div.__canvas__ = e.target;
|
442
|
-
document.body.appendChild(div);
|
443
|
-
|
444
|
-
ca.resizing.div = div;
|
445
|
-
ca.resizing.placeHolders.push(div);
|
446
|
-
|
447
|
-
// Hide the previous resize indicator layers. This is only necessary it seems for the Meter chart
|
448
|
-
for (var i=0; i<(ca.resizing.placeHolders.length - 1); ++i) {
|
449
|
-
ca.resizing.placeHolders[i].style.display = 'none';
|
450
|
-
}
|
451
|
-
|
452
|
-
// This is a repetition of the window.onmouseup function (No need to use DOM2 here)
|
453
|
-
div.onmouseup = function (e)
|
454
|
-
{
|
455
|
-
MouseupFunc(e);
|
456
|
-
}
|
457
|
-
|
458
|
-
|
459
|
-
// No need to use DOM2 here
|
460
|
-
ca.resizing.div.onmouseover = function (e)
|
461
|
-
{
|
462
|
-
e = RG.fixEventObject(e);
|
463
|
-
e.stopPropagation();
|
464
|
-
}
|
465
|
-
|
466
|
-
// The mouse
|
467
|
-
ca.resizing.originalx = e.pageX;
|
468
|
-
ca.resizing.originaly = e.pageY;
|
469
|
-
|
470
|
-
ca.resizing.originalCanvasX = RG.getCanvasXY(ca)[0];
|
471
|
-
ca.resizing.originalCanvasY = RG.getCanvasXY(ca)[1];
|
472
|
-
}
|
473
|
-
|
474
|
-
// This facilitates the reset button
|
475
|
-
if ( coords[0] > (ca.width - resizeHandleSize - resizeHandleSize)
|
476
|
-
&& coords[0] < ca.width - resizeHandleSize
|
477
|
-
&& coords[1] > (ca.height - resizeHandleSize)
|
478
|
-
&& coords[1] < ca.height
|
479
|
-
&& ca.resizing.originalw
|
480
|
-
&& ca.resizing.originaly) {
|
481
|
-
|
482
|
-
|
483
|
-
// Fire the onresizebegin event
|
484
|
-
RG.fireCustomEvent(ca.__object__, 'onresizebegin');
|
485
|
-
|
486
|
-
// Restore the original width and height
|
487
|
-
ca.width = ca.resizing.originalw;
|
488
|
-
ca.height = ca.resizing.originalh;
|
489
|
-
|
490
|
-
// TODO Need to check the parent is actually a DIV container or not?
|
491
|
-
|
492
|
-
// Show the link if it exists and the display is set to none
|
493
|
-
if (ca.__link__ && ca.__link__.style.display === 'none') {
|
494
|
-
ca.__link__.style.display = 'inline';
|
495
|
-
}
|
496
|
-
|
497
|
-
if (typeof ca.parentNode.id === 'string' && ca.parentNode.id.substring(0, 24) === 'rgraph_resize_container_') {
|
498
|
-
ca.parentNode.style.width = ca.resizing.originalw + 'px';
|
499
|
-
ca.parentNode.style.height = ca.resizing.originalh + 'px';
|
500
|
-
}
|
501
|
-
|
502
|
-
// Lose the border
|
503
|
-
ca.style.border = ca.resizing.original_css_border;
|
504
|
-
|
505
|
-
//Lose the shadow
|
506
|
-
ca.style.boxShadow = ca.resizing.original_css_shadow;
|
507
|
-
|
508
|
-
|
509
|
-
// Add 1 pixel to the top/left because the border is going
|
510
|
-
ca.style.left = (parseInt(ca.style.left)) + 'px';
|
511
|
-
ca.style.top = (parseInt(ca.style.top)) + 'px';
|
512
|
-
|
513
|
-
|
514
|
-
|
515
|
-
// Because resetting the canvas resizes it - and so loses any translation - need to reapply the
|
516
|
-
// antialiasing translation
|
517
|
-
ca.getContext('2d').translate(0.5,0.5);
|
518
|
-
|
519
|
-
|
520
|
-
RG.fireCustomEvent(ca.__object__, 'onresizebeforedraw');
|
521
|
-
|
522
|
-
// Since gradients are pre-parsed colors - this resets the colors to what they were
|
523
|
-
// before the parsing.
|
524
|
-
var objects = RG.ObjectRegistry.getObjectsByCanvasID(ca.id);
|
525
|
-
for (var i=0; i<objects.length; i+=1) {
|
526
|
-
RG.resetColorsToOriginalValues(objects[i]);
|
527
|
-
if (objects[i].reset) {
|
528
|
-
objects[i].reset();
|
529
|
-
}
|
530
|
-
|
531
|
-
RG.redrawCanvas(objects[i].canvas);
|
532
|
-
}
|
533
|
-
|
534
|
-
|
535
|
-
// Clear the cache so that old things (eg backgrounds) are not reused
|
536
|
-
RG.cache = [];
|
537
|
-
|
538
|
-
|
539
|
-
|
540
|
-
|
541
|
-
|
542
|
-
|
543
|
-
// Redraw the canvas
|
544
|
-
//RG.redrawCanvas(objects[i].canvas);
|
545
|
-
|
546
|
-
|
547
|
-
// Set the width and height on the DIV
|
548
|
-
if (ca.resizing.div) {
|
549
|
-
ca.resizing.div.style.width = ca.__original_width__ + 'px';
|
550
|
-
ca.resizing.div.style.height = ca.__original_height__ + 'px';
|
551
|
-
}
|
552
|
-
|
553
|
-
|
554
|
-
// Fire the resize event
|
555
|
-
RG.fireCustomEvent(ca.__object__, 'onresize');
|
556
|
-
RG.fireCustomEvent(ca.__object__, 'onresizeend');
|
557
|
-
}
|
558
|
-
};
|
559
|
-
|
560
|
-
// Install the function as an event listener - but only once
|
561
|
-
if (typeof ca.rgraph_resize_mousedown_listener_installed != 'boolean') {
|
562
|
-
ca.addEventListener('mousedown', canvas_onmousedown, false);
|
563
|
-
ca.rgraph_resize_mousedown_listener_installed = true;
|
564
|
-
}
|
565
|
-
}
|
566
|
-
};
|
567
|
-
// End module pattern
|
568
|
-
})(window, document);
|
2
|
+
RGraph=window.RGraph||{isRGraph:true};(function(win,doc,undefined)
|
3
|
+
{var RG=RGraph,ua=navigator.userAgent,ma=Math,active=null;RGraph.allowResizing=RGraph.AllowResizing=function(obj)
|
4
|
+
{var ca=obj.canvas,co=obj.context,pa2=RG.path2;ca.resizing=ca.resizing||{};ca.resizing.placeHolders=ca.resizing.placeHolders||[];if(!ca.resizing.originalw){ca.resizing.originalw=ca.width;}
|
5
|
+
if(!ca.resizing.originalh){ca.resizing.originalh=ca.height;}
|
6
|
+
var resizeHandleSize=15;if(!ca.resizing.__rgraph_original_width__||!ca.resizing.__rgraph_original_height__||!ca.resizing.__adjustX||!ca.resizing.__adjustY){ca.resizing.__rgraph_original_width__=ca.width;ca.resizing.__rgraph_original_height__=ca.height;ca.resizing.adjustX=(typeof obj.get('chart.resize.handle.adjust')=='object'&&typeof obj.get('chart.resize.handle.adjust')[0]=='number'?obj.Get('chart.resize.handle.adjust')[0]:0);ca.resizing.adjustY=(typeof obj.get('chart.resize.handle.adjust')=='object'&&typeof obj.get('chart.resize.handle.adjust')[1]=='number'?obj.Get('chart.resize.handle.adjust')[1]:0);ca.resizing.bgcolor=obj.get('chart.resize.handle.background')||'rgba(0,0,0,0)';}
|
7
|
+
pa2(co,'b m % % r % % % % f %',ca.width-resizeHandleSize-resizeHandleSize+ca.resizing.adjustX,ca.height-resizeHandleSize,ca.width-resizeHandleSize-resizeHandleSize+ca.resizing.adjustX,ca.height-resizeHandleSize+ca.resizing.adjustY,2*resizeHandleSize,resizeHandleSize,ca.resizing.bgcolor);pa2(co,'b lw 1 m % % l % % m % % l % % s gray f transparent',ma.round(ca.width-(resizeHandleSize/2)+ca.resizing.adjustX),ca.height-resizeHandleSize+ca.resizing.adjustY,ma.round(ca.width-(resizeHandleSize/2)+ca.resizing.adjustX),ca.height+ca.resizing.adjustY,ca.width+ca.resizing.adjustX,ma.round(ca.height-(resizeHandleSize/2)+ca.resizing.adjustY),ca.width-resizeHandleSize+ca.resizing.adjustX,ma.round(ca.height-(resizeHandleSize/2)+ca.resizing.adjustY));pa2(co,['b','m',ca.width-(resizeHandleSize/2)+ca.resizing.adjustX,ca.height-resizeHandleSize+ca.resizing.adjustY,'l',ca.width-(resizeHandleSize/2)+3+ca.resizing.adjustX,ca.height-resizeHandleSize+3+ca.resizing.adjustY,'l',ca.width-(resizeHandleSize/2)-3+ca.resizing.adjustX,ca.height-resizeHandleSize+3+ca.resizing.adjustY,'c','f','gray']);pa2(co,['b','m',ca.width-(resizeHandleSize/2)+ca.resizing.adjustX,ca.height+ca.resizing.adjustY,'l',ca.width-(resizeHandleSize/2)+3+ca.resizing.adjustX,ca.height-3+ca.resizing.adjustY,'l',ca.width-(resizeHandleSize/2)-3+ca.resizing.adjustX,ca.height-3+ca.resizing.adjustY,'c','f','gray']);pa2(co,['b','m',ca.width-resizeHandleSize+ca.resizing.adjustX,ca.height-(resizeHandleSize/2)+ca.resizing.adjustY,'l',ca.width-resizeHandleSize+3+ca.resizing.adjustX,ca.height-(resizeHandleSize/2)+3+ca.resizing.adjustY,'l',ca.width-resizeHandleSize+3+ca.resizing.adjustX,ca.height-(resizeHandleSize/2)-3+ca.resizing.adjustY,'c','f','gray']);pa2(co,['b','m',ca.width+ca.resizing.adjustX,ca.height-(resizeHandleSize/2)+ca.resizing.adjustY,'l',ca.width-3+ca.resizing.adjustX,ca.height-(resizeHandleSize/2)+3+ca.resizing.adjustY,'l',ca.width-3+ca.resizing.adjustX,ca.height-(resizeHandleSize/2)-3+ca.resizing.adjustY,'c','f','gray']);pa2(co,['b','m',ca.width+ca.resizing.adjustX,ca.height-(resizeHandleSize/2)+ca.resizing.adjustY,'r',ca.width-(resizeHandleSize/2)-2+ca.resizing.adjustX,ca.height-(resizeHandleSize/2)-2+ca.resizing.adjustY,4,4,'r',ca.width-(resizeHandleSize/2)-2+ca.resizing.adjustX,ca.height-(resizeHandleSize/2)-2+ca.resizing.adjustY,4,4,'s','gray','f','white']);pa2(co,['b','m',ma.round(ca.width-resizeHandleSize-3+ca.resizing.adjustX),ca.height-resizeHandleSize/2+ca.resizing.adjustY,'l',ma.round(ca.width-resizeHandleSize-resizeHandleSize+ca.resizing.adjustX),ca.height-(resizeHandleSize/2)+ca.resizing.adjustY,'l',ca.width-resizeHandleSize-resizeHandleSize+2+ca.resizing.adjustX,ca.height-(resizeHandleSize/2)-2+ca.resizing.adjustY,'l',ca.width-resizeHandleSize-resizeHandleSize+2+ca.resizing.adjustX,ca.height-(resizeHandleSize/2)+2+ca.resizing.adjustY,'l',ca.width-resizeHandleSize-resizeHandleSize+ca.resizing.adjustX,ca.height-(resizeHandleSize/2)+ca.resizing.adjustY,'s','gray','f','gray']);pa2(co,['b','m',ma.round(ca.width-resizeHandleSize-resizeHandleSize-1+ca.resizing.adjustX),ca.height-(resizeHandleSize/2)-3+ca.resizing.adjustY,'l',ma.round(ca.width-resizeHandleSize-resizeHandleSize-1+ca.resizing.adjustX),ca.height-(resizeHandleSize/2)+3+ca.resizing.adjustY,'s','f']);if(obj.get('chart.resizable')&&!ca.rgraphResizewrapper){ca.rgraphResizewrapper=$('<div id="rgraph_resize_container_'+ca.id+'"></div>').css({'float':ca.style.cssFloat,position:'relative'}).get(0);$(ca).wrap(ca.rgraphResizewrapper);ca.style.cssFloat='none';ca.style.top=0;ca.style.left=0;var window_onmousemove=function(e)
|
8
|
+
{var ca=active,obj=ca?ca.__object__:null;if(ca){e=RG.fixEventObject(e);if(ca.resizing.mousedown){var newWidth=ca.width+(e.pageX-ca.resizing.originalx);var newHeight=ca.height+(e.pageY-ca.resizing.originaly);if(newWidth>(ca.resizing.originalw/2)&&(typeof obj.get('resizableMaxwidth')==='number'?newWidth<obj.get('resizableMaxwidth'):true)){ca.resizing.div.style.width=newWidth+'px';}
|
9
|
+
if(newHeight>(ca.resizing.originalh/2)&&(typeof obj.get('resizableMaxheight')==='number'?newHeight<obj.get('resizableMaxheight'):true)){ca.resizing.div.style.height=newHeight+'px';}
|
10
|
+
RG.fireCustomEvent(ca.__object__,'onresize');}}}
|
11
|
+
if(typeof ca.rgraph_resize_window_mousemove_listener_installed!='boolean'){window.addEventListener('mousemove',window_onmousemove,false);ca.rgraph_resize_window_mousemove_listener_installed=true;}
|
12
|
+
var MouseupFunc=function(e)
|
13
|
+
{if(!ca.resizing||!ca.resizing.div||!ca.resizing.mousedown){return;}
|
14
|
+
if(ca.resizing.div){var div=ca.resizing.div;var coords=RG.getCanvasXY(ca);var parentNode=ca.parentNode;if(ca.style.position!='absolute'){var placeHolderDIV=document.createElement('DIV');placeHolderDIV.style.width=ca.resizing.originalw+'px';placeHolderDIV.style.height=ca.resizing.originalh+'px';placeHolderDIV.style.display='inline-block';placeHolderDIV.style.position=ca.style.position;placeHolderDIV.style.left=ca.style.left;placeHolderDIV.style.top=ca.style.top;placeHolderDIV.style.cssFloat=ca.style.cssFloat;parentNode.insertBefore(placeHolderDIV,ca);}
|
15
|
+
ca.style.backgroundColor='white';ca.style.position='absolute';ca.style.border='1px dashed gray';ca.style.boxShadow='2px 2px 5px #ddd';ca.style.left=0;ca.style.top=0;ca.width=parseInt(div.style.width);ca.height=parseInt(div.style.height);ca.getContext('2d').translate(0.5,0.5);var objects=RG.ObjectRegistry.getObjectsByCanvasID(ca.id);for(var i=0,len=objects.length;i<len;i+=1){RG.resetColorsToOriginalValues(objects[i]);if(typeof objects[i].reset==='function'){objects[i].reset();}}
|
16
|
+
RG.cache=[];RG.fireCustomEvent(ca.__object__,'onresizebeforedraw');RG.redrawCanvas(ca);ca.resizing.mousedown=false;div.style.display='none';document.body.removeChild(div);}
|
17
|
+
if(RG.Registry.Get('chart.zoomed.div')||RGraph.Registry.Get('chart.zoomed.img')){RG.Registry.Set('chart.zoomed.div',null);RG.Registry.Set('chart.zoomed.img',null);}
|
18
|
+
RG.FireCustomEvent(ca.__object__,'onresizeend');};var window_onmouseup=MouseupFunc;if(typeof ca.rgraph_resize_window_mouseup_listener_installed!='boolean'){window.addEventListener('mouseup',window_onmouseup,false);ca.rgraph_resize_window_mouseup_listener_installed=true;}
|
19
|
+
var canvas_onmousemove=function(e)
|
20
|
+
{e=RG.fixEventObject(e);var coords=RG.getMouseXY(e);var obj=e.target.__object__;var ca=e.target;var co=ca.getContext('2d');var cursor=ca.style.cursor;if(!ca.resizing.original_cursor){ca.resizing.original_cursor=cursor;}
|
21
|
+
if((coords[0]>(ca.width-resizeHandleSize)&&coords[0]<ca.width&&coords[1]>(ca.height-resizeHandleSize)&&coords[1]<ca.height)){ca.style.cursor='move';}else if(coords[0]>(ca.width-resizeHandleSize-resizeHandleSize)&&coords[0]<ca.width-resizeHandleSize&&coords[1]>(ca.height-resizeHandleSize)&&coords[1]<ca.height){ca.style.cursor='pointer';}else{if(ca.resizing.original_cursor){ca.style.cursor=ca.resizing.original_cursor;ca.resizing.original_cursor=null;}else{ca.style.cursor='default';}}};if(typeof ca.rgraph_resize_mousemove_listener_installed!='boolean'){ca.addEventListener('mousemove',canvas_onmousemove,false);ca.rgraph_resize_mousemove_listener_installed=true;}
|
22
|
+
var canvas_onmouseout=function(e)
|
23
|
+
{e.target.style.cursor='default';e.target.title='';};if(typeof ca.rgraph_resize_mouseout_listener_installed!='boolean'){ca.addEventListener('mouseout',canvas_onmouseout,false);ca.rgraph_resize_mouseout_listener_installed=true;}
|
24
|
+
var canvas_onmousedown=function(e)
|
25
|
+
{e=RG.fixEventObject(e);var coords=RG.getMouseXY(e);var canvasXY=RG.getCanvasXY(e.target);var ca=e.target;active=ca;if(coords[0]>(ca.width-resizeHandleSize)&&coords[0]<ca.width&&coords[1]>(ca.height-resizeHandleSize)&&coords[1]<ca.height){RG.fireCustomEvent(obj,'onresizebegin');if(ca.resizing.original_css_border==null){ca.resizing.original_css_border=ca.style.border;}
|
26
|
+
if(ca.resizing.original_css_shadow==null){ca.resizing.original_css_shadow=ca.style.boxShadow;}
|
27
|
+
ca.resizing.mousedown=true;var div=document.createElement('DIV');div.style.position='absolute';div.style.left=canvasXY[0]+'px';div.style.top=canvasXY[1]+'px';div.style.width=ca.width+'px';div.style.height=ca.height+'px';div.style.border='1px dotted black';div.style.backgroundColor='gray';div.style.opacity=0.5;div.__canvas__=e.target;document.body.appendChild(div);ca.resizing.div=div;ca.resizing.placeHolders.push(div);for(var i=0;i<(ca.resizing.placeHolders.length-1);++i){ca.resizing.placeHolders[i].style.display='none';}
|
28
|
+
div.onmouseup=function(e)
|
29
|
+
{MouseupFunc(e);}
|
30
|
+
ca.resizing.div.onmouseover=function(e)
|
31
|
+
{e=RG.fixEventObject(e);e.stopPropagation();}
|
32
|
+
ca.resizing.originalx=e.pageX;ca.resizing.originaly=e.pageY;ca.resizing.originalCanvasX=RG.getCanvasXY(ca)[0];ca.resizing.originalCanvasY=RG.getCanvasXY(ca)[1];}
|
33
|
+
if(coords[0]>(ca.width-resizeHandleSize-resizeHandleSize)&&coords[0]<ca.width-resizeHandleSize&&coords[1]>(ca.height-resizeHandleSize)&&coords[1]<ca.height&&ca.resizing.originalw&&ca.resizing.originaly){RG.fireCustomEvent(ca.__object__,'onresizebegin');ca.width=ca.resizing.originalw;ca.height=ca.resizing.originalh;if(ca.__link__&&ca.__link__.style.display==='none'){ca.__link__.style.display='inline';}
|
34
|
+
if(typeof ca.parentNode.id==='string'&&ca.parentNode.id.substring(0,24)==='rgraph_resize_container_'){ca.parentNode.style.width=ca.resizing.originalw+'px';ca.parentNode.style.height=ca.resizing.originalh+'px';}
|
35
|
+
ca.style.border=ca.resizing.original_css_border;ca.style.boxShadow=ca.resizing.original_css_shadow;ca.style.left=(parseInt(ca.style.left))+'px';ca.style.top=(parseInt(ca.style.top))+'px';ca.getContext('2d').translate(0.5,0.5);RG.fireCustomEvent(ca.__object__,'onresizebeforedraw');var objects=RG.ObjectRegistry.getObjectsByCanvasID(ca.id);for(var i=0;i<objects.length;i+=1){RG.resetColorsToOriginalValues(objects[i]);if(objects[i].reset){objects[i].reset();}
|
36
|
+
RG.redrawCanvas(objects[i].canvas);}
|
37
|
+
RG.cache=[];if(ca.resizing.div){ca.resizing.div.style.width=ca.__original_width__+'px';ca.resizing.div.style.height=ca.__original_height__+'px';}
|
38
|
+
RG.fireCustomEvent(ca.__object__,'onresize');RG.fireCustomEvent(ca.__object__,'onresizeend');}};if(typeof ca.rgraph_resize_mousedown_listener_installed!='boolean'){ca.addEventListener('mousedown',canvas_onmousedown,false);ca.rgraph_resize_mousedown_listener_installed=true;}}};})(window,document);
|