flot-rails 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (36) hide show
  1. data/.gitignore +1 -0
  2. data/Gemfile +3 -0
  3. data/README.md +57 -0
  4. data/Rakefile +4 -0
  5. data/flot-rails.gemspec +22 -0
  6. data/lib/flot-rails.rb +1 -0
  7. data/lib/flot/rails.rb +6 -0
  8. data/lib/flot/rails/engine.rb +7 -0
  9. data/lib/flot/rails/version.rb +6 -0
  10. data/vendor/assets/javascripts/excanvas.js +1427 -0
  11. data/vendor/assets/javascripts/excanvas.min.js +1 -0
  12. data/vendor/assets/javascripts/jquery.colorhelpers.js +179 -0
  13. data/vendor/assets/javascripts/jquery.colorhelpers.min.js +1 -0
  14. data/vendor/assets/javascripts/jquery.flot.crosshair.js +167 -0
  15. data/vendor/assets/javascripts/jquery.flot.crosshair.min.js +1 -0
  16. data/vendor/assets/javascripts/jquery.flot.fillbetween.js +183 -0
  17. data/vendor/assets/javascripts/jquery.flot.fillbetween.min.js +1 -0
  18. data/vendor/assets/javascripts/jquery.flot.image.js +238 -0
  19. data/vendor/assets/javascripts/jquery.flot.image.min.js +1 -0
  20. data/vendor/assets/javascripts/jquery.flot.js +2599 -0
  21. data/vendor/assets/javascripts/jquery.flot.min.js +6 -0
  22. data/vendor/assets/javascripts/jquery.flot.navigate.js +336 -0
  23. data/vendor/assets/javascripts/jquery.flot.navigate.min.js +1 -0
  24. data/vendor/assets/javascripts/jquery.flot.pie.js +750 -0
  25. data/vendor/assets/javascripts/jquery.flot.pie.min.js +1 -0
  26. data/vendor/assets/javascripts/jquery.flot.resize.js +60 -0
  27. data/vendor/assets/javascripts/jquery.flot.resize.min.js +1 -0
  28. data/vendor/assets/javascripts/jquery.flot.selection.js +344 -0
  29. data/vendor/assets/javascripts/jquery.flot.selection.min.js +1 -0
  30. data/vendor/assets/javascripts/jquery.flot.stack.js +184 -0
  31. data/vendor/assets/javascripts/jquery.flot.stack.min.js +1 -0
  32. data/vendor/assets/javascripts/jquery.flot.symbol.js +70 -0
  33. data/vendor/assets/javascripts/jquery.flot.symbol.min.js +1 -0
  34. data/vendor/assets/javascripts/jquery.flot.threshold.js +103 -0
  35. data/vendor/assets/javascripts/jquery.flot.threshold.min.js +1 -0
  36. metadata +41 -6
@@ -0,0 +1 @@
1
+ (function(b){var a={series:{stack:null}};function c(f){function d(k,j){var h=null;for(var g=0;g<j.length;++g){if(k==j[g]){break}if(j[g].stack==k.stack){h=j[g]}}return h}function e(C,v,g){if(v.stack==null){return}var p=d(v,C.getData());if(!p){return}var z=g.pointsize,F=g.points,h=p.datapoints.pointsize,y=p.datapoints.points,t=[],x,w,k,J,I,r,u=v.lines.show,G=v.bars.horizontal,o=z>2&&(G?g.format[2].x:g.format[2].y),n=u&&v.lines.steps,E=true,q=G?1:0,H=G?0:1,D=0,B=0,A;while(true){if(D>=F.length){break}A=t.length;if(F[D]==null){for(m=0;m<z;++m){t.push(F[D+m])}D+=z}else{if(B>=y.length){if(!u){for(m=0;m<z;++m){t.push(F[D+m])}}D+=z}else{if(y[B]==null){for(m=0;m<z;++m){t.push(null)}E=true;B+=h}else{x=F[D+q];w=F[D+H];J=y[B+q];I=y[B+H];r=0;if(x==J){for(m=0;m<z;++m){t.push(F[D+m])}t[A+H]+=I;r=I;D+=z;B+=h}else{if(x>J){if(u&&D>0&&F[D-z]!=null){k=w+(F[D-z+H]-w)*(J-x)/(F[D-z+q]-x);t.push(J);t.push(k+I);for(m=2;m<z;++m){t.push(F[D+m])}r=I}B+=h}else{if(E&&u){D+=z;continue}for(m=0;m<z;++m){t.push(F[D+m])}if(u&&B>0&&y[B-h]!=null){r=I+(y[B-h+H]-I)*(x-J)/(y[B-h+q]-J)}t[A+H]+=r;D+=z}}E=false;if(A!=t.length&&o){t[A+2]+=r}}}}if(n&&A!=t.length&&A>0&&t[A]!=null&&t[A]!=t[A-z]&&t[A+1]!=t[A-z+1]){for(m=0;m<z;++m){t[A+z+m]=t[A+m]}t[A+1]=t[A-z+1]}}g.points=t}f.hooks.processDatapoints.push(e)}b.plot.plugins.push({init:c,options:a,name:"stack",version:"1.2"})})(jQuery);
@@ -0,0 +1,70 @@
1
+ /*
2
+ Flot plugin that adds some extra symbols for plotting points.
3
+
4
+ The symbols are accessed as strings through the standard symbol
5
+ choice:
6
+
7
+ series: {
8
+ points: {
9
+ symbol: "square" // or "diamond", "triangle", "cross"
10
+ }
11
+ }
12
+
13
+ */
14
+
15
+ (function ($) {
16
+ function processRawData(plot, series, datapoints) {
17
+ // we normalize the area of each symbol so it is approximately the
18
+ // same as a circle of the given radius
19
+
20
+ var handlers = {
21
+ square: function (ctx, x, y, radius, shadow) {
22
+ // pi * r^2 = (2s)^2 => s = r * sqrt(pi)/2
23
+ var size = radius * Math.sqrt(Math.PI) / 2;
24
+ ctx.rect(x - size, y - size, size + size, size + size);
25
+ },
26
+ diamond: function (ctx, x, y, radius, shadow) {
27
+ // pi * r^2 = 2s^2 => s = r * sqrt(pi/2)
28
+ var size = radius * Math.sqrt(Math.PI / 2);
29
+ ctx.moveTo(x - size, y);
30
+ ctx.lineTo(x, y - size);
31
+ ctx.lineTo(x + size, y);
32
+ ctx.lineTo(x, y + size);
33
+ ctx.lineTo(x - size, y);
34
+ },
35
+ triangle: function (ctx, x, y, radius, shadow) {
36
+ // pi * r^2 = 1/2 * s^2 * sin (pi / 3) => s = r * sqrt(2 * pi / sin(pi / 3))
37
+ var size = radius * Math.sqrt(2 * Math.PI / Math.sin(Math.PI / 3));
38
+ var height = size * Math.sin(Math.PI / 3);
39
+ ctx.moveTo(x - size/2, y + height/2);
40
+ ctx.lineTo(x + size/2, y + height/2);
41
+ if (!shadow) {
42
+ ctx.lineTo(x, y - height/2);
43
+ ctx.lineTo(x - size/2, y + height/2);
44
+ }
45
+ },
46
+ cross: function (ctx, x, y, radius, shadow) {
47
+ // pi * r^2 = (2s)^2 => s = r * sqrt(pi)/2
48
+ var size = radius * Math.sqrt(Math.PI) / 2;
49
+ ctx.moveTo(x - size, y - size);
50
+ ctx.lineTo(x + size, y + size);
51
+ ctx.moveTo(x - size, y + size);
52
+ ctx.lineTo(x + size, y - size);
53
+ }
54
+ }
55
+
56
+ var s = series.points.symbol;
57
+ if (handlers[s])
58
+ series.points.symbol = handlers[s];
59
+ }
60
+
61
+ function init(plot) {
62
+ plot.hooks.processDatapoints.push(processRawData);
63
+ }
64
+
65
+ $.plot.plugins.push({
66
+ init: init,
67
+ name: 'symbols',
68
+ version: '1.0'
69
+ });
70
+ })(jQuery);
@@ -0,0 +1 @@
1
+ (function(b){function a(h,e,g){var d={square:function(k,j,n,i,m){var l=i*Math.sqrt(Math.PI)/2;k.rect(j-l,n-l,l+l,l+l)},diamond:function(k,j,n,i,m){var l=i*Math.sqrt(Math.PI/2);k.moveTo(j-l,n);k.lineTo(j,n-l);k.lineTo(j+l,n);k.lineTo(j,n+l);k.lineTo(j-l,n)},triangle:function(l,k,o,j,n){var m=j*Math.sqrt(2*Math.PI/Math.sin(Math.PI/3));var i=m*Math.sin(Math.PI/3);l.moveTo(k-m/2,o+i/2);l.lineTo(k+m/2,o+i/2);if(!n){l.lineTo(k,o-i/2);l.lineTo(k-m/2,o+i/2)}},cross:function(k,j,n,i,m){var l=i*Math.sqrt(Math.PI)/2;k.moveTo(j-l,n-l);k.lineTo(j+l,n+l);k.moveTo(j-l,n+l);k.lineTo(j+l,n-l)}};var f=e.points.symbol;if(d[f]){e.points.symbol=d[f]}}function c(d){d.hooks.processDatapoints.push(a)}b.plot.plugins.push({init:c,name:"symbols",version:"1.0"})})(jQuery);
@@ -0,0 +1,103 @@
1
+ /*
2
+ Flot plugin for thresholding data. Controlled through the option
3
+ "threshold" in either the global series options
4
+
5
+ series: {
6
+ threshold: {
7
+ below: number
8
+ color: colorspec
9
+ }
10
+ }
11
+
12
+ or in a specific series
13
+
14
+ $.plot($("#placeholder"), [{ data: [ ... ], threshold: { ... }}])
15
+
16
+ The data points below "below" are drawn with the specified color. This
17
+ makes it easy to mark points below 0, e.g. for budget data.
18
+
19
+ Internally, the plugin works by splitting the data into two series,
20
+ above and below the threshold. The extra series below the threshold
21
+ will have its label cleared and the special "originSeries" attribute
22
+ set to the original series. You may need to check for this in hover
23
+ events.
24
+ */
25
+
26
+ (function ($) {
27
+ var options = {
28
+ series: { threshold: null } // or { below: number, color: color spec}
29
+ };
30
+
31
+ function init(plot) {
32
+ function thresholdData(plot, s, datapoints) {
33
+ if (!s.threshold)
34
+ return;
35
+
36
+ var ps = datapoints.pointsize, i, x, y, p, prevp,
37
+ thresholded = $.extend({}, s); // note: shallow copy
38
+
39
+ thresholded.datapoints = { points: [], pointsize: ps };
40
+ thresholded.label = null;
41
+ thresholded.color = s.threshold.color;
42
+ thresholded.threshold = null;
43
+ thresholded.originSeries = s;
44
+ thresholded.data = [];
45
+
46
+ var below = s.threshold.below,
47
+ origpoints = datapoints.points,
48
+ addCrossingPoints = s.lines.show;
49
+
50
+ threspoints = [];
51
+ newpoints = [];
52
+
53
+ for (i = 0; i < origpoints.length; i += ps) {
54
+ x = origpoints[i]
55
+ y = origpoints[i + 1];
56
+
57
+ prevp = p;
58
+ if (y < below)
59
+ p = threspoints;
60
+ else
61
+ p = newpoints;
62
+
63
+ if (addCrossingPoints && prevp != p && x != null
64
+ && i > 0 && origpoints[i - ps] != null) {
65
+ var interx = (x - origpoints[i - ps]) / (y - origpoints[i - ps + 1]) * (below - y) + x;
66
+ prevp.push(interx);
67
+ prevp.push(below);
68
+ for (m = 2; m < ps; ++m)
69
+ prevp.push(origpoints[i + m]);
70
+
71
+ p.push(null); // start new segment
72
+ p.push(null);
73
+ for (m = 2; m < ps; ++m)
74
+ p.push(origpoints[i + m]);
75
+ p.push(interx);
76
+ p.push(below);
77
+ for (m = 2; m < ps; ++m)
78
+ p.push(origpoints[i + m]);
79
+ }
80
+
81
+ p.push(x);
82
+ p.push(y);
83
+ }
84
+
85
+ datapoints.points = newpoints;
86
+ thresholded.datapoints.points = threspoints;
87
+
88
+ if (thresholded.datapoints.points.length > 0)
89
+ plot.getData().push(thresholded);
90
+
91
+ // FIXME: there are probably some edge cases left in bars
92
+ }
93
+
94
+ plot.hooks.processDatapoints.push(thresholdData);
95
+ }
96
+
97
+ $.plot.plugins.push({
98
+ init: init,
99
+ options: options,
100
+ name: 'threshold',
101
+ version: '1.0'
102
+ });
103
+ })(jQuery);
@@ -0,0 +1 @@
1
+ (function(B){var A={series:{threshold:null}};function C(D){function E(L,S,M){if(!S.threshold){return }var F=M.pointsize,I,O,N,G,K,H=B.extend({},S);H.datapoints={points:[],pointsize:F};H.label=null;H.color=S.threshold.color;H.threshold=null;H.originSeries=S;H.data=[];var P=S.threshold.below,Q=M.points,R=S.lines.show;threspoints=[];newpoints=[];for(I=0;I<Q.length;I+=F){O=Q[I];N=Q[I+1];K=G;if(N<P){G=threspoints}else{G=newpoints}if(R&&K!=G&&O!=null&&I>0&&Q[I-F]!=null){var J=(O-Q[I-F])/(N-Q[I-F+1])*(P-N)+O;K.push(J);K.push(P);for(m=2;m<F;++m){K.push(Q[I+m])}G.push(null);G.push(null);for(m=2;m<F;++m){G.push(Q[I+m])}G.push(J);G.push(P);for(m=2;m<F;++m){G.push(Q[I+m])}}G.push(O);G.push(N)}M.points=newpoints;H.datapoints.points=threspoints;if(H.datapoints.points.length>0){L.getData().push(H)}}D.hooks.processDatapoints.push(E)}B.plot.plugins.push({init:C,options:A,name:"threshold",version:"1.0"})})(jQuery);
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: flot-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -13,7 +13,7 @@ date: 2012-03-31 00:00:00.000000000Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: jquery-rails
16
- requirement: &70127061499240 !ruby/object:Gem::Requirement
16
+ requirement: &70357425864580 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: '0'
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *70127061499240
24
+ version_requirements: *70357425864580
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: rails
27
- requirement: &70127061498520 !ruby/object:Gem::Requirement
27
+ requirement: &70357425864000 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ~>
@@ -32,7 +32,7 @@ dependencies:
32
32
  version: '3.1'
33
33
  type: :development
34
34
  prerelease: false
35
- version_requirements: *70127061498520
35
+ version_requirements: *70357425864000
36
36
  description: Provides easy installation and usage of jQuery-flot javascript library
37
37
  for your Rails 3.1+ application.
38
38
  email:
@@ -40,7 +40,42 @@ email:
40
40
  executables: []
41
41
  extensions: []
42
42
  extra_rdoc_files: []
43
- files: []
43
+ files:
44
+ - .gitignore
45
+ - Gemfile
46
+ - README.md
47
+ - Rakefile
48
+ - flot-rails.gemspec
49
+ - lib/flot-rails.rb
50
+ - lib/flot/rails.rb
51
+ - lib/flot/rails/engine.rb
52
+ - lib/flot/rails/version.rb
53
+ - vendor/assets/javascripts/excanvas.js
54
+ - vendor/assets/javascripts/excanvas.min.js
55
+ - vendor/assets/javascripts/jquery.colorhelpers.js
56
+ - vendor/assets/javascripts/jquery.colorhelpers.min.js
57
+ - vendor/assets/javascripts/jquery.flot.crosshair.js
58
+ - vendor/assets/javascripts/jquery.flot.crosshair.min.js
59
+ - vendor/assets/javascripts/jquery.flot.fillbetween.js
60
+ - vendor/assets/javascripts/jquery.flot.fillbetween.min.js
61
+ - vendor/assets/javascripts/jquery.flot.image.js
62
+ - vendor/assets/javascripts/jquery.flot.image.min.js
63
+ - vendor/assets/javascripts/jquery.flot.js
64
+ - vendor/assets/javascripts/jquery.flot.min.js
65
+ - vendor/assets/javascripts/jquery.flot.navigate.js
66
+ - vendor/assets/javascripts/jquery.flot.navigate.min.js
67
+ - vendor/assets/javascripts/jquery.flot.pie.js
68
+ - vendor/assets/javascripts/jquery.flot.pie.min.js
69
+ - vendor/assets/javascripts/jquery.flot.resize.js
70
+ - vendor/assets/javascripts/jquery.flot.resize.min.js
71
+ - vendor/assets/javascripts/jquery.flot.selection.js
72
+ - vendor/assets/javascripts/jquery.flot.selection.min.js
73
+ - vendor/assets/javascripts/jquery.flot.stack.js
74
+ - vendor/assets/javascripts/jquery.flot.stack.min.js
75
+ - vendor/assets/javascripts/jquery.flot.symbol.js
76
+ - vendor/assets/javascripts/jquery.flot.symbol.min.js
77
+ - vendor/assets/javascripts/jquery.flot.threshold.js
78
+ - vendor/assets/javascripts/jquery.flot.threshold.min.js
44
79
  homepage: http://rubygems.org/gems/flot-rails
45
80
  licenses: []
46
81
  post_install_message: