src/pyams_skin/resources/js/ext/flot/jquery.canvaswrapper.min.js
changeset 557 bca7a7e058a3
equal deleted inserted replaced
-1:000000000000 557:bca7a7e058a3
       
     1 !function(t){function e(t,e){t.transform.baseVal.clear(),e&&e.forEach(function(e){t.transform.baseVal.appendItem(e)})}function i(t){return t.replace(/0|1|2|3|4|5|6|7|8|9/g,"0")}var n=function(e,i){var n=i.getElementsByClassName(e)[0];if(!n&&(n=document.createElement("canvas"),n.className=e,n.style.direction="ltr",n.style.position="absolute",n.style.left="0px",n.style.top="0px",i.appendChild(n),!n.getContext))throw new Error("Canvas is not available.");this.element=n;var r=this.context=n.getContext("2d");this.pixelRatio=t.plot.browser.getPixelRatio(r);var l=t(i).width(),o=t(i).height();this.resize(l,o),this.SVGContainer=null,this.SVG={},this._textCache={}};n.prototype.resize=function(t,e){t=t<10?10:t,e=e<10?10:e;var i=this.element,n=this.context,r=this.pixelRatio;this.width!==t&&(i.width=t*r,i.style.width=t+"px",this.width=t),this.height!==e&&(i.height=e*r,i.style.height=e+"px",this.height=e),n.restore(),n.save(),n.scale(r,r)},n.prototype.clear=function(){this.context.clearRect(0,0,this.width,this.height)},n.prototype.render=function(){var t=this._textCache;for(var e in t)if(hasOwnProperty.call(t,e)){var i=this.getSVGLayer(e),n=t[e],r=i.style.display;i.style.display="none";for(var l in n)if(hasOwnProperty.call(n,l)){var o=n[l];for(var s in o)if(hasOwnProperty.call(o,s)){for(var a,h=o[s],d=h.positions,p=0;d[p];p++)if((a=d[p]).active)a.rendered||(i.appendChild(a.element),a.rendered=!0);else if(d.splice(p--,1),a.rendered){for(;a.element.firstChild;)a.element.removeChild(a.element.firstChild);a.element.parentNode.removeChild(a.element)}0===d.length&&(h.measured?h.measured=!1:delete o[s])}}i.style.display=r}},n.prototype.getSVGLayer=function(t){var e=this.SVG[t];if(!e){var i;this.SVGContainer?i=this.SVGContainer.firstChild:(this.SVGContainer=document.createElement("div"),this.SVGContainer.className="flot-svg",this.SVGContainer.style.position="absolute",this.SVGContainer.style.top="0px",this.SVGContainer.style.left="0px",this.SVGContainer.style.height="100%",this.SVGContainer.style.width="100%",this.SVGContainer.style.pointerEvents="none",this.element.parentNode.appendChild(this.SVGContainer),(i=document.createElementNS("http://www.w3.org/2000/svg","svg")).style.width="100%",i.style.height="100%",this.SVGContainer.appendChild(i)),(e=document.createElementNS("http://www.w3.org/2000/svg","g")).setAttribute("class",t),e.style.position="absolute",e.style.top="0px",e.style.left="0px",e.style.bottom="0px",e.style.right="0px",i.appendChild(e),this.SVG[t]=e}return e},n.prototype.getTextInfo=function(t,e,n,l,o){var s,a,h,d;e=""+e,s="object"==typeof n?n.style+" "+n.variant+" "+n.weight+" "+n.size+"px/"+n.lineHeight+"px "+n.family:n,null==(a=this._textCache[t])&&(a=this._textCache[t]={}),null==(h=a[s])&&(h=a[s]={});var p=i(e);if(!(d=h[p])){var c=document.createElementNS("http://www.w3.org/2000/svg","text");if(-1!==e.indexOf("<br>"))r(e,c,-9999);else{var f=document.createTextNode(e);c.appendChild(f)}c.style.position="absolute",c.style.maxWidth=o,c.setAttributeNS(null,"x",-9999),c.setAttributeNS(null,"y",-9999),"object"==typeof n?(c.style.font=s,c.style.fill=n.fill):"string"==typeof n&&c.setAttribute("class",n),this.getSVGLayer(t).appendChild(c);var y=c.getBBox();for(d=h[p]={width:y.width,height:y.height,measured:!0,element:c,positions:[]};c.firstChild;)c.removeChild(c.firstChild);c.parentNode.removeChild(c)}return d.measured=!0,d},n.prototype.addText=function(t,i,n,l,o,s,a,h,d,p){var c=this.getTextInfo(t,l,o,s,a),f=c.positions;"center"===h?i-=c.width/2:"right"===h&&(i-=c.width),"middle"===d?n-=c.height/2:"bottom"===d&&(n-=c.height),n+=.75*c.height;for(var y,m=0;f[m];m++){if((y=f[m]).x===i&&y.y===n&&y.text===l)return y.active=!0,void e(y.element,p);if(!1===y.active)return y.active=!0,y.text=l,-1!==l.indexOf("<br>")?(n-=.25*c.height,r(l,y.element,i)):y.element.textContent=l,y.element.setAttributeNS(null,"x",i),y.element.setAttributeNS(null,"y",n),y.x=i,y.y=n,void e(y.element,p)}y={active:!0,rendered:!1,element:f.length?c.element.cloneNode():c.element,text:l,x:i,y:n},f.push(y),-1!==l.indexOf("<br>")?(n-=.25*c.height,r(l,y.element,i)):y.element.textContent=l,y.element.setAttributeNS(null,"x",i),y.element.setAttributeNS(null,"y",n),y.element.style.textAlign=h,e(y.element,p)};var r=function(t,e,i){var n,r,l,o=t.split("<br>");for(r=0;r<o.length;r++)e.childNodes[r]?n=e.childNodes[r]:(n=document.createElementNS("http://www.w3.org/2000/svg","tspan"),e.appendChild(n)),n.textContent=o[r],l=1*r+"em",n.setAttributeNS(null,"dy",l),n.setAttributeNS(null,"x",i)};n.prototype.removeText=function(t,e,i,n,r,l){var o,s;if(null==n){var a=this._textCache[t];if(null!=a)for(var h in a)if(hasOwnProperty.call(a,h)){var d=a[h];for(var p in d)if(hasOwnProperty.call(d,p)){var c=d[p].positions;c.forEach(function(t){t.active=!1})}}}else(c=(o=this.getTextInfo(t,n,r,l)).positions).forEach(function(t){s=i+.75*o.height,t.x===e&&t.y===s&&t.text===n&&(t.active=!1)})},n.prototype.clearCache=function(){var t=this._textCache;for(var e in t)if(hasOwnProperty.call(t,e))for(var i=this.getSVGLayer(e);i.firstChild;)i.removeChild(i.firstChild);this._textCache={}},window.Flot||(window.Flot={}),window.Flot.Canvas=n}(jQuery);