You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
1 line
8.9 KiB
1 line
8.9 KiB
4 years ago
|
define("echarts/chart/venn",["require","./base","zrender/shape/Text","zrender/shape/Circle","zrender/shape/Path","../config","../util/ecData","zrender/tool/util","../chart"],function(e){function t(e,t,i,a,o){n.call(this,e,t,i,a,o),this.refresh(a)}var n=e("./base"),i=e("zrender/shape/Text"),a=e("zrender/shape/Circle"),o=e("zrender/shape/Path"),r=e("../config");r.venn={zlevel:0,z:1,calculable:!1};var s=e("../util/ecData"),l=e("zrender/tool/util");return t.prototype={type:r.CHART_TYPE_VENN,_buildShape:function(){this.selectedMap={},this._symbol=this.option.symbolList,this._queryTarget,this._dropBoxList=[],this._vennDataCounter=0;var e=this.series;this.data=e[0].data,this._buildVenn(this.data),this.addShapeList()},_buildVenn:function(e){var t,n;e[0].value>e[1].value?(t=this.zr.getHeight()/3,n=t*Math.sqrt(e[1].value)/Math.sqrt(e[0].value)):(n=this.zr.getHeight()/3,t=n*Math.sqrt(e[0].value)/Math.sqrt(e[1].value));var i=this.zr.getWidth()/2-t,a=(t+n)/2*Math.sqrt(e[2].value)/Math.sqrt((e[0].value+e[1].value)/2),o=t+n;0!==e[2].value&&(o=this._getCoincideLength(e[0].value,e[1].value,e[2].value,t,n,a,Math.abs(t-n),t+n));var r=i+o,s=this.zr.getHeight()/2;if(this._buildItem(0,0,i,s,t),this._buildItem(0,1,r,s,n),0!==e[2].value&&e[2].value!==e[0].value&&e[2].value!==e[1].value){var l=(t*t-n*n)/(2*o)+o/2,h=o/2-(t*t-n*n)/(2*o),m=Math.sqrt(t*t-l*l),V=0,U=0;e[0].value>e[1].value&&i+l>r&&(U=1),e[0].value<e[1].value&&i+h>r&&(V=1),this._buildCoincideItem(2,i+l,s-m,s+m,t,n,V,U)}},_getCoincideLength:function(e,t,n,i,a,o,r,s){var l=(i*i-a*a)/(2*o)+o/2,h=o/2-(i*i-a*a)/(2*o),m=Math.acos(l/i),V=Math.acos(h/a),U=i*i*Math.PI,d=m*i*i-l*i*Math.sin(m)+V*a*a-h*a*Math.sin(V),p=d/U,c=n/e,u=Math.abs(p/c);return u>.999&&1.001>u?o:.999>=u?(s=o,o=(o+r)/2,this._getCoincideLength(e,t,n,i,a,o,r,s)):(r=o,o=(o+s)/2,this._getCoincideLength(e,t,n,i,a,o,r,s))},_buildItem:function(e,t,n,i,a){var o=this.series,r=this.getCircle(t,n,i,a);if(s.pack(r,o[0],e,o[0].data[t],t,o[0].data[t].name),this.shapeList.push(r),o[0].itemStyle.normal.label.show){var l=this.getLabel(t,n,i,a);s.pack(l,o[0],e,o[0].data[t],t,o[0].data[t].name),this.shapeList.push(l)}},_buildCoincideItem:function(e,t,n,i,a,r,l,h){var m=this.series,V=m[0],U=this.data[e],d=[U,V],p=this.deepMerge(d,"itemStyle.normal")||{},c=this.deepMerge(d,"itemStyle.emphasis")||{},u=p.color||this.zr.getColor(e),g=c.color||this.zr.getColor(e),y="M"+t+","+n+"A"+a+","+a+",0,"+l+",1,"+t+","+i+"A"+r+","+r+",0,"+h+",1,"+t+","+n,b={color:u,path:y},f={zlevel:this.getZlevelBase(),z:this.getZBase(),style:b,highlightStyle:{color:g,lineWidth:c.borderWidth,strokeColor:c.borderColor}};f=new o(f),f.buildPathArray&&(f.style.pathArray=f.buildPathArray(b.path)),s.pack(f,m[0],0,m[0].data[e],e,m[0].data[e].name),this.shapeList.push(f)},getCircle:function(e,t,n,i){var o=this.series[0],r=this.data[e],s=[r,o],l=this.deepMerge(s,"itemStyle.normal")||{},h=this.deepMerge(s,"itemStyle.emphasis")||{},m=l.color||this.zr.getColor(e),V=h.color||this.zr.getColor(e),U={zlevel:this.getZlevelBase(),clickable:!0,style:{x:t,y:n,r:i,brushType:"fill",opacity:1,color:m},highlightStyle:{color:V,lineWidth:h.borderWidth,strokeColor:h.borderColor}};return this.deepQuery([r,o,this.option],"calculable")&&(this.setCalculable(U),U.draggable=!0),new a(U)},getLabel:function(e,t,n,a){var o=this.series[0],s=o.itemStyle,l=this.data[e],h=[l,o],m=this.deepMerge(h,"itemStyle.normal")||{},V="normal",U=s[V].label,d=U.textStyle||{},p=this.getLabelText(e,V),c=this.getFont(d),u=m.color||this.zr.getColor(e),g=d.fontSize||12,y={zlevel:r.venn.zlevel+1,style:{x:t,y:n-a-g,color:d.color||u,text:p,textFont:c,textAlign:"center"}};return new i(y)},getLabelText:function(e,t){var n=this.series,i=n[0],a=i.data[e],o=this.deepQuery([a,i],"itemStyle."+t+".label.formatter");return o?"function"==typeof o?o(i.name,a.name,a.value):"string"==typeof o?(o=o.replace("{a}","{a0}").replace("{b}","{b0}").replace("{c}","{c0}"),o=o.replace("{a0}",i.name).replace("{b0}",a.name).replace("{c0}",a.value)):void 0:a.name},refresh:function(e){e&&(this.option=e,this.series=e.series),this._buildShape()}},l.inherits(t,n),e(
|