rgraph-rails 1.0.3 → 1.0.4

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 (63) hide show
  1. checksums.yaml +8 -8
  2. data/.travis.yml +1 -0
  3. data/README.md +5 -5
  4. data/lib/rgraph-rails/version.rb +1 -1
  5. data/rgraph-rails.gemspec +2 -2
  6. data/vendor/assets/images/bg.png +0 -0
  7. data/vendor/assets/images/bullet.png +0 -0
  8. data/vendor/assets/images/facebook-large.png +0 -0
  9. data/vendor/assets/images/google-plus-large.png +0 -0
  10. data/vendor/assets/images/logo.png +0 -0
  11. data/vendor/assets/images/meter-image-sd-needle.png +0 -0
  12. data/vendor/assets/images/meter-image-sd.png +0 -0
  13. data/vendor/assets/images/meter-sketch-needle.png +0 -0
  14. data/vendor/assets/images/meter-sketch.png +0 -0
  15. data/vendor/assets/images/odometer-background.png +0 -0
  16. data/vendor/assets/images/rgraph.jpg +0 -0
  17. data/vendor/assets/images/title.png +0 -0
  18. data/vendor/assets/images/twitter-large.png +0 -0
  19. data/vendor/assets/javascripts/RGraph.bar.js +258 -30
  20. data/vendor/assets/javascripts/RGraph.bipolar.js +4 -3
  21. data/vendor/assets/javascripts/RGraph.common.annotate.js +4 -3
  22. data/vendor/assets/javascripts/RGraph.common.context.js +4 -3
  23. data/vendor/assets/javascripts/RGraph.common.core.js +227 -105
  24. data/vendor/assets/javascripts/RGraph.common.csv.js +4 -3
  25. data/vendor/assets/javascripts/RGraph.common.deprecated.js +4 -3
  26. data/vendor/assets/javascripts/RGraph.common.dynamic.js +5 -4
  27. data/vendor/assets/javascripts/RGraph.common.effects.js +4 -3
  28. data/vendor/assets/javascripts/RGraph.common.key.js +4 -3
  29. data/vendor/assets/javascripts/RGraph.common.resizing.js +4 -3
  30. data/vendor/assets/javascripts/RGraph.common.sheets.js +357 -0
  31. data/vendor/assets/javascripts/RGraph.common.tooltips.js +6 -4
  32. data/vendor/assets/javascripts/RGraph.common.zoom.js +4 -3
  33. data/vendor/assets/javascripts/RGraph.drawing.background.js +4 -3
  34. data/vendor/assets/javascripts/RGraph.drawing.circle.js +4 -3
  35. data/vendor/assets/javascripts/RGraph.drawing.image.js +4 -3
  36. data/vendor/assets/javascripts/RGraph.drawing.marker1.js +4 -3
  37. data/vendor/assets/javascripts/RGraph.drawing.marker2.js +4 -3
  38. data/vendor/assets/javascripts/RGraph.drawing.marker3.js +1 -1
  39. data/vendor/assets/javascripts/RGraph.drawing.poly.js +1 -1
  40. data/vendor/assets/javascripts/RGraph.drawing.rect.js +1 -1
  41. data/vendor/assets/javascripts/RGraph.drawing.text.js +1 -1
  42. data/vendor/assets/javascripts/RGraph.drawing.xaxis.js +1 -1
  43. data/vendor/assets/javascripts/RGraph.drawing.yaxis.js +33 -30
  44. data/vendor/assets/javascripts/RGraph.fuel.js +14 -16
  45. data/vendor/assets/javascripts/RGraph.funnel.js +1 -1
  46. data/vendor/assets/javascripts/RGraph.gantt.js +1 -1
  47. data/vendor/assets/javascripts/RGraph.gauge.js +3 -5
  48. data/vendor/assets/javascripts/RGraph.hbar.js +738 -212
  49. data/vendor/assets/javascripts/RGraph.hprogress.js +30 -33
  50. data/vendor/assets/javascripts/RGraph.line.js +246 -31
  51. data/vendor/assets/javascripts/RGraph.meter.js +72 -36
  52. data/vendor/assets/javascripts/RGraph.modaldialog.js +1 -1
  53. data/vendor/assets/javascripts/RGraph.odo.js +3 -5
  54. data/vendor/assets/javascripts/RGraph.pie.js +23 -15
  55. data/vendor/assets/javascripts/RGraph.radar.js +1 -1
  56. data/vendor/assets/javascripts/RGraph.rose.js +2 -2
  57. data/vendor/assets/javascripts/RGraph.rscatter.js +116 -27
  58. data/vendor/assets/javascripts/RGraph.scatter.js +14 -15
  59. data/vendor/assets/javascripts/RGraph.thermometer.js +8 -10
  60. data/vendor/assets/javascripts/RGraph.vprogress.js +8 -10
  61. data/vendor/assets/javascripts/RGraph.waterfall.js +1 -1
  62. data/vendor/assets/stylesheets/website.css +32 -2
  63. metadata +6 -5
@@ -1,4 +1,4 @@
1
- // version: 2015-11-02
1
+ // version: 2016-02-06
2
2
  /**
3
3
  * o--------------------------------------------------------------------------------o
4
4
  * | This file is part of the RGraph package - you can learn more at: |
@@ -29,8 +29,6 @@
29
29
  * Allow for object config style
30
30
  */
31
31
  if ( typeof conf === 'object'
32
- && typeof conf.min === 'number'
33
- && typeof conf.max === 'number'
34
32
  && typeof conf.value !== 'undefined'
35
33
  && typeof conf.id === 'string') {
36
34
 
@@ -60,8 +58,8 @@
60
58
  this.context = this.canvas.getContext ? this.canvas.getContext("2d", {alpha: (typeof id === 'object' && id.alpha === false) ? false : true}) : null;
61
59
  this.canvas.__object__ = this;
62
60
  this.type = 'meter';
63
- this.min = min;
64
- this.max = max;
61
+ this.min = RGraph.stringsToNumbers(min);
62
+ this.max = RGraph.stringsToNumbers(max);
65
63
  this.value = RGraph.stringsToNumbers(value);
66
64
  this.centerx = null;
67
65
  this.centery = null;
@@ -162,6 +160,7 @@
162
160
  'chart.centery': null,
163
161
  'chart.labels': true,
164
162
  'chart.labels.count': 10,
163
+ 'chart.labels.specific': null,
165
164
  'chart.segment.radius.start': 0,
166
165
  'chart.needle.radius': null,
167
166
  'chart.needle.tail': false,
@@ -865,18 +864,55 @@
865
864
  return;
866
865
  }
867
866
 
868
- var radius = this.radius;
869
- var text_size = prop['chart.text.size'];
870
- var text_font = prop['chart.text.font'];
871
- var units_post = prop['chart.units.post'];
872
- var units_pre = prop['chart.units.pre'];
873
- var centerx = this.centerx;
874
- var centery = this.centery;
875
- var min = this.min;
876
- var max = this.max;
877
- var decimals = prop['chart.scale.decimals'];
878
- var numLabels = prop['chart.labels.count'];
879
-
867
+ var radius = this.radius,
868
+ text_size = prop['chart.text.size'],
869
+ text_font = prop['chart.text.font'],
870
+ units_post = prop['chart.units.post'],
871
+ units_pre = prop['chart.units.pre'],
872
+ centerx = this.centerx,
873
+ centery = this.centery,
874
+ min = this.min,
875
+ max = this.max,
876
+ decimals = prop['chart.scale.decimals'],
877
+ numLabels = prop['chart.labels.count'],
878
+ specific = prop['chart.labels.specific']
879
+
880
+
881
+
882
+
883
+ //
884
+ // Draw the specific labels if they're specifid
885
+ //
886
+ if (specific) {
887
+ for (var i=0; i<specific.length; ++i) {
888
+
889
+ var angle = this.getAngle(specific[i][1]),
890
+ angle_degrees = angle * (180 / RG.PI),
891
+ text = specific[i][0].toString(),
892
+ coords = RG.getRadiusEndPoint(this.centerx, this.centery, angle, this.radius * 0.925)
893
+
894
+
895
+ RG.text2(this, {
896
+ 'font':text_font,
897
+ 'size':text_size,
898
+ 'x': coords[0],
899
+ 'y': coords[1],
900
+ 'text':text,
901
+ 'halign':'center',
902
+ 'valign':'center',
903
+ 'angle':angle_degrees + 90,
904
+ 'bounding': false,
905
+ 'tag': 'labels-specific',
906
+ color: 'black'
907
+ });
908
+ }
909
+
910
+ return;
911
+ }
912
+
913
+
914
+
915
+
880
916
  co.fillStyle = prop['chart.text.color'];
881
917
  co.lineWidth = 1;
882
918
 
@@ -887,13 +923,12 @@
887
923
  var angle = ((prop['chart.angles.end'] - prop['chart.angles.start']) * (i / numLabels)) + prop['chart.angles.start'];
888
924
  var coords = RG.getRadiusEndPoint(centerx, centery, angle + (((i == 0 || i == numLabels) && prop['chart.border']) ? (i == 0 ? 0.05 : -0.05) : 0), (this.radius * 0.925) - (prop['chart.text.valign'] === 'bottom' ? 15 : 0));
889
925
 
890
- var angleStart = prop['chart.angles.start'];
891
- var angleEnd = prop['chart.angles.end'];
892
- var angleRange = angleEnd - angleStart;
893
-
894
- var angleStart_degrees = angleStart * (180 / RG.PI);
895
- var angleEnd_degrees = angleEnd * (180 / RG.PI);
896
- var angleRange_degrees = angleRange * (180 / RG.PI);
926
+ var angleStart = prop['chart.angles.start'],
927
+ angleEnd = prop['chart.angles.end'],
928
+ angleRange = angleEnd - angleStart,
929
+ angleStart_degrees = angleStart * (180 / RG.PI),
930
+ angleEnd_degrees = angleEnd * (180 / RG.PI),
931
+ angleRange_degrees = angleRange * (180 / RG.PI)
897
932
 
898
933
  // Vertical alignment
899
934
  valign = prop['chart.text.valign'];
@@ -911,18 +946,19 @@
911
946
  halign = 'center';
912
947
  }
913
948
 
914
- RG.Text2(this, {'font':text_font,
915
- 'size':text_size,
916
- 'x':coords[0],
917
- 'y':coords[1],
918
- 'text':RG.numberFormat(this, (((this.max - this.min) * (i / numLabels)) + this.min).toFixed(decimals),units_pre,units_post),
919
- 'halign':halign,
920
- 'valign':valign,
921
- 'angle':((angleRange_degrees * (1 / numLabels) * i) + angleStart_degrees) - 270,
922
- 'bounding':false,
923
- 'boundingFill':(i == 0 || i == numLabels) ? 'white': null,
924
- 'tag': 'scale'
925
- });
949
+ RG.text2(this, {
950
+ 'font':text_font,
951
+ 'size':text_size,
952
+ 'x':coords[0],
953
+ 'y':coords[1],
954
+ 'text':RG.numberFormat(this, (((this.max - this.min) * (i / numLabels)) + this.min).toFixed(decimals),units_pre,units_post),
955
+ 'halign':halign,
956
+ 'valign':valign,
957
+ 'angle':((angleRange_degrees * (1 / numLabels) * i) + angleStart_degrees) - 270,
958
+ 'bounding':false,
959
+ 'boundingFill':(i == 0 || i == numLabels) ? 'white': null,
960
+ 'tag': 'scale'
961
+ });
926
962
  }
927
963
  };
928
964
 
@@ -1,4 +1,4 @@
1
- // version: 2015-11-02
1
+ // version: 2016-02-06
2
2
  /**
3
3
  * o--------------------------------------------------------------------------------o
4
4
  * | This file is part of the RGraph package - you can learn more at: |
@@ -1,4 +1,4 @@
1
- // version: 2015-11-02
1
+ // version: 2016-02-06
2
2
  /**
3
3
  * o--------------------------------------------------------------------------------o
4
4
  * | This file is part of the RGraph package - you can learn more at: |
@@ -30,8 +30,6 @@
30
30
  * Allow for object config style
31
31
  */
32
32
  if ( typeof conf === 'object'
33
- && typeof conf.min === 'number'
34
- && typeof conf.max === 'number'
35
33
  && typeof conf.value !== 'undefined'
36
34
  && typeof conf.id === 'string') {
37
35
 
@@ -60,8 +58,8 @@
60
58
  this.canvas.__object__ = this;
61
59
  this.type = 'odo';
62
60
  this.isRGraph = true;
63
- this.min = min;
64
- this.max = max;
61
+ this.min = RGraph.stringsToNumbers(min);
62
+ this.max = RGraph.stringsToNumbers(max);
65
63
  this.value = RGraph.stringsToNumbers(value);
66
64
  this.currentValue = null;
67
65
  this.uid = RGraph.CreateUID();
@@ -1,4 +1,4 @@
1
- // version: 2015-11-02
1
+ // version: 2016-02-06
2
2
  /**
3
3
  * o--------------------------------------------------------------------------------o
4
4
  * | This file is part of the RGraph package - you can learn more at: |
@@ -83,6 +83,8 @@
83
83
  'chart.labels.sticks': false,
84
84
  'chart.labels.sticks.length': 7,
85
85
  'chart.labels.sticks.color': '#aaa',
86
+ 'chart.labels.sticks.usecolors': false,
87
+ 'chart.labels.sticks.linewidth': 1,
86
88
  'chart.labels.sticks.hlength': 5,
87
89
  'chart.labels.ingraph': null,
88
90
  'chart.labels.ingraph.color': null,
@@ -875,14 +877,16 @@
875
877
  this.drawSticks =
876
878
  this.DrawSticks = function ()
877
879
  {
878
- var context = co;
879
- var offset = prop['chart.linewidth'] / 2;
880
- var exploded = prop['chart.exploded'];
881
- var sticks = prop['chart.labels.sticks'];
882
- var cx = this.centerx;
883
- var cy = this.centery;
884
- var radius = this.radius;
885
- var points = [];
880
+ var context = co,
881
+ offset = prop['chart.linewidth'] / 2,
882
+ exploded = prop['chart.exploded'],
883
+ sticks = prop['chart.labels.sticks'],
884
+ colors = prop['chart.colors'],
885
+ cx = this.centerx,
886
+ cy = this.centery,
887
+ radius = this.radius,
888
+ points = [],
889
+ linewidth = prop['chart.labels.sticks.linewidth']
886
890
 
887
891
  for (var i=0,len=this.angles.length; i<len; ++i) {
888
892
 
@@ -897,7 +901,14 @@
897
901
 
898
902
  co.beginPath();
899
903
  co.strokeStyle = prop['chart.labels.sticks.color'];
900
- co.lineWidth = 1;
904
+ co.lineWidth = prop['chart.labels.sticks.linewidth'];
905
+
906
+ //
907
+ // Allow for labelsSticksUseColors
908
+ //
909
+ if (prop['chart.labels.sticks.usecolors']) {
910
+ co.strokeStyle = prop['chart.colors'][i];
911
+ }
901
912
 
902
913
  var midpoint = (segment[0] + (radians / 2));
903
914
 
@@ -908,9 +919,6 @@
908
919
  } else {
909
920
  var extra = 0;
910
921
  }
911
-
912
- //context.lineJoin = 'round';
913
- co.lineWidth = 1;
914
922
 
915
923
  /**
916
924
  * Determine the stick length
@@ -1228,8 +1236,8 @@
1228
1236
 
1229
1237
  co.strokeStyle = prop['chart.highlight.style.2d.stroke'];
1230
1238
  co.fillStyle = prop['chart.highlight.style.2d.fill'];
1231
-
1232
- if (prop['chart.variant'].indexOf('donut') -1) {
1239
+
1240
+ if (prop['chart.variant'].indexOf('donut') > -1) {
1233
1241
  co.arc(shape['x'], shape['y'], shape['radius'], shape['angle.start'], shape['angle.end'], false);
1234
1242
  co.arc(shape['x'], shape['y'], typeof(prop['chart.variant.donut.width']) == 'number' ? this.radius - prop['chart.variant.donut.width'] : shape['radius'] / 2, shape['angle.end'], shape['angle.start'], true);
1235
1243
  } else {
@@ -1,4 +1,4 @@
1
- // version: 2015-11-02
1
+ // version: 2016-02-06
2
2
  /**
3
3
  * o--------------------------------------------------------------------------------o
4
4
  * | This file is part of the RGraph package - you can learn more at: |
@@ -1,4 +1,4 @@
1
- // version: 2015-11-02
1
+ // version: 2016-02-06
2
2
  /**
3
3
  * o--------------------------------------------------------------------------------o
4
4
  * | This file is part of the RGraph package - you can learn more at: |
@@ -1219,7 +1219,7 @@
1219
1219
 
1220
1220
 
1221
1221
  if (co.isPointInPath(mouseXY[0], mouseXY[1])) {
1222
-
1222
+
1223
1223
  angles[i][6] = i;
1224
1224
 
1225
1225
  if (RG.parseTooltipText) {
@@ -1,4 +1,4 @@
1
- // version: 2015-11-02
1
+ // version: 2016-02-06
2
2
  /**
3
3
  * o--------------------------------------------------------------------------------o
4
4
  * | This file is part of the RGraph package - you can learn more at: |
@@ -201,7 +201,16 @@
201
201
  'chart.segment.highlight': false,
202
202
  'chart.segment.highlight.count': null,
203
203
  'chart.segment.highlight.fill': 'rgba(0,255,0,0.5)',
204
- 'chart.segment.highlight.stroke':'rgba(0,0,0,0)'
204
+ 'chart.segment.highlight.stroke':'rgba(0,0,0,0)',
205
+ 'chart.line': false,
206
+ 'chart.line.close': false,
207
+ 'chart.line.linewidth': 1,
208
+ 'chart.line.colors': ['black'],
209
+ 'chart.line.shadow': false,
210
+ 'chart.line.shadow.color': 'black',
211
+ 'chart.line.shadow.blur': 2,
212
+ 'chart.line.shadow.offsetx': 3,
213
+ 'chart.line.shadow.offsety': 3
205
214
  }
206
215
 
207
216
 
@@ -741,35 +750,108 @@
741
750
  var data = this.data[dataset];
742
751
  this.coords2[dataset] = [];
743
752
 
744
- for (var i=0; i<data.length; ++i) {
745
-
746
- var d1 = data[i][0];
747
- var d2 = data[i][1];
748
- var a = d1 / (180 / RG.PI); // RADIANS
749
- var r = ( (d2 - prop['chart.ymin']) / (this.scale2.max - this.scale2.min) ) * this.radius;
750
- var x = Math.sin(a) * r;
751
- var y = Math.cos(a) * r;
752
- var color = data[i][2] ? data[i][2] : prop['chart.colors.default'];
753
- var tooltip = data[i][3] ? data[i][3] : null;
754
-
755
- if (tooltip && String(tooltip).length) {
756
- this.hasTooltips = true;
753
+ var drawPoints = function (obj)
754
+ {
755
+ for (var i=0; i<data.length; ++i) {
756
+
757
+ var d1 = data[i][0],
758
+ d2 = data[i][1],
759
+ a = d1 / (180 / RG.PI), // RADIANS
760
+ r = ( (d2 - prop['chart.ymin']) / (obj.scale2.max - obj.scale2.min) ) * obj.radius,
761
+ x = Math.sin(a) * r,
762
+ y = Math.cos(a) * r,
763
+ color = data[i][2] ? data[i][2] : prop['chart.colors.default'],
764
+ tooltip = data[i][3] ? data[i][3] : null
765
+
766
+ if (tooltip && String(tooltip).length) {
767
+ obj.hasTooltips = true;
768
+ }
769
+
770
+ /**
771
+ * Account for the correct quadrant
772
+ */
773
+ x = x + obj.centerx;
774
+ y = obj.centery - y;
775
+
776
+
777
+ obj.drawTick(x, y, color);
778
+
779
+ // Populate the coords array with the coordinates and the tooltip
780
+ obj.coords.push([x, y, color, tooltip]);
781
+ obj.coords2[dataset].push([x, y, color, tooltip]);
757
782
  }
758
-
759
- /**
760
- * Account for the correct quadrant
761
- */
762
- x = x + this.centerx;
763
- y = this.centery - y;
764
-
765
-
766
- this.DrawTick(x, y, color);
783
+ }
784
+
785
+ drawPoints(this);
786
+
787
+ if (prop['chart.line']) {
788
+ this.drawLine(dataset);
789
+ }
790
+
791
+ drawPoints(this);
792
+ }
793
+ };
794
+
795
+
796
+
797
+
798
+ /*
799
+ * Draws a connecting line through the points if requested
800
+ *
801
+ * @param object opt The options to the line
802
+ */
803
+ this.drawLine = function (idx)
804
+ {
805
+ var opt = {
806
+ dataset: idx,
807
+ coords: this.coords2[idx],
808
+ color: prop['chart.line.colors'][idx],
809
+ shadow: prop['chart.line.shadow'],
810
+ shadowColor: prop['chart.line.shadow.color'],
811
+ shadowOffsetX: prop['chart.line.shadow.offsetx'],
812
+ shadowOffsetY: prop['chart.line.shadow.offsety'],
813
+ shadowBlur: prop['chart.line.shadow.blur'],
814
+ linewidth: prop['chart.line.linewidth']
815
+ };
816
+
817
+ co.beginPath();
818
+
819
+ co.strokeStyle = this.parseSingleColorForGradient(opt.color);
820
+ co.lineWidth = typeof prop['chart.line.linewidth'] === 'object' ? prop['chart.line.linewidth'][idx] : prop['chart.line.linewidth'];
821
+ co.lineCap = 'round';
822
+
823
+ if (opt.shadow) {
824
+ RG.setShadow(
825
+ this,
826
+ opt.shadowColor,
827
+ opt.shadowOffsetX,
828
+ opt.shadowOffsetY,
829
+ opt.shadowBlur
830
+ );
831
+ }
832
+
833
+ for (var i=0; i<this.coords2[idx].length; ++i) {
834
+ if (i === 0) {
835
+ co.moveTo(this.coords2[idx][i][0], this.coords2[idx][i][1]);
767
836
 
768
- // Populate the coords array with the coordinates and the tooltip
769
- this.coords.push([x, y, color, tooltip]);
770
- this.coords2[dataset].push([x, y, color, tooltip]);
837
+ var startCoords = RG.arrayClone(this.coords2[idx]);
838
+
839
+ } else {
840
+ co.lineTo(this.coords2[idx][i][0], this.coords2[idx][i][1]);
771
841
  }
772
842
  }
843
+
844
+ // Draw the line back to the start?
845
+ if (
846
+ (typeof prop['chart.line.close'] === 'boolean' && prop['chart.line.close'])
847
+ || (typeof prop['chart.line.close'] === 'object' && prop['chart.line.close'][idx])
848
+ ) {
849
+ co.lineTo(this.coords2[idx][0][0], this.coords2[idx][0][1]);
850
+ }
851
+
852
+ co.stroke();
853
+
854
+ RG.noShadow(this);
773
855
  };
774
856
 
775
857
 
@@ -908,6 +990,10 @@
908
990
  co.strokeStyle = color;
909
991
  co.fillStyle = color;
910
992
 
993
+ // Set the linewidth for the tickmark to 1
994
+ var prevLinewidth = co.lineWidth;
995
+ co.lineWidth = 1;
996
+
911
997
  // Cross
912
998
  if (tickmarks == 'cross') {
913
999
 
@@ -958,6 +1044,9 @@
958
1044
  co.lineTo(x + ticksize, y);
959
1045
  co.stroke();
960
1046
  }
1047
+
1048
+
1049
+ co.lineWidth = prevLinewidth;
961
1050
  };
962
1051
 
963
1052