天津投入产出系统后端
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 lines
4.1 KiB

define("echarts/chart/treemap",["require","./base","zrender/tool/area","zrender/shape/Rectangle","zrender/shape/Text","../layout/TreeMap","../config","../util/ecData","zrender/tool/util","../chart"],function(e){function t(e,t,n,a,o){i.call(this,e,t,n,a,o),this.refresh(a)}var i=e("./base"),n=e("zrender/tool/area"),a=e("zrender/shape/Rectangle"),o=(e("zrender/shape/Text"),e("../layout/TreeMap")),r=e("../config");r.treemap={zlevel:0,z:1,calculable:!1,clickable:!0};var s=e("../util/ecData"),l=e("zrender/tool/util");return t.prototype={type:r.CHART_TYPE_TREEMAP,_buildShape:function(){var e=this.series;this.data=e[0].data,this.x0=100,this.y0=50,this.width0=500,this.height0=300,this._buildTreemap(this.data),this.addShapeList()},_buildTreemap:function(e){for(var t=this.width0*this.height0,i=0,n=[],a=0;a<e.length;a++)i+=e[a].value;for(var r=0;r<e.length;r++)n.push(e[r].value*t/i);for(var s=new o({areas:n,x0:this.x0,y0:this.y0,width0:this.width0,height0:this.height0}),l=s.rectangleList,h=0;h<l.length;h++){var m=l[h];this._buildItem(m.x,m.y,m.width,m.height,h)}},_buildItem:function(e,t,i,n,a){var o=this.series,r=this.getRectangle(e,t,i,n,this.data[a].name,a);s.pack(r,o[0],0,o[0].data[a],0,o[0].data[a].name),this.shapeList.push(r)},getRectangle:function(e,t,i,n,o,r){var s=this.series[0],l=this.data[r],h=[l,s],m=this.deepMerge(h,"itemStyle.normal")||{},V=this.deepMerge(h,"itemStyle.emphasis")||{},U=m.color||this.zr.getColor(r),d=V.color||this.zr.getColor(r),p=m.borderWidth||0,c=m.borderColor||"#ccc",u=this.getLabel(e,t,i,n,this.data[r].name,r),g={zlevel:this.getZlevelBase(),z:this.getZBase(),hoverable:!0,clickable:!0,style:$.extend({x:e,y:t,width:i,height:n,brushType:"both",color:U,lineWidth:p,strokeColor:c},u.style),highlightStyle:$.extend({color:d,lineWidth:V.borderWidth,strokeColor:V.borderColor},u.highlightStyle)};return new a(g)},getLabel:function(e,t,i,a,o,r){if(!this.series[0].itemStyle.normal.label.show)return{};var s=12,l=5,h=13,m=h+"px Arial",V=n.getTextWidth(o,m),U=n.getTextHeight(o,m);if(l+V>i||s+U>a)return{};var d=this.data[r],p={zlevel:this.getZlevelBase()+1,z:this.getZBase()+1,hoverable:!1,style:{x:e+l,y:t+s,text:o,textColor:"#777",textFont:m},highlightStyle:{text:o}};return p={style:{text:o},highlightStyle:{text:o}},p=this.addLabel(p,this.series[0],d,o),p.style.textPosition="specific",p.style.textX=e+l,p.style.textY=t+s,p.style.textColor=p.style.textColor||"#000",p.highlightStyle.textPosition="specific",p.highlightStyle.textX=e+l,p.highlightStyle.textY=t+s,p.highlightStyle.textColor=p.highlightStyle.textColor||"#000",p},refresh:function(e){e&&(this.option=e,this.series=e.series),this._buildShape()}},l.inherits(t,i),e("../chart").define("treemap",t),t}),define("echarts/layout/TreeMap",["require"],function(){function e(e){this.rectangleList=[];var t={x:e.x0,y:e.y0,width:e.width0,height:e.height0};this.squarify(e.areas,t)}return e.prototype.squarify=function(e,t){var i="VERTICAL",n=t.width,a=t.height;t.width<t.height&&(i="HORIZONTAL",n=t.height,a=t.width);for(var o=this.getShapeListInAbstractRow(e,n,a),r=0;r<o.length;r++){o[r].x=0,o[r].y=0;for(var s=0;r>s;s++)o[r].y+=o[s].height}var l={};if("VERTICAL"==i){for(var h=0;h<o.length;h++)this.rectangleList.push({x:o[h].x+t.x,y:o[h].y+t.y,width:o[h].width,height:o[h].height});l={x:o[0].width+t.x,y:t.y,width:t.width-o[0].width,height:t.height}}else{for(var m=0;m<o.length;m++)this.rectangleList.push({x:o[m].y+t.x,y:o[m].x+t.y,width:o[m].height,height:o[m].width});l={x:t.x,y:t.y+o[0].width,width:t.width,height:t.height-o[0].width}}var V=e.slice(o.length);0!==V.length&&this.squarify(V,l)},e.prototype.getShapeListInAbstractRow=function(e,t,i){if(1===e.length)return[{width:t,height:i}];for(var n=1;n<e.length;n++){var a=this.placeFixedNumberRectangles(e.slice(0,n),t,i),o=this.placeFixedNumberRectangles(e.slice(0,n+1),t,i);if(this.isFirstBetter(a,o))return a}},e.prototype.placeFixedNumberRectangles=function(e,t,i){for(var n=e.length,a=[],o=0,r=0;r<e.length;r++)o+=e[r];for(var s=o/i,l=0;n>l;l++){var h=i*e[l]/o;a.push({width:s,height:h})}return a},e.prototype.isFirstBetter=function(e,t){var i=e[0].height/e[0].width;i=i>1?1/i:i;var n=t[0].height/t[0].width;return n=n>1?1/n:n,Math.abs(i-1)<=Math.abs(n-1)?!0:!1},e});