src/pyams_skin/resources/js/ext/flot/jquery.flot.threshold.min.js
changeset 475 79ae32c82e3e
parent 98 89a28618a327
child 546 9f02c09d2393
equal deleted inserted replaced
473:ca7ba7882abe 475:79ae32c82e3e
     1 /* Javascript plotting library for jQuery, version 0.8.3.
     1 !function(o){o.plot.plugins.push({init:function(s){function t(s,t,n,l,h){var r,e,i,p,u,a=n.pointsize,f=o.extend({},t);f.datapoints={points:[],pointsize:a,format:n.format},f.label=null,f.color=h,f.threshold=null,f.originSeries=t,f.data=[];var d,c=n.points,g=t.lines.show,b=[],v=[];for(r=0;r<c.length;r+=a){if(e=c[r],i=c[r+1],u=p,p=i<l?b:v,g&&u!=p&&null!=e&&r>0&&null!=c[r-a]){var w=e+(l-i)*(e-c[r-a])/(i-c[r-a+1]);for(u.push(w),u.push(l),d=2;d<a;++d)u.push(c[r+d]);for(p.push(null),p.push(null),d=2;d<a;++d)p.push(c[r+d]);for(p.push(w),p.push(l),d=2;d<a;++d)p.push(c[r+d])}for(p.push(e),p.push(i),d=2;d<a;++d)p.push(c[r+d])}if(n.points=v,f.datapoints.points=b,f.datapoints.points.length>0){var m=o.inArray(t,s.getData());s.getData().splice(m+1,0,f)}}s.hooks.processDatapoints.push(function(s,n,l){n.threshold&&(n.threshold instanceof Array?(n.threshold.sort(function(o,s){return o.below-s.below}),o(n.threshold).each(function(o,h){t(s,n,l,h.below,h.color)})):t(s,n,l,n.threshold.below,n.threshold.color))})},options:{series:{threshold:null}},name:"threshold",version:"1.2"})}(jQuery);
     2 
       
     3 Copyright (c) 2007-2014 IOLA and Ole Laursen.
       
     4 Licensed under the MIT license.
       
     5 
       
     6 */
       
     7 (function($){var options={series:{threshold:null}};function init(plot){function thresholdData(plot,s,datapoints,below,color){var ps=datapoints.pointsize,i,x,y,p,prevp,thresholded=$.extend({},s);thresholded.datapoints={points:[],pointsize:ps,format:datapoints.format};thresholded.label=null;thresholded.color=color;thresholded.threshold=null;thresholded.originSeries=s;thresholded.data=[];var origpoints=datapoints.points,addCrossingPoints=s.lines.show;var threspoints=[];var newpoints=[];var m;for(i=0;i<origpoints.length;i+=ps){x=origpoints[i];y=origpoints[i+1];prevp=p;if(y<below)p=threspoints;else p=newpoints;if(addCrossingPoints&&prevp!=p&&x!=null&&i>0&&origpoints[i-ps]!=null){var interx=x+(below-y)*(x-origpoints[i-ps])/(y-origpoints[i-ps+1]);prevp.push(interx);prevp.push(below);for(m=2;m<ps;++m)prevp.push(origpoints[i+m]);p.push(null);p.push(null);for(m=2;m<ps;++m)p.push(origpoints[i+m]);p.push(interx);p.push(below);for(m=2;m<ps;++m)p.push(origpoints[i+m])}p.push(x);p.push(y);for(m=2;m<ps;++m)p.push(origpoints[i+m])}datapoints.points=newpoints;thresholded.datapoints.points=threspoints;if(thresholded.datapoints.points.length>0){var origIndex=$.inArray(s,plot.getData());plot.getData().splice(origIndex+1,0,thresholded)}}function processThresholds(plot,s,datapoints){if(!s.threshold)return;if(s.threshold instanceof Array){s.threshold.sort(function(a,b){return a.below-b.below});$(s.threshold).each(function(i,th){thresholdData(plot,s,datapoints,th.below,th.color)})}else{thresholdData(plot,s,datapoints,s.threshold.below,s.threshold.color)}}plot.hooks.processDatapoints.push(processThresholds)}$.plot.plugins.push({init:init,options:options,name:"threshold",version:"1.2"})})(jQuery);