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: |
@@ -27,26 +27,24 @@
27
27
  /**
28
28
  * Allow for object config style
29
29
  */
30
- if ( typeof conf === 'object'
31
- && typeof conf.min === 'number'
32
- && typeof conf.max === 'number'
30
+ if ( typeof conf === 'object'
33
31
  && typeof conf.value !== 'undefined'
34
- && typeof conf.id === 'string') {
35
-
36
- var id = conf.id
37
- var canvas = document.getElementById(id);
38
- var min = conf.min;
39
- var max = conf.max;
40
- var value = conf.value;
41
- var parseConfObjectForOptions = true; // Set this so the config is parsed (at the end of the constructor)
32
+ && typeof conf.id === 'string') {
33
+
34
+ var id = conf.id,
35
+ canvas = document.getElementById(id),
36
+ min = conf.min,
37
+ max = conf.max,
38
+ value = conf.value,
39
+ parseConfObjectForOptions = true; // Set this so the config is parsed (at the end of the constructor)
42
40
 
43
41
  } else {
44
42
 
45
- var id = conf;
46
- var canvas = document.getElementById(id);
47
- var min = arguments[1];
48
- var max = arguments[2];
49
- var value = arguments[3];
43
+ var id = conf,
44
+ canvas = document.getElementById(id),
45
+ min = arguments[1],
46
+ max = arguments[2],
47
+ value = arguments[3];
50
48
  }
51
49
 
52
50
 
@@ -56,8 +54,8 @@
56
54
  this.context = this.canvas.getContext('2d');
57
55
  this.canvas.__object__ = this;
58
56
 
59
- this.min = min;
60
- this.max = max;
57
+ this.min = RGraph.stringsToNumbers(min);
58
+ this.max = RGraph.stringsToNumbers(max);
61
59
  this.value = RGraph.stringsToNumbers(value);
62
60
  this.type = 'hprogress';
63
61
  this.coords = [];
@@ -319,7 +317,7 @@
319
317
  /**
320
318
  * Fire the onbeforedraw event
321
319
  */
322
- RG.FireCustomEvent(this, 'onbeforedraw');
320
+ RG.fireCustomEvent(this, 'onbeforedraw');
323
321
 
324
322
 
325
323
 
@@ -430,7 +428,7 @@
430
428
  this.exec = function (func)
431
429
  {
432
430
  func(this);
433
-
431
+
434
432
  return this;
435
433
  };
436
434
 
@@ -446,19 +444,18 @@
446
444
  /**
447
445
  * First get the scale
448
446
  */
449
-
450
447
  this.scale2 = RG.getScale2(this, {
451
- 'max':this.max,
452
- 'min':this.min,
453
- 'strict':true,
454
- 'scale.thousand':prop['chart.scale.thousand'],
455
- 'scale.point':prop['chart.scale.point'],
456
- 'scale.decimals':prop['chart.scale.decimals'],
457
- 'ylabels.count':prop['chart.labels.count'],
458
- 'scale.round':prop['chart.scale.round'],
459
- 'units.pre': prop['chart.units.pre'],
460
- 'units.post': prop['chart.units.post']
461
- });
448
+ 'max':this.max,
449
+ 'min':this.min,
450
+ 'strict':true,
451
+ 'scale.thousand':prop['chart.scale.thousand'],
452
+ 'scale.point':prop['chart.scale.point'],
453
+ 'scale.decimals':prop['chart.scale.decimals'],
454
+ 'ylabels.count':prop['chart.labels.count'],
455
+ 'scale.round':prop['chart.scale.round'],
456
+ 'units.pre': prop['chart.units.pre'],
457
+ 'units.post': prop['chart.units.post']
458
+ });
462
459
 
463
460
  // Set a shadow if requested
464
461
  if (prop['chart.shadow']) {
@@ -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: |
@@ -266,6 +266,7 @@
266
266
  'chart.adjustable': false,
267
267
  'chart.noredraw': false,
268
268
  'chart.outofbounds': false,
269
+ 'chart.outofbounds.clip': false,
269
270
  'chart.chromefix': true,
270
271
  'chart.animation.factor': 1,
271
272
  'chart.animation.unfold.x': false,
@@ -275,7 +276,15 @@
275
276
  'chart.curvy': false,
276
277
  'chart.line.visible': true,
277
278
  'chart.events.click': null,
278
- 'chart.events.mousemove': null
279
+ 'chart.events.mousemove': null,
280
+ 'chart.errorbars': false,
281
+ 'chart.errorbars.color': 'black',
282
+ 'chart.errorbars.capped': true,
283
+ 'chart.errorbars.capped.width': 12,
284
+ 'chart.errorbars.linewidth': 1,
285
+ 'chart.combinedchart.effect': null,
286
+ 'chart.combinedchart.effect.options': null,
287
+ 'chart.combinedchart.effect.callback': null
279
288
  }
280
289
 
281
290
  /**
@@ -831,16 +840,39 @@
831
840
  } else {
832
841
  var tickmarks = null;
833
842
  }
834
-
835
843
 
836
- this.DrawLine(this.data[i],
837
- prop['chart.colors'][j],
838
- fill,
839
- this.GetLineWidth(j),
840
- tickmarks,
841
- i);
842
-
844
+ //
845
+ // Draw the line, accounting for the outofboundsClip option
846
+ //
847
+ if (prop['chart.outofbounds.clip']) {
848
+ pa2(
849
+ co,
850
+ 'sa b r % % % % cl b',
851
+ 0,
852
+ this.gutterTop,
853
+ ca.width,
854
+ ca.height - this.gutterTop - this.gutterBottom
855
+ );
856
+ }
857
+ this.drawLine(
858
+ this.data[i],
859
+ prop['chart.colors'][j],
860
+ fill,
861
+ this.getLineWidth(j),
862
+ tickmarks,
863
+ i
864
+ );
865
+ if (prop['chart.outofbounds.clip']) {
866
+ co.restore();
867
+ }
868
+
843
869
  co.stroke();
870
+
871
+ /**
872
+ * Draw errorbars
873
+ *
874
+ * ** This is now done in the redrawLine function **
875
+ */
844
876
  }
845
877
 
846
878
  /**
@@ -869,7 +901,7 @@
869
901
  co.stroke();
870
902
  // No fill!
871
903
  }
872
-
904
+
873
905
  //Redraw the tickmarks
874
906
  if (prop['chart.tickmarks']) {
875
907
 
@@ -925,6 +957,10 @@
925
957
 
926
958
 
927
959
 
960
+
961
+
962
+
963
+
928
964
  for (var i=0,len=this.coords2.length; i<len; i+=1) {
929
965
  for (var j=0,len2=this.coords2[i].length; j<len2; ++j) {
930
966
  if (typeof(this.coords2[i][j]) == 'object' && typeof(this.coords2[i][j][0]) == 'number' && typeof(this.coords2[i][j][1]) == 'number') {
@@ -1098,11 +1134,6 @@
1098
1134
  this.drawAxes =
1099
1135
  this.DrawAxes = function ()
1100
1136
  {
1101
- //var RG = RGraph;
1102
- //var ca = this.canvas;
1103
- //var co = this.context;
1104
- //var prop = this.properties;
1105
-
1106
1137
  // Don't draw the axes?
1107
1138
  if (prop['chart.noaxes']) {
1108
1139
  return;
@@ -1112,7 +1143,8 @@
1112
1143
  RG.noShadow(this);
1113
1144
 
1114
1145
  co.lineWidth = prop['chart.axis.linewidth'] + 0.001;
1115
- co.lineCap = 'butt';
1146
+ co.lineCap = 'square';
1147
+ co.lineJoin = 'miter';
1116
1148
  co.strokeStyle = prop['chart.axis.color'];
1117
1149
  co.beginPath();
1118
1150
 
@@ -2050,15 +2082,32 @@
2050
2082
  co.beginPath();
2051
2083
  co.rect(0,0,ca.width * prop['chart.animation.trace.clip'],ca.height);
2052
2084
  co.clip();
2053
-
2085
+
2086
+
2087
+
2088
+
2089
+
2090
+ //
2091
+ // Draw errorbars
2092
+ //
2093
+ if (typeof prop['chart.errorbars'] !== 'null') {
2094
+ this.drawErrorbars();
2095
+ }
2096
+
2097
+
2098
+
2099
+
2054
2100
  // Now redraw the lines with the correct line width
2055
2101
  this.SetShadow(index);
2056
2102
  this.RedrawLine(lineCoords, color, linewidth, index);
2057
2103
  co.stroke();
2058
2104
  RG.NoShadow(this);
2059
-
2060
-
2061
-
2105
+
2106
+
2107
+
2108
+
2109
+
2110
+
2062
2111
 
2063
2112
  // Draw the tickmarks
2064
2113
  for (var i=0; i<lineCoords.length; ++i) {
@@ -2694,15 +2743,15 @@
2694
2743
  this.getShape =
2695
2744
  this.getPoint = function (e)
2696
2745
  {
2697
- var obj = this;
2698
- var RG = RGraph;
2699
- var ca = canvas = e.target;
2700
- var co = context = this.context;
2701
- var prop = this.properties;
2702
-
2703
- var mouseXY = RG.getMouseXY(e);
2704
- var mouseX = mouseXY[0];
2705
- var mouseY = mouseXY[1];
2746
+ var obj = this,
2747
+ RG = RGraph,
2748
+ ca = canvas = e.target,
2749
+ co = context = this.context,
2750
+ prop = this.properties;
2751
+
2752
+ var mouseXY = RG.getMouseXY(e),
2753
+ mouseX = mouseXY[0],
2754
+ mouseY = mouseXY[1];
2706
2755
 
2707
2756
  // This facilitates you being able to pass in the bar object as a parameter instead of
2708
2757
  // the function getting it from the object
@@ -3027,7 +3076,7 @@
3027
3076
 
3028
3077
  y = ca.height - this.gutterBottom - y;
3029
3078
  }
3030
-
3079
+
3031
3080
  return y;
3032
3081
  };
3033
3082
 
@@ -3424,6 +3473,169 @@
3424
3473
 
3425
3474
 
3426
3475
 
3476
+ //
3477
+ // Draws error-bars for the Bar and Line charts
3478
+ //
3479
+ this.drawErrorbars = function ()
3480
+ {
3481
+ // Save the state of the canvas so that it can be restored at the end
3482
+ co.save();
3483
+
3484
+ RG.noShadow(this);
3485
+
3486
+ var coords = this.coords,
3487
+ x = 0,
3488
+ errorbars = prop['chart.errorbars'],
3489
+ length = 0;
3490
+
3491
+ // If not capped set the width of the cap to zero
3492
+ if (!prop['chart.errorbars.capped']) {
3493
+ prop['chart.errorbars.capped.width'] = 0.001;
3494
+ halfwidth = 0.0005;
3495
+ }
3496
+
3497
+ // Set the linewidth
3498
+ co.lineWidth = prop['chart.errorbars.linewidth'];
3499
+
3500
+
3501
+
3502
+
3503
+ for (var i=0; i<coords.length; ++i) {
3504
+
3505
+ var halfwidth = prop['chart.errorbars.capped.width'] / 2 || 5,
3506
+ color = prop['chart.errorbars.color'] || 'black';
3507
+
3508
+ // Set the perbar linewidth if the fourth option in the array
3509
+ // is specified
3510
+ if (errorbars[i] && typeof errorbars[i][3] === 'number') {
3511
+ co.lineWidth = errorbars[i][3];
3512
+ } else if (typeof prop['chart.errorbars.linewidth'] === 'number') {
3513
+ co.lineWidth = prop['chart.errorbars.linewidth'];
3514
+ } else {
3515
+ co.lineWidth = 1;
3516
+ }
3517
+
3518
+
3519
+
3520
+ // Calulate the pixel size
3521
+ if (typeof errorbars === 'number' || typeof errorbars[i] === 'number') {
3522
+
3523
+ if (typeof errorbars === 'number') {
3524
+ var positiveLength = this.getYCoord(this.min) - this.getYCoord(this.min + errorbars),
3525
+ negativeLength = positiveLength;
3526
+ } else {
3527
+ var positiveLength = this.getYCoord(this.min) - this.getYCoord(this.min + errorbars[i]),
3528
+ negativeLength = positiveLength;
3529
+ }
3530
+
3531
+ if (positiveLength || negativeLength) {
3532
+
3533
+ pa2(
3534
+ co,
3535
+ 'lj miter lc square b m % % l % % m % % l % % l % % m % % l % % s %',
3536
+ coords[i][0] - halfwidth,
3537
+ coords[i][1] + negativeLength,
3538
+ coords[i][0] + halfwidth,
3539
+ coords[i][1] + negativeLength,
3540
+ coords[i][0],
3541
+ coords[i][1] + negativeLength,
3542
+ coords[i][0],
3543
+ coords[i][1] - positiveLength,
3544
+ coords[i][0] - halfwidth,
3545
+ coords[i][1] - positiveLength,
3546
+ coords[i][0],
3547
+ coords[i][1] - positiveLength,
3548
+ coords[i][0] + halfwidth,
3549
+ coords[i][1] - positiveLength,
3550
+ color
3551
+ );
3552
+
3553
+ pa2(
3554
+ co,
3555
+ 'lj miter lc square b m % % l % % s %',
3556
+ coords[i][0] - halfwidth,
3557
+ coords[i][1] + negativeLength,
3558
+ coords[i][0] + halfwidth,
3559
+ coords[i][1] + negativeLength,
3560
+ color
3561
+ );
3562
+ }
3563
+
3564
+
3565
+
3566
+ } else if (typeof errorbars[i] === 'object' && !RG.isNull(errorbars[i])) {
3567
+
3568
+ var positiveLength = this.getYCoord(this.min) - this.getYCoord(this.min + errorbars[i][0]),
3569
+ negativeLength = this.getYCoord(this.min) - this.getYCoord(this.min + errorbars[i][1]);
3570
+
3571
+
3572
+ // Color
3573
+ if (typeof errorbars[i][2] === 'string') {
3574
+ color = errorbars[i][2];
3575
+ }
3576
+
3577
+ // Cap width
3578
+ halfwidth = typeof errorbars[i][4] === 'number' ? errorbars[i][4] / 2 : halfwidth;
3579
+
3580
+
3581
+ // Set the linewidth
3582
+ if (typeof errorbars[i] === 'object' && typeof errorbars[i][3] === 'number') {
3583
+ co.lineWidth = errorbars[i][3];
3584
+ } else if (typeof prop['chart.errorbars.linewidth'] === 'number') {
3585
+ co.lineWidth = prop['chart.errorbars.linewidth'];
3586
+ } else {
3587
+ co.lineWidth = 1;
3588
+ }
3589
+
3590
+
3591
+ if (!RG.isNull(errorbars[i][0])) {
3592
+
3593
+ pa2(
3594
+ co,
3595
+ 'lc square b m % % l % % l % % m % % l % % s %',
3596
+ coords[i][0],
3597
+ coords[i][1],
3598
+ coords[i][0],
3599
+ coords[i][1] - positiveLength,
3600
+ coords[i][0] - halfwidth,
3601
+ ma.round(coords[i][1] - positiveLength),
3602
+ coords[i][0],
3603
+ ma.round(coords[i][1] - positiveLength),
3604
+ coords[i][0] + halfwidth,
3605
+ ma.round(coords[i][1] - positiveLength),
3606
+ color
3607
+ );
3608
+ }
3609
+
3610
+ if (typeof errorbars[i][1] === 'number') {
3611
+
3612
+ var negativeLength = ma.abs(this.getYCoord(errorbars[i][1]) - this.getYCoord(0));
3613
+
3614
+ pa2(
3615
+ co,
3616
+ 'b m % % l % % l % % m % % l % % s %',
3617
+ coords[i][0],
3618
+ coords[i][1],
3619
+ coords[i][0],
3620
+ coords[i][1] + negativeLength,
3621
+ coords[i][0] - halfwidth,
3622
+ ma.round(coords[i][1] + negativeLength),
3623
+ coords[i][0],
3624
+ ma.round(coords[i][1] + negativeLength),
3625
+ coords[i][0] + halfwidth,
3626
+ ma.round(coords[i][1] + negativeLength),
3627
+ color
3628
+ );
3629
+ }
3630
+ }
3631
+ }
3632
+
3633
+ co.restore();
3634
+ };
3635
+
3636
+
3637
+
3638
+
3427
3639
  /**
3428
3640
  * Trace
3429
3641
  *
@@ -3697,6 +3909,7 @@
3697
3909
  function iterator ()
3698
3910
  {
3699
3911
  RG.clear(obj.canvas);
3912
+
3700
3913
  RG.redrawCanvas(obj.canvas);
3701
3914
 
3702
3915
  if (frame++ < frames) {
@@ -3829,6 +4042,8 @@
3829
4042
 
3830
4043
  RG.clear(obj.canvas);
3831
4044
  obj.trace2({frames: frames / 2}, unfoldCallback);
4045
+
4046
+ return obj;
3832
4047
  };
3833
4048
 
3834
4049