83198c338a
git-svn-id: https://svn.code.sf.net/p/xcat/code/xcat-core/trunk@8655 8638fb3e-16cb-4fca-ae20-7b5d299a9bcd
63 lines
29 KiB
JavaScript
63 lines
29 KiB
JavaScript
/*
|
|
Javascript plotting library for jQuery, v. 0.6.
|
|
Released under the MIT license by IOLA, December 2007.
|
|
*/
|
|
(function(){jQuery.color={};jQuery.color.make=function(E,y,x,M){var z={};z.r=E||0;z.g=y||0;z.b=x||0;z.a=M!=null?M:1;z.add=function(G,H){for(var F=0;F<G.length;++F)z[G.charAt(F)]+=H;return z.normalize()};z.scale=function(G,H){for(var F=0;F<G.length;++F)z[G.charAt(F)]*=H;return z.normalize()};z.toString=function(){return z.a>=1?"rgb("+[z.r,z.g,z.b].join(",")+")":"rgba("+[z.r,z.g,z.b,z.a].join(",")+")"};z.normalize=function(){function G(H,F,J){return F<H?H:F>J?J:F}z.r=G(0,parseInt(z.r),255);z.g=G(0,
|
|
parseInt(z.g),255);z.b=G(0,parseInt(z.b),255);z.a=G(0,z.a,1);return z};z.clone=function(){return jQuery.color.make(z.r,z.b,z.g,z.a)};return z.normalize()};jQuery.color.extract=function(E,y){var x;do{x=E.css(y).toLowerCase();if(x!=""&&x!="transparent")break;E=E.parent()}while(!jQuery.nodeName(E.get(0),"body"));if(x=="rgba(0, 0, 0, 0)")x="transparent";return jQuery.color.parse(x)};jQuery.color.parse=function(E){var y,x=jQuery.color.make;if(y=/rgb\(\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*\)/.exec(E))return x(parseInt(y[1],
|
|
10),parseInt(y[2],10),parseInt(y[3],10));if(y=/rgba\(\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*,\s*([0-9]+(?:\.[0-9]+)?)\s*\)/.exec(E))return x(parseInt(y[1],10),parseInt(y[2],10),parseInt(y[3],10),parseFloat(y[4]));if(y=/rgb\(\s*([0-9]+(?:\.[0-9]+)?)\%\s*,\s*([0-9]+(?:\.[0-9]+)?)\%\s*,\s*([0-9]+(?:\.[0-9]+)?)\%\s*\)/.exec(E))return x(parseFloat(y[1])*2.55,parseFloat(y[2])*2.55,parseFloat(y[3])*2.55);if(y=/rgba\(\s*([0-9]+(?:\.[0-9]+)?)\%\s*,\s*([0-9]+(?:\.[0-9]+)?)\%\s*,\s*([0-9]+(?:\.[0-9]+)?)\%\s*,\s*([0-9]+(?:\.[0-9]+)?)\s*\)/.exec(E))return x(parseFloat(y[1])*
|
|
2.55,parseFloat(y[2])*2.55,parseFloat(y[3])*2.55,parseFloat(y[4]));if(y=/#([a-fA-F0-9]{2})([a-fA-F0-9]{2})([a-fA-F0-9]{2})/.exec(E))return x(parseInt(y[1],16),parseInt(y[2],16),parseInt(y[3],16));if(y=/#([a-fA-F0-9])([a-fA-F0-9])([a-fA-F0-9])/.exec(E))return x(parseInt(y[1]+y[1],16),parseInt(y[2]+y[2],16),parseInt(y[3]+y[3],16));E=jQuery.trim(E).toLowerCase();if(E=="transparent")return x(255,255,255,0);else{y=A[E];return x(y[0],y[1],y[2])}};var A={aqua:[0,255,255],azure:[240,255,255],beige:[245,245,
|
|
220],black:[0,0,0],blue:[0,0,255],brown:[165,42,42],cyan:[0,255,255],darkblue:[0,0,139],darkcyan:[0,139,139],darkgrey:[169,169,169],darkgreen:[0,100,0],darkkhaki:[189,183,107],darkmagenta:[139,0,139],darkolivegreen:[85,107,47],darkorange:[255,140,0],darkorchid:[153,50,204],darkred:[139,0,0],darksalmon:[233,150,122],darkviolet:[148,0,211],fuchsia:[255,0,255],gold:[255,215,0],green:[0,128,0],indigo:[75,0,130],khaki:[240,230,140],lightblue:[173,216,230],lightcyan:[224,255,255],lightgreen:[144,238,144],
|
|
lightgrey:[211,211,211],lightpink:[255,182,193],lightyellow:[255,255,224],lime:[0,255,0],magenta:[255,0,255],maroon:[128,0,0],navy:[0,0,128],olive:[128,128,0],orange:[255,165,0],pink:[255,192,203],purple:[128,0,128],violet:[128,0,128],red:[255,0,0],silver:[192,192,192],white:[255,255,255],yellow:[255,255,0]}})();
|
|
(function(A){function E(x,M,z,G){function H(a,e){e=[D].concat(e);for(var b=0;b<a.length;++b)a[b].apply(this,e)}function F(a){for(var e=[],b=0;b<a.length;++b){var c=A.extend(true,{},r.series);if(a[b].data){c.data=a[b].data;delete a[b].data;A.extend(true,c,a[b]);a[b].data=c.data}else c.data=a[b];e.push(c)}C=e;e=C.length;b=[];c=[];for(a=0;a<C.length;++a){var d=C[a].color;if(d!=null){--e;typeof d=="number"?c.push(d):b.push(A.color.parse(C[a].color))}}for(a=0;a<c.length;++a)e=Math.max(e,c[a]+1);b=[];for(a=
|
|
c=0;b.length<e;){d=r.colors.length==a?A.color.make(100,100,100):A.color.parse(r.colors[a]);d.scale("rgb",1+(c%2==1?-1:1)*Math.ceil(c/2)*0.2);b.push(d);++a;if(a>=r.colors.length){a=0;++c}}for(a=e=0;a<C.length;++a){c=C[a];if(c.color==null){c.color=b[e].toString();++e}else if(typeof c.color=="number")c.color=b[c.color].toString();if(c.lines.show==null){var f;d=true;for(f in c)if(c[f].show){d=false;break}if(d)c.lines.show=true}c.xaxis=J(c,"xaxis");c.yaxis=J(c,"yaxis")}Y()}function J(a,e){var b=a[e];if(!b||
|
|
b==1)return u[e];if(typeof b=="number")return u[e.charAt(0)+b+e.slice(1)];return b}function Y(){function a(t,B,O){if(B<t.datamin)t.datamin=B;if(O>t.datamax)t.datamax=O}var e=Number.POSITIVE_INFINITY,b=Number.NEGATIVE_INFINITY,c,d,f,k,g,j,h,m,l,v,s;for(m in u){u[m].datamin=e;u[m].datamax=b;u[m].used=false}for(c=0;c<C.length;++c){g=C[c];g.datapoints={points:[]};H(S.processRawData,[g,g.data,g.datapoints])}for(c=0;c<C.length;++c){g=C[c];var q=g.data,n=g.datapoints.format;if(!n){n=[];n.push({x:true,number:true,
|
|
required:true});n.push({y:true,number:true,required:true});g.bars.show&&n.push({y:true,number:true,required:false,defaultValue:0});g.datapoints.format=n}if(g.datapoints.pointsize==null){if(g.datapoints.pointsize==null)g.datapoints.pointsize=n.length;h=g.datapoints.pointsize;j=g.datapoints.points;insertSteps=g.lines.show&&g.lines.steps;g.xaxis.used=g.yaxis.used=true;for(d=f=0;d<q.length;++d,f+=h){s=q[d];var p=s==null;if(!p)for(k=0;k<h;++k){l=s[k];if(v=n[k]){if(v.number&&l!=null){l=+l;if(isNaN(l))l=
|
|
null}if(l==null){if(v.required)p=true;if(v.defaultValue!=null)l=v.defaultValue}}j[f+k]=l}if(p)for(k=0;k<h;++k){l=j[f+k];if(l!=null){v=n[k];v.x&&a(g.xaxis,l,l);v.y&&a(g.yaxis,l,l)}j[f+k]=null}else if(insertSteps&&f>0&&j[f-h]!=null&&j[f-h]!=j[f]&&j[f-h+1]!=j[f+1]){for(k=0;k<h;++k)j[f+h+k]=j[f+k];j[f+1]=j[f-h+1];f+=h}}}}for(c=0;c<C.length;++c){g=C[c];H(S.processDatapoints,[g,g.datapoints])}for(c=0;c<C.length;++c){g=C[c];j=g.datapoints.points;h=g.datapoints.pointsize;s=f=e;p=q=b;for(d=0;d<j.length;d+=
|
|
h)if(j[d]!=null)for(k=0;k<h;++k){l=j[d+k];if(v=n[k]){if(v.x){if(l<f)f=l;if(l>q)q=l}if(v.y){if(l<s)s=l;if(l>p)p=l}}}if(g.bars.show){d=g.bars.align=="left"?0:-g.bars.barWidth/2;if(g.bars.horizontal){s+=d;p+=d+g.bars.barWidth}else{f+=d;q+=d+g.bars.barWidth}}a(g.xaxis,f,q);a(g.yaxis,s,p)}for(m in u){if(u[m].datamin==e)u[m].datamin=null;if(u[m].datamax==b)u[m].datamax=null}}function W(){function a(d,f){function k(l){return l}var g,j,h=f.transform||k,m=f.inverseTransform;if(d==u.xaxis||d==u.x2axis){g=d.scale=
|
|
P/(h(d.max)-h(d.min));j=h(d.min);d.p2c=h==k?function(l){return(l-j)*g}:function(l){return(h(l)-j)*g};d.c2p=m?function(l){return m(j+l/g)}:function(l){return j+l/g}}else{g=d.scale=Q/(h(d.max)-h(d.min));j=h(d.max);d.p2c=h==k?function(l){return(j-l)*g}:function(l){return(j-h(l))*g};d.c2p=m?function(l){return m(j-l/g)}:function(l){return j-l/g}}}function e(d,f){var k,g=[],j;d.labelWidth=f.labelWidth;d.labelHeight=f.labelHeight;if(d==u.xaxis||d==u.x2axis){if(d.labelWidth==null)d.labelWidth=R/(d.ticks.length>
|
|
0?d.ticks.length:1);if(d.labelHeight==null){g=[];for(k=0;k<d.ticks.length;++k)(j=d.ticks[k].label)&&g.push('<div class="tickLabel" style="float:left;width:'+d.labelWidth+'px">'+j+"</div>");if(g.length>0){k=A('<div style="position:absolute;top:-10000px;width:10000px;font-size:smaller">'+g.join("")+'<div style="clear:left"></div></div>').appendTo(x);d.labelHeight=k.height();k.remove()}}}else if(d.labelWidth==null||d.labelHeight==null){for(k=0;k<d.ticks.length;++k)(j=d.ticks[k].label)&&g.push('<div class="tickLabel">'+
|
|
j+"</div>");if(g.length>0){k=A('<div style="position:absolute;top:-10000px;font-size:smaller">'+g.join("")+"</div>").appendTo(x);if(d.labelWidth==null)d.labelWidth=k.width();if(d.labelHeight==null)d.labelHeight=k.find("div").height();k.remove()}}if(d.labelWidth==null)d.labelWidth=0;if(d.labelHeight==null)d.labelHeight=0}function b(){var d=r.grid.borderWidth;for(i=0;i<C.length;++i)d=Math.max(d,2*(C[i].points.radius+C[i].points.lineWidth/2));w.left=w.right=w.top=w.bottom=d;var f=r.grid.labelMargin+
|
|
r.grid.borderWidth;if(u.xaxis.labelHeight>0)w.bottom=Math.max(d,u.xaxis.labelHeight+f);if(u.yaxis.labelWidth>0)w.left=Math.max(d,u.yaxis.labelWidth+f);if(u.x2axis.labelHeight>0)w.top=Math.max(d,u.x2axis.labelHeight+f);if(u.y2axis.labelWidth>0)w.right=Math.max(d,u.y2axis.labelWidth+f);P=R-w.left-w.right;Q=T-w.bottom-w.top}for(var c in u)I(u[c],r[c]);if(r.grid.show){for(c in u){V(u[c],r[c]);ma(u[c],r[c]);e(u[c],r[c])}b()}else{w.left=w.right=w.top=w.bottom=0;P=R;Q=T}for(c in u)a(u[c],r[c]);r.grid.show&&
|
|
na();oa()}function I(a,e){var b=+(e.min!=null?e.min:a.datamin),c=+(e.max!=null?e.max:a.datamax),d=c-b;if(d==0){d=c==0?1:0.01;if(e.min==null)b-=d;if(e.max==null||e.min!=null)c+=d}else{var f=e.autoscaleMargin;if(f!=null){if(e.min==null){b-=d*f;if(b<0&&a.datamin!=null&&a.datamin>=0)b=0}if(e.max==null){c+=d*f;if(c>0&&a.datamax!=null&&a.datamax<=0)c=0}}}a.min=b;a.max=c}function V(a,e){var b=(a.max-a.min)/(typeof e.ticks=="number"&&e.ticks>0?e.ticks:a==u.xaxis||a==u.x2axis?0.3*Math.sqrt(R):0.3*Math.sqrt(T)),
|
|
c,d,f;if(e.mode=="time"){var k={second:1E3,minute:6E4,hour:36E5,day:864E5,month:2592E6,year:525949.2*60*1E3};f=[[1,"second"],[2,"second"],[5,"second"],[10,"second"],[30,"second"],[1,"minute"],[2,"minute"],[5,"minute"],[10,"minute"],[30,"minute"],[1,"hour"],[2,"hour"],[4,"hour"],[8,"hour"],[12,"hour"],[1,"day"],[2,"day"],[3,"day"],[0.25,"month"],[0.5,"month"],[1,"month"],[2,"month"],[3,"month"],[6,"month"],[1,"year"]];c=0;if(e.minTickSize!=null)c=typeof e.tickSize=="number"?e.tickSize:e.minTickSize[0]*
|
|
k[e.minTickSize[1]];for(d=0;d<f.length-1;++d)if(b<(f[d][0]*k[f[d][1]]+f[d+1][0]*k[f[d+1][1]])/2&&f[d][0]*k[f[d][1]]>=c)break;c=f[d][0];d=f[d][1];if(d=="year"){f=Math.pow(10,Math.floor(Math.log(b/k.year)/Math.LN10));b=b/k.year/f;c=b<1.5?1:b<3?2:b<7.5?5:10;c*=f}if(e.tickSize){c=e.tickSize[0];d=e.tickSize[1]}b=function(h){var m=[],l=h.tickSize[0],v=h.tickSize[1],s=new Date(h.min),q=l*k[v];v=="second"&&s.setUTCSeconds(y(s.getUTCSeconds(),l));v=="minute"&&s.setUTCMinutes(y(s.getUTCMinutes(),l));v=="hour"&&
|
|
s.setUTCHours(y(s.getUTCHours(),l));v=="month"&&s.setUTCMonth(y(s.getUTCMonth(),l));v=="year"&&s.setUTCFullYear(y(s.getUTCFullYear(),l));s.setUTCMilliseconds(0);q>=k.minute&&s.setUTCSeconds(0);q>=k.hour&&s.setUTCMinutes(0);q>=k.day&&s.setUTCHours(0);q>=k.day*4&&s.setUTCDate(1);q>=k.year&&s.setUTCMonth(0);var n=0,p=Number.NaN,t;do{t=p;p=s.getTime();m.push({v:p,label:h.tickFormatter(p,h)});if(v=="month")if(l<1){s.setUTCDate(1);var B=s.getTime();s.setUTCMonth(s.getUTCMonth()+1);var O=s.getTime();s.setTime(p+
|
|
n*k.hour+(O-B)*l);n=s.getUTCHours();s.setUTCHours(0)}else s.setUTCMonth(s.getUTCMonth()+l);else v=="year"?s.setUTCFullYear(s.getUTCFullYear()+l):s.setTime(p+q)}while(p<h.max&&p!=t);return m};f=function(h,m){var l=new Date(h);if(e.timeformat!=null)return A.plot.formatDate(l,e.timeformat,e.monthNames);var v=m.tickSize[0]*k[m.tickSize[1]],s=m.max-m.min,q=e.twelveHourClock?" %p":"";fmt=v<k.minute?"%h:%M:%S"+q:v<k.day?s<2*k.day?"%h:%M"+q:"%b %d %h:%M"+q:v<k.month?"%b %d":v<k.year?s<k.year?"%b":"%b %y":
|
|
"%y";return A.plot.formatDate(l,fmt,e.monthNames)}}else{var g=e.tickDecimals,j=-Math.floor(Math.log(b)/Math.LN10);if(g!=null&&j>g)j=g;f=Math.pow(10,-j);b=b/f;if(b<1.5)c=1;else if(b<3){c=2;if(b>2.25&&(g==null||j+1<=g)){c=2.5;++j}}else c=b<7.5?5:10;c*=f;if(e.minTickSize!=null&&c<e.minTickSize)c=e.minTickSize;if(e.tickSize!=null)c=e.tickSize;a.tickDecimals=Math.max(0,g!=null?g:j);b=function(h){var m=[],l=y(h.min,h.tickSize),v=0,s=Number.NaN,q;do{q=s;s=l+v*h.tickSize;m.push({v:s,label:h.tickFormatter(s,
|
|
h)});++v}while(s<h.max&&s!=q);return m};f=function(h,m){return h.toFixed(m.tickDecimals)}}a.tickSize=d?[c,d]:c;a.tickGenerator=b;a.tickFormatter=A.isFunction(e.tickFormatter)?function(h,m){return""+e.tickFormatter(h,m)}:f}function ma(a,e){a.ticks=[];if(a.used){if(e.ticks==null)a.ticks=a.tickGenerator(a);else if(typeof e.ticks=="number"){if(e.ticks>0)a.ticks=a.tickGenerator(a)}else if(e.ticks){var b=e.ticks;if(A.isFunction(b))b=b({min:a.min,max:a.max});var c,d;for(c=0;c<b.length;++c){var f=null,k=
|
|
b[c];if(typeof k=="object"){d=k[0];if(k.length>1)f=k[1]}else d=k;if(f==null)f=a.tickFormatter(d,a);a.ticks[c]={v:d,label:f}}}if(e.autoscaleMargin!=null&&a.ticks.length>0){if(e.min==null)a.min=Math.min(a.min,a.ticks[0].v);if(e.max==null&&a.ticks.length>1)a.max=Math.max(a.max,a.ticks[a.ticks.length-1].v)}}}function da(){o.clearRect(0,0,R,T);var a=r.grid;a.show&&!a.aboveData&&ea();for(var e=0;e<C.length;++e){var b=C[e];b.lines.show&&pa(b);b.bars.show&&qa(b);b.points.show&&ra(b)}H(S.draw,[o]);a.show&&
|
|
a.aboveData&&ea()}function fa(a,e){var b=e+"axis",c=e+"2axis",d,f;if(a[b]){d=u[b];f=a[b].from;b=a[b].to}else if(a[c]){d=u[c];f=a[c].from;b=a[c].to}else{d=u[b];f=a[e+"1"];b=a[e+"2"]}if(f!=null&&b!=null&&f>b)return{from:b,to:f,axis:d};return{from:f,to:b,axis:d}}function ea(){var a;o.save();o.translate(w.left,w.top);if(r.grid.backgroundColor){o.fillStyle=ga(r.grid.backgroundColor,Q,0,"rgba(255, 255, 255, 0)");o.fillRect(0,0,P,Q)}var e=r.grid.markings;if(e){if(A.isFunction(e))e=e({xmin:u.xaxis.min,xmax:u.xaxis.max,
|
|
ymin:u.yaxis.min,ymax:u.yaxis.max,xaxis:u.xaxis,yaxis:u.yaxis,x2axis:u.x2axis,y2axis:u.y2axis});for(a=0;a<e.length;++a){var b=e[a],c=fa(b,"x"),d=fa(b,"y");if(c.from==null)c.from=c.axis.min;if(c.to==null)c.to=c.axis.max;if(d.from==null)d.from=d.axis.min;if(d.to==null)d.to=d.axis.max;if(!(c.to<c.axis.min||c.from>c.axis.max||d.to<d.axis.min||d.from>d.axis.max)){c.from=Math.max(c.from,c.axis.min);c.to=Math.min(c.to,c.axis.max);d.from=Math.max(d.from,d.axis.min);d.to=Math.min(d.to,d.axis.max);if(!(c.from==
|
|
c.to&&d.from==d.to)){c.from=c.axis.p2c(c.from);c.to=c.axis.p2c(c.to);d.from=d.axis.p2c(d.from);d.to=d.axis.p2c(d.to);if(c.from==c.to||d.from==d.to){o.beginPath();o.strokeStyle=b.color||r.grid.markingsColor;o.lineWidth=b.lineWidth||r.grid.markingsLineWidth;o.moveTo(c.from,d.from);o.lineTo(c.to,d.to);o.stroke()}else{o.fillStyle=b.color||r.grid.markingsColor;o.fillRect(c.from,d.to,c.to-c.from,d.from-d.to)}}}}}o.lineWidth=1;o.strokeStyle=r.grid.tickColor;o.beginPath();b=u.xaxis;for(a=0;a<b.ticks.length;++a){e=
|
|
b.ticks[a].v;if(!(e<=b.min||e>=u.xaxis.max)){o.moveTo(Math.floor(b.p2c(e))+o.lineWidth/2,0);o.lineTo(Math.floor(b.p2c(e))+o.lineWidth/2,Q)}}b=u.yaxis;for(a=0;a<b.ticks.length;++a){e=b.ticks[a].v;if(!(e<=b.min||e>=b.max)){o.moveTo(0,Math.floor(b.p2c(e))+o.lineWidth/2);o.lineTo(P,Math.floor(b.p2c(e))+o.lineWidth/2)}}b=u.x2axis;for(a=0;a<b.ticks.length;++a){e=b.ticks[a].v;if(!(e<=b.min||e>=b.max)){o.moveTo(Math.floor(b.p2c(e))+o.lineWidth/2,-5);o.lineTo(Math.floor(b.p2c(e))+o.lineWidth/2,5)}}b=u.y2axis;
|
|
for(a=0;a<b.ticks.length;++a){e=b.ticks[a].v;if(!(e<=b.min||e>=b.max)){o.moveTo(P-5,Math.floor(b.p2c(e))+o.lineWidth/2);o.lineTo(P+5,Math.floor(b.p2c(e))+o.lineWidth/2)}}o.stroke();if(r.grid.borderWidth){a=r.grid.borderWidth;o.lineWidth=a;o.strokeStyle=r.grid.borderColor;o.strokeRect(-a/2,-a/2,P+a,Q+a)}o.restore()}function na(){function a(c,d){for(var f=0;f<c.ticks.length;++f){var k=c.ticks[f];!k.label||k.v<c.min||k.v>c.max||e.push(d(k,c))}}x.find(".tickLabels").remove();var e=['<div class="tickLabels" style="font-size:smaller;color:'+
|
|
r.grid.color+'">'],b=r.grid.labelMargin+r.grid.borderWidth;a(u.xaxis,function(c,d){return'<div style="position:absolute;top:'+(w.top+Q+b)+"px;left:"+Math.round(w.left+d.p2c(c.v)-d.labelWidth/2)+"px;width:"+d.labelWidth+'px;text-align:center" class="tickLabel">'+c.label+"</div>"});a(u.yaxis,function(c,d){return'<div style="position:absolute;top:'+Math.round(w.top+d.p2c(c.v)-d.labelHeight/2)+"px;right:"+(w.right+P+b)+"px;width:"+d.labelWidth+'px;text-align:right" class="tickLabel">'+c.label+"</div>"});
|
|
a(u.x2axis,function(c,d){return'<div style="position:absolute;bottom:'+(w.bottom+Q+b)+"px;left:"+Math.round(w.left+d.p2c(c.v)-d.labelWidth/2)+"px;width:"+d.labelWidth+'px;text-align:center" class="tickLabel">'+c.label+"</div>"});a(u.y2axis,function(c,d){return'<div style="position:absolute;top:'+Math.round(w.top+d.p2c(c.v)-d.labelHeight/2)+"px;left:"+(w.left+P+b)+"px;width:"+d.labelWidth+'px;text-align:left" class="tickLabel">'+c.label+"</div>"});e.push("</div>");x.append(e.join(""))}function pa(a){function e(k,
|
|
g,j,h,m){var l=k.points;k=k.pointsize;var v=null,s=null;o.beginPath();for(var q=k;q<l.length;q+=k){var n=l[q-k],p=l[q-k+1],t=l[q],B=l[q+1];if(!(n==null||t==null)){if(p<=B&&p<m.min){if(B<m.min)continue;n=(m.min-p)/(B-p)*(t-n)+n;p=m.min}else if(B<=p&&B<m.min){if(p<m.min)continue;t=(m.min-p)/(B-p)*(t-n)+n;B=m.min}if(p>=B&&p>m.max){if(B>m.max)continue;n=(m.max-p)/(B-p)*(t-n)+n;p=m.max}else if(B>=p&&B>m.max){if(p>m.max)continue;t=(m.max-p)/(B-p)*(t-n)+n;B=m.max}if(n<=t&&n<h.min){if(t<h.min)continue;p=
|
|
(h.min-n)/(t-n)*(B-p)+p;n=h.min}else if(t<=n&&t<h.min){if(n<h.min)continue;B=(h.min-n)/(t-n)*(B-p)+p;t=h.min}if(n>=t&&n>h.max){if(t>h.max)continue;p=(h.max-n)/(t-n)*(B-p)+p;n=h.max}else if(t>=n&&t>h.max){if(n>h.max)continue;B=(h.max-n)/(t-n)*(B-p)+p;t=h.max}if(n!=v||p!=s)o.moveTo(h.p2c(n)+g,m.p2c(p)+j);v=t;s=B;o.lineTo(h.p2c(t)+g,m.p2c(B)+j)}}o.stroke()}function b(k,g,j){var h=k.points;k=k.pointsize;var m=Math.min(Math.max(0,j.min),j.max),l;l=0;for(var v=false,s=k;s<h.length;s+=k){var q=h[s-k],n=
|
|
h[s-k+1],p=h[s],t=h[s+1];if(v&&q!=null&&p==null){o.lineTo(g.p2c(l),j.p2c(m));o.fill();v=false}else if(!(q==null||p==null)){if(q<=p&&q<g.min){if(p<g.min)continue;n=(g.min-q)/(p-q)*(t-n)+n;q=g.min}else if(p<=q&&p<g.min){if(q<g.min)continue;t=(g.min-q)/(p-q)*(t-n)+n;p=g.min}if(q>=p&&q>g.max){if(p>g.max)continue;n=(g.max-q)/(p-q)*(t-n)+n;q=g.max}else if(p>=q&&p>g.max){if(q>g.max)continue;t=(g.max-q)/(p-q)*(t-n)+n;p=g.max}if(!v){o.beginPath();o.moveTo(g.p2c(q),j.p2c(m));v=true}if(n>=j.max&&t>=j.max){o.lineTo(g.p2c(q),
|
|
j.p2c(j.max));o.lineTo(g.p2c(p),j.p2c(j.max));l=p}else if(n<=j.min&&t<=j.min){o.lineTo(g.p2c(q),j.p2c(j.min));o.lineTo(g.p2c(p),j.p2c(j.min));l=p}else{var B=q,O=p;if(n<=t&&n<j.min&&t>=j.min){q=(j.min-n)/(t-n)*(p-q)+q;n=j.min}else if(t<=n&&t<j.min&&n>=j.min){p=(j.min-n)/(t-n)*(p-q)+q;t=j.min}if(n>=t&&n>j.max&&t<=j.max){q=(j.max-n)/(t-n)*(p-q)+q;n=j.max}else if(t>=n&&t>j.max&&n<=j.max){p=(j.max-n)/(t-n)*(p-q)+q;t=j.max}if(q!=B){l=n<=j.min?j.min:j.max;o.lineTo(g.p2c(B),j.p2c(l));o.lineTo(g.p2c(q),j.p2c(l))}o.lineTo(g.p2c(q),
|
|
j.p2c(n));o.lineTo(g.p2c(p),j.p2c(t));if(p!=O){l=t<=j.min?j.min:j.max;o.lineTo(g.p2c(p),j.p2c(l));o.lineTo(g.p2c(O),j.p2c(l))}l=Math.max(p,O)}}}if(v){o.lineTo(g.p2c(l),j.p2c(m));o.fill()}}o.save();o.translate(w.left,w.top);o.lineJoin="round";var c=a.lines.lineWidth,d=a.shadowSize;if(c>0&&d>0){o.lineWidth=d;o.strokeStyle="rgba(0,0,0,0.1)";var f=Math.PI/18;e(a.datapoints,Math.sin(f)*(c/2+d/2),Math.cos(f)*(c/2+d/2),a.xaxis,a.yaxis);o.lineWidth=d/2;e(a.datapoints,Math.sin(f)*(c/2+d/4),Math.cos(f)*(c/
|
|
2+d/4),a.xaxis,a.yaxis)}o.lineWidth=c;o.strokeStyle=a.color;if(d=aa(a.lines,a.color,0,Q)){o.fillStyle=d;b(a.datapoints,a.xaxis,a.yaxis)}c>0&&e(a.datapoints,0,0,a.xaxis,a.yaxis);o.restore()}function ra(a){function e(f,k,g,j,h,m,l){var v=f.points;f=f.pointsize;for(var s=0;s<v.length;s+=f){var q=v[s],n=v[s+1];if(!(q==null||q<m.min||q>m.max||n<l.min||n>l.max)){o.beginPath();o.arc(m.p2c(q),l.p2c(n)+j,k,0,h,false);if(g){o.fillStyle=g;o.fill()}o.stroke()}}}o.save();o.translate(w.left,w.top);var b=a.lines.lineWidth,
|
|
c=a.shadowSize,d=a.points.radius;if(b>0&&c>0){c=c/2;o.lineWidth=c;o.strokeStyle="rgba(0,0,0,0.1)";e(a.datapoints,d,null,c+c/2,Math.PI,a.xaxis,a.yaxis);o.strokeStyle="rgba(0,0,0,0.2)";e(a.datapoints,d,null,c/2,Math.PI,a.xaxis,a.yaxis)}o.lineWidth=b;o.strokeStyle=a.color;e(a.datapoints,d,aa(a.points,a.color),0,2*Math.PI,a.xaxis,a.yaxis);o.restore()}function ha(a,e,b,c,d,f,k,g,j,h,m){var l,v,s,q;if(m){q=v=s=true;l=false;m=b;a=a;b=e+c;d=e+d;if(a<m){e=a;a=m;m=e;l=true;v=false}}else{l=v=s=true;q=false;
|
|
m=a+c;a=a+d;d=b;b=e;if(b<d){e=b;b=d;d=e;q=true;s=false}}if(!(a<g.min||m>g.max||b<j.min||d>j.max)){if(m<g.min){m=g.min;l=false}if(a>g.max){a=g.max;v=false}if(d<j.min){d=j.min;q=false}if(b>j.max){b=j.max;s=false}m=g.p2c(m);d=j.p2c(d);a=g.p2c(a);b=j.p2c(b);if(k){h.beginPath();h.moveTo(m,d);h.lineTo(m,b);h.lineTo(a,b);h.lineTo(a,d);h.fillStyle=k(d,b);h.fill()}if(l||v||s||q){h.beginPath();h.moveTo(m,d+f);l?h.lineTo(m,b+f):h.moveTo(m,b+f);s?h.lineTo(a,b+f):h.moveTo(a,b+f);v?h.lineTo(a,d+f):h.moveTo(a,d+
|
|
f);q?h.lineTo(m,d+f):h.moveTo(m,d+f);h.stroke()}}}function qa(a){o.save();o.translate(w.left,w.top);o.lineWidth=a.bars.lineWidth;o.strokeStyle=a.color;var e=a.bars.align=="left"?0:-a.bars.barWidth/2;(function(b,c,d,f,k,g,j){var h=b.points;b=b.pointsize;for(var m=0;m<h.length;m+=b)h[m]!=null&&ha(h[m],h[m+1],h[m+2],c,d,f,k,g,j,o,a.bars.horizontal)})(a.datapoints,e,e+a.bars.barWidth,0,a.bars.fill?function(b,c){return aa(a.bars,a.color,b,c)}:null,a.xaxis,a.yaxis);o.restore()}function aa(a,e,b,c){var d=
|
|
a.fill;if(!d)return null;if(a.fillColor)return ga(a.fillColor,b,c,e);a=A.color.parse(e);a.a=typeof d=="number"?d:0.4;a.normalize();return a.toString()}function oa(){x.find(".legend").remove();if(r.legend.show){var a=[],e=false,b=r.legend.labelFormatter,c,d;for(i=0;i<C.length;++i){c=C[i];if(d=c.label){if(i%r.legend.noColumns==0){e&&a.push("</tr>");a.push("<tr>");e=true}if(b)d=b(d,c);a.push('<td class="legendColorBox"><div style="border:1px solid '+r.legend.labelBoxBorderColor+';padding:1px"><div style="width:4px;height:0;border:5px solid '+
|
|
c.color+';overflow:hidden"></div></div></td><td class="legendLabel">'+d+"</td>")}}e&&a.push("</tr>");if(a.length!=0){e='<table style="font-size:smaller;color:'+r.grid.color+'">'+a.join("")+"</table>";if(r.legend.container!=null)A(r.legend.container).html(e);else{a="";b=r.legend.position;c=r.legend.margin;if(c[0]==null)c=[c,c];if(b.charAt(0)=="n")a+="top:"+(c[1]+w.top)+"px;";else if(b.charAt(0)=="s")a+="bottom:"+(c[1]+w.bottom)+"px;";if(b.charAt(1)=="e")a+="right:"+(c[0]+w.right)+"px;";else if(b.charAt(1)==
|
|
"w")a+="left:"+(c[0]+w.left)+"px;";e=A('<div class="legend">'+e.replace('style="','style="position:absolute;'+a+";")+"</div>").appendTo(x);if(r.legend.backgroundOpacity!=0){b=r.legend.backgroundColor;if(b==null){b=(b=r.grid.backgroundColor)&&typeof b=="string"?A.color.parse(b):A.color.extract(e,"background-color");b.a=1;b=b.toString()}c=e.children();A('<div style="position:absolute;width:'+c.width()+"px;height:"+c.height()+"px;"+a+"background-color:"+b+';"> </div>').prependTo(e).css("opacity",r.legend.backgroundOpacity)}}}}}
|
|
function sa(a){r.grid.hoverable&&ia("plothover",a,function(e){return e.hoverable!=false})}function ta(a){ia("plotclick",a,function(e){return e.clickable!=false})}function ia(a,e,b){var c=X.offset(),d={pageX:e.pageX,pageY:e.pageY},f=e.pageX-c.left-w.left;e=e.pageY-c.top-w.top;if(u.xaxis.used)d.x=u.xaxis.c2p(f);if(u.yaxis.used)d.y=u.yaxis.c2p(e);if(u.x2axis.used)d.x2=u.x2axis.c2p(f);if(u.y2axis.used)d.y2=u.y2axis.c2p(e);var k=r.grid.mouseActiveRadius,g=k*k+1,j=null,h,m;for(h=0;h<C.length;++h)if(b(C[h])){var l=
|
|
C[h],v=l.xaxis,s=l.yaxis,q=l.datapoints.points,n=l.datapoints.pointsize,p=v.c2p(f),t=s.c2p(e),B=k/v.scale,O=k/s.scale;if(l.lines.show||l.points.show)for(m=0;m<q.length;m+=n){var N=q[m],L=q[m+1];if(N!=null)if(!(N-p>B||N-p<-B||L-t>O||L-t<-O)){N=Math.abs(v.p2c(N)-f);L=Math.abs(s.p2c(L)-e);L=N*N+L*L;if(L<=g){g=L;j=[h,m/n]}}}if(l.bars.show&&!j){v=l.bars.align=="left"?0:-l.bars.barWidth/2;l=v+l.bars.barWidth;for(m=0;m<q.length;m+=n){N=q[m];L=q[m+1];s=q[m+2];if(N!=null)if(C[h].bars.horizontal?p<=Math.max(s,
|
|
N)&&p>=Math.min(s,N)&&t>=L+v&&t<=L+l:p>=N+v&&p<=N+l&&t>=Math.min(s,L)&&t<=Math.max(s,L))j=[h,m/n]}}}if(j){h=j[0];m=j[1];n=C[h].datapoints.pointsize;b={datapoint:C[h].datapoints.points.slice(m*n,(m+1)*n),dataIndex:m,series:C[h],seriesIndex:h}}else b=null;if(b){b.pageX=parseInt(b.series.xaxis.p2c(b.datapoint[0])+c.left+w.left);b.pageY=parseInt(b.series.yaxis.p2c(b.datapoint[1])+c.top+w.top)}if(r.grid.autoHighlight){for(c=0;c<U.length;++c){f=U[c];f.auto==a&&!(b&&f.series==b.series&&f.point==b.datapoint)&&
|
|
ja(f.series,f.point)}b&&ka(b.series,b.datapoint,a)}x.trigger(a,[d,b])}function Z(){ba||(ba=setTimeout(ua,30))}function ua(){ba=null;K.save();K.clearRect(0,0,R,T);K.translate(w.left,w.top);var a,e;for(a=0;a<U.length;++a){e=U[a];if(e.series.bars.show)va(e.series,e.point);else{var b=e.series,c=e.point;e=c[0];c=c[1];var d=b.xaxis,f=b.yaxis;if(!(e<d.min||e>d.max||c<f.min||c>f.max)){var k=b.points.radius+b.points.lineWidth/2;K.lineWidth=k;K.strokeStyle=A.color.parse(b.color).scale("a",0.5).toString();b=
|
|
1.5*k;K.beginPath();K.arc(d.p2c(e),f.p2c(c),b,0,2*Math.PI,false);K.stroke()}}}K.restore();H(S.drawOverlay,[K])}function ka(a,e,b){if(typeof a=="number")a=C[a];if(typeof e=="number")e=a.data[e];var c=la(a,e);if(c==-1){U.push({series:a,point:e,auto:b});Z()}else if(!b)U[c].auto=false}function ja(a,e){if(a==null&&e==null){U=[];Z()}if(typeof a=="number")a=C[a];if(typeof e=="number")e=a.data[e];var b=la(a,e);if(b!=-1){U.splice(b,1);Z()}}function la(a,e){for(var b=0;b<U.length;++b){var c=U[b];if(c.series==
|
|
a&&c.point[0]==e[0]&&c.point[1]==e[1])return b}return-1}function va(a,e){K.lineWidth=a.bars.lineWidth;K.strokeStyle=A.color.parse(a.color).scale("a",0.5).toString();var b=A.color.parse(a.color).scale("a",0.5).toString(),c=a.bars.align=="left"?0:-a.bars.barWidth/2;ha(e[0],e[1],e[2]||0,c,c+a.bars.barWidth,0,function(){return b},a.xaxis,a.yaxis,K,a.bars.horizontal)}function ga(a,e,b,c){if(typeof a=="string")return a;else{e=o.createLinearGradient(0,b,0,e);b=0;for(var d=a.colors.length;b<d;++b){var f=
|
|
a.colors[b];if(typeof f!="string"){f=A.color.parse(c).scale("rgb",f.brightness);f.a*=f.opacity;f=f.toString()}e.addColorStop(b/(d-1),f)}return e}}var C=[],r={colors:["#edc240","#afd8f8","#cb4b4b","#4da74d","#9440ed"],legend:{show:true,noColumns:1,labelFormatter:null,labelBoxBorderColor:"#ccc",container:null,position:"ne",margin:5,backgroundColor:null,backgroundOpacity:0.85},xaxis:{mode:null,transform:null,inverseTransform:null,min:null,max:null,autoscaleMargin:null,ticks:null,tickFormatter:null,labelWidth:null,
|
|
labelHeight:null,tickDecimals:null,tickSize:null,minTickSize:null,monthNames:null,timeformat:null,twelveHourClock:false},yaxis:{autoscaleMargin:0.02},x2axis:{autoscaleMargin:null},y2axis:{autoscaleMargin:0.02},series:{points:{show:false,radius:3,lineWidth:2,fill:true,fillColor:"#ffffff"},lines:{lineWidth:2,fill:false,fillColor:null,steps:false},bars:{show:false,lineWidth:2,barWidth:1,fill:true,fillColor:null,align:"left",horizontal:false},shadowSize:3},grid:{show:true,aboveData:false,color:"#545454",
|
|
backgroundColor:null,tickColor:"rgba(0,0,0,0.15)",labelMargin:5,borderWidth:2,borderColor:null,markings:null,markingsColor:"#f4f4f4",markingsLineWidth:2,clickable:false,hoverable:false,autoHighlight:true,mouseActiveRadius:10},hooks:{}},$=null,ca=null,X=null,o=null,K=null,u={xaxis:{},yaxis:{},x2axis:{},y2axis:{}},w={left:0,right:0,top:0,bottom:0},R=0,T=0,P=0,Q=0,S={processOptions:[],processRawData:[],processDatapoints:[],draw:[],bindEvents:[],drawOverlay:[]},D=this;D.setData=F;D.setupGrid=W;D.draw=
|
|
da;D.getPlaceholder=function(){return x};D.getCanvas=function(){return $};D.getPlotOffset=function(){return w};D.width=function(){return P};D.height=function(){return Q};D.offset=function(){var a=X.offset();a.left+=w.left;a.top+=w.top;return a};D.getData=function(){return C};D.getAxes=function(){return u};D.getOptions=function(){return r};D.highlight=ka;D.unhighlight=ja;D.triggerRedrawOverlay=Z;D.pointOffset=function(a){return{left:parseInt(J(a,"xaxis").p2c(+a.x)+w.left),top:parseInt(J(a,"yaxis").p2c(+a.y)+
|
|
w.top)}};D.hooks=S;(function(){for(var a=0;a<G.length;++a){var e=G[a];e.init(D);e.options&&A.extend(true,r,e.options)}})(D);(function(a){A.extend(true,r,a);if(r.grid.borderColor==null)r.grid.borderColor=r.grid.color;if(r.xaxis.noTicks&&r.xaxis.ticks==null)r.xaxis.ticks=r.xaxis.noTicks;if(r.yaxis.noTicks&&r.yaxis.ticks==null)r.yaxis.ticks=r.yaxis.noTicks;if(r.grid.coloredAreas)r.grid.markings=r.grid.coloredAreas;if(r.grid.coloredAreasColor)r.grid.markingsColor=r.grid.coloredAreasColor;r.lines&&A.extend(true,
|
|
r.series.lines,r.lines);r.points&&A.extend(true,r.series.points,r.points);r.bars&&A.extend(true,r.series.bars,r.bars);if(r.shadowSize)r.series.shadowSize=r.shadowSize;for(var e in S)if(r.hooks[e]&&r.hooks[e].length)S[e]=S[e].concat(r.hooks[e]);H(S.processOptions,[r])})(z);(function(){function a(e,b){var c=document.createElement("canvas");c.width=e;c.height=b;if(A.browser.msie)c=window.G_vmlCanvasManager.initElement(c);return c}R=x.width();T=x.height();x.html("");x.css("position")=="static"&&x.css("position",
|
|
"relative");if(R<=0||T<=0)throw"Invalid dimensions for plot, width = "+R+", height = "+T;A.browser.msie&&window.G_vmlCanvasManager.init_(document);$=A(a(R,T)).appendTo(x).get(0);o=$.getContext("2d");ca=A(a(R,T)).css({position:"absolute",left:0,top:0}).appendTo(x).get(0);K=ca.getContext("2d");K.stroke()})();F(M);W();da();X=A([ca,$]);r.grid.hoverable&&X.mousemove(sa);r.grid.clickable&&X.click(ta);H(S.bindEvents,[X]);var U=[],ba=null}function y(x,M){return M*Math.floor(x/M)}A.plot=function(x,M,z){return new E(A(x),
|
|
M,z,A.plot.plugins)};A.plot.plugins=[];A.plot.formatDate=function(x,M,z){var G=function(V){V=""+V;return V.length==1?"0"+V:V},H=[],F=false,J=x.getUTCHours(),Y=J<12;if(z==null)z=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];if(M.search(/%p|%P/)!=-1)if(J>12)J-=12;else if(J==0)J=12;for(var W=0;W<M.length;++W){var I=M.charAt(W);if(F){switch(I){case "h":I=""+J;break;case "H":I=G(J);break;case "M":I=G(x.getUTCMinutes());break;case "S":I=G(x.getUTCSeconds());break;case "d":I=
|
|
""+x.getUTCDate();break;case "m":I=""+(x.getUTCMonth()+1);break;case "y":I=""+x.getUTCFullYear();break;case "b":I=""+z[x.getUTCMonth()];break;case "p":I=Y?"am":"pm";break;case "P":I=Y?"AM":"PM"}H.push(I);F=false}else if(I=="%")F=true;else H.push(I)}return H.join("")}})(jQuery);
|