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