1 line
1.3 KiB
JavaScript
1 line
1.3 KiB
JavaScript
jQuery.plot.plugins.push({init:function(e){e.hooks.processDatapoints.push(function(e,l,n){if(null!=l.fillBetween){var i=function(e,l){var n;for(n=0;n<l.length;++n)if(l[n].id===e.fillBetween)return l[n];return"number"==typeof e.fillBetween?e.fillBetween<0||e.fillBetween>=l.length?null:l[e.fillBetween]:null}(l,e.getData());if(i){for(var t,s,f,o,u,p,r,h,a=n.pointsize,g=n.points,w=i.datapoints.pointsize,B=i.datapoints.points,c=[],v=l.lines.show,d=2<a&&n.format[2].y,m=v&&l.lines.steps,y=!0,b=0,z=0;!(b>=g.length);){if(r=c.length,null==g[b]){for(h=0;h<a;++h)c.push(g[b+h]);b+=a}else if(z>=B.length){if(!v)for(h=0;h<a;++h)c.push(g[b+h]);b+=a}else if(null==B[z]){for(h=0;h<a;++h)c.push(null);y=!0,z+=w}else{if(t=g[b],s=g[b+1],o=B[z],u=B[z+1],p=0,t===o){for(h=0;h<a;++h)c.push(g[b+h]);p=u,b+=a,z+=w}else if(o<t){if(v&&0<b&&null!=g[b-a]){for(f=s+(g[b-a+1]-s)*(o-t)/(g[b-a]-t),c.push(o),c.push(f),h=2;h<a;++h)c.push(g[b+h]);p=u}z+=w}else{if(y&&v){b+=a;continue}for(h=0;h<a;++h)c.push(g[b+h]);v&&0<z&&null!=B[z-w]&&(p=u+(B[z-w+1]-u)*(t-o)/(B[z-w]-o)),b+=a}y=!1,r!==c.length&&d&&(c[r+2]=p)}if(m&&r!==c.length&&0<r&&null!==c[r]&&c[r]!==c[r-a]&&c[r+1]!==c[r-a+1]){for(h=0;h<a;++h)c[r+a+h]=c[r+h];c[r+1]=c[r-a+1]}}n.points=c}}})},options:{series:{fillBetween:null}},name:"fillbetween",version:"1.0"}); |