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,400 +1,36 @@
|
|
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
|
-
mouseX = mouseXY[0],
|
53
|
-
mouseY = mouseXY[1]
|
54
|
-
|
55
|
-
// Allow for the Bar chart 3D
|
56
|
-
if (obj.type === 'bar' && prop['chart.variant'] === '3d') {
|
57
|
-
var adjustment = prop['chart.variant.threed.angle'] * mouseXY[0];
|
58
|
-
mouseY -= adjustment;
|
59
|
-
}
|
60
|
-
|
61
|
-
// Clear the annotation recording
|
62
|
-
RG.Registry.Set('annotate.actions', [obj.Get('chart.annotate.color')]);
|
63
|
-
|
64
|
-
// This sets the initial X/Y position
|
65
|
-
obj.context.moveTo(mouseX, mouseY);
|
66
|
-
RG.Registry.Set('annotate.last.coordinates', [mouseX,mouseY]);
|
67
|
-
|
68
|
-
RG.Registry.Set('started.annotating', false);
|
69
|
-
RG.Registry.Set('chart.annotating', obj);
|
70
|
-
|
71
|
-
// Fire the onannotatebegin event.
|
72
|
-
RG.FireCustomEvent(obj, 'onannotatebegin');
|
73
|
-
}
|
74
|
-
|
75
|
-
return false;
|
76
|
-
};
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
/**
|
82
|
-
* This cancels annotating for ALL canvases
|
83
|
-
*/
|
84
|
-
RG.annotating_window_onmouseup = function (e)
|
85
|
-
{
|
86
|
-
var obj = RG.Registry.Get('chart.annotating');
|
87
|
-
var win = window;
|
88
|
-
|
89
|
-
if (e.button != 0 || !obj) {
|
90
|
-
return;
|
91
|
-
}
|
92
|
-
|
93
|
-
// This cancels annotating on ALL canvas tags on the page
|
94
|
-
var tags = doc.getElementsByTagName('canvas');
|
95
|
-
|
96
|
-
for (var i=0; i<tags.length; ++i) {
|
97
|
-
if (tags[i].__object__) {
|
98
|
-
tags[i].__object__.Set('chart.mousedown', false);
|
99
|
-
}
|
100
|
-
}
|
101
|
-
|
102
|
-
// Store the annotations in browser storage if it's available
|
103
|
-
if (RG.Registry.Get('annotate.actions') && RG.Registry.Get('annotate.actions').length > 0 && win.localStorage) {
|
104
|
-
|
105
|
-
var id = '__rgraph_annotations_' + e.target.id + '__';
|
106
|
-
var annotations = win.localStorage[id] ? win.localStorage[id] + '|' : '';
|
107
|
-
annotations += RG.Registry.Get('annotate.actions');
|
108
|
-
|
109
|
-
// Store the annotations information in HTML5 browser storage here
|
110
|
-
win.localStorage[id] = annotations;
|
111
|
-
}
|
112
|
-
|
113
|
-
// Clear the recorded annotations
|
114
|
-
RG.Registry.Set('annotate.actions', []);
|
115
|
-
|
116
|
-
// Fire the annotate event
|
117
|
-
RG.FireCustomEvent(obj, 'onannotateend');
|
118
|
-
};
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
/**
|
124
|
-
* The canvas onmousemove function
|
125
|
-
*/
|
126
|
-
RGraph.annotating_canvas_onmousemove = function (e)
|
127
|
-
{
|
128
|
-
var obj = e.target.__object__;
|
129
|
-
var prop = obj.properties;
|
130
|
-
var mouseXY = RG.getMouseXY(e);
|
131
|
-
var mouseX = mouseXY[0];
|
132
|
-
var mouseY = mouseXY[1];
|
133
|
-
var lastXY = RG.Registry.Get('annotate.last.coordinates');
|
134
|
-
|
135
|
-
if (obj.Get('chart.mousedown')) {
|
136
|
-
|
137
|
-
// Allow for the Bar chart 3D
|
138
|
-
if (obj.type === 'bar' && prop['chart.variant'] === '3d') {
|
139
|
-
var adjustment = prop['chart.variant.threed.angle'] * mouseXY[0];
|
140
|
-
mouseY -= adjustment;
|
141
|
-
}
|
142
|
-
|
143
|
-
obj.context.beginPath();
|
144
|
-
|
145
|
-
if (!lastXY) {
|
146
|
-
obj.context.moveTo(mouseX, mouseY)
|
147
|
-
} else {
|
148
|
-
obj.context.strokeStyle = obj.properties['chart.annotate.color'];
|
149
|
-
obj.context.moveTo(lastXY[0], lastXY[1]);
|
150
|
-
obj.context.lineTo(mouseX, mouseY);
|
151
|
-
}
|
152
|
-
|
153
|
-
RG.Registry.Set('annotate.actions', RG.Registry.Get('annotate.actions') + '|' + mouseX + ',' + mouseY);
|
154
|
-
RG.Registry.Set('annotate.last.coordinates', [mouseX,mouseY]);
|
155
|
-
|
156
|
-
RG.FireCustomEvent(obj, 'onannotate');
|
157
|
-
obj.context.stroke();
|
158
|
-
}
|
159
|
-
};
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
/**
|
165
|
-
* Shows the mini palette used for annotations
|
166
|
-
*
|
167
|
-
* @param object e The event object
|
168
|
-
*/
|
169
|
-
RG.ShowPalette =
|
170
|
-
RG.Showpalette = function (e)
|
171
|
-
{
|
172
|
-
var isSafari = navigator.userAgent.indexOf('Safari') ? true : false;
|
173
|
-
|
174
|
-
e = RG.FixEventObject(e);
|
175
|
-
|
176
|
-
var canvas = e.target.parentNode.__canvas__,
|
177
|
-
context = canvas.getContext('2d'),
|
178
|
-
obj = canvas.__object__,
|
179
|
-
div = document.createElement('DIV'),
|
180
|
-
coords = RG.getMouseXY(e)
|
181
|
-
|
182
|
-
div.__object__ = obj; // The graph object
|
183
|
-
div.className = 'RGraph_palette';
|
184
|
-
div.style.position = 'absolute';
|
185
|
-
div.style.backgroundColor = 'white';
|
186
|
-
div.style.border = '1px solid black';
|
187
|
-
div.style.left = 0;
|
188
|
-
div.style.top = 0;
|
189
|
-
div.style.padding = '3px';
|
190
|
-
div.style.paddingLeft = '5px';
|
191
|
-
div.style.opacity = 0;
|
192
|
-
div.style.boxShadow = 'rgba(96,96,96,0.5) 3px 3px 3px';
|
193
|
-
div.style.WebkitBoxShadow = 'rgba(96,96,96,0.5) 3px 3px 3px';
|
194
|
-
div.style.MozBoxShadow = 'rgba(96,96,96,0.5) 3px 3px 3px';
|
195
|
-
|
196
|
-
|
197
|
-
// MUST use named colors that are capitalised
|
198
|
-
var colors = [
|
199
|
-
'Black',
|
200
|
-
'Red',
|
201
|
-
'Yellow',
|
202
|
-
'Green',
|
203
|
-
'Orange',
|
204
|
-
'White',
|
205
|
-
'Magenta',
|
206
|
-
'Pink'
|
207
|
-
];
|
208
|
-
|
209
|
-
// Add the colors to the palette
|
210
|
-
for (var i=0,len=colors.length; i<len; i+=1) {
|
211
|
-
|
212
|
-
var div2 = doc.createElement('DIV');
|
213
|
-
div2.cssClass = 'RGraph_palette_color';
|
214
|
-
div2.style.fontSize = '12pt';
|
215
|
-
div2.style.cursor = 'pointer';
|
216
|
-
div2.style.padding = '1px';
|
217
|
-
div2.style.paddingRight = '10px';
|
218
|
-
div2.style.textAlign = 'left';
|
219
|
-
|
220
|
-
var span = document.createElement('SPAN');
|
221
|
-
span.style.display = 'inline-block';
|
222
|
-
span.style.marginRight = '9px';
|
223
|
-
span.style.width = '17px';
|
224
|
-
span.style.height = '17px';
|
225
|
-
span.style.top = '2px';
|
226
|
-
span.style.position = 'relative';
|
227
|
-
span.style.backgroundColor = colors[i];
|
228
|
-
div2.appendChild(span);
|
229
|
-
|
230
|
-
div2.innerHTML += colors[i];
|
231
|
-
|
232
|
-
|
233
|
-
div2.onmouseover = function ()
|
234
|
-
{
|
235
|
-
this.style.backgroundColor = '#eee';
|
236
|
-
}
|
237
|
-
|
238
|
-
div2.onmouseout = function ()
|
239
|
-
{
|
240
|
-
this.style.backgroundColor = '';
|
241
|
-
}
|
242
|
-
|
243
|
-
div2.onclick = function (e)
|
244
|
-
{
|
245
|
-
var color = this.childNodes[0].style.backgroundColor;
|
246
|
-
|
247
|
-
obj.Set('chart.annotate.color', color);
|
248
|
-
}
|
249
|
-
div.appendChild(div2);
|
250
|
-
}
|
251
|
-
|
252
|
-
|
253
|
-
doc.body.appendChild(div);
|
254
|
-
|
255
|
-
/**
|
256
|
-
* Now the div has been added to the document, move it up and left
|
257
|
-
*/
|
258
|
-
div.style.left = e.pageX + 'px';
|
259
|
-
div.style.top = e.pageY + 'px';
|
260
|
-
|
261
|
-
/**
|
262
|
-
* Chang the position if the cursor is near the right edge of the browser window
|
263
|
-
*/
|
264
|
-
if ((e.pageX + (div.offsetWidth + 5) ) > document.body.offsetWidth) {
|
265
|
-
div.style.left = (e.pageX - div.offsetWidth) + 'px';
|
266
|
-
}
|
267
|
-
|
268
|
-
/**
|
269
|
-
* Store the palette div in the registry
|
270
|
-
*/
|
271
|
-
RGraph.Registry.Set('chart.palette', div);
|
272
|
-
|
273
|
-
setTimeout(function () {div.style.opacity = 0.2;}, 50);
|
274
|
-
setTimeout(function () {div.style.opacity = 0.4;}, 100);
|
275
|
-
setTimeout(function () {div.style.opacity = 0.6;}, 150);
|
276
|
-
setTimeout(function () {div.style.opacity = 0.8;}, 200);
|
277
|
-
setTimeout(function () {div.style.opacity = 1;}, 250);
|
278
|
-
|
279
|
-
RGraph.hideContext();
|
280
|
-
|
281
|
-
window.onclick = function ()
|
282
|
-
{
|
283
|
-
RG.hidePalette();
|
284
|
-
}
|
285
|
-
|
286
|
-
// Should this be here? Yes. This function is being used as an event handler.
|
287
|
-
e.stopPropagation();
|
288
|
-
return false;
|
289
|
-
};
|
290
|
-
|
291
|
-
|
292
|
-
|
293
|
-
|
294
|
-
/**
|
295
|
-
* Clears any annotation data from global storage
|
296
|
-
*
|
297
|
-
* @param object canvas The canvas tag object
|
298
|
-
*/
|
299
|
-
RG.clearAnnotations =
|
300
|
-
RG.ClearAnnotations = function (canvas)
|
301
|
-
{
|
302
|
-
/**
|
303
|
-
* For BC the argument can also be the ID of the canvas
|
304
|
-
*/
|
305
|
-
if (typeof canvas === 'string') {
|
306
|
-
var id = canvas;
|
307
|
-
canvas = doc.getElementById(id);
|
308
|
-
} else {
|
309
|
-
var id = canvas.id
|
310
|
-
}
|
311
|
-
|
312
|
-
var obj = canvas.__object__;
|
313
|
-
|
314
|
-
if (win.localStorage && win.localStorage['__rgraph_annotations_' + id + '__'] && win.localStorage['__rgraph_annotations_' + id + '__'].length) {
|
315
|
-
win.localStorage['__rgraph_annotations_' + id + '__'] = [];
|
316
|
-
|
317
|
-
RGraph.FireCustomEvent(obj, 'onannotateclear');
|
318
|
-
}
|
319
|
-
};
|
320
|
-
|
321
|
-
|
322
|
-
|
323
|
-
|
324
|
-
/**
|
325
|
-
* Replays stored annotations
|
326
|
-
*
|
327
|
-
* @param object obj The graph object
|
328
|
-
*/
|
329
|
-
RG.replayAnnotations =
|
330
|
-
RG.ReplayAnnotations = function (obj)
|
331
|
-
{
|
332
|
-
// Check for support
|
333
|
-
if (!win.localStorage) {
|
334
|
-
return;
|
335
|
-
}
|
336
|
-
|
337
|
-
var context = obj.context;
|
338
|
-
var annotations = win.localStorage['__rgraph_annotations_' + obj.id + '__'];
|
339
|
-
var i, len, move, coords;
|
340
|
-
|
341
|
-
context.beginPath();
|
342
|
-
context.lineWidth = obj.Get('annotate.linewidth');
|
343
|
-
|
344
|
-
if (annotations && annotations.length) {
|
345
|
-
annotations = annotations.split('|');
|
346
|
-
} else {
|
347
|
-
return;
|
348
|
-
}
|
349
|
-
|
350
|
-
|
351
|
-
for (i=0,len=annotations.length; i<len; ++i) {
|
352
|
-
|
353
|
-
// If the element of the array is a color - finish the path,
|
354
|
-
// stroke it and start a new one
|
355
|
-
if (annotations[i].match(/[a-z]+/)) {
|
356
|
-
context.stroke();
|
357
|
-
context.beginPath();
|
358
|
-
|
359
|
-
context.strokeStyle = annotations[i];
|
360
|
-
move = true;
|
361
|
-
continue;
|
362
|
-
}
|
363
|
-
|
364
|
-
coords = annotations[i].split(',');
|
365
|
-
coords[0] = Number(coords[0]);
|
366
|
-
coords[1] = Number(coords[1]);
|
367
|
-
|
368
|
-
if (move) {
|
369
|
-
context.moveTo(coords[0], coords[1]);
|
370
|
-
move = false;
|
371
|
-
} else {
|
372
|
-
context.lineTo(coords[0], coords[1]);
|
373
|
-
}
|
374
|
-
}
|
375
|
-
|
376
|
-
context.stroke();
|
377
|
-
};
|
378
|
-
|
379
|
-
|
380
|
-
|
381
|
-
|
382
|
-
window.addEventListener('load', function (e)
|
383
|
-
{
|
384
|
-
// This delay is necessary to allow the window.onload event listener to run
|
385
|
-
setTimeout(function ()
|
386
|
-
{
|
387
|
-
var tags = doc.getElementsByTagName('canvas');
|
388
|
-
for (var i=0; i<tags.length; ++i) {
|
389
|
-
if (tags[i].__object__ && tags[i].__object__.isRGraph && tags[i].__object__.Get('chart.annotatable')) {
|
390
|
-
RG.replayAnnotations(tags[i].__object__);
|
391
|
-
}
|
392
|
-
}
|
393
|
-
}, 100); // This delay is sufficient to wait before replaying the annotations
|
394
|
-
}, false);
|
395
|
-
|
396
|
-
|
397
|
-
|
398
|
-
|
399
|
-
// End module pattern
|
400
|
-
})(window, document);
|
2
|
+
RGraph=window.RGraph||{isRGraph:true};(function(win,doc,undefined)
|
3
|
+
{var RG=RGraph,ua=navigator.userAgent,ma=Math;RG.annotating_canvas_onmousedown=function(e)
|
4
|
+
{if(e.button===0){e.target.__object__.Set('chart.mousedown',true);var obj=e.target.__object__,prop=obj.properties
|
5
|
+
obj.context.beginPath();obj.context.strokeStyle=obj.Get('chart.annotate.color');obj.context.lineWidth=obj.Get('chart.annotate.linewidth');var mouseXY=RG.getMouseXY(e),mouseX=mouseXY[0],mouseY=mouseXY[1]
|
6
|
+
if(obj.type==='bar'&&prop['chart.variant']==='3d'){var adjustment=prop['chart.variant.threed.angle']*mouseXY[0];mouseY-=adjustment;}
|
7
|
+
RG.Registry.Set('annotate.actions',[obj.Get('chart.annotate.color')]);obj.context.moveTo(mouseX,mouseY);RG.Registry.Set('annotate.last.coordinates',[mouseX,mouseY]);RG.Registry.Set('started.annotating',false);RG.Registry.Set('chart.annotating',obj);RG.FireCustomEvent(obj,'onannotatebegin');}
|
8
|
+
return false;};RG.annotating_window_onmouseup=function(e)
|
9
|
+
{var obj=RG.Registry.Get('chart.annotating');var win=window;if(e.button!=0||!obj){return;}
|
10
|
+
var tags=doc.getElementsByTagName('canvas');for(var i=0;i<tags.length;++i){if(tags[i].__object__){tags[i].__object__.Set('chart.mousedown',false);}}
|
11
|
+
if(RG.Registry.Get('annotate.actions')&&RG.Registry.Get('annotate.actions').length>0&&win.localStorage){var id='__rgraph_annotations_'+e.target.id+'__';var annotations=win.localStorage[id]?win.localStorage[id]+'|':'';annotations+=RG.Registry.Get('annotate.actions');win.localStorage[id]=annotations;}
|
12
|
+
RG.Registry.Set('annotate.actions',[]);RG.FireCustomEvent(obj,'onannotateend');};RGraph.annotating_canvas_onmousemove=function(e)
|
13
|
+
{var obj=e.target.__object__;var prop=obj.properties;var mouseXY=RG.getMouseXY(e);var mouseX=mouseXY[0];var mouseY=mouseXY[1];var lastXY=RG.Registry.Get('annotate.last.coordinates');if(obj.Get('chart.mousedown')){if(obj.type==='bar'&&prop['chart.variant']==='3d'){var adjustment=prop['chart.variant.threed.angle']*mouseXY[0];mouseY-=adjustment;}
|
14
|
+
obj.context.beginPath();if(!lastXY){obj.context.moveTo(mouseX,mouseY)}else{obj.context.strokeStyle=obj.properties['chart.annotate.color'];obj.context.moveTo(lastXY[0],lastXY[1]);obj.context.lineTo(mouseX,mouseY);}
|
15
|
+
RG.Registry.Set('annotate.actions',RG.Registry.Get('annotate.actions')+'|'+mouseX+','+mouseY);RG.Registry.Set('annotate.last.coordinates',[mouseX,mouseY]);RG.FireCustomEvent(obj,'onannotate');obj.context.stroke();}};RG.ShowPalette=RG.Showpalette=function(e)
|
16
|
+
{var isSafari=navigator.userAgent.indexOf('Safari')?true:false;e=RG.FixEventObject(e);var canvas=e.target.parentNode.__canvas__,context=canvas.getContext('2d'),obj=canvas.__object__,div=document.createElement('DIV'),coords=RG.getMouseXY(e)
|
17
|
+
div.__object__=obj;div.className='RGraph_palette';div.style.position='absolute';div.style.backgroundColor='white';div.style.border='1px solid black';div.style.left=0;div.style.top=0;div.style.padding='3px';div.style.paddingLeft='5px';div.style.opacity=0;div.style.boxShadow='rgba(96,96,96,0.5) 3px 3px 3px';div.style.WebkitBoxShadow='rgba(96,96,96,0.5) 3px 3px 3px';div.style.MozBoxShadow='rgba(96,96,96,0.5) 3px 3px 3px';var colors=['Black','Red','Yellow','Green','Orange','White','Magenta','Pink'];for(var i=0,len=colors.length;i<len;i+=1){var div2=doc.createElement('DIV');div2.cssClass='RGraph_palette_color';div2.style.fontSize='12pt';div2.style.cursor='pointer';div2.style.padding='1px';div2.style.paddingRight='10px';div2.style.textAlign='left';var span=document.createElement('SPAN');span.style.display='inline-block';span.style.marginRight='9px';span.style.width='17px';span.style.height='17px';span.style.top='2px';span.style.position='relative';span.style.backgroundColor=colors[i];div2.appendChild(span);div2.innerHTML+=colors[i];div2.onmouseover=function()
|
18
|
+
{this.style.backgroundColor='#eee';}
|
19
|
+
div2.onmouseout=function()
|
20
|
+
{this.style.backgroundColor='';}
|
21
|
+
div2.onclick=function(e)
|
22
|
+
{var color=this.childNodes[0].style.backgroundColor;obj.Set('chart.annotate.color',color);}
|
23
|
+
div.appendChild(div2);}
|
24
|
+
doc.body.appendChild(div);div.style.left=e.pageX+'px';div.style.top=e.pageY+'px';if((e.pageX+(div.offsetWidth+5))>document.body.offsetWidth){div.style.left=(e.pageX-div.offsetWidth)+'px';}
|
25
|
+
RGraph.Registry.Set('chart.palette',div);setTimeout(function(){div.style.opacity=0.2;},50);setTimeout(function(){div.style.opacity=0.4;},100);setTimeout(function(){div.style.opacity=0.6;},150);setTimeout(function(){div.style.opacity=0.8;},200);setTimeout(function(){div.style.opacity=1;},250);RGraph.hideContext();window.onclick=function()
|
26
|
+
{RG.hidePalette();}
|
27
|
+
e.stopPropagation();return false;};RG.clearAnnotations=RG.ClearAnnotations=function(canvas)
|
28
|
+
{if(typeof canvas==='string'){var id=canvas;canvas=doc.getElementById(id);}else{var id=canvas.id}
|
29
|
+
var obj=canvas.__object__;if(win.localStorage&&win.localStorage['__rgraph_annotations_'+id+'__']&&win.localStorage['__rgraph_annotations_'+id+'__'].length){win.localStorage['__rgraph_annotations_'+id+'__']=[];RGraph.FireCustomEvent(obj,'onannotateclear');}};RG.replayAnnotations=RG.ReplayAnnotations=function(obj)
|
30
|
+
{if(!win.localStorage){return;}
|
31
|
+
var context=obj.context;var annotations=win.localStorage['__rgraph_annotations_'+obj.id+'__'];var i,len,move,coords;context.beginPath();context.lineWidth=obj.Get('annotate.linewidth');if(annotations&&annotations.length){annotations=annotations.split('|');}else{return;}
|
32
|
+
for(i=0,len=annotations.length;i<len;++i){if(annotations[i].match(/[a-z]+/)){context.stroke();context.beginPath();context.strokeStyle=annotations[i];move=true;continue;}
|
33
|
+
coords=annotations[i].split(',');coords[0]=Number(coords[0]);coords[1]=Number(coords[1]);if(move){context.moveTo(coords[0],coords[1]);move=false;}else{context.lineTo(coords[0],coords[1]);}}
|
34
|
+
context.stroke();};window.addEventListener('load',function(e)
|
35
|
+
{setTimeout(function()
|
36
|
+
{var tags=doc.getElementsByTagName('canvas');for(var i=0;i<tags.length;++i){if(tags[i].__object__&&tags[i].__object__.isRGraph&&tags[i].__object__.Get('chart.annotatable')){RG.replayAnnotations(tags[i].__object__);}}},100);},false);})(window,document);
|