From 5c2786721348e04fb0cc48d0d1f0708d3507fe5d Mon Sep 17 00:00:00 2001 From: neuhausi Date: Mon, 1 Aug 2022 20:50:20 -0400 Subject: [PATCH] CanvasXpress Version 39.3 --- src/canvasXpress.min.js | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/src/canvasXpress.min.js b/src/canvasXpress.min.js index a3c806f..487edee 100755 --- a/src/canvasXpress.min.js +++ b/src/canvasXpress.min.js @@ -1,28 +1,28 @@ +/** - * + * * CanvasXpress 39.3 - JavaScript Canvas Library - * + * * Copyright (c) 2009-2022 - license@canvasxpress.org - * + * * Redistributions of the source code must retain this copyright * notice and the following disclaimer. - * + * * CanvasXpress is released as open source for personal and * educational use with dual licensing for commercial purposes. - * + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - * + * * Please see a copy of the CanvasXpress License at * https://www.canvasxpress.org/docs/license.html. - * + * * Dual licensing: * Commercial use may be granted to the extent that this source * code does NOT become part of any other Open Source or * Commercially licensed development library or toolkit without * explicit permission from CanvasXpress. - * + * */ /** * @@ -296,11 +296,11 @@ * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -+(function(b,a){if(typeof exports==="object"&&typeof module!=="undefined"){a(exports)}else{if(typeof define==="function"&&define.amd){define(["exports"],a)}else{(a((b.CanvasXpress=b.CanvasXpress||{})))}}}(this,(function(b){var c,a;if(this){c=this.window;a=this.document}CanvasXpress=function(j,f,e,o,d,k,g,n,m,i){var h=this;var l=function(){h.init(j,f,e,o,d,k,g,n,m,i)};if((e&&e.fonts)||(j&&j.config&&j.config.fonts)){if(e&&e.fonts){CanvasXpress.loadFonts(e.fonts,l)}else{CanvasXpress.loadFonts(j.config.fonts,l)}}else{if((e&&e.fontsExternal)||(j&&j.config&&j.config.fontsExternal)){if(e&&e.fontsExternal){CanvasXpress.loadFontsExternal(e.fontsExternal,l)}else{CanvasXpress.loadFontsExternal(j.config.fontsExternal,l)}}else{this.init(j,f,e,o,d,k,g,n,m,i)}}}})));(function(b,a){if(typeof exports==="object"&&typeof module!=="undefined"){a(exports)}else{if(typeof define==="function"&&define.amd){define(["exports"],a)}else{(a((b.cxplot=b.cxplot||{})))}}}(this,(function(){cxplot=function(h,b,j,m){if(typeof(h)=="object"&&h.isGGPlot){var n=function(f){if(Array.isArray(f)&&!f.length){return{}}else{return f}};delete (h.isGGPlot);var k=Array.isArray(h.geoms)?h.geoms:[h.geoms];var l=new cxplot(h.renderTo,h.data,aes(h.aes));for(var c=0;c1){if(b==0){e.x=a[b][c]}else{if(b==1){e.y=a[b][c]}else{if(b==2){e.z=a[b][c]}}}}}else{if(d.includes(c)){if(a[b][c] instanceof Object&&a[b][c].factor){if(!e.stringSampleFactors){e.stringSampleFactors=[]}if(!e.stringVariableFactors){e.stringVariableFactors=[]}if(!e.asSampleFactors){e.asSampleFactors=[]}if(!e.asVariableFactors){e.asVariableFactors=[]}e.stringSampleFactors.push(a[b][c].factor);e.stringVariableFactors.push(a[b][c].factor);e.asSampleFactors.push(a[b][c].factor);e.asVariableFactors.push(a[b][c].factor);e[c]=a[b][c].factor}}else{if(c=="sample"){e.x=a[b][c]}}}}}else{if(b==0){e.x=a[b]}else{if(b==1){e.y=a[b]}else{if(b==2){e.z=a[b]}}}e[a[b]]=a[b]}}}return e}})));CanvasXpress.instances=[];CanvasXpress.config=[];CanvasXpress.transitions={};CanvasXpress.cacheImages={};CanvasXpress.cacheImagesReady=false;CanvasXpress.cachePatterns={};CanvasXpress.cacheText={};CanvasXpress.fonts={Arial:true,Courier:true,Verdana:true};CanvasXpress.loadFonts=function(d,c){if(d&&d.length){var b=false;for(var a=0;an?",":"\t";for(var k=0;k=0;p--){if(l[p].replace(/"\s+$/,'"').charAt(l[p].length-1)=='"'){var q=l[p].replace(/^\s+"/,'"');if(q.length>1&&q.charAt(0)=='"'){l[p]=l[p].replace(/^\s*"|"\s*$/g,"").replace(/""/g,'"')}else{if(p){l.splice(p-1,2,[l[p-1],l[p]].join(g))}else{l=l.shift().split(g).concat(l)}}}else{l[p].replace(/""/g,'"')}}if(l.length==1&&l[0]==""){h.splice(k,1);k--;continue}h[k]=l}c(h)}catch(m){alert("Oooops! Not a valid callback")}};a.readAsText(b)};CanvasXpress.$=function(b,a){return CanvasXpress.getObject(b,a)};CanvasXpress.destroy=function(b,a){if(CanvasXpress.instances.length>0){CanvasXpress.instances[0].destroy(b,a)}};CanvasXpress.prototype.init=function(g,d,b,k,a,h,e,j,i,f){this.setInit=function(){this.target=g;this.events=k;this.info=a;this.userId=1;this.url={};this.meta={ids:{},time:{start:new Date().getTime(),elapsed:null,end:null,draw:[],render:[]},data:false,canvas:{},config:{user:b,orig:{},vals:{},remote:false},vals:{},render:{objects:[],groups:{},types:{},order:[],map:{},origin:[],transition:false},events:{},state:{save:0,clip:false,translate:[0,0],rotate:[0],scale:[1,1],last:{translate:[0,0],rotate:[0],scale:[1,1]}},stack:[],def:{},dom:{}};this.config={};this.legend={color:{},shape:{},size:{},sample:{},variable:{},line:{},pattern:{},outline:{},connect:{},contour:{},bin2d:{},decoration:{},oncoprint:{},overlays:{},colorNode:{},shapeNode:{},sizeNode:{},patternNode:{},colorEdge:{},sizeEdge:{}};this.scales={};this.panel={};this.plot={}};this.validateParameters=function(l){this.validateData(l);this.validateConfig(l);this.validateEvents(l);this.validateInfo(l);this.validateAfterRender(l)};this.validateData=function(p){this.dataURL=false;this.dataString=false;if(typeof(p.data)=="string"){var n=window.document.getElementById(p.data);if(n&&n.tagName.toLowerCase()=="table"&&n.className=="CanvasXpress"&&n.id){var q=p.data;p.data=this.parseHTMLTable(n,true);p.config=p.data.config;p.data=p.data.data;n.parentNode.removeChild(n);var l=window.document.getElementById("temp-table-id-"+q);if(l){l.id=q}else{alert("Dude! What did you do?")}}else{var n=this.isValidString(p.data);switch(n.type){case"URL":this.dataURL=p.data;p.data=false;break;case"XML":this.dataString=n.data;p.data=false;break;case"JSON":p.data=n.data;break;case"DELIM":p.data=n.data.data;if(!p.config){p.config=n.data.config}break;default:alert("Not a valid data string\n");break}}}else{if(typeof(p.data)=="function"){try{p.data=d.call(this)}catch(m){alert("Not a valid Data object:\n"+m)}}else{if(!f){try{this.stringifyJSON(p.data)}catch(m){alert("Data object malformed:\n"+m)}}}}};this.validateConfig=function(n){if(n.config){if(typeof(n.config)=="function"){try{n.config=n.config.call(this)}catch(m){alert("Not a valid Data object:\n"+m)}}else{if(!n.noValidate){try{this.stringifyJSON(n.config)}catch(m){alert("Config object malformed:\n"+m)}}}this.topoJSONURL=false;if(n.config.topoJSON&&typeof(n.config.topoJSON)=="string"){var l=this.isValidString(n.config.topoJSON);switch(l.type){case"URL":this.topoJSONURL=n.config.topoJSON;break}}}};this.validateEvents=function(l){};this.validateInfo=function(l){if(!l.info){l.info=""}};this.validateAfterRender=function(m){if(m.afterRender){try{this.stringifyJSON(m.afterRender)}catch(l){alert("AfterRender object malformed:\n"+l)}}};this.isOneTimeFunctionInConfig=function(l){if(!l){l=this}if(l.transposeData){return true}if(l.transformData){return true}if(l.asSampleFactors&&l.asSampleFactors.length){return true}if(l.asVariableFactors&&l.asVariableFactors.length){return true}if(l.stringSampleFactors&&l.stringSampleFactors.length){return true}if(l.stringVariableFactors&&l.stringVariableFactors.length){return true}if(l.histogramData){return true}if(l.ridgeBy){return true}if(l.sortData&&l.sortData.length){return true}if(l.asDOE){}return false};this.getAfterRender=function(l){var n=[];if(l.histogramData||l.ridgeBy){if(l.histogramData===true&&l.colorBy){n.unshift(["createHistogram",[],{}])}else{n.unshift(["createHistogram",[l.ridgeBy||l.histogramData||l.colorBy],{}])}}if(l.stringVariableFactors&&l.stringVariableFactors.length){for(var m=0;m=0){this.addRemoveToSelected([p,this.xAxisIndices[0],this.yAxisIndices[0]]);y=true}}if(y){z.unshift(["broadcastDraw",[{func:"afterRender"}],{},D,true])}}var s=z.length-1;var m=false;for(var q=0;q0?o.shift():[];var x=o.length>0?o.shift():{};var C=o.length>0?o.shift():D;var r=o.length>0?o.shift():false;if(this.showFunctionNamesAfterRender){this.flashInfoSpan(20,20,w)}var n=z[q+1]&&z[q+1][0]&&z[q+1][0].match(/drag/i)?true:false;this.skipRender=w=="createDOE"||w=="createHistogram"||w=="modifyColorScheme"||w.match(/segregate/)||n?false:!this.showTransition&&q";return c};if(CanvasXpress.icons.use.hasOwnProperty(k)){var svg='';if(CanvasXpress.icons.gradients.hasOwnProperty(k)){svg+=CanvasXpress.icons.gradients[k].replace(/"/g,'"')}for(var i=0;i"+p[i]+""}}}}if(s){for(var i in s){el.style[i]=s[i]}}el.innerHTML=t+c+svg}return x?new XMLSerializer().serializeToString(el):el};this.$cXIU=function(el,k,p,s){var t="";var classes=function(svg){var sn={};var sp=svg.split(/class=/);var c="";return c};if(el&&CanvasXpress.icons.use.hasOwnProperty(k)){var svg='';if(CanvasXpress.icons.gradients.hasOwnProperty(k)){svg+=CanvasXpress.icons.gradients[k].replace(/"/g,'"')}for(var i=0;i"+p[i]+""}}}}if(s){for(var i in s){el.style[i]=s[i]}}el.innerHTML=t+c+svg}};this.setPixelImage=function(){if(CanvasXpress.instances.length==1){this.beaconImage=this.$cX("img",{id:this.target+"-cX-Beacon-Image",src:(window.navigator.onLine?"https://www.canvasxpress.org/assets/images/beacon.gif?"+CanvasXpress.factory.client:CanvasXpress.png),title:"",alt:""})}else{this.beaconImage=CanvasXpress.instances[0].beaconImage}};this.$$=function(){var t=this;var c=CanvasXpress;var f=function(k){if(!k){k=c[d[4]]}else{if(k.length>36){return 0}}var len=k.length;var ini=Number(k.substring(2,3));var end=Number(k.substring(len-3,len-2));var str=k.substring(3+ini,3+ini+5)[d[7]]("")[d[8]]()[d[9]]("");var fns=k.substring(len-(3+end+5),len-(3+end));return Number(str+""+fns+"000")};var w=["686578546f537472696e67","6472617754657874","666163746f7279","73797374656d","72656769737465726564","76616c6964","737562737472696e67","73706c6974","72657665727365","6a6f696e","43616e766173587072657373","4e6f7420612076616c696420636f7079206f6620","556e737570706f727465642056657273696f6e206f6620","20522056657273696f6e","204e6f64652056657273696f6e","697352566965776572","697352436f6e736f6c65","68726566","2f7777772e63616e7661737870726573732e6f72672f646973742f","72616e646f6d496e744265747765656e","666f6e7453697a65","666f6e744e616d65","69734378706c6f74","6378706c6f742042792043616e766173587072657373","736574506978656c496d616765","64697361626c65426561636f6e"];var h=t.hexToString("686578546f537472696e67");var d=[];for(var i=0;i=0&&b.top>=0&&c<=w[0]&&m<=w[1]};this.hasClass=function(e,n){return e?e.classList.contains(n):false};this.addClass=function(e,n){if(e){e.classList.add(n)}};this.removeClass=function(e,n){if(e){e.classList.remove(n)}};this.getComputedCSS=function(e){var s="";var o=getComputedStyle(e);for(var i=0;i0?1:-1)*Math.floor(Math.abs(number))};var maxSafeInteger=Math.pow(2,53)-1;var toLength=function(value){var len=toInteger(value);return Math.min(Math.max(len,0),maxSafeInteger)};return function from(arrayLike){var C=this;var items=Object(arrayLike);if(arrayLike==null){throw new TypeError("Array.from requires an array-like object - not null or undefined")}var mapFn=arguments.length>1?arguments[1]:void undefined;var T;if(typeof mapFn!=="undefined"){if(!isCallable(mapFn)){throw new TypeError("Array.from: when provided, the second argument must be a function")}if(arguments.length>2){T=arguments[2]}}var len=toLength(items.length);var A=isCallable(C)?Object(new C(len)):new Array(len);var k=0;var kValue;while(k>>0;var start=arguments[1];var relativeStart=start>>0;var k=relativeStart<0?Math.max(len+relativeStart,0):Math.min(relativeStart,len);var end=arguments[2];var relativeEnd=end===undefined?len:end>>0;var finl=relativeEnd<0?Math.max(len+relativeEnd,0):Math.min(relativeEnd,len);while(k>>0;if(typeof callback!=="function"){throw new TypeError(callback+" is not a function")}if(arguments.length>1){T=arguments[1]}A=new Array(len);k=0;while(k>>0;if(typeof predicate!=="function"){throw new TypeError("predicate must be a function")}var thisArg=arguments[1];var k=0;while(k>>0;if(len===0){return false}var n=fromIndex|0;var k=Math.max(n>=0?n:len-Math.abs(n),0);function sameValueZero(x,y){return x===y||(typeof x==="number"&&typeof y==="number"&&isNaN(x)&&isNaN(y))}while(k1){m=l;m.width=arguments[0];m.height=arguments[1]}else{if(!n){m=l}else{m=n}}if(!(this instanceof k)){return new k(m)}this.width=m.width||l.width;this.height=m.height||l.height;this.enableMirroring=m.enableMirroring!==undefined?m.enableMirroring:l.enableMirroring;this.canvas=this;this.__document=m.document||document;if(m.ctx){this.__ctx=m.ctx}else{this.__canvas=this.__document.createElement("canvas");this.__ctx=this.__canvas.getContext("2d")}this.__setDefaultStyles();this.__stack=[this.__getStyleState()];this.__groupStack=[];this.__root=this.__document.createElementNS("http://www.w3.org/2000/svg","svg");this.__root.setAttribute("version",1.1);this.__root.setAttribute("xmlns","http://www.w3.org/2000/svg");this.__root.setAttributeNS("http://www.w3.org/2000/xmlns/","xmlns:xlink","http://www.w3.org/1999/xlink");this.__root.setAttribute("width",this.width);this.__root.setAttribute("height",this.height);this.__ids={};this.__defs=this.__document.createElementNS("http://www.w3.org/2000/svg","defs");this.__root.appendChild(this.__defs);this.__currentElement=this.__document.createElementNS("http://www.w3.org/2000/svg","g");this.__root.appendChild(this.__currentElement)};k.prototype.__createElement=function(l,p,r){if(typeof p==="undefined"){p={}}var o=this.__document.createElementNS("http://www.w3.org/2000/svg",l),q=Object.keys(p),n,m;if(r){o.setAttribute("fill","none");o.setAttribute("stroke","none")}for(n=0;n0){if(this.__currentElement.nodeName==="path"){if(!this.__currentElementsToStyle){this.__currentElementsToStyle={element:n,children:[]}}this.__currentElementsToStyle.children.push(this.__currentElement);this.__applyCurrentDefaultPath()}var o=this.__createElement("g");n.appendChild(o);this.__currentElement=o}var l=this.__currentElement.getAttribute("transform");if(l){l+=" "}else{l=""}l+=m;this.__currentElement.setAttribute("transform",l)};k.prototype.scale=function(l,m){if(m===undefined){m=l}this.__addTransform(g("scale({x},{y})",{x:l,y:m}))};k.prototype.rotate=function(m){var l=(m*180/Math.PI);this.__addTransform(g("rotate({angle},{cx},{cy})",{angle:l,cx:0,cy:0}))};k.prototype.translate=function(l,m){this.__addTransform(g("translate({x},{y})",{x:l,y:m}))};k.prototype.transform=function(m,l,q,p,o,n){this.__addTransform(g("matrix({a},{b},{c},{d},{e},{f})",{a:m,b:l,c:q,d:p,e:o,f:n}))};k.prototype.beginPath=function(){var m,l;this.__currentDefaultPath="";this.__currentPosition={};m=this.__createElement("path",{},true);l=this.__closestGroupOrSvg();l.appendChild(m);this.__currentElement=m};k.prototype.__applyCurrentDefaultPath=function(){var l=this.__currentElement;if(l.nodeName==="path"){l.setAttribute("d",this.__currentDefaultPath)}else{console.error("Attempted to apply path command to node",l.nodeName)}};k.prototype.__addPathCommand=function(l){this.__currentDefaultPath+=" ";this.__currentDefaultPath+=l};k.prototype.moveTo=function(l,m){if(this.__currentElement.nodeName!=="path"){this.beginPath()}this.__currentPosition={x:l,y:m};this.__addPathCommand(g("M {x} {y}",{x:l,y:m}))};k.prototype.closePath=function(){if(this.__currentDefaultPath){this.__addPathCommand("Z")}};k.prototype.lineTo=function(l,m){this.__currentPosition={x:l,y:m};if(this.__currentDefaultPath.indexOf("M")>-1){this.__addPathCommand(g("L {x} {y}",{x:l,y:m}))}else{this.__addPathCommand(g("M {x} {y}",{x:l,y:m}))}};k.prototype.bezierCurveTo=function(n,m,p,o,l,q){this.__currentPosition={x:l,y:q};this.__addPathCommand(g("C {cp1x} {cp1y} {cp2x} {cp2y} {x} {y}",{cp1x:n,cp1y:m,cp2x:p,cp2y:o,x:l,y:q}))};k.prototype.quadraticCurveTo=function(n,m,l,o){this.__currentPosition={x:l,y:o};this.__addPathCommand(g("Q {cpx} {cpy} {x} {y}",{cpx:n,cpy:m,x:l,y:o}))};var b=function(m){var l=Math.sqrt(m[0]*m[0]+m[1]*m[1]);return[m[0]/l,m[1]/l]};k.prototype.arcTo=function(F,o,E,n,q){var G=this.__currentPosition&&this.__currentPosition.x;var p=this.__currentPosition&&this.__currentPosition.y;if(typeof G=="undefined"||typeof p=="undefined"){return}if(q<0){throw new Error("IndexSizeError: The radius provided ("+q+") is negative.")}if(((G===F)&&(p===o))||((F===E)&&(o===n))||(q===0)){this.lineTo(F,o);return}var u=b([G-F,p-o]);var t=b([E-F,n-o]);if(u[0]*t[1]===u[1]*t[0]){this.lineTo(F,o);return}var m=(u[0]*t[0]+u[1]*t[1]);var v=Math.acos(Math.abs(m));var B=b([u[0]+t[0],u[1]+t[1]]);var r=q/Math.sin(v/2);var A=F+r*B[0];var z=o+r*B[1];var l=[-u[1],u[0]];var w=[t[1],-t[0]];var s=function(I){var H=I[0];var J=I[1];if(J>=0){return Math.acos(H)}else{return -Math.acos(H)}};var D=s(l);var C=s(w);this.lineTo(A+l[0]*q,z+l[1]*q);this.arc(A,z,q,D,C)};k.prototype.stroke=function(){if(this.__currentElement.nodeName==="path"){this.__currentElement.setAttribute("paint-order","fill stroke markers")}this.__applyCurrentDefaultPath();this.__applyStyleToCurrentElement("stroke")};k.prototype.fill=function(){if(this.__currentElement.nodeName==="path"){this.__currentElement.setAttribute("paint-order","stroke fill markers")}this.__applyCurrentDefaultPath();this.__applyStyleToCurrentElement("fill")};k.prototype.rect=function(m,o,n,l){if(this.__currentElement.nodeName!=="path"){this.beginPath()}this.moveTo(m,o);this.lineTo(m+n,o);this.lineTo(m+n,o+l);this.lineTo(m,o+l);this.lineTo(m,o);this.closePath()};k.prototype.fillRect=function(m,q,o,l){var p,n;p=this.__createElement("rect",{x:m,y:q,width:o,height:l},true);n=this.__closestGroupOrSvg();n.appendChild(p);this.__currentElement=p;this.__applyStyleToCurrentElement("fill")};k.prototype.strokeRect=function(m,q,o,l){var p,n;p=this.__createElement("rect",{x:m,y:q,width:o,height:l},true);n=this.__closestGroupOrSvg();n.appendChild(p);this.__currentElement=p;this.__applyStyleToCurrentElement("stroke")};k.prototype.__clearCanvas=function(){var o=this.__closestGroupOrSvg(),l=o.getAttribute("transform");var n=this.__root.childNodes[1];var p=n.childNodes;for(var m=p.length-1;m>=0;m--){if(p[m]){n.removeChild(p[m])}}this.__currentElement=n;this.__groupStack=[];if(l){this.__addTransform(l)}};k.prototype.clearRect=function(m,q,o,l){if(m===0&&q===0&&o===this.width&&l===this.height){this.__clearCanvas();return}var p,n=this.__closestGroupOrSvg();p=this.__createElement("rect",{x:m,y:q,width:o,height:l,fill:"#FFFFFF"},true);n.appendChild(p)};k.prototype.createLinearGradient=function(m,o,l,n){var p=this.__createElement("linearGradient",{id:h(this.__ids),x1:m+"px",x2:l+"px",y1:o+"px",y2:n+"px",gradientUnits:"userSpaceOnUse"},false);this.__defs.appendChild(p);return new i(p,this)};k.prototype.createRadialGradient=function(o,q,n,m,p,l){var r=this.__createElement("radialGradient",{id:h(this.__ids),cx:m+"px",cy:p+"px",r:l+"px",fx:o+"px",fy:q+"px",gradientUnits:"userSpaceOnUse"},false);this.__defs.appendChild(r);return new i(r,this)};k.prototype.__parseFont=function(){var m=/^\s*(?=(?:(?:[-a-z]+\s*){0,2}(italic|oblique))?)(?=(?:(?:[-a-z]+\s*){0,2}(small-caps))?)(?=(?:(?:[-a-z]+\s*){0,2}(bold(?:er)?|lighter|[1-9]00))?)(?:(?:normal|\1|\2|\3)\s*){0,3}((?:xx?-)?(?:small|large)|medium|smaller|larger|[.\d]+(?:\%|in|[cem]m|ex|p[ctx]))(?:\s*\/\s*(normal|[.\d]+(?:\%|in|[cem]m|ex|p[ctx])))?\s*([-,\'\"\sa-z0-9]+?)\s*$/i;var l=m.exec(this.font);var n={style:l[1]||"normal",size:l[4]||"10px",family:l[6]||"sans-serif",weight:l[3]||"normal",decoration:l[2]||"normal",href:null};if(this.__fontUnderline==="underline"){n.decoration="underline"}if(this.__fontHref){n.href=this.__fontHref}return n};k.prototype.__wrapTextLink=function(m,n){if(m.href){var l=this.__createElement("a");l.setAttributeNS("http://www.w3.org/1999/xlink","xlink:href",m.href);l.appendChild(n);return l}return n};k.prototype.__applyText=function(q,l,r,p){var n=this.__parseFont(),o=this.__closestGroupOrSvg(),m=this.__createElement("text",{"font-family":n.family,"font-size":n.size,"font-style":n.style,"font-weight":n.weight,"text-decoration":n.decoration,x:l,y:r,"text-anchor":f(this.textAlign),"dominant-baseline":c(this.textBaseline)},true);m.appendChild(this.__document.createTextNode(q));this.__currentElement=m;this.__applyStyleToCurrentElement(p);o.appendChild(this.__wrapTextLink(n,m))};k.prototype.fillText=function(m,l,n){this.__applyText(m,l,n,"fill")};k.prototype.strokeText=function(m,l,n){this.__applyText(m,l,n,"stroke")};k.prototype.measureText=function(l){this.__ctx.font=this.font;return this.__ctx.measureText(l)};k.prototype.arc=function(t,s,q,r,m,v){if(r===m){return}r=r%(2*Math.PI);m=m%(2*Math.PI);if(r===m){m=((m+(2*Math.PI))-0.001*(v?-1:1))%(2*Math.PI)}var z=t+q*Math.cos(m),w=s+q*Math.sin(m),p=t+q*Math.cos(r),o=s+q*Math.sin(r),n=v?0:1,l=0,u=m-r;if(u<0){u+=2*Math.PI}if(v){l=u>Math.PI?0:1}else{l=u>Math.PI?1:0}this.lineTo(p,o);this.__addPathCommand(g("A {rx} {ry} {xAxisRotation} {largeArcFlag} {sweepFlag} {endX} {endY}",{rx:q,ry:q,xAxisRotation:0,largeArcFlag:l,sweepFlag:n,endX:z,endY:w}));this.__currentPosition={x:z,y:w}};k.prototype.clip=function(){var m=this.__closestGroupOrSvg(),l=this.__createElement("clipPath"),o=h(this.__ids),n=this.__createElement("g");this.__applyCurrentDefaultPath();m.removeChild(this.__currentElement);l.setAttribute("id",o);l.appendChild(this.__currentElement);this.__defs.appendChild(l);m.setAttribute("clip-path",g("url(#{id})",{id:o}));m.appendChild(n);this.__currentElement=n};k.prototype.drawImage=function(){var n=Array.prototype.slice.call(arguments),z=n[0],u,t,v,F,x=0,w=0,C,G,s,y,l,q,o,D,p,m,B;if(n.length===3){u=n[1];t=n[2];C=z.width;G=z.height;v=C;F=G}else{if(n.length===5){u=n[1];t=n[2];v=n[3];F=n[4];C=z.width;G=z.height}else{if(n.length===9){x=n[1];w=n[2];C=n[3];G=n[4];u=n[5];t=n[6];v=n[7];F=n[8]}else{throw new Error("Inavlid number of arguments passed to drawImage: "+arguments.length)}}}s=this.__closestGroupOrSvg();o=this.__currentElement;var r="translate("+u+", "+t+")";if(z instanceof k){y=z.getSvg().cloneNode(true);if(y.childNodes&&y.childNodes.length>1){l=y.childNodes[0];while(l.childNodes.length){B=l.childNodes[0].getAttribute("id");this.__ids[B]=B;this.__defs.appendChild(l.childNodes[0])}q=y.childNodes[1];if(q){var E=q.getAttribute("transform");var A;if(E){A=E+" "+r}else{A=r}q.setAttribute("transform",A);s.appendChild(q)}}}else{if(z.nodeName==="CANVAS"||z.nodeName==="IMG"){D=this.__createElement("image");D.setAttribute("width",v);D.setAttribute("height",F);D.setAttribute("preserveAspectRatio","none");if(x||w||C!==z.width||G!==z.height){p=this.__document.createElement("canvas");p.width=v;p.height=F;m=p.getContext("2d");m.drawImage(z,x,w,C,G,0,0,v,F);z=p}D.setAttribute("transform",r);D.setAttributeNS("http://www.w3.org/1999/xlink","xlink:href",z.nodeName==="CANVAS"?z.toDataURL():z.getAttribute("src"));s.appendChild(D)}}};k.prototype.createPattern=function(o,m){var n=this.__document.createElementNS("http://www.w3.org/2000/svg","pattern"),p=h(this.__ids),l;n.setAttribute("id",p);n.setAttribute("width",o.width);n.setAttribute("height",o.height);if(o.nodeName==="CANVAS"||o.nodeName==="IMG"){l=this.__document.createElementNS("http://www.w3.org/2000/svg","image");l.setAttribute("width",o.width);l.setAttribute("height",o.height);l.setAttributeNS("http://www.w3.org/1999/xlink","xlink:href",o.nodeName==="CANVAS"?o.toDataURL():o.getAttribute("src"));n.appendChild(l);this.__defs.appendChild(n)}else{if(o instanceof k){n.appendChild(o.__root.childNodes[1]);this.__defs.appendChild(n)}}return new e(n,this)};k.prototype.setLineDash=function(l){if(l&&l.length>0){this.lineDash=l.join(",")}else{this.lineDash=null}};k.prototype.drawFocusRing=function(){};k.prototype.createImageData=function(){};k.prototype.getImageData=function(){};k.prototype.putImageData=function(){};k.prototype.globalCompositeOperation=function(){};k.prototype.setTransform=function(){};this.canvasToSVG=k};CanvasXpress.prototype.initInterface=function(){this.parseJSON=function(s,r){if(s.toString().match(/1){x.name+=seen[x.name]}var o=that.cloneObject(x);o.level=level||1;o.parent=parent||null;return o}),children.map(function(x){max=Math.max(max,(level||1)+1);if(!x.children){smps.push(x.name);vals.push(x.value||1)}return flatten(extractChildren(x)||[],extractChildren,(level||1)+1,x.name)}))};var extractChildren=function extractChildren(x){return x.children||null};var flat=flatten(extractChildren(treeStructure),extractChildren).map(function(x){x.n=x.children?x.children.length:0;return delete x.children&&x});var data={y:{vars:["Dummy"],smps:smps,data:[vals]},x:{}};for(var i=0;i1?l:"")][s]=flat[m].name;while(f){m=map[f];l=flat[m].level;data.x[levl+(l>1?l:"")][s]=flat[m].name;f=flat[m].parent}}}return{renderTo:"newTree",data:data,config:{graphType:"Tree",hierarchy:hier}}};return reformat(json)};this.loadFile=function(t){return function(e,jr,callback,f){t.removeMenus();t.showMask();var checkBackgroundImage=function(data){if(data.config&&data.config.backgroundImage&&data.config.backgroundImage.match(/^javascript:\/\//)&&data.config.backgroundImageSrc){var im=new Image();im.id=data.config.backgroundImage.split("//")[1];im.style.display="none";im.src="data:image/png;base64,"+atob(data.config.backgroundImageSrc);document.body.appendChild(im);CanvasXpress.cacheImages[t.getFileName(im.src)]=im}};var file=f?f:e.target?e.target.files[0]:e.files[0];var type=file.type;var part=file.name.split(".");var reader=new FileReader();if(type=="image/png"){var istEXt=function(dv,idx){var c="";for(var i=0;i<4;i++){c+=String.fromCharCode(dv.getUint8(idx+i))}return c=="tEXt"};var isCanvasXpress=function(dv,idx,len){var c="";for(var i=0;itt?",":"\t";var data;if(t.graphType=="Network"){data=t.delimitedToArray(str,dl,false,true);if(data&&!t.isArray(data)){var fail="";if(data.fail>0){fail=data.fail+" records couldn't be mapped to network data"}alert(data.rows+" "+data.type+" records added to network data\n"+fail);if(data.type=="node"){t.appendNodeData(data.data)}else{t.appendEdgeData(data.data)}t.hideMask();return}else{data=t.arrayToCanvasXpress(data)}}else{data=t.isMetaDataFile(t.delimitedToArray(str,dl),t.graphType=="Map");if(data&&!t.isArray(data)){if(data.addt){alert(data.recs+" records added as an additional data set\n")}else{alert(data.recs+" records added to meta data\n")}t.appendMetaData(data.data,data.addt);t.hideMask();return}else{data=t.arrayToCanvasXpress(data)}}data.renderTo=part[0].replace(/\s/g,"").replace(/\(/g,"").replace(/\)/g,"");data.uploadFile=true;t.remoteServiceType="file";t.updateRemoteData(data,callback);t.hideMask()}catch(e){t.hideMask();alert("Oooops! Not a valid CanvasXpress delimited file")}}}else{if(ext=="esv"){reader.onload=function(){try{var str=reader.result;var tc=0;var tt=0;if(str.match(/,/g)){tc=str.match(/,/g).length}if(str.match(/\t/g)){tt=str.match(/\t/g).length}var dl=tc>tt?",":"\t";var data=t.delimitedToArray(str,dl,false,true,"edge");data.renderTo=part[0];data.uploadFile=true;t.remoteServiceType="file";t.updateRemoteData(data,callback);t.hideMask()}catch(e){t.hideMask();alert("Oooops! Not a valid CanvasXpress delimited file")}}}else{if(ext=="gml"){reader.onload=function(){try{var data=t.parseGML(reader.result);data.renderTo=part[0];data.uploadFile=true;t.remoteServiceType="file";t.updateRemoteData(data,callback);t.hideMask()}catch(e){t.hideMask();alert("Oooops! Not a valid gml file for CanvasXpress")}}}else{if(ext=="gexf"){reader.onload=function(){t.remoteServiceType="file";try{var xml=t.parseXML(reader.result);t.gexfToCX(xml,part[0])}catch(e){t.hideMask();alert("Oooops! Not a valid "+ext+" file for CanvasXpress")}}}else{if(ext.match(/ml$/)){reader.onload=function(){try{var xml=t.parseXML(reader.result);t.loadXML(xml,part[0])}catch(e){t.hideMask();alert("Oooops! Not a valid "+ext+" file for CanvasXpress")}}}}}}}}}}reader.readAsText(file)}}}}(this);this.loadXML=function(xml,target,config,events){this.remoteServiceType="file";var ts1=xml.childNodes[0];var ts2=xml.childNodes[2]||xml.childNodes[1];if(ts1.tagName&&ts1.tagName.toLowerCase()=="map"){this.metabaseToCX(xml,target,config,events)}else{if(ts1.tagName&&ts1.tagName.toLowerCase()=="graph"){this.cytoscapeToCX(xml,target,config,events)}else{if(ts1.tagName&&ts1.tagName.toLowerCase()=="pathway"){this.wikipathwayToCX(xml,target,config,events)}else{if(ts2&&ts2.tagName&&ts2.tagName.toLowerCase()=="pathway"){this.keggToCX(xml,target,config,events)}}}}};this.editJSFiddle=function(t){return function(e,f){if(t.editable||f){t.removeMenus();var js="onReady(function () {\n"+t.getCodeJSONJS()+"})";var ht="\n";ht+="