rgraph-rails 4.62 → 4.64

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