OpenAuth.Net/OpenAuth.Mvc/Content/echarts/chart/funnel.js

1 line
8.2 KiB
JavaScript
Raw Normal View History

define("echarts/chart/funnel",["require","../component/base","./base","zrender/shape/Text","zrender/shape/Line","zrender/shape/Polygon","../config","../util/ecData","../util/number","zrender/tool/util","zrender/tool/color","zrender/tool/area","../chart"],function(e){function t(e,t,a,o,s){n.call(this,e,t,a,o,s),i.call(this),this.refresh(o)}var n=e("../component/base"),i=e("./base"),a=e("zrender/shape/Text"),o=e("zrender/shape/Line"),s=e("zrender/shape/Polygon"),r=e("../config"),l=e("../util/ecData"),h=e("../util/number"),m=e("zrender/tool/util"),V=e("zrender/tool/color"),U=e("zrender/tool/area");return t.prototype={type:r.CHART_TYPE_FUNNEL,_buildShape:function(){var e=this.series,t=this.component.legend;this._paramsMap={},this._selected={},this.selectedMap={};for(var n,i=0,a=e.length;a>i;i++)if(e[i].type===r.CHART_TYPE_FUNNEL){if(e[i]=this.reformOption(e[i]),this.legendHoverLink=e[i].legendHoverLink||this.legendHoverLink,n=e[i].name||"",this.selectedMap[n]=t?t.isSelected(n):!0,!this.selectedMap[n])continue;this._buildSingleFunnel(i),this.buildMark(i)}this.addShapeList()},_buildSingleFunnel:function(e){var t=this.component.legend,n=this.series[e],i=this._mapData(e),a=this._getLocation(e);this._paramsMap[e]={location:a,data:i};for(var o,s=0,r=[],l=0,m=i.length;m>l;l++)o=i[l].name,this.selectedMap[o]=t?t.isSelected(o):!0,this.selectedMap[o]&&!isNaN(i[l].value)&&(r.push(i[l]),s++);if(0!==s){for(var V,U,d,p,c=this._buildFunnelCase(e),u=n.funnelAlign,y=n.gap,g=s>1?(a.height-(s-1)*y)/s:a.height,b=a.y,f="descending"===n.sort?this._getItemWidth(e,r[0].value):h.parsePercent(n.minSize,a.width),k="descending"===n.sort?1:0,_=a.centerX,x=[],l=0,m=r.length;m>l;l++)if(o=r[l].name,this.selectedMap[o]&&!isNaN(r[l].value)){switch(V=m-2>=l?this._getItemWidth(e,r[l+k].value):"descending"===n.sort?h.parsePercent(n.minSize,a.width):h.parsePercent(n.maxSize,a.width),u){case"left":U=a.x;break;case"right":U=a.x+a.width-f;break;default:U=_-f/2}d=this._buildItem(e,r[l]._index,t?t.getColor(o):this.zr.getColor(r[l]._index),U,b,f,V,g,u),b+=g+y,p=d.style.pointList,x.unshift([p[0][0]-10,p[0][1]]),x.push([p[1][0]+10,p[1][1]]),0===l&&(0===f?(p=x.pop(),"center"==u&&(x[0][0]+=10),"right"==u&&(x[0][0]=p[0]),x[0][1]-="center"==u?10:15,1==m&&(p=d.style.pointList)):(x[x.length-1][1]-=5,x[0][1]-=5)),f=V}c&&(x.unshift([p[3][0]-10,p[3][1]]),x.push([p[2][0]+10,p[2][1]]),0===f?(p=x.pop(),"center"==u&&(x[0][0]+=10),"right"==u&&(x[0][0]=p[0]),x[0][1]+="center"==u?10:15):(x[x.length-1][1]+=5,x[0][1]+=5),c.style.pointList=x)}},_buildFunnelCase:function(e){var t=this.series[e];if(this.deepQuery([t,this.option],"calculable")){var n=this._paramsMap[e].location,i=10,a={hoverable:!1,style:{pointListd:[[n.x-i,n.y-i],[n.x+n.width+i,n.y-i],[n.x+n.width+i,n.y+n.height+i],[n.x-i,n.y+n.height+i]],brushType:"stroke",lineWidth:1,strokeColor:t.calculableHolderColor||this.ecTheme.calculableHolderColor}};return l.pack(a,t,e,void 0,-1),this.setCalculable(a),a=new s(a),this.shapeList.push(a),a}},_getLocation:function(e){var t,n=this.series[e],i=this.zr.getWidth(),a=this.zr.getHeight(),o=this.parsePercent(n.x,i),s=this.parsePercent(n.y,a);t=null==n.width?i-o-this.parsePercent(n.x2,i):this.parsePercent(n.width,i);var r;return r=null==n.height?a-s-this.parsePercent(n.y2,a):this.parsePercent(n.height,a),{x:o,y:s,width:t,height:r,centerX:o+t/2}},_mapData:function(e){function t(e,t){return"-"===e.value?1:"-"===t.value?-1:t.value-e.value}function n(e,n){return-t(e,n)}for(var i=this.series[e],a=m.clone(i.data),o=0,s=a.length;s>o;o++)a[o]._index=o;return"none"!=i.sort&&a.sort("descending"===i.sort?t:n),a},_buildItem:function(e,t,n,i,a,o,s,r,h){var m=this.series,V=m[e],U=V.data[t],d=this.getPolygon(e,t,n,i,a,o,s,r,h);l.pack(d,m[e],e,m[e].data[t],t,m[e].data[t].name),this.shapeList.push(d);var p=this.getLabel(e,t,n,i,a,o,s,r,h);l.pack(p,m[e],e,m[e].data[t],t,m[e].data[t].name),this.shapeList.push(p),this._needLabel(V,U,!1)||(p.invisible=!0);var c=this.getLabelLine(e,t,n,i,a,o,s,r,h);this.shapeList.push(c),this._needLabelLine(V,U,!1)||(c.invisible=!0);var u=[],y=[];return this._needLabelLine(V,U,!0)