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,756 +1,55 @@
|
|
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
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
key_non_null.push(key[i]);
|
72
|
-
}
|
73
|
-
}
|
74
|
-
|
75
|
-
key = key_non_null;
|
76
|
-
colors = colors_non_null;
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
/**
|
105
|
-
* This does the actual drawing of the key when it's in the graph
|
106
|
-
*
|
107
|
-
* @param object obj The graph object
|
108
|
-
* @param array key The key items to draw
|
109
|
-
* @param array colors An aray of colors that the key will use
|
110
|
-
*/
|
111
|
-
function DrawKey_graph (obj, key, colors)
|
112
|
-
{
|
113
|
-
var text_size = typeof(prop['chart.key.text.size']) == 'number' ? prop['chart.key.text.size'] : prop['chart.text.size'];
|
114
|
-
var text_italic = prop['chart.key.text.italic'] ? true : false
|
115
|
-
var text_bold = prop['chart.key.text.bold'] ? true : false
|
116
|
-
var text_font = prop['chart.key.text.font'] || prop['chart.key.font'] || prop['chart.text.font'];
|
117
|
-
|
118
|
-
var gutterLeft = obj.gutterLeft;
|
119
|
-
var gutterRight = obj.gutterRight;
|
120
|
-
var gutterTop = obj.gutterTop;
|
121
|
-
var gutterBottom = obj.gutterBottom;
|
122
|
-
var hpos = prop['chart.yaxispos'] == 'right' ? gutterLeft + 10 : ca.width - gutterRight - 10;
|
123
|
-
var vpos = gutterTop + 10;
|
124
|
-
var title = prop['chart.title'];
|
125
|
-
var blob_size = text_size; // The blob of color
|
126
|
-
var hmargin = 8; // This is the size of the gaps between the blob of color and the text
|
127
|
-
var vmargin = 4; // This is the vertical margin of the key
|
128
|
-
var fillstyle = prop['chart.key.background'];
|
129
|
-
var text_color = prop['chart.key.text.color'];
|
130
|
-
var strokestyle = '#333';
|
131
|
-
var height = 0;
|
132
|
-
var width = 0;
|
133
|
-
|
134
|
-
if (!obj.coords) obj.coords = {};
|
135
|
-
obj.coords.key = [];
|
136
|
-
|
137
|
-
|
138
|
-
// Need to set this so that measuring the text works out OK
|
139
|
-
co.font = text_size + 'pt ' + prop['chart.text.font'];
|
140
|
-
|
141
|
-
// Work out the longest bit of text
|
142
|
-
for (i=0; i<key.length; ++i) {
|
143
|
-
width = Math.max(width, co.measureText(key[i]).width);
|
144
|
-
}
|
145
|
-
|
146
|
-
width += 5;
|
147
|
-
width += blob_size;
|
148
|
-
width += 5;
|
149
|
-
width += 5;
|
150
|
-
width += 5;
|
151
|
-
|
152
|
-
/**
|
153
|
-
* Now we know the width, we can move the key left more accurately
|
154
|
-
*/
|
155
|
-
if ( prop['chart.yaxispos'] == 'left'
|
156
|
-
|| (obj.type === 'pie' && !prop['chart.yaxispos'])
|
157
|
-
|| (obj.type === 'hbar' && !prop['chart.yaxispos'])
|
158
|
-
|| (obj.type === 'hbar' && prop['chart.yaxispos'] === 'center')
|
159
|
-
|| (obj.type === 'hbar' && prop['chart.yaxispos'] === 'right')
|
160
|
-
|| (obj.type === 'rscatter' && !prop['chart.yaxispos'])
|
161
|
-
|| (obj.type === 'radar' && !prop['chart.yaxispos'])
|
162
|
-
|| (obj.type === 'rose' && !prop['chart.yaxispos'])
|
163
|
-
|| (obj.type === 'funnel' && !prop['chart.yaxispos'])
|
164
|
-
|| (obj.type === 'vprogress' && !prop['chart.yaxispos'])
|
165
|
-
|| (obj.type === 'hprogress' && !prop['chart.yaxispos'])
|
166
|
-
) {
|
167
|
-
|
168
|
-
hpos -= width;
|
169
|
-
}
|
170
|
-
|
171
|
-
/**
|
172
|
-
* Horizontal alignment
|
173
|
-
*/
|
174
|
-
if (typeof(prop['chart.key.halign']) == 'string') {
|
175
|
-
if (prop['chart.key.halign'] == 'left') {
|
176
|
-
hpos = gutterLeft + 10;
|
177
|
-
} else if (prop['chart.key.halign'] == 'right') {
|
178
|
-
hpos = ca.width - gutterRight - width;
|
179
|
-
}
|
180
|
-
}
|
181
|
-
|
182
|
-
/**
|
183
|
-
* Specific location coordinates
|
184
|
-
*/
|
185
|
-
if (typeof(prop['chart.key.position.x']) == 'number') {
|
186
|
-
hpos = prop['chart.key.position.x'];
|
187
|
-
}
|
188
|
-
|
189
|
-
if (typeof(prop['chart.key.position.y']) == 'number') {
|
190
|
-
vpos = prop['chart.key.position.y'];
|
191
|
-
}
|
192
|
-
|
193
|
-
|
194
|
-
// Stipulate the shadow for the key box
|
195
|
-
if (prop['chart.key.shadow']) {
|
196
|
-
co.shadowColor = prop['chart.key.shadow.color'];
|
197
|
-
co.shadowBlur = prop['chart.key.shadow.blur'];
|
198
|
-
co.shadowOffsetX = prop['chart.key.shadow.offsetx'];
|
199
|
-
co.shadowOffsetY = prop['chart.key.shadow.offsety'];
|
200
|
-
}
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
// Draw the box that the key resides in
|
206
|
-
co.beginPath();
|
207
|
-
co.fillStyle = prop['chart.key.background'];
|
208
|
-
co.strokeStyle = 'black';
|
209
|
-
|
210
|
-
if (typeof(prop['chart.key.position.graph.boxed']) == 'undefined' || (typeof(prop['chart.key.position.graph.boxed']) == 'boolean' && prop['chart.key.position.graph.boxed']) ) {
|
211
|
-
if (arguments[3] != false) {
|
212
|
-
|
213
|
-
co.lineWidth = typeof(prop['chart.key.linewidth']) == 'number' ? prop['chart.key.linewidth'] : 1;
|
214
|
-
|
215
|
-
// The older square rectangled key
|
216
|
-
if (prop['chart.key.rounded'] == true) {
|
217
|
-
co.beginPath();
|
218
|
-
co.strokeStyle = strokestyle;
|
219
|
-
RG.strokedCurvyRect(co, Math.round(hpos), Math.round(vpos), width - 5, 5 + ( (text_size + 5) * RG.getKeyLength(key)),4);
|
220
|
-
co.stroke();
|
221
|
-
co.fill();
|
222
|
-
|
223
|
-
RG.NoShadow(obj);
|
224
|
-
|
225
|
-
} else {
|
226
|
-
co.strokeRect(Math.round(hpos), Math.round(vpos), width - 5, 5 + ( (text_size + 5) * RG.getKeyLength(key)));
|
227
|
-
co.fillRect(Math.round(hpos), Math.round(vpos), width - 5, 5 + ( (text_size + 5) * RG.getKeyLength(key)));
|
228
|
-
}
|
229
|
-
}
|
230
|
-
}
|
231
|
-
|
232
|
-
RG.NoShadow(obj);
|
233
|
-
|
234
|
-
co.beginPath();
|
235
|
-
|
236
|
-
/**
|
237
|
-
* Custom colors for the key
|
238
|
-
*/
|
239
|
-
if (prop['chart.key.colors']) {
|
240
|
-
colors = prop['chart.key.colors'];
|
241
|
-
}
|
242
|
-
|
243
|
-
|
244
|
-
|
245
|
-
////////////////////////////////////////////////////////////////////////////////////////////
|
246
|
-
|
247
|
-
|
248
|
-
|
249
|
-
// Draw the labels given
|
250
|
-
for (var i=key.length - 1; i>=0; i--) {
|
251
|
-
|
252
|
-
var j = Number(i) + 1;
|
253
|
-
|
254
|
-
/**
|
255
|
-
* Draw the blob of color
|
256
|
-
*/
|
257
|
-
if (typeof(prop['chart.key.color.shape']) == 'object' && typeof(prop['chart.key.color.shape'][i]) == 'string') {
|
258
|
-
var blob_shape = prop['chart.key.color.shape'][i];
|
259
|
-
|
260
|
-
} else if (typeof(prop['chart.key.color.shape']) == 'string') {
|
261
|
-
var blob_shape = prop['chart.key.color.shape'];
|
262
|
-
} else {
|
263
|
-
var blob_shape = 'square';
|
264
|
-
}
|
265
|
-
|
266
|
-
if (blob_shape == 'circle') {
|
267
|
-
co.beginPath();
|
268
|
-
co.fillStyle = colors[i];
|
269
|
-
co.arc(hpos + 5 + (blob_size / 2), vpos + (5 * j) + (text_size * j) - text_size + (blob_size / 2), blob_size / 2, 0, 6.26, 0);
|
270
|
-
co.fill();
|
271
|
-
|
272
|
-
} else if (blob_shape == 'line') {
|
273
|
-
co.beginPath();
|
274
|
-
co.strokeStyle = colors[i];
|
275
|
-
co.moveTo(hpos + 5, vpos + (5 * j) + (text_size * j) - text_size + (blob_size / 2));
|
276
|
-
co.lineTo(hpos + blob_size + 5, vpos + (5 * j) + (text_size * j) - text_size + (blob_size / 2));
|
277
|
-
co.stroke();
|
278
|
-
|
279
|
-
} else if (blob_shape == 'triangle') {
|
280
|
-
co.beginPath();
|
281
|
-
co.strokeStyle = colors[i];
|
282
|
-
co.moveTo(hpos + 5, vpos + (5 * j) + (text_size * j) - text_size + blob_size);
|
283
|
-
co.lineTo(hpos + (blob_size / 2) + 5, vpos + (5 * j) + (text_size * j) - text_size );
|
284
|
-
co.lineTo(hpos + blob_size + 5, vpos + (5 * j) + (text_size * j) - text_size + blob_size);
|
285
|
-
co.closePath();
|
286
|
-
co.fillStyle = colors[i];
|
287
|
-
co.fill();
|
288
|
-
|
289
|
-
} else {
|
290
|
-
co.fillStyle = colors[i];
|
291
|
-
co.fillRect(hpos + 5, vpos + (5 * j) + (text_size * j) - text_size, text_size, text_size + 1);
|
292
|
-
}
|
293
|
-
|
294
|
-
///////////////////////////////////////////////////////////////////////////////////////////////////////////
|
295
|
-
|
296
|
-
|
297
|
-
|
298
|
-
co.beginPath();
|
299
|
-
co.fillStyle = typeof text_color == 'object' ? text_color[i] : text_color;
|
300
|
-
|
301
|
-
ret = RG.Text2(obj, {
|
302
|
-
'font': text_font,
|
303
|
-
'size': text_size,
|
304
|
-
'bold': text_bold,
|
305
|
-
'italic': text_italic,
|
306
|
-
'x': hpos + blob_size + 5 + 5,
|
307
|
-
'y': vpos + (5 * j) + (text_size * j) + 3,
|
308
|
-
'text': key[i],
|
309
|
-
'accessible': !obj.properties['chart.key.interactive']
|
310
|
-
});
|
311
|
-
|
312
|
-
obj.coords.key[i] = [
|
313
|
-
ret.x,
|
314
|
-
ret.y,
|
315
|
-
ret.width,
|
316
|
-
ret.height,
|
317
|
-
key[i],
|
318
|
-
colors[i],
|
319
|
-
obj
|
320
|
-
];
|
321
|
-
}
|
322
|
-
co.fill();
|
323
|
-
}
|
324
|
-
|
325
|
-
|
326
|
-
|
327
|
-
|
328
|
-
|
329
|
-
|
330
|
-
|
331
|
-
|
332
|
-
|
333
|
-
|
334
|
-
|
335
|
-
|
336
|
-
|
337
|
-
|
338
|
-
|
339
|
-
|
340
|
-
|
341
|
-
|
342
|
-
|
343
|
-
|
344
|
-
|
345
|
-
|
346
|
-
|
347
|
-
/**
|
348
|
-
* This does the actual drawing of the key when it's in the gutter
|
349
|
-
*
|
350
|
-
* @param object obj The graph object
|
351
|
-
* @param array key The key items to draw
|
352
|
-
* @param array colors An aray of colors that the key will use
|
353
|
-
*/
|
354
|
-
function DrawKey_gutter (obj, key, colors)
|
355
|
-
{
|
356
|
-
var text_size = typeof(prop['chart.key.text.size']) == 'number' ? prop['chart.key.text.size'] : prop['chart.text.size'],
|
357
|
-
text_bold = prop['chart.key.text.bold'],
|
358
|
-
text_italic = prop['chart.key.text.italic'],
|
359
|
-
text_font = prop['chart.key.text.font'] || prop['chart.key.font'] || prop['chart.text.font'],
|
360
|
-
text_color = prop['chart.key.text.color'],
|
361
|
-
gutterLeft = obj.gutterLeft,
|
362
|
-
gutterRight = obj.gutterRight,
|
363
|
-
gutterTop = obj.gutterTop,
|
364
|
-
gutterBottom = obj.gutterBottom,
|
365
|
-
hpos = ((ca.width - gutterLeft - gutterRight) / 2) + obj.gutterLeft,
|
366
|
-
vpos = gutterTop - text_size - 5,
|
367
|
-
title = prop['chart.title'],
|
368
|
-
blob_size = text_size, // The blob of color
|
369
|
-
hmargin = 8, // This is the size of the gaps between the blob of color and the text
|
370
|
-
vmargin = 4, // This is the vertical margin of the key
|
371
|
-
fillstyle = prop['chart.key.background'],
|
372
|
-
strokestyle = '#999',
|
373
|
-
length = 0;
|
374
|
-
|
375
|
-
if (!obj.coords) obj.coords = {};
|
376
|
-
obj.coords.key = [];
|
377
|
-
|
378
|
-
|
379
|
-
|
380
|
-
// Need to work out the length of the key first
|
381
|
-
co.font = text_size + 'pt ' + text_font;
|
382
|
-
for (i=0; i<key.length; ++i) {
|
383
|
-
length += hmargin;
|
384
|
-
length += blob_size;
|
385
|
-
length += hmargin;
|
386
|
-
length += co.measureText(key[i]).width;
|
387
|
-
}
|
388
|
-
length += hmargin;
|
389
|
-
|
390
|
-
|
391
|
-
|
392
|
-
|
393
|
-
/**
|
394
|
-
* Work out hpos since in the Pie it isn't necessarily dead center
|
395
|
-
*/
|
396
|
-
if (obj.type == 'pie') {
|
397
|
-
if (prop['chart.align'] == 'left') {
|
398
|
-
var hpos = obj.radius + gutterLeft;
|
399
|
-
|
400
|
-
} else if (prop['chart.align'] == 'right') {
|
401
|
-
var hpos = ca.width - obj.radius - gutterRight;
|
402
|
-
|
403
|
-
} else {
|
404
|
-
hpos = ca.width / 2;
|
405
|
-
}
|
406
|
-
}
|
407
|
-
|
408
|
-
|
409
|
-
|
410
|
-
|
411
|
-
|
412
|
-
/**
|
413
|
-
* This makes the key centered
|
414
|
-
*/
|
415
|
-
hpos -= (length / 2);
|
416
|
-
|
417
|
-
|
418
|
-
/**
|
419
|
-
* Override the horizontal/vertical positioning
|
420
|
-
*/
|
421
|
-
if (typeof(prop['chart.key.position.x']) == 'number') {
|
422
|
-
hpos = prop['chart.key.position.x'];
|
423
|
-
}
|
424
|
-
if (typeof(prop['chart.key.position.y']) == 'number') {
|
425
|
-
vpos = prop['chart.key.position.y'];
|
426
|
-
}
|
427
|
-
|
428
|
-
|
429
|
-
|
430
|
-
/**
|
431
|
-
* Draw the box that the key sits in
|
432
|
-
*/
|
433
|
-
if (obj.Get('chart.key.position.gutter.boxed')) {
|
434
|
-
|
435
|
-
if (prop['chart.key.shadow']) {
|
436
|
-
co.shadowColor = prop['chart.key.shadow.color'];
|
437
|
-
co.shadowBlur = prop['chart.key.shadow.blur'];
|
438
|
-
co.shadowOffsetX = prop['chart.key.shadow.offsetx'];
|
439
|
-
co.shadowOffsetY = prop['chart.key.shadow.offsety'];
|
440
|
-
}
|
441
|
-
|
442
|
-
|
443
|
-
co.beginPath();
|
444
|
-
co.fillStyle = fillstyle;
|
445
|
-
co.strokeStyle = strokestyle;
|
446
|
-
|
447
|
-
if (prop['chart.key.rounded']) {
|
448
|
-
RG.strokedCurvyRect(co, hpos, vpos - vmargin, length, text_size + vmargin + vmargin)
|
449
|
-
// Odd... RG.filledCurvyRect(co, hpos, vpos - vmargin, length, text_size + vmargin + vmargin);
|
450
|
-
} else {
|
451
|
-
co.rect(hpos, vpos - vmargin, length, text_size + vmargin + vmargin);
|
452
|
-
}
|
453
|
-
|
454
|
-
co.stroke();
|
455
|
-
co.fill();
|
456
|
-
|
457
|
-
|
458
|
-
RG.NoShadow(obj);
|
459
|
-
}
|
460
|
-
|
461
|
-
|
462
|
-
/**
|
463
|
-
* Draw the blobs of color and the text
|
464
|
-
*/
|
465
|
-
|
466
|
-
// Custom colors for the key
|
467
|
-
if (prop['chart.key.colors']) {
|
468
|
-
colors = prop['chart.key.colors'];
|
469
|
-
}
|
470
|
-
|
471
|
-
for (var i=0, pos=hpos; i<key.length; ++i) {
|
472
|
-
pos += hmargin;
|
473
|
-
|
474
|
-
|
475
|
-
|
476
|
-
//////////////////////////////////////////////////////////////////////////////////////////////////////
|
477
|
-
|
478
|
-
|
479
|
-
|
480
|
-
// Draw the blob of color
|
481
|
-
if (typeof(prop['chart.key.color.shape']) == 'object' && typeof(prop['chart.key.color.shape'][i]) == 'string') {
|
482
|
-
var blob_shape = prop['chart.key.color.shape'][i];
|
483
|
-
|
484
|
-
} else if (typeof(prop['chart.key.color.shape']) == 'string') {
|
485
|
-
var blob_shape = prop['chart.key.color.shape'];
|
486
|
-
|
487
|
-
} else {
|
488
|
-
var blob_shape = 'square';
|
489
|
-
}
|
490
|
-
|
491
|
-
|
492
|
-
/**
|
493
|
-
* Draw the blob of color - line
|
494
|
-
*/
|
495
|
-
if (blob_shape =='line') {
|
496
|
-
|
497
|
-
co.beginPath();
|
498
|
-
co.strokeStyle = colors[i];
|
499
|
-
co.moveTo(pos, vpos + (blob_size / 2));
|
500
|
-
co.lineTo(pos + blob_size, vpos + (blob_size / 2));
|
501
|
-
co.stroke();
|
502
|
-
|
503
|
-
// Circle
|
504
|
-
} else if (blob_shape == 'circle') {
|
505
|
-
|
506
|
-
co.beginPath();
|
507
|
-
co.fillStyle = colors[i];
|
508
|
-
co.moveTo(pos, vpos + (blob_size / 2));
|
509
|
-
co.arc(pos + (blob_size / 2), vpos + (blob_size / 2), (blob_size / 2), 0, 6.28, 0);
|
510
|
-
co.fill();
|
511
|
-
|
512
|
-
} else if (blob_shape == 'triangle') {
|
513
|
-
|
514
|
-
co.fillStyle = colors[i];
|
515
|
-
co.beginPath();
|
516
|
-
co.strokeStyle = colors[i];
|
517
|
-
co.moveTo(pos, vpos + blob_size);
|
518
|
-
co.lineTo(pos + (blob_size / 2), vpos);
|
519
|
-
co.lineTo(pos + blob_size, vpos + blob_size);
|
520
|
-
co.closePath();
|
521
|
-
co.fill();
|
522
|
-
|
523
|
-
} else {
|
524
|
-
|
525
|
-
co.beginPath();
|
526
|
-
co.fillStyle = colors[i];
|
527
|
-
co.rect(pos, vpos, blob_size, blob_size);
|
528
|
-
co.fill();
|
529
|
-
}
|
530
|
-
|
531
|
-
|
532
|
-
|
533
|
-
//////////////////////////////////////////////////////////////////////////////////////////////////////
|
534
|
-
|
535
|
-
|
536
|
-
|
537
|
-
|
538
|
-
pos += blob_size;
|
539
|
-
|
540
|
-
pos += hmargin;
|
541
|
-
|
542
|
-
co.beginPath();
|
543
|
-
co.fillStyle = typeof text_color == 'object' ? text_color[i] : text_color;;
|
544
|
-
var ret = RG.Text2(obj, {
|
545
|
-
'font':text_font,
|
546
|
-
'bold':text_bold,
|
547
|
-
'size':text_size,
|
548
|
-
'italic': text_italic,
|
549
|
-
'x':pos,
|
550
|
-
'y':vpos + text_size + 3,
|
551
|
-
'text': key[i],
|
552
|
-
accessible: !obj.properties['chart.key.interactive']
|
553
|
-
});
|
554
|
-
co.fill();
|
555
|
-
pos += co.measureText(key[i]).width;
|
556
|
-
|
557
|
-
obj.coords.key[i] = [
|
558
|
-
ret.x,
|
559
|
-
ret.y,
|
560
|
-
ret.width,
|
561
|
-
ret.height,
|
562
|
-
key[i],
|
563
|
-
colors[i],
|
564
|
-
obj
|
565
|
-
];
|
566
|
-
}
|
567
|
-
}
|
568
|
-
|
569
|
-
|
570
|
-
|
571
|
-
|
572
|
-
if (keypos && keypos == 'gutter') {
|
573
|
-
DrawKey_gutter(obj, key, colors);
|
574
|
-
} else if (keypos && keypos == 'graph') {
|
575
|
-
DrawKey_graph(obj, key, colors);
|
576
|
-
} else {
|
577
|
-
alert('[COMMON] (' + obj.id + ') Unknown key position: ' + keypos);
|
578
|
-
}
|
579
|
-
|
580
|
-
|
581
|
-
|
582
|
-
|
583
|
-
|
584
|
-
|
585
|
-
if (prop['chart.key.interactive']) {
|
586
|
-
|
587
|
-
if (!RGraph.Drawing || !RGraph.Drawing.Rect) {
|
588
|
-
alert('[INTERACTIVE KEY] The drawing API Rect library does not appear to have been included (which the interactive key uses)');
|
589
|
-
}
|
590
|
-
|
591
|
-
|
592
|
-
|
593
|
-
/**
|
594
|
-
* Check that the RGraph.common.dynamic.js file has been included
|
595
|
-
*/
|
596
|
-
if (!RGraph.InstallWindowMousedownListener) {
|
597
|
-
alert('[INTERACTIVE KEY] The dynamic library does not appear to have been included');
|
598
|
-
}
|
599
|
-
|
600
|
-
|
601
|
-
|
602
|
-
// Determine the maximum width of the labels
|
603
|
-
for (var i=0,len=obj.coords.key.length,maxlen=0; i<len; i+=1) {
|
604
|
-
maxlen = Math.max(maxlen, obj.coords.key[i][2]);
|
605
|
-
}
|
606
|
-
|
607
|
-
|
608
|
-
//obj.coords.key.forEach(function (value, index, arr)
|
609
|
-
//{
|
610
|
-
for (var i=0,len=obj.coords.key.length; i<len; i+=1) {
|
611
|
-
|
612
|
-
// Because the loop would have finished when the i variable is needed - put
|
613
|
-
// the onclick function inside a new context so that the value of the i
|
614
|
-
// variable is what we expect when the key has been clicked
|
615
|
-
(function (idx)
|
616
|
-
{
|
617
|
-
var arr = obj.coords.key;
|
618
|
-
var value = obj.coords.key[idx];
|
619
|
-
var index = idx;
|
620
|
-
|
621
|
-
|
622
|
-
var rect = new RGraph.Drawing.Rect(obj.id,value[0], value[1], prop['chart.key.position'] == 'gutter' ? value[2] : maxlen, value[3])
|
623
|
-
.Set('fillstyle', 'rgba(0,0,0,0)')
|
624
|
-
.Draw();
|
625
|
-
|
626
|
-
rect.onclick = function (e, shape)
|
627
|
-
{
|
628
|
-
var co = rect.context;
|
629
|
-
|
630
|
-
co.fillStyle = prop['chart.key.interactive.highlight.label'];
|
631
|
-
co.fillRect(shape.x, shape.y, shape.width, shape.height);
|
632
|
-
|
633
|
-
if (typeof obj.interactiveKeyHighlight == 'function') {
|
634
|
-
|
635
|
-
obj.Set('chart.key.interactive.index', idx);
|
636
|
-
|
637
|
-
RG.FireCustomEvent(obj, 'onbeforeinteractivekey');
|
638
|
-
obj.interactiveKeyHighlight(index);
|
639
|
-
RG.FireCustomEvent(obj, 'onafterinteractivekey');
|
640
|
-
}
|
641
|
-
}
|
642
|
-
|
643
|
-
rect.onmousemove = function (e, shape)
|
644
|
-
{
|
645
|
-
return true;
|
646
|
-
}
|
647
|
-
})(i);
|
648
|
-
}
|
649
|
-
}
|
650
|
-
};
|
651
|
-
|
652
|
-
|
653
|
-
|
654
|
-
|
655
|
-
/**
|
656
|
-
* Returns the key length, but accounts for null values
|
657
|
-
*
|
658
|
-
* @param array key The key elements
|
659
|
-
*/
|
660
|
-
RG.getKeyLength = function (key)
|
661
|
-
{
|
662
|
-
var length = 0;
|
663
|
-
|
664
|
-
for (var i=0,len=key.length; i<len; i+=1) {
|
665
|
-
if (key[i] != null) {
|
666
|
-
++length;
|
667
|
-
}
|
668
|
-
}
|
669
|
-
|
670
|
-
return length;
|
671
|
-
};
|
672
|
-
|
673
|
-
|
674
|
-
|
675
|
-
|
676
|
-
/**
|
677
|
-
* Create a TABLE based HTML key. There's lots of options so it's
|
678
|
-
* suggested that you consult the documentation page
|
679
|
-
*
|
680
|
-
* @param mixed id This should be a string consisting of the ID of the container
|
681
|
-
* @param object prop An object map of the various properties that you can use to
|
682
|
-
* configure the key. See the documentation page for a list.
|
683
|
-
*/
|
684
|
-
RGraph.HTML.key =
|
685
|
-
RGraph.HTML.Key = function (id, prop)
|
686
|
-
{
|
687
|
-
var div = doc.getElementById(id);
|
688
|
-
|
689
|
-
|
690
|
-
/**
|
691
|
-
* Create the table that becomes the key
|
692
|
-
*/
|
693
|
-
var str = '<table border="0" cellspacing="0" cellpadding="0" id="rgraph_key" style="display: inline;' + (function ()
|
694
|
-
{
|
695
|
-
var style = ''
|
696
|
-
for (i in prop.tableCss) {
|
697
|
-
if (typeof i === 'string') {
|
698
|
-
style = style + i + ': ' + prop.tableCss[i] + ';';
|
699
|
-
}
|
700
|
-
}
|
701
|
-
return style;
|
702
|
-
})() + '" ' + (prop.tableClass ? 'class="' + prop.tableClass + '"' : '') + '>';
|
703
|
-
|
704
|
-
|
705
|
-
|
706
|
-
/**
|
707
|
-
* Add the individual key elements
|
708
|
-
*/
|
709
|
-
for (var i=0; i<prop.labels.length; i+=1) {
|
710
|
-
str += '<tr><td><div style="' + (function ()
|
711
|
-
{
|
712
|
-
var style = '';
|
713
|
-
|
714
|
-
for (var j in prop.blobCss) {
|
715
|
-
if (typeof j === 'string') {
|
716
|
-
style = style + j + ': ' + prop.blobCss[j] + ';';
|
717
|
-
}
|
718
|
-
}
|
719
|
-
|
720
|
-
return style;
|
721
|
-
})() + 'display: inline-block; margin-right: 5px; margin-top: 4px; width: 15px; height: 15px; background-color: ' + prop.colors[i] + '"' + (prop.blobClass ? 'class="' + prop.blobClass + '"' : '') + '> </div><td>' + (prop.links && prop.links[i] ? '<a href="' + prop.links[i] + '">' : '') + '<span ' + (prop.labelClass ? 'class="' + prop.labelClass + '"' : '') + '" ' + (function ()
|
722
|
-
{
|
723
|
-
var style = '';
|
724
|
-
|
725
|
-
for (var j in prop.labelCss) {
|
726
|
-
if (typeof j === 'string') {
|
727
|
-
style = style + j + ': ' + prop.labelCss[j] + ';';
|
728
|
-
}
|
729
|
-
}
|
730
|
-
|
731
|
-
return style;
|
732
|
-
})() + (function ()
|
733
|
-
{
|
734
|
-
var style = '';
|
735
|
-
|
736
|
-
if (prop['labelCss_' + i]) {
|
737
|
-
for (var j in prop['labelCss_' + i]) {
|
738
|
-
style = style + j + ': ' + prop['labelCss_' + i][j] + ';';
|
739
|
-
}
|
740
|
-
}
|
741
|
-
|
742
|
-
return style ? 'style="' + style + '"' : '';
|
743
|
-
})() + '>' + prop.labels[i] + '</span>' + (prop.links && prop.links[i] ? '</a>' : '') + '</td></tr>';
|
744
|
-
}
|
745
|
-
|
746
|
-
div.innerHTML += (str + '</table>');
|
747
|
-
|
748
|
-
// Return the TABLE object that is the HTML key
|
749
|
-
return doc.getElementById('rgraph_key');
|
750
|
-
};
|
751
|
-
|
752
|
-
|
753
|
-
|
754
|
-
|
755
|
-
// End module pattern
|
756
|
-
})(window, document);
|
2
|
+
RGraph=window.RGraph||{isRGraph:true};RGraph.HTML=RGraph.HTML||{};(function(win,doc,undefined)
|
3
|
+
{var RG=RGraph,ua=navigator.userAgent,ma=Math;RG.drawKey=RG.DrawKey=function(obj,key,colors)
|
4
|
+
{if(!key){return;}
|
5
|
+
var ca=obj.canvas,co=obj.context,prop=obj.properties,keypos=prop['chart.key.position'],textsize=prop['chart.text.size'],key_non_null=[],colors_non_null=[];co.lineWidth=1;co.beginPath();if(typeof(prop['chart.key.vpos'])=='number'){obj.Set('chart.key.position.y',prop['chart.key.vpos']*prop['chart.gutter.top']);}
|
6
|
+
for(var i=0;i<key.length;++i){if(key[i]!=null){colors_non_null.push(colors[i]);key_non_null.push(key[i]);}}
|
7
|
+
key=key_non_null;colors=colors_non_null;function DrawKey_graph(obj,key,colors)
|
8
|
+
{var text_size=typeof(prop['chart.key.text.size'])=='number'?prop['chart.key.text.size']:prop['chart.text.size'];var text_italic=prop['chart.key.text.italic']?true:false
|
9
|
+
var text_bold=prop['chart.key.text.bold']?true:false
|
10
|
+
var text_font=prop['chart.key.text.font']||prop['chart.key.font']||prop['chart.text.font'];var gutterLeft=obj.gutterLeft;var gutterRight=obj.gutterRight;var gutterTop=obj.gutterTop;var gutterBottom=obj.gutterBottom;var hpos=prop['chart.yaxispos']=='right'?gutterLeft+10:ca.width-gutterRight-10;var vpos=gutterTop+10;var title=prop['chart.title'];var blob_size=text_size;var hmargin=8;var vmargin=4;var fillstyle=prop['chart.key.background'];var text_color=prop['chart.key.text.color'];var strokestyle='#333';var height=0;var width=0;if(!obj.coords)obj.coords={};obj.coords.key=[];co.font=text_size+'pt '+prop['chart.text.font'];for(i=0;i<key.length;++i){width=Math.max(width,co.measureText(key[i]).width);}
|
11
|
+
width+=5;width+=blob_size;width+=5;width+=5;width+=5;if(prop['chart.yaxispos']=='left'||(obj.type==='pie'&&!prop['chart.yaxispos'])||(obj.type==='hbar'&&!prop['chart.yaxispos'])||(obj.type==='hbar'&&prop['chart.yaxispos']==='center')||(obj.type==='hbar'&&prop['chart.yaxispos']==='right')||(obj.type==='rscatter'&&!prop['chart.yaxispos'])||(obj.type==='radar'&&!prop['chart.yaxispos'])||(obj.type==='rose'&&!prop['chart.yaxispos'])||(obj.type==='funnel'&&!prop['chart.yaxispos'])||(obj.type==='vprogress'&&!prop['chart.yaxispos'])||(obj.type==='hprogress'&&!prop['chart.yaxispos'])){hpos-=width;}
|
12
|
+
if(typeof(prop['chart.key.halign'])=='string'){if(prop['chart.key.halign']=='left'){hpos=gutterLeft+10;}else if(prop['chart.key.halign']=='right'){hpos=ca.width-gutterRight-width;}}
|
13
|
+
if(typeof(prop['chart.key.position.x'])=='number'){hpos=prop['chart.key.position.x'];}
|
14
|
+
if(typeof(prop['chart.key.position.y'])=='number'){vpos=prop['chart.key.position.y'];}
|
15
|
+
if(prop['chart.key.shadow']){co.shadowColor=prop['chart.key.shadow.color'];co.shadowBlur=prop['chart.key.shadow.blur'];co.shadowOffsetX=prop['chart.key.shadow.offsetx'];co.shadowOffsetY=prop['chart.key.shadow.offsety'];}
|
16
|
+
co.beginPath();co.fillStyle=prop['chart.key.background'];co.strokeStyle='black';if(typeof(prop['chart.key.position.graph.boxed'])=='undefined'||(typeof(prop['chart.key.position.graph.boxed'])=='boolean'&&prop['chart.key.position.graph.boxed'])){if(arguments[3]!=false){co.lineWidth=typeof(prop['chart.key.linewidth'])=='number'?prop['chart.key.linewidth']:1;if(prop['chart.key.rounded']==true){co.beginPath();co.strokeStyle=strokestyle;RG.strokedCurvyRect(co,Math.round(hpos),Math.round(vpos),width-5,5+((text_size+5)*RG.getKeyLength(key)),4);co.stroke();co.fill();RG.NoShadow(obj);}else{co.strokeRect(Math.round(hpos),Math.round(vpos),width-5,5+((text_size+5)*RG.getKeyLength(key)));co.fillRect(Math.round(hpos),Math.round(vpos),width-5,5+((text_size+5)*RG.getKeyLength(key)));}}}
|
17
|
+
RG.NoShadow(obj);co.beginPath();if(prop['chart.key.colors']){colors=prop['chart.key.colors'];}
|
18
|
+
for(var i=key.length-1;i>=0;i--){var j=Number(i)+1;if(typeof(prop['chart.key.color.shape'])=='object'&&typeof(prop['chart.key.color.shape'][i])=='string'){var blob_shape=prop['chart.key.color.shape'][i];}else if(typeof(prop['chart.key.color.shape'])=='string'){var blob_shape=prop['chart.key.color.shape'];}else{var blob_shape='square';}
|
19
|
+
if(blob_shape=='circle'){co.beginPath();co.fillStyle=colors[i];co.arc(hpos+5+(blob_size/2),vpos+(5*j)+(text_size*j)-text_size+(blob_size/2),blob_size/2,0,6.26,0);co.fill();}else if(blob_shape=='line'){co.beginPath();co.strokeStyle=colors[i];co.moveTo(hpos+5,vpos+(5*j)+(text_size*j)-text_size+(blob_size/2));co.lineTo(hpos+blob_size+5,vpos+(5*j)+(text_size*j)-text_size+(blob_size/2));co.stroke();}else if(blob_shape=='triangle'){co.beginPath();co.strokeStyle=colors[i];co.moveTo(hpos+5,vpos+(5*j)+(text_size*j)-text_size+blob_size);co.lineTo(hpos+(blob_size/2)+5,vpos+(5*j)+(text_size*j)-text_size);co.lineTo(hpos+blob_size+5,vpos+(5*j)+(text_size*j)-text_size+blob_size);co.closePath();co.fillStyle=colors[i];co.fill();}else{co.fillStyle=colors[i];co.fillRect(hpos+5,vpos+(5*j)+(text_size*j)-text_size,text_size,text_size+1);}
|
20
|
+
co.beginPath();co.fillStyle=typeof text_color=='object'?text_color[i]:text_color;ret=RG.Text2(obj,{'font':text_font,'size':text_size,'bold':text_bold,'italic':text_italic,'x':hpos+blob_size+5+5,'y':vpos+(5*j)+(text_size*j)+3,'text':key[i],'accessible':!obj.properties['chart.key.interactive']});obj.coords.key[i]=[ret.x,ret.y,ret.width,ret.height,key[i],colors[i],obj];}
|
21
|
+
co.fill();}
|
22
|
+
function DrawKey_gutter(obj,key,colors)
|
23
|
+
{var text_size=typeof(prop['chart.key.text.size'])=='number'?prop['chart.key.text.size']:prop['chart.text.size'],text_bold=prop['chart.key.text.bold'],text_italic=prop['chart.key.text.italic'],text_font=prop['chart.key.text.font']||prop['chart.key.font']||prop['chart.text.font'],text_color=prop['chart.key.text.color'],gutterLeft=obj.gutterLeft,gutterRight=obj.gutterRight,gutterTop=obj.gutterTop,gutterBottom=obj.gutterBottom,hpos=((ca.width-gutterLeft-gutterRight)/2)+obj.gutterLeft,vpos=gutterTop-text_size-5,title=prop['chart.title'],blob_size=text_size,hmargin=8,vmargin=4,fillstyle=prop['chart.key.background'],strokestyle='#999',length=0;if(!obj.coords)obj.coords={};obj.coords.key=[];co.font=text_size+'pt '+text_font;for(i=0;i<key.length;++i){length+=hmargin;length+=blob_size;length+=hmargin;length+=co.measureText(key[i]).width;}
|
24
|
+
length+=hmargin;if(obj.type=='pie'){if(prop['chart.align']=='left'){var hpos=obj.radius+gutterLeft;}else if(prop['chart.align']=='right'){var hpos=ca.width-obj.radius-gutterRight;}else{hpos=ca.width/2;}}
|
25
|
+
hpos-=(length/2);if(typeof(prop['chart.key.position.x'])=='number'){hpos=prop['chart.key.position.x'];}
|
26
|
+
if(typeof(prop['chart.key.position.y'])=='number'){vpos=prop['chart.key.position.y'];}
|
27
|
+
if(obj.Get('chart.key.position.gutter.boxed')){if(prop['chart.key.shadow']){co.shadowColor=prop['chart.key.shadow.color'];co.shadowBlur=prop['chart.key.shadow.blur'];co.shadowOffsetX=prop['chart.key.shadow.offsetx'];co.shadowOffsetY=prop['chart.key.shadow.offsety'];}
|
28
|
+
co.beginPath();co.fillStyle=fillstyle;co.strokeStyle=strokestyle;if(prop['chart.key.rounded']){RG.strokedCurvyRect(co,hpos,vpos-vmargin,length,text_size+vmargin+vmargin)}else{co.rect(hpos,vpos-vmargin,length,text_size+vmargin+vmargin);}
|
29
|
+
co.stroke();co.fill();RG.NoShadow(obj);}
|
30
|
+
if(prop['chart.key.colors']){colors=prop['chart.key.colors'];}
|
31
|
+
for(var i=0,pos=hpos;i<key.length;++i){pos+=hmargin;if(typeof(prop['chart.key.color.shape'])=='object'&&typeof(prop['chart.key.color.shape'][i])=='string'){var blob_shape=prop['chart.key.color.shape'][i];}else if(typeof(prop['chart.key.color.shape'])=='string'){var blob_shape=prop['chart.key.color.shape'];}else{var blob_shape='square';}
|
32
|
+
if(blob_shape=='line'){co.beginPath();co.strokeStyle=colors[i];co.moveTo(pos,vpos+(blob_size/2));co.lineTo(pos+blob_size,vpos+(blob_size/2));co.stroke();}else if(blob_shape=='circle'){co.beginPath();co.fillStyle=colors[i];co.moveTo(pos,vpos+(blob_size/2));co.arc(pos+(blob_size/2),vpos+(blob_size/2),(blob_size/2),0,6.28,0);co.fill();}else if(blob_shape=='triangle'){co.fillStyle=colors[i];co.beginPath();co.strokeStyle=colors[i];co.moveTo(pos,vpos+blob_size);co.lineTo(pos+(blob_size/2),vpos);co.lineTo(pos+blob_size,vpos+blob_size);co.closePath();co.fill();}else{co.beginPath();co.fillStyle=colors[i];co.rect(pos,vpos,blob_size,blob_size);co.fill();}
|
33
|
+
pos+=blob_size;pos+=hmargin;co.beginPath();co.fillStyle=(typeof text_color==='object')?text_color[i]:text_color;var ret=RG.Text2(obj,{'font':text_font,'bold':text_bold,'size':text_size,'italic':text_italic,'x':pos,'y':vpos+text_size+3,'text':key[i],accessible:!obj.properties['chart.key.interactive']});co.fill();pos+=co.measureText(key[i]).width;obj.coords.key[i]=[ret.x,ret.y,ret.width,ret.height,key[i],colors[i],obj];}}
|
34
|
+
if(keypos&&keypos=='gutter'){DrawKey_gutter(obj,key,colors);}else if(keypos&&keypos=='graph'){DrawKey_graph(obj,key,colors);}else{alert('[COMMON] ('+obj.id+') Unknown key position: '+keypos);}
|
35
|
+
if(prop['chart.key.interactive']){if(!RGraph.Drawing||!RGraph.Drawing.Rect){alert('[INTERACTIVE KEY] The drawing API Rect library does not appear to have been included (which the interactive key uses)');}
|
36
|
+
if(!RGraph.InstallWindowMousedownListener){alert('[INTERACTIVE KEY] The dynamic library does not appear to have been included');}
|
37
|
+
for(var i=0,len=obj.coords.key.length,maxlen=0;i<len;i+=1){maxlen=Math.max(maxlen,obj.coords.key[i][2]);}
|
38
|
+
for(var i=0,len=obj.coords.key.length;i<len;i+=1){(function(idx)
|
39
|
+
{var arr=obj.coords.key;var value=obj.coords.key[idx];var index=idx;var rect=new RGraph.Drawing.Rect(obj.id,value[0],value[1],prop['chart.key.position']=='gutter'?value[2]:maxlen,value[3]).Set('fillstyle','rgba(0,0,0,0)').Draw();rect.onclick=function(e,shape)
|
40
|
+
{var co=rect.context;co.fillStyle=prop['chart.key.interactive.highlight.label'];co.fillRect(shape.x,shape.y,shape.width,shape.height);if(typeof obj.interactiveKeyHighlight=='function'){obj.Set('chart.key.interactive.index',idx);RG.FireCustomEvent(obj,'onbeforeinteractivekey');obj.interactiveKeyHighlight(index);RG.FireCustomEvent(obj,'onafterinteractivekey');}}
|
41
|
+
rect.onmousemove=function(e,shape)
|
42
|
+
{return true;}})(i);}}};RG.getKeyLength=function(key)
|
43
|
+
{var length=0;for(var i=0,len=key.length;i<len;i+=1){if(key[i]!=null){++length;}}
|
44
|
+
return length;};RGraph.HTML.key=RGraph.HTML.Key=function(id,prop)
|
45
|
+
{var div=doc.getElementById(id);var str='<table border="0" cellspacing="0" cellpadding="0" id="rgraph_key" style="display: inline;'+(function()
|
46
|
+
{var style=''
|
47
|
+
for(i in prop.tableCss){if(typeof i==='string'){style=style+i+': '+prop.tableCss[i]+';';}}
|
48
|
+
return style;})()+'" '+(prop.tableClass?'class="'+prop.tableClass+'"':'')+'>';for(var i=0;i<prop.labels.length;i+=1){str+='<tr><td><div style="'+(function()
|
49
|
+
{var style='';for(var j in prop.blobCss){if(typeof j==='string'){style=style+j+': '+prop.blobCss[j]+';';}}
|
50
|
+
return style;})()+'display: inline-block; margin-right: 5px; margin-top: 4px; width: 15px; height: 15px; background-color: '+prop.colors[i]+'"'+(prop.blobClass?'class="'+prop.blobClass+'"':'')+'> </div><td>'+(prop.links&&prop.links[i]?'<a href="'+prop.links[i]+'">':'')+'<span '+(prop.labelClass?'class="'+prop.labelClass+'"':'')+'" '+(function()
|
51
|
+
{var style='';for(var j in prop.labelCss){if(typeof j==='string'){style=style+j+': '+prop.labelCss[j]+';';}}
|
52
|
+
return style;})()+(function()
|
53
|
+
{var style='';if(prop['labelCss_'+i]){for(var j in prop['labelCss_'+i]){style=style+j+': '+prop['labelCss_'+i][j]+';';}}
|
54
|
+
return style?'style="'+style+'"':'';})()+'>'+prop.labels[i]+'</span>'+(prop.links&&prop.links[i]?'</a>':'')+'</td></tr>';}
|
55
|
+
div.innerHTML+=(str+'</table>');return doc.getElementById('rgraph_key');};})(window,document);
|