flot-rails 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (37) hide show
  1. data/README.md +2 -2
  2. data/lib/flot/rails/version.rb +2 -2
  3. data/vendor/assets/javascripts/excanvas.js +1428 -1427
  4. data/vendor/assets/javascripts/excanvas.min.js +1 -1
  5. data/vendor/assets/javascripts/jquery.colorhelpers.js +179 -179
  6. data/vendor/assets/javascripts/jquery.colorhelpers.min.js +21 -1
  7. data/vendor/assets/javascripts/jquery.flot.canvas.js +317 -0
  8. data/vendor/assets/javascripts/jquery.flot.canvas.min.js +28 -0
  9. data/vendor/assets/javascripts/jquery.flot.categories.js +190 -0
  10. data/vendor/assets/javascripts/jquery.flot.categories.min.js +44 -0
  11. data/vendor/assets/javascripts/jquery.flot.crosshair.js +176 -167
  12. data/vendor/assets/javascripts/jquery.flot.crosshair.min.js +59 -1
  13. data/vendor/assets/javascripts/jquery.flot.errorbars.js +353 -0
  14. data/vendor/assets/javascripts/jquery.flot.errorbars.min.js +63 -0
  15. data/vendor/assets/javascripts/jquery.flot.fillbetween.js +226 -183
  16. data/vendor/assets/javascripts/jquery.flot.fillbetween.min.js +30 -1
  17. data/vendor/assets/javascripts/jquery.flot.image.js +241 -238
  18. data/vendor/assets/javascripts/jquery.flot.image.min.js +53 -1
  19. data/vendor/assets/javascripts/jquery.flot.js +2980 -2599
  20. data/vendor/assets/javascripts/jquery.flot.min.js +26 -4
  21. data/vendor/assets/javascripts/jquery.flot.navigate.js +345 -336
  22. data/vendor/assets/javascripts/jquery.flot.navigate.min.js +96 -1
  23. data/vendor/assets/javascripts/jquery.flot.pie.js +561 -499
  24. data/vendor/assets/javascripts/jquery.flot.pie.min.js +56 -1
  25. data/vendor/assets/javascripts/jquery.flot.resize.js +60 -60
  26. data/vendor/assets/javascripts/jquery.flot.resize.min.js +21 -1
  27. data/vendor/assets/javascripts/jquery.flot.selection.js +360 -344
  28. data/vendor/assets/javascripts/jquery.flot.selection.min.js +79 -1
  29. data/vendor/assets/javascripts/jquery.flot.stack.js +188 -184
  30. data/vendor/assets/javascripts/jquery.flot.stack.min.js +36 -1
  31. data/vendor/assets/javascripts/jquery.flot.symbol.js +71 -70
  32. data/vendor/assets/javascripts/jquery.flot.symbol.min.js +14 -1
  33. data/vendor/assets/javascripts/jquery.flot.threshold.js +142 -103
  34. data/vendor/assets/javascripts/jquery.flot.threshold.min.js +43 -1
  35. data/vendor/assets/javascripts/jquery.flot.time.js +424 -0
  36. data/vendor/assets/javascripts/jquery.flot.time.min.js +9 -0
  37. metadata +25 -7
@@ -1 +1,36 @@
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);
1
+ /* Flot plugin for stacking data sets rather than overlyaing them.
2
+
3
+ Copyright (c) 2007-2013 IOLA and Ole Laursen.
4
+ Licensed under the MIT license.
5
+
6
+ The plugin assumes the data is sorted on x (or y if stacking horizontally).
7
+ For line charts, it is assumed that if a line has an undefined gap (from a
8
+ null point), then the line above it should have the same gap - insert zeros
9
+ instead of "null" if you want another behaviour. This also holds for the start
10
+ and end of the chart. Note that stacking a mix of positive and negative values
11
+ in most instances doesn't make sense (so it looks weird).
12
+
13
+ Two or more series are stacked when their "stack" attribute is set to the same
14
+ key (which can be any number or string or just "true"). To specify the default
15
+ stack, you can set the stack option like this:
16
+
17
+ series: {
18
+ stack: null/false, true, or a key (number/string)
19
+ }
20
+
21
+ You can also specify it for a single series, like this:
22
+
23
+ $.plot( $("#placeholder"), [{
24
+ data: [ ... ],
25
+ stack: true
26
+ }])
27
+
28
+ The stacking order is determined by the order of the data series in the array
29
+ (later series end up on top of the previous).
30
+
31
+ Internally, the plugin modifies the datapoints in each series, adding an
32
+ offset to the y value. For line series, extra data points are inserted through
33
+ interpolation. If there's a second y value, it's also adjusted (e.g for bar
34
+ charts or filled areas).
35
+
36
+ */(function(e){function n(e){function t(e,t){var n=null;for(var r=0;r<t.length;++r){if(e==t[r])break;t[r].stack==e.stack&&(n=t[r])}return n}function n(e,n,r){if(n.stack==null||n.stack===!1)return;var i=t(n,e.getData());if(!i)return;var s=r.pointsize,o=r.points,u=i.datapoints.pointsize,a=i.datapoints.points,f=[],l,c,h,p,d,v,m=n.lines.show,g=n.bars.horizontal,y=s>2&&(g?r.format[2].x:r.format[2].y),b=m&&n.lines.steps,w=!0,E=g?1:0,S=g?0:1,x=0,T=0,N,C;for(;;){if(x>=o.length)break;N=f.length;if(o[x]==null){for(C=0;C<s;++C)f.push(o[x+C]);x+=s}else if(T>=a.length){if(!m)for(C=0;C<s;++C)f.push(o[x+C]);x+=s}else if(a[T]==null){for(C=0;C<s;++C)f.push(null);w=!0,T+=u}else{l=o[x+E],c=o[x+S],p=a[T+E],d=a[T+S],v=0;if(l==p){for(C=0;C<s;++C)f.push(o[x+C]);f[N+S]+=d,v=d,x+=s,T+=u}else if(l>p){if(m&&x>0&&o[x-s]!=null){h=c+(o[x-s+S]-c)*(p-l)/(o[x-s+E]-l),f.push(p),f.push(h+d);for(C=2;C<s;++C)f.push(o[x+C]);v=d}T+=u}else{if(w&&m){x+=s;continue}for(C=0;C<s;++C)f.push(o[x+C]);m&&T>0&&a[T-u]!=null&&(v=d+(a[T-u+S]-d)*(l-p)/(a[T-u+E]-p)),f[N+S]+=v,x+=s}w=!1,N!=f.length&&y&&(f[N+2]+=v)}if(b&&N!=f.length&&N>0&&f[N]!=null&&f[N]!=f[N-s]&&f[N+1]!=f[N-s+1]){for(C=0;C<s;++C)f[N+s+C]=f[N+C];f[N+1]=f[N-s+1]}}r.points=f}e.hooks.processDatapoints.push(n)}var t={series:{stack:null}};e.plot.plugins.push({init:n,options:t,name:"stack",version:"1.2"})})(jQuery);
@@ -1,70 +1,71 @@
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);
1
+ /* Flot plugin that adds some extra symbols for plotting points.
2
+
3
+ Copyright (c) 2007-2013 IOLA and Ole Laursen.
4
+ Licensed under the MIT license.
5
+
6
+ The symbols are accessed as strings through the standard symbol options:
7
+
8
+ series: {
9
+ points: {
10
+ symbol: "square" // or "diamond", "triangle", "cross"
11
+ }
12
+ }
13
+
14
+ */
15
+
16
+ (function ($) {
17
+ function processRawData(plot, series, datapoints) {
18
+ // we normalize the area of each symbol so it is approximately the
19
+ // same as a circle of the given radius
20
+
21
+ var handlers = {
22
+ square: function (ctx, x, y, radius, shadow) {
23
+ // pi * r^2 = (2s)^2 => s = r * sqrt(pi)/2
24
+ var size = radius * Math.sqrt(Math.PI) / 2;
25
+ ctx.rect(x - size, y - size, size + size, size + size);
26
+ },
27
+ diamond: function (ctx, x, y, radius, shadow) {
28
+ // pi * r^2 = 2s^2 => s = r * sqrt(pi/2)
29
+ var size = radius * Math.sqrt(Math.PI / 2);
30
+ ctx.moveTo(x - size, y);
31
+ ctx.lineTo(x, y - size);
32
+ ctx.lineTo(x + size, y);
33
+ ctx.lineTo(x, y + size);
34
+ ctx.lineTo(x - size, y);
35
+ },
36
+ triangle: function (ctx, x, y, radius, shadow) {
37
+ // pi * r^2 = 1/2 * s^2 * sin (pi / 3) => s = r * sqrt(2 * pi / sin(pi / 3))
38
+ var size = radius * Math.sqrt(2 * Math.PI / Math.sin(Math.PI / 3));
39
+ var height = size * Math.sin(Math.PI / 3);
40
+ ctx.moveTo(x - size/2, y + height/2);
41
+ ctx.lineTo(x + size/2, y + height/2);
42
+ if (!shadow) {
43
+ ctx.lineTo(x, y - height/2);
44
+ ctx.lineTo(x - size/2, y + height/2);
45
+ }
46
+ },
47
+ cross: function (ctx, x, y, radius, shadow) {
48
+ // pi * r^2 = (2s)^2 => s = r * sqrt(pi)/2
49
+ var size = radius * Math.sqrt(Math.PI) / 2;
50
+ ctx.moveTo(x - size, y - size);
51
+ ctx.lineTo(x + size, y + size);
52
+ ctx.moveTo(x - size, y + size);
53
+ ctx.lineTo(x + size, y - size);
54
+ }
55
+ };
56
+
57
+ var s = series.points.symbol;
58
+ if (handlers[s])
59
+ series.points.symbol = handlers[s];
60
+ }
61
+
62
+ function init(plot) {
63
+ plot.hooks.processDatapoints.push(processRawData);
64
+ }
65
+
66
+ $.plot.plugins.push({
67
+ init: init,
68
+ name: 'symbols',
69
+ version: '1.0'
70
+ });
71
+ })(jQuery);
@@ -1 +1,14 @@
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);
1
+ /* Flot plugin that adds some extra symbols for plotting points.
2
+
3
+ Copyright (c) 2007-2013 IOLA and Ole Laursen.
4
+ Licensed under the MIT license.
5
+
6
+ The symbols are accessed as strings through the standard symbol options:
7
+
8
+ series: {
9
+ points: {
10
+ symbol: "square" // or "diamond", "triangle", "cross"
11
+ }
12
+ }
13
+
14
+ */(function(e){function t(e,t,n){var r={square:function(e,t,n,r,i){var s=r*Math.sqrt(Math.PI)/2;e.rect(t-s,n-s,s+s,s+s)},diamond:function(e,t,n,r,i){var s=r*Math.sqrt(Math.PI/2);e.moveTo(t-s,n),e.lineTo(t,n-s),e.lineTo(t+s,n),e.lineTo(t,n+s),e.lineTo(t-s,n)},triangle:function(e,t,n,r,i){var s=r*Math.sqrt(2*Math.PI/Math.sin(Math.PI/3)),o=s*Math.sin(Math.PI/3);e.moveTo(t-s/2,n+o/2),e.lineTo(t+s/2,n+o/2),i||(e.lineTo(t,n-o/2),e.lineTo(t-s/2,n+o/2))},cross:function(e,t,n,r,i){var s=r*Math.sqrt(Math.PI)/2;e.moveTo(t-s,n-s),e.lineTo(t+s,n+s),e.moveTo(t-s,n+s),e.lineTo(t+s,n-s)}},i=t.points.symbol;r[i]&&(t.points.symbol=r[i])}function n(e){e.hooks.processDatapoints.push(t)}e.plot.plugins.push({init:n,name:"symbols",version:"1.0"})})(jQuery);
@@ -1,103 +1,142 @@
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);
1
+ /* Flot plugin for thresholding data.
2
+
3
+ Copyright (c) 2007-2013 IOLA and Ole Laursen.
4
+ Licensed under the MIT license.
5
+
6
+ The plugin supports these options:
7
+
8
+ series: {
9
+ threshold: {
10
+ below: number
11
+ color: colorspec
12
+ }
13
+ }
14
+
15
+ It can also be applied to a single series, like this:
16
+
17
+ $.plot( $("#placeholder"), [{
18
+ data: [ ... ],
19
+ threshold: { ... }
20
+ }])
21
+
22
+ An array can be passed for multiple thresholding, like this:
23
+
24
+ threshold: [{
25
+ below: number1
26
+ color: color1
27
+ },{
28
+ below: number2
29
+ color: color2
30
+ }]
31
+
32
+ These multiple threshold objects can be passed in any order since they are
33
+ sorted by the processing function.
34
+
35
+ The data points below "below" are drawn with the specified color. This makes
36
+ it easy to mark points below 0, e.g. for budget data.
37
+
38
+ Internally, the plugin works by splitting the data into two series, above and
39
+ below the threshold. The extra series below the threshold will have its label
40
+ cleared and the special "originSeries" attribute set to the original series.
41
+ You may need to check for this in hover events.
42
+
43
+ */
44
+
45
+ (function ($) {
46
+ var options = {
47
+ series: { threshold: null } // or { below: number, color: color spec}
48
+ };
49
+
50
+ function init(plot) {
51
+ function thresholdData(plot, s, datapoints, below, color) {
52
+ var ps = datapoints.pointsize, i, x, y, p, prevp,
53
+ thresholded = $.extend({}, s); // note: shallow copy
54
+
55
+ thresholded.datapoints = { points: [], pointsize: ps, format: datapoints.format };
56
+ thresholded.label = null;
57
+ thresholded.color = color;
58
+ thresholded.threshold = null;
59
+ thresholded.originSeries = s;
60
+ thresholded.data = [];
61
+
62
+ var origpoints = datapoints.points,
63
+ addCrossingPoints = s.lines.show;
64
+
65
+ var threspoints = [];
66
+ var newpoints = [];
67
+ var m;
68
+
69
+ for (i = 0; i < origpoints.length; i += ps) {
70
+ x = origpoints[i];
71
+ y = origpoints[i + 1];
72
+
73
+ prevp = p;
74
+ if (y < below)
75
+ p = threspoints;
76
+ else
77
+ p = newpoints;
78
+
79
+ if (addCrossingPoints && prevp != p && x != null
80
+ && i > 0 && origpoints[i - ps] != null) {
81
+ var interx = x + (below - y) * (x - origpoints[i - ps]) / (y - origpoints[i - ps + 1]);
82
+ prevp.push(interx);
83
+ prevp.push(below);
84
+ for (m = 2; m < ps; ++m)
85
+ prevp.push(origpoints[i + m]);
86
+
87
+ p.push(null); // start new segment
88
+ p.push(null);
89
+ for (m = 2; m < ps; ++m)
90
+ p.push(origpoints[i + m]);
91
+ p.push(interx);
92
+ p.push(below);
93
+ for (m = 2; m < ps; ++m)
94
+ p.push(origpoints[i + m]);
95
+ }
96
+
97
+ p.push(x);
98
+ p.push(y);
99
+ for (m = 2; m < ps; ++m)
100
+ p.push(origpoints[i + m]);
101
+ }
102
+
103
+ datapoints.points = newpoints;
104
+ thresholded.datapoints.points = threspoints;
105
+
106
+ if (thresholded.datapoints.points.length > 0) {
107
+ var origIndex = $.inArray(s, plot.getData());
108
+ // Insert newly-generated series right after original one (to prevent it from becoming top-most)
109
+ plot.getData().splice(origIndex + 1, 0, thresholded);
110
+ }
111
+
112
+ // FIXME: there are probably some edge cases left in bars
113
+ }
114
+
115
+ function processThresholds(plot, s, datapoints) {
116
+ if (!s.threshold)
117
+ return;
118
+
119
+ if (s.threshold instanceof Array) {
120
+ s.threshold.sort(function(a, b) {
121
+ return a.below - b.below;
122
+ });
123
+
124
+ $(s.threshold).each(function(i, th) {
125
+ thresholdData(plot, s, datapoints, th.below, th.color);
126
+ });
127
+ }
128
+ else {
129
+ thresholdData(plot, s, datapoints, s.threshold.below, s.threshold.color);
130
+ }
131
+ }
132
+
133
+ plot.hooks.processDatapoints.push(processThresholds);
134
+ }
135
+
136
+ $.plot.plugins.push({
137
+ init: init,
138
+ options: options,
139
+ name: 'threshold',
140
+ version: '1.2'
141
+ });
142
+ })(jQuery);
@@ -1 +1,43 @@
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);
1
+ /* Flot plugin for thresholding data.
2
+
3
+ Copyright (c) 2007-2013 IOLA and Ole Laursen.
4
+ Licensed under the MIT license.
5
+
6
+ The plugin supports these options:
7
+
8
+ series: {
9
+ threshold: {
10
+ below: number
11
+ color: colorspec
12
+ }
13
+ }
14
+
15
+ It can also be applied to a single series, like this:
16
+
17
+ $.plot( $("#placeholder"), [{
18
+ data: [ ... ],
19
+ threshold: { ... }
20
+ }])
21
+
22
+ An array can be passed for multiple thresholding, like this:
23
+
24
+ threshold: [{
25
+ below: number1
26
+ color: color1
27
+ },{
28
+ below: number2
29
+ color: color2
30
+ }]
31
+
32
+ These multiple threshold objects can be passed in any order since they are
33
+ sorted by the processing function.
34
+
35
+ The data points below "below" are drawn with the specified color. This makes
36
+ it easy to mark points below 0, e.g. for budget data.
37
+
38
+ Internally, the plugin works by splitting the data into two series, above and
39
+ below the threshold. The extra series below the threshold will have its label
40
+ cleared and the special "originSeries" attribute set to the original series.
41
+ You may need to check for this in hover events.
42
+
43
+ */(function(e){function n(t){function n(t,n,r,i,s){var o=r.pointsize,u,a,f,l,c,h=e.extend({},n);h.datapoints={points:[],pointsize:o,format:r.format},h.label=null,h.color=s,h.threshold=null,h.originSeries=n,h.data=[];var p=r.points,d=n.lines.show,v=[],m=[],g;for(u=0;u<p.length;u+=o){a=p[u],f=p[u+1],c=l,f<i?l=v:l=m;if(d&&c!=l&&a!=null&&u>0&&p[u-o]!=null){var y=a+(i-f)*(a-p[u-o])/(f-p[u-o+1]);c.push(y),c.push(i);for(g=2;g<o;++g)c.push(p[u+g]);l.push(null),l.push(null);for(g=2;g<o;++g)l.push(p[u+g]);l.push(y),l.push(i);for(g=2;g<o;++g)l.push(p[u+g])}l.push(a),l.push(f);for(g=2;g<o;++g)l.push(p[u+g])}r.points=m,h.datapoints.points=v;if(h.datapoints.points.length>0){var b=e.inArray(n,t.getData());t.getData().splice(b+1,0,h)}}function r(t,r,i){if(!r.threshold)return;r.threshold instanceof Array?(r.threshold.sort(function(e,t){return e.below-t.below}),e(r.threshold).each(function(e,o){n(t,r,i,o.below,o.color)})):n(t,r,i,r.threshold.below,r.threshold.color)}t.hooks.processDatapoints.push(r)}var t={series:{threshold:null}};e.plot.plugins.push({init:n,options:t,name:"threshold",version:"1.2"})})(jQuery);