define("echarts/chart/force",["require","./base","../data/Graph","../layout/Force","zrender/shape/Line","zrender/shape/BezierCurve","zrender/shape/Image","../util/shape/Icon","../config","../util/ecData","zrender/tool/util","zrender/config","zrender/tool/vector","../chart"],function(t){"use strict";function e(t,e,a,l,d){var p=this;n.call(this,t,e,a,l,d),this.__nodePositionMap={},this._graph=new r(!0),this._layout=new h,this._layout.onupdate=function(){p._step()},this._steps=1,this.ondragstart=function(){i.apply(p,arguments)},this.ondragend=function(){o.apply(p,arguments)},this.ondrop=function(){},this.shapeHandler.ondragstart=function(){p.isDragstart=!0},this.onmousemove=function(){s.apply(p,arguments)},this.refresh(l)}function i(t){if(this.isDragstart&&t.target){var e=t.target;e.fixed=!0,this.isDragstart=!1,this.zr.on(y.EVENT.MOUSEMOVE,this.onmousemove)}}function s(){this._layout.temperature=.8,this._step()}function o(t,e){if(this.isDragend&&t.target){var i=t.target;i.fixed=!1,e.dragIn=!0,e.needRefresh=!1,this.isDragend=!1,this.zr.un(y.EVENT.MOUSEMOVE,this.onmousemove)}}function a(t,e,i){var s=m.create();return s[0]=(Math.random()-.5)*i+t,s[1]=(Math.random()-.5)*i+e,s}var n=t("./base"),r=t("../data/Graph"),h=t("../layout/Force"),l=t("zrender/shape/Line"),d=t("zrender/shape/BezierCurve"),p=t("zrender/shape/Image"),c=t("../util/shape/Icon"),u=t("../config");u.force={zlevel:1,z:2,center:["50%","50%"],size:"80%",preventOverlap:!1,coolDown:.99,minRadius:10,maxRadius:20,ratioScaling:!1,large:!1,useWorker:!1,steps:1,scaling:1,gravity:1.2,symbol:"circle",symbolSize:0,linkSymbol:null,linkSymbolSize:[10,15],draggable:!0,clickable:!0,roam:!1,itemStyle:{normal:{label:{show:!1,position:"inside"},nodeStyle:{brushType:"both",borderColor:"#5182ab",borderWidth:1},linkStyle:{color:"#5182ab",width:1,type:"line"}},emphasis:{label:{show:!1},nodeStyle:{},linkStyle:{opacity:0}}}};var g=t("../util/ecData"),f=t("zrender/tool/util"),y=t("zrender/config"),m=t("zrender/tool/vector");return e.prototype={constructor:e,type:u.CHART_TYPE_FORCE,_init:function(){var t,e=this.component.legend,i=this.series;this.clear();for(var s=0,o=i.length;o>s;s++){var a=i[s];if(a.type===u.CHART_TYPE_FORCE){if(i[s]=this.reformOption(i[s]),t=i[s].name||"",this.selectedMap[t]=e?e.isSelected(t):!0,!this.selectedMap[t])continue;this.buildMark(s),this._initSerie(a,s);break}}this.animationEffect()},_getNodeCategory:function(t,e){return t.categories&&t.categories[e.category||0]},_getNodeQueryTarget:function(t,e,i){i=i||"normal";var s=this._getNodeCategory(t,e)||{};return[e.itemStyle&&e.itemStyle[i],s&&s.itemStyle&&s.itemStyle[i],t.itemStyle[i].nodeStyle]},_getEdgeQueryTarget:function(t,e,i){return i=i||"normal",[e.itemStyle&&e.itemStyle[i],t.itemStyle[i].linkStyle]},_initSerie:function(t,e){this._temperature=1,this._graph=t.data?this._getSerieGraphFromDataMatrix(t):this._getSerieGraphFromNodeLinks(t),this._buildLinkShapes(t,e),this._buildNodeShapes(t,e);var i=t.roam===!0||"move"===t.roam,s=t.roam===!0||"scale"===t.roam;this.zr.modLayer(this.getZlevelBase(),{panable:i,zoomable:s}),(this.query("markPoint.effect.show")||this.query("markLine.effect.show"))&&this.zr.modLayer(u.EFFECT_ZLEVEL,{panable:i,zoomable:s}),this._initLayout(t),this._step()},_getSerieGraphFromDataMatrix:function(t){for(var e=[],i=0,s=[],o=0;os;s++){var a=i[s];if(a&&!a.ignore){var n=this._getNodeCategory(t,a),h=n?n.name:a.name;if(this.selectedMap[h]=this.isSelected(h),this.selectedMap[h]){var l=e.addNode(a.name,a);l.rawIndex=s}}}for(var s=0,o=t.links.length;o>s;s++){var d=t.links[s],p=d.source,c=d.target;"number"==typeof p&&(p=i[p],p&&(p=p.name)),"number"==typeof c&&(c=i[c],c&&(c=c.name));var u=e.addEdge(p,c,d);u&&(u.rawIndex=s)}return e.eachNode(function(t){var e=t.data.value;if(null==e){e=0;for(var i=0;ih;h++){var l=e.nodes[h];r=Math.max(l.layout.size,r),n=Math.min(l.layout.size,n)}for(var d=r-n,h=0;i>h;h++){var l=e.nodes[h];d>0?(l.layout.size=(l.layout.size-n)*(o-s)/d+s,l.layout.mass=l.layout.size/o):(l.layout.size=(o-s)/2,l.layout.mass=.5)}for(var h=0;i>h;h++){var l=e.nodes[h];if("undefined"!=typeof this.__nodePositionMap[l.id])l.layout.position=m.create(),m.copy(l.layout.position,this.__nodePositionMap[l.id]);else if("undefined"!=typeof l.data.initial)l.layout.position=m.create(),m.copy(l.layout.position,l.data.initial);else{var p=this._layout.center,c=Math.min(this._layout.width,this._layout.height);l.layout.position=a(p[0],p[1],.8*c)}var u=l.shape.style,g=l.layout.size;u.width=u.width||2*g,u.height=u.height||2*g,u.x=-u.width/2,u.y=-u.height/2,m.copy(l.shape.position,l.layout.position)}i=e.edges.length,r=-1/0;for(var h=0;i>h;h++){var f=e.edges[h];f.layout.weight>r&&(r=f.layout.weight)}for(var h=0;i>h;h++){var f=e.edges[h];f.layout.weight/=r}this._layout.init(e,t.useWorker)},_buildNodeShapes:function(t,e){var i=this._graph,s=this.query(t,"categories");i.eachNode(function(i){var o=this._getNodeCategory(t,i.data),a=[i.data,o,t],n=this._getNodeQueryTarget(t,i.data),r=this._getNodeQueryTarget(t,i.data,"emphasis"),h=new c({style:{x:0,y:0,color:this.deepQuery(n,"color"),brushType:"both",strokeColor:this.deepQuery(n,"strokeColor")||this.deepQuery(n,"borderColor"),lineWidth:this.deepQuery(n,"lineWidth")||this.deepQuery(n,"borderWidth")},highlightStyle:{color:this.deepQuery(r,"color"),strokeColor:this.deepQuery(r,"strokeColor")||this.deepQuery(r,"borderColor"),lineWidth:this.deepQuery(r,"lineWidth")||this.deepQuery(r,"borderWidth")},clickable:t.clickable,zlevel:this.getZlevelBase(),z:this.getZBase()});h.style.color||(h.style.color=this.getColor(o?o.name:i.id)),h.style.iconType=this.deepQuery(a,"symbol"),h.style.width=h.style.height=2*(this.deepQuery(a,"symbolSize")||0),h.style.iconType.match("image")&&(h.style.image=h.style.iconType.replace(new RegExp("^image:\\/\\/"),""),h=new p({style:h.style,highlightStyle:h.highlightStyle,clickable:h.clickable,zlevel:this.getZlevelBase(),z:this.getZBase()})),this.deepQuery(a,"itemStyle.normal.label.show")&&(h.style.text=null==i.data.label?i.id:i.data.label,h.style.textPosition=this.deepQuery(a,"itemStyle.normal.label.position"),h.style.textColor=this.deepQuery(a,"itemStyle.normal.label.textStyle.color"),h.style.textFont=this.getFont(this.deepQuery(a,"itemStyle.normal.label.textStyle")||{})),this.deepQuery(a,"itemStyle.emphasis.label.show")&&(h.highlightStyle.textPosition=this.deepQuery(a,"itemStyle.emphasis.label.position"),h.highlightStyle.textColor=this.deepQuery(a,"itemStyle.emphasis.label.textStyle.color"),h.highlightStyle.textFont=this.getFont(this.deepQuery(a,"itemStyle.emphasis.label.textStyle")||{})),this.deepQuery(a,"draggable")&&(this.setCalculable(h),h.dragEnableTime=0,h.draggable=!0,h.ondragstart=this.shapeHandler.ondragstart,h.ondragover=null);var l="";if("undefined"!=typeof i.category){var o=s[i.category];l=o&&o.name||""}g.pack(h,t,e,i.data,i.rawIndex,i.data.name||"",i.category),this.shapeList.push(h),this.zr.addShape(h),i.shape=h},this)},_buildLinkShapes:function(t,e){for(var i=this._graph,s=i.edges.length,o=0;s>o;o++){var a=i.edges[o],n=a.data,r=a.node1,h=a.node2,p=this._getEdgeQueryTarget(t,n),u=this.deepQuery(p,"type");t.linkSymbol&&"none"!==t.linkSymbol&&(u="line");var y="line"===u?l:d,m=new y({style:{xStart:0,yStart:0,xEnd:0,yEnd:0},clickable:this.query(t,"clickable"),highlightStyle:{},zlevel:this.getZlevelBase(),z:this.getZBase()});if(f.merge(m.style,this.query(t,"itemStyle.normal.linkStyle"),!0),f.merge(m.highlightStyle,this.query(t,"itemStyle.emphasis.linkStyle"),!0),"undefined"!=typeof n.itemStyle&&(n.itemStyle.normal&&f.merge(m.style,n.itemStyle.normal,!0),n.itemStyle.emphasis&&f.merge(m.highlightStyle,n.itemStyle.emphasis,!0)),m.style.lineWidth=m.style.lineWidth||m.style.width,m.style.strokeColor=m.style.strokeColor||m.style.color,m.highlightStyle.lineWidth=m.highlightStyle.lineWidth||m.highlightStyle.width,m.highlightStyle.strokeColor=m.highlightStyle.strokeColor||m.highlightStyle.color,g.pack(m,t,e,a.data,null==a.rawIndex?o:a.rawIndex,a.data.name||r.id+" - "+h.id,r.id,h.id),this.shapeList.push(m),this.zr.addShape(m),a.shape=m,t.linkSymbol&&"none"!==t.linkSymbol){var _=new c({style:{x:-5,y:0,width:t.linkSymbolSize[0],height:t.linkSymbolSize[1],iconType:t.linkSymbol,brushType:"fill",color:m.style.strokeColor},highlightStyle:{brushType:"fill"},position:[0,0],rotation:0});m._symbolShape=_,this.shapeList.push(_),this.zr.addShape(_)}}},_updateLinkShapes:function(){for(var t=m.create(),e=this._graph.edges,i=0,s=e.length;s>i;i++){var o=e[i],a=o.node1.shape,n=o.node2.shape,r=a.position,h=n.position;if(o.shape.style.xStart=r[0],o.shape.style.yStart=r[1],o.shape.style.xEnd=h[0],o.shape.style.yEnd=h[1],"bezier-curve"===o.shape.type&&(o.shape.style.cpX1=(r[0]+h[0])/2-(h[1]-r[1])/4,o.shape.style.cpY1=(r[1]+h[1])/2-(r[0]-h[0])/4),o.shape.modSelf(),o.shape._symbolShape){var l=o.shape._symbolShape;m.copy(l.position,n.position),m.sub(t,a.position,n.position),m.normalize(t,t),m.scaleAndAdd(l.position,l.position,t,n.style.width/2+2);var d=Math.atan2(t[1],t[0]);l.rotation=Math.PI/2-d,l.modSelf()}}},_syncNodePositions:function(){for(var t=this._graph,e=0;e.01?this._layout.step(this._steps):this.messageCenter.dispatch(u.EVENT.FORCE_LAYOUT_END,{},{},this.myChart)},refresh:function(t){if(t&&(this.option=t,this.series=this.option.series),this.legend=this.component.legend,this.legend)this.getColor=function(t){return this.legend.getColor(t)},this.isSelected=function(t){return this.legend.isSelected(t)};else{var e={},i=0;this.getColor=function(t){return e[t]?e[t]:(e[t]||(e[t]=this.zr.getColor(i++)),e[t])},this.isSelected=function(){return!0}}this._init()},dispose:function(){this.clear(),this.shapeList=null,this.effectList=null,this._layout.dispose(),this._layout=null,this.__nodePositionMap={}},getPosition:function(){var t=[];return this._graph.eachNode(function(e){e.layout&&t.push({name:e.data.name,position:Array.prototype.slice.call(e.layout.position)})}),t}},f.inherits(e,n),t("../chart").define("force",e),e}),define("echarts/data/Graph",["require","zrender/tool/util"],function(t){var e=t("zrender/tool/util"),i=function(t){this._directed=t||!1,this.nodes=[],this.edges=[],this._nodesMap={},this._edgesMap={}};i.prototype.isDirected=function(){return this._directed},i.prototype.addNode=function(t,e){if(this._nodesMap[t])return this._nodesMap[t];var s=new i.Node(t,e);return this.nodes.push(s),this._nodesMap[t]=s,s},i.prototype.getNodeById=function(t){return this._nodesMap[t]},i.prototype.addEdge=function(t,e,s){if("string"==typeof t&&(t=this._nodesMap[t]),"string"==typeof e&&(e=this._nodesMap[e]),t&&e){var o=t.id+"-"+e.id;if(this._edgesMap[o])return this._edgesMap[o];var a=new i.Edge(t,e,s);return this._directed&&(t.outEdges.push(a),e.inEdges.push(a)),t.edges.push(a),t!==e&&e.edges.push(a),this.edges.push(a),this._edgesMap[o]=a,a}},i.prototype.removeEdge=function(t){var i=t.node1,s=t.node2,o=i.id+"-"+s.id;this._directed&&(i.outEdges.splice(e.indexOf(i.outEdges,t),1),s.inEdges.splice(e.indexOf(s.inEdges,t),1)),i.edges.splice(e.indexOf(i.edges,t),1),i!==s&&s.edges.splice(e.indexOf(s.edges,t),1),delete this._edgesMap[o],this.edges.splice(e.indexOf(this.edges,t),1)},i.prototype.getEdge=function(t,e){return"string"!=typeof t&&(t=t.id),"string"!=typeof e&&(e=e.id),this._directed?this._edgesMap[t+"-"+e]:this._edgesMap[t+"-"+e]||this._edgesMap[e+"-"+t]},i.prototype.removeNode=function(t){if("string"!=typeof t||(t=this._nodesMap[t])){delete this._nodesMap[t.id],this.nodes.splice(e.indexOf(this.nodes,t),1);for(var i=0;is;)t.call(e,this.nodes[s],s)?s++:(this.removeNode(this.nodes[s]),i--)},i.prototype.filterEdge=function(t,e){for(var i=this.edges.length,s=0;i>s;)t.call(e,this.edges[s],s)?s++:(this.removeEdge(this.edges[s]),i--)},i.prototype.eachNode=function(t,e){for(var i=this.nodes.length,s=0;i>s;s++)this.nodes[s]&&t.call(e,this.nodes[s],s)},i.prototype.eachEdge=function(t,e){for(var i=this.edges.length,s=0;i>s;s++)this.edges[s]&&t.call(e,this.edges[s],s)},i.prototype.clear=function(){this.nodes.length=0,this.edges.length=0,this._nodesMap={},this._edgesMap={}},i.prototype.breadthFirstTraverse=function(t,e,i,s){if("string"==typeof e&&(e=this._nodesMap[e]),e){var o="edges";"out"===i?o="outEdges":"in"===i&&(o="inEdges");for(var a=0;an;n++){var r=a.addNode(t[n].id,t[n]);r.data.value=0,s&&(r.data.outValue=r.data.inValue=0)}for(var n=0;o>n;n++)for(var h=0;o>h;h++){var l=e[n][h];s&&(a.nodes[n].data.outValue+=l,a.nodes[h].data.inValue+=l),a.nodes[n].data.value+=l,a.nodes[h].data.value+=l}for(var n=0;o>n;n++)for(var h=n;o>h;h++){var l=e[n][h];if(0!==l){var d=a.nodes[n],p=a.nodes[h],c=a.addEdge(d,p,{});if(c.data.weight=l,n!==h&&s&&e[h][n]){var u=a.addEdge(p,d,{});u.data.weight=e[h][n]}}}return a}},i}),define("echarts/layout/Force",["require","./forceLayoutWorker","zrender/tool/vector"],function(t){function e(){if("undefined"!=typeof Worker&&"undefined"!=typeof Blob)try{var t=new Blob([s.getWorkerCode()]);i=window.URL.createObjectURL(t)}catch(e){i=""}return i}var i,s=t("./forceLayoutWorker"),o=t("zrender/tool/vector"),a=window.requestAnimationFrame||window.msRequestAnimationFrame||window.mozRequestAnimationFrame||window.webkitRequestAnimationFrame||function(t){setTimeout(t,16)},n="undefined"==typeof Float32Array?Array:Float32Array,r=function(t){"undefined"==typeof i&&e(),t=t||{},this.width=t.width||500,this.height=t.height||500,this.center=t.center||[this.width/2,this.height/2],this.ratioScaling=t.ratioScaling||!1,this.scaling=t.scaling||1,this.gravity="undefined"!=typeof t.gravity?t.gravity:1,this.large=t.large||!1,this.preventNodeOverlap=t.preventNodeOverlap||!1,this.preventNodeEdgeOverlap=t.preventNodeEdgeOverlap||!1,this.maxSpeedIncrease=t.maxSpeedIncrease||1,this.onupdate=t.onupdate||function(){},this.temperature=t.temperature||1,this.coolDown=t.coolDown||.99,this._layout=null,this._layoutWorker=null;var s=this,o=this._$onupdate;this._$onupdate=function(t){o.call(s,t)}};return r.prototype.updateConfig=function(){var t=this.width,e=this.height,i=Math.min(t,e),s={center:this.center,width:this.ratioScaling?t:i,height:this.ratioScaling?e:i,scaling:this.scaling||1,gravity:this.gravity||1,barnesHutOptimize:this.large,preventNodeOverlap:this.preventNodeOverlap,preventNodeEdgeOverlap:this.preventNodeEdgeOverlap,maxSpeedIncrease:this.maxSpeedIncrease};if(this._layoutWorker)this._layoutWorker.postMessage({cmd:"updateConfig",config:s});else for(var o in s)this._layout[o]=s[o]},r.prototype.init=function(t,e){if(i&&e)try{this._layoutWorker||(this._layoutWorker=new Worker(i),this._layoutWorker.onmessage=this._$onupdate),this._layout=null}catch(o){this._layoutWorker=null,this._layout||(this._layout=new s)}else this._layout||(this._layout=new s),this._layoutWorker&&(this._layoutWorker.terminate(),this._layoutWorker=null);this.temperature=1,this.graph=t;for(var a=t.nodes.length,r=new n(2*a),h=new n(a),l=new n(a),d=0;a>d;d++){var p=t.nodes[d];r[2*d]=p.layout.position[0],r[2*d+1]=p.layout.position[1],h[d]="undefined"==typeof p.layout.mass?1:p.layout.mass,l[d]="undefined"==typeof p.layout.size?1:p.layout.size,p.layout.__index=d}a=t.edges.length;for(var c=new n(2*a),u=new n(a),d=0;a>d;d++){var g=t.edges[d];c[2*d]=g.node1.layout.__index,c[2*d+1]=g.node2.layout.__index,u[d]=g.layout.weight||1}this._layoutWorker?this._layoutWorker.postMessage({cmd:"init",nodesPosition:r,nodesMass:h,nodesSize:l,edges:c,edgesWeight:u}):(this._layout.initNodes(r,h,l),this._layout.initEdges(c,u)),this.updateConfig()},r.prototype.step=function(t){var e=this.graph.nodes;if(this._layoutWorker){for(var i=new n(2*e.length),s=0;ss;s++)this.temperature*=this.coolDown}else{a(this._$onupdate);for(var s=0;ss;s++)this._layout.temperature=this.temperature,this._layout.update(),this.temperature*=this.coolDown}},r.prototype._$onupdate=function(t){if(this._layoutWorker){for(var e=new Float32Array(t.data),i=0;i0&&(o=1/Math.sqrt(o),t[0]=e[0]*o,t[1]=e[1]*o),t},negate:function(t,e){return t[0]=-e[0],t[1]=-e[1],t},copy:function(t,e){return t[0]=e[0],t[1]=e[1],t},set:function(t,e,i){return t[0]=e,t[1]=i,t}}:e("zrender/tool/vector");var h="undefined"==typeof Float32Array?Array:Float32Array;if(i.prototype.beforeUpdate=function(){for(var t=0;t=t&&this.bbox[1]<=e&&this.bbox[3]>=e},i.prototype.setBBox=function(t,e,i,s){this.bbox[0]=t,this.bbox[1]=e,this.bbox[2]=i,this.bbox[3]=s,this.size=(i-t+s-e)/2},i.prototype._newSubRegion=function(){var t=this.subRegions[this.nSubRegions];return t||(t=new i,this.subRegions[this.nSubRegions]=t),this.nSubRegions++,t},i.prototype._addNodeToSubRegion=function(t){var e=this.findSubRegion(t.position[0],t.position[1]),i=this.bbox;if(!e){var s=(i[0]+i[2])/2,o=(i[1]+i[3])/2,a=(i[2]-i[0])/2,n=(i[3]-i[1])/2,r=t.position[0]>=s?1:0,h=t.position[1]>=o?1:0,e=this._newSubRegion();e.setBBox(r*a+i[0],h*n+i[1],(r+1)*a+i[0],(h+1)*n+i[1])}e.addNode(t)},i.prototype._updateCenterOfMass=function(t){null==this.centerOfMass&&(this.centerOfMass=n.create());var e=this.centerOfMass[0]*this.mass,i=this.centerOfMass[1]*this.mass;e+=t.position[0]*t.mass,i+=t.position[1]*t.mass,this.mass+=t.mass,this.centerOfMass[0]=e/this.mass,this.centerOfMass[1]=i/this.mass},a.prototype.nodeToNodeRepulsionFactor=function(t,e,i){return i*i*t/e},a.prototype.edgeToNodeRepulsionFactor=function(t,e,i){return i*t/e},a.prototype.attractionFactor=function(t,e,i){return t*e/i},a.prototype.initNodes=function(t,e,i){this.temperature=1;var o=t.length/2;this.nodes.length=0;for(var a="undefined"!=typeof i,n=0;o>n;n++){var r=new s;r.position[0]=t[2*n],r.position[1]=t[2*n+1],r.mass=e[n],a&&(r.size=i[n]),this.nodes.push(r)}this._massArr=e,a&&(this._sizeArr=i)},a.prototype.initEdges=function(t,e){var i=t.length/2;this.edges.length=0;for(var s="undefined"!=typeof e,a=0;i>a;a++){var n=t[2*a],r=t[2*a+1],h=this.nodes[n],l=this.nodes[r];if(h&&l){h.outDegree++,l.inDegree++;var d=new o(h,l);s&&(d.weight=e[a]),this.edges.push(d)}}},a.prototype.update=function(){var t=this.nodes.length;if(this.updateBBox(),this._k=.4*this.scaling*Math.sqrt(this.width*this.height/t),this.barnesHutOptimize){this._rootRegion.setBBox(this.bbox[0],this.bbox[1],this.bbox[2],this.bbox[3]),this._rootRegion.beforeUpdate();for(var e=0;t>e;e++)this._rootRegion.addNode(this.nodes[e]);this._rootRegion.afterUpdate()}else{var i=0,s=this._rootRegion.centerOfMass;n.set(s,0,0);for(var e=0;t>e;e++){var o=this.nodes[e];i+=o.mass,n.scaleAndAdd(s,s,o.position,o.mass)}i>0&&n.scale(s,s,1/i)}this.updateForce(),this.updatePosition()},a.prototype.updateForce=function(){for(var t=this.nodes.length,e=0;t>e;e++){var i=this.nodes[e];n.copy(i.forcePrev,i.force),n.copy(i.speedPrev,i.speed),n.set(i.force,0,0)}this.updateNodeNodeForce(),this.gravity>0&&this.updateGravityForce(),this.updateEdgeForce(),this.preventNodeEdgeOverlap&&this.updateNodeEdgeForce()},a.prototype.updatePosition=function(){for(var t=this.nodes.length,e=n.create(),i=0;t>i;i++){var s=this.nodes[i],o=s.speed;n.scale(s.force,s.force,1/30);var a=n.len(s.force)+.1,r=Math.min(a,500)/a;n.scale(s.force,s.force,r),n.add(o,o,s.force),n.scale(o,o,this.temperature),n.sub(e,o,s.speedPrev);var h=n.len(e);if(h>0){n.scale(e,e,1/h);var l=n.len(s.speedPrev);l>0&&(h=Math.min(h/l,this.maxSpeedIncrease)*l,n.scaleAndAdd(o,s.speedPrev,e,h))}var d=n.len(o),r=Math.min(d,100)/(d+.1);n.scale(o,o,r),n.add(s.position,s.position,o)}},a.prototype.updateNodeNodeForce=function(){for(var t=this.nodes.length,e=0;t>e;e++){var i=this.nodes[e];if(this.barnesHutOptimize)this.applyRegionToNodeRepulsion(this._rootRegion,i);else for(var s=e+1;t>s;s++){var o=this.nodes[s];this.applyNodeToNodeRepulsion(i,o,!1)}}},a.prototype.updateGravityForce=function(){for(var t=0;tthis.barnesHutTheta*e.size*e.size){var o=this._k*this._k*(i.mass+e.mass)/(s+1);n.scaleAndAdd(i.force,i.force,t,2*o)}else for(var a=0;a0?a=this.nodeToNodeRepulsionFactor(r,h,this._k):0>=h&&(a=this._k*this._k*10*r)):a=this.nodeToNodeRepulsionFactor(r,h,this._k),s||n.scaleAndAdd(e.force,e.force,t,2*a),n.scaleAndAdd(i.force,i.force,t,2*-a)}}}}(),a.prototype.applyEdgeAttraction=function(){var t=n.create();return function(e){var i=e.node1,s=e.node2;n.sub(t,i.position,s.position);var o,a=n.len(t);o=0===this.edgeWeightInfluence?1:1==this.edgeWeightInfluence?e.weight:Math.pow(e.weight,this.edgeWeightInfluence);var r;if(!(this.preventOverlap&&(a=a-i.size-s.size,0>=a))){var r=this.attractionFactor(o,a,this._k);n.scaleAndAdd(i.force,i.force,t,-r),n.scaleAndAdd(s.force,s.force,t,r)}}}(),a.prototype.applyNodeGravity=function(){var t=n.create();return function(e){n.sub(t,this.center,e.position),this.width>this.height?t[1]*=this.width/this.height:t[0]*=this.height/this.width;var i=n.len(t)/100;this.strongGravity?n.scaleAndAdd(e.force,e.force,t,i*this.gravity*e.mass):n.scaleAndAdd(e.force,e.force,t,this.gravity*e.mass/(i+1))}}(),a.prototype.applyEdgeToNodeRepulsion=function(){var t=n.create(),e=n.create(),i=n.create();return function(s,o){var a=s.node1,r=s.node2;if(a!==o&&r!==o){n.sub(t,r.position,a.position),n.sub(e,o.position,a.position);var h=n.len(t);n.scale(t,t,1/h);var l=n.dot(t,e);if(!(0>l||l>h)){n.scaleAndAdd(i,a.position,t,l);var d=n.dist(i,o.position)-o.size,p=this.edgeToNodeRepulsionFactor(o.mass,Math.max(d,.1),100);n.sub(t,o.position,i),n.normalize(t,t),n.scaleAndAdd(o.force,o.force,t,p),n.scaleAndAdd(a.force,a.force,t,-p),n.scaleAndAdd(r.force,r.force,t,-p)}}}}(),a.prototype.updateBBox=function(){for(var t=1/0,e=1/0,i=-1/0,s=-1/0,o=0;os;s++){var o=l.nodes[s];o.position[0]=e[2*s],o.position[1]=e[2*s+1]}}else switch(t.data.cmd){case"init":l||(l=new a),l.initNodes(t.data.nodesPosition,t.data.nodesMass,t.data.nodesSize),l.initEdges(t.data.edges,t.data.edgesWeight);break;case"updateConfig":if(l)for(var n in t.data.config)l[n]=t.data.config[n];break;case"update":var r=t.data.steps;if(l){var i=l.nodes.length,e=new Float32Array(2*i);l.temperature=t.data.temperature;for(var s=0;r>s;s++)l.update(),l.temperature*=t.data.coolDown;for(var s=0;i>s;s++){var o=l.nodes[s];e[2*s]=o.position[0],e[2*s+1]=o.position[1]}self.postMessage(e.buffer,[e.buffer])}else{var h=new Float32Array;self.postMessage(h.buffer,[h.buffer])}}}}return a});