rgraph-rails 1.0.8 → 4.62

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 +4 -4
  2. data/README.md +3 -3
  3. data/lib/rgraph-rails/version.rb +1 -1
  4. data/vendor/assets/javascripts/RGraph.bar.js +16 -8
  5. data/vendor/assets/javascripts/RGraph.bipolar.js +1 -1
  6. data/vendor/assets/javascripts/RGraph.common.annotate.js +1 -1
  7. data/vendor/assets/javascripts/RGraph.common.context.js +1 -1
  8. data/vendor/assets/javascripts/RGraph.common.core.js +84 -7
  9. data/vendor/assets/javascripts/RGraph.common.csv.js +1 -1
  10. data/vendor/assets/javascripts/RGraph.common.deprecated.js +1 -1
  11. data/vendor/assets/javascripts/RGraph.common.dynamic.js +1 -1
  12. data/vendor/assets/javascripts/RGraph.common.effects.js +1 -1
  13. data/vendor/assets/javascripts/RGraph.common.key.js +3 -3
  14. data/vendor/assets/javascripts/RGraph.common.resizing.js +1 -1
  15. data/vendor/assets/javascripts/RGraph.common.sheets.js +1 -1
  16. data/vendor/assets/javascripts/RGraph.common.tooltips.js +1 -1
  17. data/vendor/assets/javascripts/RGraph.common.zoom.js +1 -1
  18. data/vendor/assets/javascripts/RGraph.drawing.background.js +1 -1
  19. data/vendor/assets/javascripts/RGraph.drawing.circle.js +1 -1
  20. data/vendor/assets/javascripts/RGraph.drawing.image.js +1 -1
  21. data/vendor/assets/javascripts/RGraph.drawing.marker1.js +1 -1
  22. data/vendor/assets/javascripts/RGraph.drawing.marker2.js +1 -1
  23. data/vendor/assets/javascripts/RGraph.drawing.marker3.js +1 -1
  24. data/vendor/assets/javascripts/RGraph.drawing.poly.js +1 -1
  25. data/vendor/assets/javascripts/RGraph.drawing.rect.js +1 -1
  26. data/vendor/assets/javascripts/RGraph.drawing.text.js +1 -1
  27. data/vendor/assets/javascripts/RGraph.drawing.xaxis.js +1 -1
  28. data/vendor/assets/javascripts/RGraph.drawing.yaxis.js +1 -1
  29. data/vendor/assets/javascripts/RGraph.fuel.js +1 -1
  30. data/vendor/assets/javascripts/RGraph.funnel.js +1 -1
  31. data/vendor/assets/javascripts/RGraph.gantt.js +1 -1
  32. data/vendor/assets/javascripts/RGraph.gauge.js +1 -1
  33. data/vendor/assets/javascripts/RGraph.hbar.js +228 -2
  34. data/vendor/assets/javascripts/RGraph.hprogress.js +1 -1
  35. data/vendor/assets/javascripts/RGraph.line.js +27 -5
  36. data/vendor/assets/javascripts/RGraph.meter.js +1 -1
  37. data/vendor/assets/javascripts/RGraph.modaldialog.js +1 -1
  38. data/vendor/assets/javascripts/RGraph.odo.js +1 -1
  39. data/vendor/assets/javascripts/RGraph.pie.js +1 -1
  40. data/vendor/assets/javascripts/RGraph.radar.js +1 -1
  41. data/vendor/assets/javascripts/RGraph.rose.js +1 -1
  42. data/vendor/assets/javascripts/RGraph.rscatter.js +1 -1
  43. data/vendor/assets/javascripts/RGraph.scatter.js +161 -34
  44. data/vendor/assets/javascripts/RGraph.semicircularprogress.js +1 -1
  45. data/vendor/assets/javascripts/RGraph.svg.bar.js +772 -103
  46. data/vendor/assets/javascripts/RGraph.svg.common.ajax.js +1 -1
  47. data/vendor/assets/javascripts/RGraph.svg.common.core.js +806 -231
  48. data/vendor/assets/javascripts/RGraph.svg.common.csv.js +1 -1
  49. data/vendor/assets/javascripts/RGraph.svg.common.fx.js +24 -24
  50. data/vendor/assets/javascripts/RGraph.svg.common.key.js +206 -0
  51. data/vendor/assets/javascripts/RGraph.svg.common.sheets.js +1 -1
  52. data/vendor/assets/javascripts/RGraph.svg.common.tooltips.js +63 -22
  53. data/vendor/assets/javascripts/RGraph.svg.hbar.js +351 -91
  54. data/vendor/assets/javascripts/RGraph.svg.line.js +159 -64
  55. data/vendor/assets/javascripts/RGraph.svg.pie.js +402 -51
  56. data/vendor/assets/javascripts/RGraph.svg.radar.js +320 -143
  57. data/vendor/assets/javascripts/RGraph.svg.rose.js +1818 -0
  58. data/vendor/assets/javascripts/RGraph.svg.scatter.js +1262 -0
  59. data/vendor/assets/javascripts/RGraph.svg.semicircularprogress.js +106 -57
  60. data/vendor/assets/javascripts/RGraph.svg.waterfall.js +1253 -0
  61. data/vendor/assets/javascripts/RGraph.thermometer.js +7 -6
  62. data/vendor/assets/javascripts/RGraph.vprogress.js +1 -1
  63. data/vendor/assets/javascripts/RGraph.waterfall.js +1 -1
  64. data/vendor/assets/javascripts/financial-data.js +1067 -0
  65. metadata +8 -5
  66. data/vendor/assets/javascripts/RGraph.cornergauge.js +0 -71
  67. data/vendor/assets/javascripts/RGraph.thermometer.old.js +0 -68
@@ -1,4 +1,4 @@
1
- // version: 2017-01-02
1
+ // version: 2017-05-08
2
2
  /**
3
3
  * o--------------------------------------------------------------------------------o
4
4
  * | This file is part of the RGraph package - you can learn more at: |
@@ -26,6 +26,55 @@
26
26
 
27
27
  RG.SVG.Pie = function (conf)
28
28
  {
29
+ //
30
+ // A setter that the constructor uses (at the end)
31
+ // to set all of the properties
32
+ //
33
+ // @param string name The name of the property to set
34
+ // @param string value The value to set the property to
35
+ //
36
+ this.set = function (name, value)
37
+ {
38
+ if (arguments.length === 1 && typeof name === 'object') {
39
+ for (i in arguments[0]) {
40
+ if (typeof i === 'string') {
41
+
42
+ var ret = RG.SVG.commonSetter({
43
+ object: this,
44
+ name: i,
45
+ value: arguments[0][i]
46
+ });
47
+
48
+ name = ret.name;
49
+ value = ret.value;
50
+
51
+ this.set(name, value);
52
+ }
53
+ }
54
+ } else {
55
+
56
+ var ret = RG.SVG.commonSetter({
57
+ object: this,
58
+ name: name,
59
+ value: value
60
+ });
61
+
62
+ name = ret.name;
63
+ value = ret.value;
64
+
65
+ this.properties[name] = value;
66
+ }
67
+
68
+ return this;
69
+ };
70
+
71
+
72
+
73
+
74
+
75
+
76
+
77
+
29
78
  this.id = conf.id;
30
79
  this.uid = RG.SVG.createUID();
31
80
  this.container = document.getElementById(this.id);
@@ -73,6 +122,8 @@
73
122
  textBold: false,
74
123
  textItalic: false,
75
124
  labels: [],
125
+ labelsSticks: true,
126
+ labelsSticksHlength: 50,
76
127
 
77
128
  linewidth: 1,
78
129
 
@@ -91,7 +142,7 @@
91
142
  titleX: null,
92
143
  titleY: null,
93
144
  titleHalign: 'center',
94
- titleValign: 'bottom',
145
+ titleValign: null,
95
146
  titleColor: 'black',
96
147
  titleFont: null,
97
148
  titleBold: false,
@@ -102,7 +153,7 @@
102
153
  titleSubtitleX: null,
103
154
  titleSubtitleY: null,
104
155
  titleSubtitleHalign: 'center',
105
- titleSubtitleValign: 'top',
156
+ titleSubtitleValign: null,
106
157
  titleSubtitleColor: '#aaa',
107
158
  titleSubtitleFont: null,
108
159
  titleSubtitleBold: false,
@@ -117,13 +168,26 @@
117
168
  exploded: 0,
118
169
  roundRobinMultiplier: 1,
119
170
 
171
+ donut: false,
172
+ donutWidth: 75,
173
+
174
+ key: null,
175
+ keyColors: null,
176
+ keyOffsetx: 0,
177
+ keyOffsety: 0,
178
+ keyTextOffsetx: 0,
179
+ keyTextOffsety: -1,
180
+ keyTextSize: null,
181
+ keyTextBold: null,
182
+ keyTextItalic: null,
183
+
120
184
  attribution: true,
121
185
  attributionX: null,
122
186
  attributionY: null,
123
- attributionHref: 'http://www.rgraph.net/svg/index.html',
187
+ attributionHref: null,// Default is set in RGraph.svg.common.core.js
124
188
  attributionHalign: 'right',
125
189
  attributionValign: 'bottom',
126
- attributionSize: 8,
190
+ attributionSize: 7,
127
191
  attributionColor: 'gray',
128
192
  attributionFont: 'sans-serif',
129
193
  attributionItalic: false,
@@ -149,31 +213,6 @@
149
213
 
150
214
 
151
215
 
152
- //
153
- // A setter that the constructor uses (at the end)
154
- // to set all of the properties
155
- //
156
- // @param string name The name of the property to set
157
- // @param string value The value to set the property to
158
- //
159
- this.set = function (name, value)
160
- {
161
- if (arguments.length === 1 && typeof name === 'object') {
162
- for (i in arguments[0]) {
163
- if (typeof i === 'string') {
164
- this.set(i, arguments[0][i]);
165
- }
166
- }
167
- } else {
168
- this.properties[name] = value;
169
- }
170
-
171
- return this;
172
- };
173
-
174
-
175
-
176
-
177
216
 
178
217
 
179
218
 
@@ -216,21 +255,14 @@
216
255
  // Allow the centerx/centery/radius to be a plus/minus
217
256
  //
218
257
  if (typeof prop.radius === 'string' && prop.radius.match(/^\+|-\d+$/) ) this.radius += parseFloat(prop.radius);
219
- if (typeof prop.centerx === 'string' && prop.centerx.match(/^\+|-\d+$/) ) this.centery += parseFloat(prop.centerx);
220
- if (typeof prop.centery === 'string' && prop.centery.match(/^\+|-\d+$/) ) this.centerx += parseFloat(prop.centery);
258
+ if (typeof prop.centerx === 'string' && prop.centerx.match(/^\+|-\d+$/) ) this.centerx += parseFloat(prop.centerx);
259
+ if (typeof prop.centery === 'string' && prop.centery.match(/^\+|-\d+$/) ) this.centery += parseFloat(prop.centery);
221
260
 
222
261
 
223
- /**
224
- * Parse the colors. This allows for simple gradient syntax
225
- *
226
- * ** must be after the cx/cy/r has been calcuated **
227
- */
228
- if (!this.colorsParsed) {
229
- this.parseColors();
230
-
231
- // Don't want to do this again
232
- this.colorsParsed = true;
233
- }
262
+ // Parse the colors for gradients
263
+ // Must be after the cx/cy/r calculations
264
+ RG.SVG.resetColorsToOriginalValues({object:this});
265
+ this.parseColors();
234
266
 
235
267
 
236
268
  // Go through the data and work out the maximum value
@@ -261,8 +293,22 @@
261
293
 
262
294
 
263
295
  // Draw the labels
264
- this.drawLabels();
265
-
296
+ if (prop.labelsSticks) {
297
+ this.drawLabelsSticks();
298
+ } else {
299
+ this.drawLabels();
300
+ }
301
+
302
+
303
+
304
+
305
+ // Draw the key
306
+ if (typeof prop.key !== null && RG.SVG.drawKey) {
307
+ RG.SVG.drawKey(this);
308
+ } else if (!RGraph.SVG.isNull(prop.key)) {
309
+ alert('The drawKey() function does not exist - have you forgotten to include the key library?');
310
+ }
311
+
266
312
 
267
313
  // Add the attribution link. If you're adding this elsewhere on your page/site
268
314
  // and you don't want it displayed then there are options available to not
@@ -374,14 +420,54 @@
374
420
  });
375
421
 
376
422
 
423
+
424
+
425
+
426
+ // Donut
427
+ if (prop.donut) {
428
+
429
+ var donutWidth = prop.donutWidth;
430
+
431
+ var donut_path = RG.SVG.TRIG.getArcPath({
432
+ cx: this.angles[i].cx,
433
+ cy: this.angles[i].cy,
434
+ r: this.radius - donutWidth,
435
+ start: this.angles[i].end,
436
+ end: this.angles[i].start,
437
+ moveto: false,
438
+ anticlockwise: true
439
+ });
440
+
441
+ var xy = RG.SVG.TRIG.getRadiusEndPoint({
442
+ angle: this.angles[i].end - RG.SVG.TRIG.HALFPI,
443
+ r: this.radius - donutWidth
444
+ });
445
+
446
+
447
+
448
+
449
+ path = path
450
+ + " L {1} {2} ".format(xy[0] + this.angles[i].cx, xy[1] + this.angles[i].cy)
451
+ + donut_path
452
+ + " Z";
453
+
454
+
455
+ } else {
456
+
457
+ path = path + " L {1} {2} ".format(
458
+ this.angles[i].cx,
459
+ this.angles[i].cy
460
+ ) + " Z"
461
+ }
462
+
463
+
464
+
377
465
  var arc = RG.SVG.create({
378
466
  svg: this.svg,
467
+ parent: this.svg.all,
379
468
  type: 'path',
380
469
  attr: {
381
- d: path + " L {1} {2} Z".format(
382
- this.angles[i].cx,
383
- this.angles[i].cy
384
- ),
470
+ d: path,
385
471
  fill: prop.colors[i],
386
472
  stroke: prop.strokestyle,
387
473
  'stroke-width': prop.linewidth,
@@ -413,6 +499,8 @@
413
499
  {
414
500
  arc.addEventListener(prop.tooltipsEvent, function (e)
415
501
  {
502
+ obj.removeHighlight();
503
+
416
504
  // Show the tooltip
417
505
  RG.SVG.tooltip({
418
506
  object: obj,
@@ -497,7 +585,7 @@
497
585
  y = endpoint[1] + angles[i].cy,
498
586
  valign,
499
587
  halign;
500
-
588
+
501
589
  // Figure out the valign and halign based on the quadrant
502
590
  // the the center of the sgement is in.
503
591
  if (angles[i].halfway > 0 && angles[i].halfway < RG.SVG.TRIG.HALFPI) {
@@ -516,6 +604,7 @@
516
604
 
517
605
  RG.SVG.text({
518
606
  object: this,
607
+ parent: this.svg.all,
519
608
  text: typeof labels[i] === 'string' ? labels[i] : '',
520
609
  font: prop.textFont,
521
610
  size: prop.textSize,
@@ -537,6 +626,202 @@
537
626
 
538
627
 
539
628
 
629
+ //
630
+ // This function draws the labels in a list format
631
+ //
632
+ this.drawLabelsSticks = function ()
633
+ {
634
+ var labels_right = [],
635
+ labels_left = [],
636
+ labels_coords = [];
637
+
638
+ for (var i=0; i<this.angles.length; ++i) {
639
+
640
+ var angle = (this.angles[i].start + ((this.angles[i].end - this.angles[i].start) / 2)) - RGraph.SVG.TRIG.HALFPI, // Midpoint
641
+
642
+ endpoint_inner = RG.SVG.TRIG.getRadiusEndPoint({angle: angle, r: this.radius + 5}),
643
+ endpoint_outer = RG.SVG.TRIG.getRadiusEndPoint({angle: angle, r: this.radius + 20}),
644
+
645
+ explosion = [
646
+ (typeof prop.exploded === 'number' ? prop.exploded : prop.exploded[i]),
647
+ ma.cos(angle) * (typeof prop.exploded === 'number' ? prop.exploded : prop.exploded[i]),
648
+ ma.sin(angle) * (typeof prop.exploded === 'number' ? prop.exploded : prop.exploded[i])
649
+ ];
650
+
651
+ // Initialise this array
652
+ labels_coords[i] = [];
653
+
654
+ // Initialise this
655
+ var labels = {};
656
+
657
+
658
+
659
+
660
+
661
+ // Push the label into the correct array
662
+ if (angle > RG.SVG.TRIG.HALFPI) {
663
+
664
+ var index = labels_left.length;
665
+
666
+ labels_left[index] = [];
667
+ labels_left[index].text = prop.labels[i];
668
+ labels_left[index].halign = 'right';
669
+ labels = labels_left;
670
+
671
+ labels_coords[i].halign = 'right';
672
+ } else {
673
+
674
+ var index = labels_right.length;
675
+
676
+ labels_right[index] = [];
677
+ labels_right[index].text = prop.labels[i];
678
+ labels_right[index].halign = 'right';
679
+ labels = labels_right;
680
+
681
+ labels_coords[i].halign = 'left';
682
+ }
683
+
684
+
685
+
686
+
687
+
688
+
689
+
690
+ endpoint_inner[0] += (explosion[1] || 0);
691
+ endpoint_inner[1] += (explosion[2] || 0);
692
+
693
+ endpoint_outer[0] += (explosion[1] || 0);
694
+ endpoint_outer[1] += (explosion[2] || 0);
695
+
696
+ var x,y;
697
+
698
+ if (labels[index].text) {
699
+ var stick = RG.SVG.create({
700
+ svg: this.svg,
701
+ parent: this.svg.all,
702
+ type: 'path',
703
+ attr: {
704
+ d: 'M {1} {2} L {3} {4}'.format(
705
+ this.centerx + endpoint_inner[0],
706
+ this.centery + endpoint_inner[1],
707
+ this.centerx + endpoint_outer[0],
708
+ this.centery + endpoint_outer[1]
709
+ ),
710
+ stroke: '#999',
711
+ fill: 'rgba(0,0,0,0)'
712
+ }
713
+ });
714
+ }
715
+
716
+ // The path is altered later so this needs saving
717
+ if (stick) {
718
+ labels[index].stick = stick;
719
+ }
720
+
721
+ x = (this.centerx + endpoint_outer[0] + (angle > 1.57 ? -50 : 50));
722
+ y = (this.centery + endpoint_outer[1]);
723
+
724
+
725
+ labels_coords[i].x = x ;
726
+ labels_coords[i].y = y;
727
+ labels_coords[i].text = prop.labels[i];
728
+ }
729
+
730
+ // Calculate the spacing for each side
731
+ var vspace_right = (this.height - prop.gutterTop - prop.gutterBottom) / labels_right.length;
732
+ var vspace_left = (this.height - prop.gutterTop - prop.gutterBottom) / labels_left.length;
733
+
734
+ // Reset these
735
+ x = y = 0;
736
+
737
+
738
+
739
+
740
+
741
+ // Loop through the RHS labels
742
+ for (var i=0; i<labels_right.length; ++i) {
743
+ if (labels_right[i] && labels_right[i].text) {
744
+
745
+ x = this.centerx + this.radius + 100;
746
+ y = prop.gutterTop + (vspace_right * i) + (vspace_right / 2);
747
+
748
+
749
+ // Add the label to the scene
750
+ RGraph.SVG.text({
751
+ object: this,
752
+ parent: this.svg.all,
753
+ text: typeof labels_right[i].text === 'string' ? labels_right[i].text : '',
754
+ font: prop.textFont,
755
+ size: prop.textSize,
756
+ x: x,
757
+ y: y,
758
+ valign: 'center',
759
+ halign: labels_right[i].text,
760
+ bold: prop.textBold,
761
+ italic: prop.textItalic,
762
+ color: prop.textColor
763
+ });
764
+
765
+ // Now update the path of the stick
766
+ labels_right[i].stick.setAttribute(
767
+ 'd',
768
+ labels_right[i].stick.getAttribute('d') + ' H {3} L {1} {2} '.format(
769
+ x - 5,
770
+ y,
771
+ this.centerx + this.radius + prop.labelsSticksHlength
772
+ )
773
+ );
774
+ }
775
+ }
776
+
777
+
778
+
779
+
780
+
781
+ // Loop through the LHS labels
782
+ for (var i=0; i<labels_left.length; ++i) {
783
+ if (labels_left[i] && labels_left[i].text) {
784
+
785
+ x = this.centerx - this.radius - 100;
786
+ y = this.height - (prop.gutterTop + (vspace_left * i) + (vspace_left / 2));
787
+
788
+
789
+ // Add the label to the scene
790
+ RGraph.SVG.text({
791
+ object: this,
792
+ parent: this.svg.all,
793
+ text: typeof labels_left[i].text === 'string' ? labels_left[i].text : '',
794
+ font: prop.textFont,
795
+ size: prop.textSize,
796
+ x: x - 7,
797
+ y: y,
798
+ valign: 'center',
799
+ halign: labels_left[i].halign,
800
+ bold: prop.textBold,
801
+ italic: prop.textItalic,
802
+ color: prop.textColor
803
+ });
804
+
805
+ // Now update the path of the stick
806
+ labels_left[i].stick.setAttribute(
807
+ 'd',
808
+ labels_left[i].stick.getAttribute('d') + ' H {3} L {1} {2} '.format(
809
+ x - 5,
810
+ y,
811
+ this.centerx - this.radius - prop.labelsSticksHlength
812
+ )
813
+ );
814
+ }
815
+ }
816
+ };
817
+
818
+
819
+
820
+
821
+
822
+
823
+
824
+
540
825
  /**
541
826
  * This function can be used to highlight a segment on the chart
542
827
  *
@@ -546,6 +831,7 @@
546
831
  {
547
832
  var highlight = RG.SVG.create({
548
833
  svg: this.svg,
834
+ parent: this.svg.all,
549
835
  type: 'path',
550
836
  attr: {
551
837
  d: segment.getAttribute('d'),
@@ -675,11 +961,56 @@
675
961
  var path = RG.SVG.TRIG.getArcPath({
676
962
  cx: obj.centerx + explodedX,
677
963
  cy: obj.centery + explodedY,
678
- r: obj.radius,// * prop.roundRobinMultiplier,
964
+ r: obj.radius,
679
965
  start: obj.angles[i].start,
680
966
  end: obj.angles[i].end
681
967
  });
968
+
969
+
970
+
971
+
972
+
973
+ // Donut
974
+ if (prop.donut) {
975
+
976
+ var donutWidth = prop.donutWidth;
977
+
978
+ var donut_path = RG.SVG.TRIG.getArcPath({
979
+ cx: obj.angles[i].cx,
980
+ cy: obj.angles[i].cy,
981
+ r: obj.radius - donutWidth,
982
+ start: obj.angles[i].end,
983
+ end: obj.angles[i].start,
984
+ moveto: false,
985
+ anticlockwise: true
986
+ });
987
+
988
+ var xy = RG.SVG.TRIG.getRadiusEndPoint({
989
+ angle: obj.angles[i].end - RG.SVG.TRIG.HALFPI,
990
+ r: obj.radius - donutWidth
991
+ });
682
992
 
993
+ path = path
994
+ + " L {1} {2} ".format(xy[0] + obj.angles[i].cx, xy[1] + obj.angles[i].cy)
995
+ + donut_path
996
+ + " Z";
997
+
998
+ } else {
999
+
1000
+ path = path + " L {1} {2} ".format(
1001
+ obj.angles[i].cx,
1002
+ obj.angles[i].cy
1003
+ ) + " Z"
1004
+ }
1005
+
1006
+
1007
+
1008
+
1009
+
1010
+
1011
+
1012
+
1013
+
683
1014
  path = path + " L {1} {2} Z".format(
684
1015
  obj.centerx + explodedX,
685
1016
  obj.centery + explodedY
@@ -760,6 +1091,26 @@
760
1091
 
761
1092
 
762
1093
 
1094
+ //
1095
+ // Remove highlight from the chart (tooltips)
1096
+ //
1097
+ this.removeHighlight = function ()
1098
+ {
1099
+ var highlight = RG.SVG.REG.get('highlight');
1100
+ if (highlight && highlight.parentNode) {
1101
+ highlight.parentNode.removeChild(highlight);
1102
+ }
1103
+
1104
+ RG.SVG.REG.set('highlight', null);
1105
+ };
1106
+
1107
+
1108
+
1109
+
1110
+
1111
+
1112
+
1113
+
763
1114
  //
764
1115
  // Set the options that the user has provided
765
1116
  //