tupali_fork/librerias/gantt/code/modules/treemap.js
2020-05-23 15:45:54 -05:00

42 lines
16 KiB
JavaScript

/*
Highcharts JS v8.1.0 (2020-05-05)
(c) 2014-2019 Highsoft AS
Authors: Jon Arild Nygard / Oystein Moseng
License: www.highcharts.com/license
*/
(function(c){"object"===typeof module&&module.exports?(c["default"]=c,module.exports=c):"function"===typeof define&&define.amd?define("highcharts/modules/treemap",["highcharts"],function(w){c(w);c.Highcharts=w;return c}):c("undefined"!==typeof Highcharts?Highcharts:void 0)})(function(c){function w(c,d,x,l){c.hasOwnProperty(d)||(c[d]=l.apply(null,x))}c=c?c._modules:{};w(c,"mixins/tree-series.js",[c["parts/Color.js"],c["parts/Utilities.js"]],function(c,d){var x=d.extend,l=d.isArray,n=d.isNumber,q=d.isObject,
h=d.merge,v=d.pick;return{getColor:function(f,k){var r=k.index,d=k.mapOptionsToLevel,h=k.parentColor,q=k.parentColorIndex,C=k.series,A=k.colors,x=k.siblings,p=C.points,l=C.chart.options.chart,y;if(f){p=p[f.i];f=d[f.level]||{};if(d=p&&f.colorByPoint){var t=p.index%(A?A.length:l.colorCount);var n=A&&A[t]}if(!C.chart.styledMode){A=p&&p.options.color;l=f&&f.color;if(y=h)y=(y=f&&f.colorVariation)&&"brightness"===y.key?c.parse(h).brighten(r/x*y.to).get():h;y=v(A,l,n,y,C.color)}var w=v(p&&p.options.colorIndex,
f&&f.colorIndex,t,q,k.colorIndex)}return{color:y,colorIndex:w}},getLevelOptions:function(f){var k=null;if(q(f)){k={};var d=n(f.from)?f.from:1;var c=f.levels;var z={};var v=q(f.defaults)?f.defaults:{};l(c)&&(z=c.reduce(function(k,c){if(q(c)&&n(c.level)){var f=h({},c);var r="boolean"===typeof f.levelIsConstant?f.levelIsConstant:v.levelIsConstant;delete f.levelIsConstant;delete f.level;c=c.level+(r?0:d-1);q(k[c])?x(k[c],f):k[c]=f}return k},{}));c=n(f.to)?f.to:1;for(f=0;f<=c;f++)k[f]=h({},v,q(z[f])?z[f]:
{})}return k},setTreeValues:function J(k,c){var d=c.before,h=c.idRoot,r=c.mapIdToNode[h],l=c.points[k.i],q=l&&l.options||{},p=0,n=[];x(k,{levelDynamic:k.level-(("boolean"===typeof c.levelIsConstant?c.levelIsConstant:1)?0:r.level),name:v(l&&l.name,""),visible:h===k.id||("boolean"===typeof c.visible?c.visible:!1)});"function"===typeof d&&(k=d(k,c));k.children.forEach(function(d,h){var l=x({},c);x(l,{index:h,siblings:k.children.length,visible:k.visible});d=J(d,l);n.push(d);d.visible&&(p+=d.val)});k.visible=
0<p||k.visible;d=v(q.value,p);x(k,{children:n,childrenTotal:p,isLeaf:k.visible&&!p,val:d});return k},updateRootId:function(c){if(q(c)){var d=q(c.options)?c.options:{};d=v(c.rootNode,d.rootId,"");q(c.userOptions)&&(c.userOptions.rootId=d);c.rootNode=d}return d}}});w(c,"mixins/draw-point.js",[],function(){var c=function(c){var d,l=this,n=l.graphic,q=c.animatableAttribs,h=c.onComplete,v=c.css,f=c.renderer,k=null===(d=l.series)||void 0===d?void 0:d.options.animation;if(l.shouldDraw())n||(l.graphic=n=
f[c.shapeType](c.shapeArgs).add(c.group)),n.css(v).attr(c.attribs).animate(q,c.isNew?!1:k,h);else if(n){var r=function(){l.graphic=n=n.destroy();"function"===typeof h&&h()};Object.keys(q).length?n.animate(q,void 0,function(){r()}):r()}};return function(d){(d.attribs=d.attribs||{})["class"]=this.getClassName();c.call(this,d)}});w(c,"modules/treemap.src.js",[c["parts/Globals.js"],c["mixins/tree-series.js"],c["mixins/draw-point.js"],c["parts/Color.js"],c["mixins/legend-symbol.js"],c["parts/Point.js"],
c["parts/Utilities.js"]],function(c,d,x,l,n,q,h){var v=l.parse,f=h.addEvent,k=h.correctFloat,r=h.defined,w=h.error,z=h.extend,K=h.fireEvent,C=h.isArray,A=h.isNumber,L=h.isObject,p=h.isString,E=h.merge,y=h.objectEach,t=h.pick;l=h.seriesType;var M=h.stableSort,H=c.seriesTypes;h=c.noop;var N=d.getColor,O=d.getLevelOptions,F=c.Series,P=function(a,b,e){e=e||this;y(a,function(c,g){b.call(e,c,g,a)})},G=function(a,b,e){e=e||this;a=b.call(e,a);!1!==a&&G(a,b,e)},Q=d.updateRootId,I=!1;l("treemap","scatter",
{allowTraversingTree:!1,animationLimit:250,showInLegend:!1,marker:!1,colorByPoint:!1,dataLabels:{defer:!1,enabled:!0,formatter:function(){var a=this&&this.point?this.point:{};return p(a.name)?a.name:""},inside:!0,verticalAlign:"middle"},tooltip:{headerFormat:"",pointFormat:"<b>{point.name}</b>: {point.value}<br/>"},ignoreHiddenPoint:!0,layoutAlgorithm:"sliceAndDice",layoutStartingDirection:"vertical",alternateStartingDirection:!1,levelIsConstant:!0,drillUpButton:{position:{align:"right",x:-10,y:10}},
traverseUpButton:{position:{align:"right",x:-10,y:10}},borderColor:"#e6e6e6",borderWidth:1,colorKey:"colorValue",opacity:.15,states:{hover:{borderColor:"#999999",brightness:H.heatmap?0:.1,halo:!1,opacity:.75,shadow:!1}}},{pointArrayMap:["value"],directTouch:!0,optionalAxis:"colorAxis",getSymbol:h,parallelArrays:["x","y","value","colorValue"],colorKey:"colorValue",trackerGroups:["group","dataLabelsGroup"],getListOfParents:function(a,b){a=C(a)?a:[];var e=C(b)?b:[];b=a.reduce(function(a,b,e){b=t(b.parent,
"");"undefined"===typeof a[b]&&(a[b]=[]);a[b].push(e);return a},{"":[]});P(b,function(a,b,c){""!==b&&-1===e.indexOf(b)&&(a.forEach(function(a){c[""].push(a)}),delete c[b])});return b},getTree:function(){var a=this.data.map(function(a){return a.id});a=this.getListOfParents(this.data,a);this.nodeMap=[];return this.buildNode("",-1,0,a,null)},hasData:function(){return!!this.processedXData.length},init:function(a,b){var e=c.colorMapSeriesMixin;e&&(this.colorAttribs=e.colorAttribs);this.eventsToUnbind.push(f(this,
"setOptions",function(a){a=a.userOptions;r(a.allowDrillToNode)&&!r(a.allowTraversingTree)&&(a.allowTraversingTree=a.allowDrillToNode,delete a.allowDrillToNode);r(a.drillUpButton)&&!r(a.traverseUpButton)&&(a.traverseUpButton=a.drillUpButton,delete a.drillUpButton)}));F.prototype.init.call(this,a,b);this.options.allowTraversingTree&&this.eventsToUnbind.push(f(this,"click",this.onClickDrillToNode))},buildNode:function(a,b,e,c,g){var B=this,m=[],u=B.points[b],d=0,D;(c[a]||[]).forEach(function(b){D=B.buildNode(B.points[b].id,
b,e+1,c,a);d=Math.max(D.height+1,d);m.push(D)});b={id:a,i:b,children:m,height:d,level:e,parent:g,visible:!1};B.nodeMap[b.id]=b;u&&(u.node=b);return b},setTreeValues:function(a){var b=this,e=b.options,c=b.nodeMap[b.rootNode];e="boolean"===typeof e.levelIsConstant?e.levelIsConstant:!0;var g=0,B=[],m=b.points[a.i];a.children.forEach(function(a){a=b.setTreeValues(a);B.push(a);a.ignore||(g+=a.val)});M(B,function(a,b){return a.sortIndex-b.sortIndex});var d=t(m&&m.options.value,g);m&&(m.value=d);z(a,{children:B,
childrenTotal:g,ignore:!(t(m&&m.visible,!0)&&0<d),isLeaf:a.visible&&!g,levelDynamic:a.level-(e?0:c.level),name:t(m&&m.name,""),sortIndex:t(m&&m.sortIndex,-d),val:d});return a},calculateChildrenAreas:function(a,b){var e=this,c=e.options,g=e.mapOptionsToLevel[a.level+1],d=t(e[g&&g.layoutAlgorithm]&&g.layoutAlgorithm,c.layoutAlgorithm),m=c.alternateStartingDirection,f=[];a=a.children.filter(function(a){return!a.ignore});g&&g.layoutStartingDirection&&(b.direction="vertical"===g.layoutStartingDirection?
0:1);f=e[d](b,a);a.forEach(function(a,c){c=f[c];a.values=E(c,{val:a.childrenTotal,direction:m?1-b.direction:b.direction});a.pointValues=E(c,{x:c.x/e.axisRatio,y:100-c.y-c.height,width:c.width/e.axisRatio});a.children.length&&e.calculateChildrenAreas(a,a.values)})},setPointValues:function(){var a=this,b=a.xAxis,e=a.yAxis,c=a.chart.styledMode;a.points.forEach(function(g){var d=g.node,m=d.pointValues;d=d.visible;if(m&&d){d=m.height;var u=m.width,f=m.x,k=m.y,h=c?0:(a.pointAttribs(g)["stroke-width"]||
0)%2/2;m=Math.round(b.toPixels(f,!0))-h;u=Math.round(b.toPixels(f+u,!0))-h;f=Math.round(e.toPixels(k,!0))-h;d=Math.round(e.toPixels(k+d,!0))-h;g.shapeArgs={x:Math.min(m,u),y:Math.min(f,d),width:Math.abs(u-m),height:Math.abs(d-f)};g.plotX=g.shapeArgs.x+g.shapeArgs.width/2;g.plotY=g.shapeArgs.y+g.shapeArgs.height/2}else delete g.plotX,delete g.plotY})},setColorRecursive:function(a,b,e,c,g){var d=this,m=d&&d.chart;m=m&&m.options&&m.options.colors;if(a){var f=N(a,{colors:m,index:c,mapOptionsToLevel:d.mapOptionsToLevel,
parentColor:b,parentColorIndex:e,series:d,siblings:g});if(b=d.points[a.i])b.color=f.color,b.colorIndex=f.colorIndex;(a.children||[]).forEach(function(b,e){d.setColorRecursive(b,f.color,f.colorIndex,e,a.children.length)})}},algorithmGroup:function(a,b,e,c){this.height=a;this.width=b;this.plot=c;this.startDirection=this.direction=e;this.lH=this.nH=this.lW=this.nW=this.total=0;this.elArr=[];this.lP={total:0,lH:0,nH:0,lW:0,nW:0,nR:0,lR:0,aspectRatio:function(a,b){return Math.max(a/b,b/a)}};this.addElement=
function(a){this.lP.total=this.elArr[this.elArr.length-1];this.total+=a;0===this.direction?(this.lW=this.nW,this.lP.lH=this.lP.total/this.lW,this.lP.lR=this.lP.aspectRatio(this.lW,this.lP.lH),this.nW=this.total/this.height,this.lP.nH=this.lP.total/this.nW,this.lP.nR=this.lP.aspectRatio(this.nW,this.lP.nH)):(this.lH=this.nH,this.lP.lW=this.lP.total/this.lH,this.lP.lR=this.lP.aspectRatio(this.lP.lW,this.lH),this.nH=this.total/this.width,this.lP.nW=this.lP.total/this.nH,this.lP.nR=this.lP.aspectRatio(this.lP.nW,
this.nH));this.elArr.push(a)};this.reset=function(){this.lW=this.nW=0;this.elArr=[];this.total=0}},algorithmCalcPoints:function(a,b,e,c){var g,d,f,u,h=e.lW,D=e.lH,l=e.plot,q=0,n=e.elArr.length-1;if(b)h=e.nW,D=e.nH;else var p=e.elArr[e.elArr.length-1];e.elArr.forEach(function(a){if(b||q<n)0===e.direction?(g=l.x,d=l.y,f=h,u=a/f):(g=l.x,d=l.y,u=D,f=a/u),c.push({x:g,y:d,width:f,height:k(u)}),0===e.direction?l.y+=u:l.x+=f;q+=1});e.reset();0===e.direction?e.width-=h:e.height-=D;l.y=l.parent.y+(l.parent.height-
e.height);l.x=l.parent.x+(l.parent.width-e.width);a&&(e.direction=1-e.direction);b||e.addElement(p)},algorithmLowAspectRatio:function(a,b,e){var c=[],g=this,d,f={x:b.x,y:b.y,parent:b},h=0,l=e.length-1,k=new this.algorithmGroup(b.height,b.width,b.direction,f);e.forEach(function(e){d=e.val/b.val*b.height*b.width;k.addElement(d);k.lP.nR>k.lP.lR&&g.algorithmCalcPoints(a,!1,k,c,f);h===l&&g.algorithmCalcPoints(a,!0,k,c,f);h+=1});return c},algorithmFill:function(a,b,e){var c=[],g,d=b.direction,f=b.x,h=b.y,
k=b.width,l=b.height,q,n,p,r;e.forEach(function(e){g=e.val/b.val*b.height*b.width;q=f;n=h;0===d?(r=l,p=g/r,k-=p,f+=p):(p=k,r=g/p,l-=r,h+=r);c.push({x:q,y:n,width:p,height:r});a&&(d=1-d)});return c},strip:function(a,b){return this.algorithmLowAspectRatio(!1,a,b)},squarified:function(a,b){return this.algorithmLowAspectRatio(!0,a,b)},sliceAndDice:function(a,b){return this.algorithmFill(!0,a,b)},stripes:function(a,b){return this.algorithmFill(!1,a,b)},translate:function(){var a=this,b=a.options,c=Q(a);
F.prototype.translate.call(a);var d=a.tree=a.getTree();var g=a.nodeMap[c];a.renderTraverseUpButton(c);a.mapOptionsToLevel=O({from:g.level+1,levels:b.levels,to:d.height,defaults:{levelIsConstant:a.options.levelIsConstant,colorByPoint:b.colorByPoint}});""===c||g&&g.children.length||(a.setRootNode("",!1),c=a.rootNode,g=a.nodeMap[c]);G(a.nodeMap[a.rootNode],function(b){var c=!1,e=b.parent;b.visible=!0;if(e||""===e)c=a.nodeMap[e];return c});G(a.nodeMap[a.rootNode].children,function(a){var b=!1;a.forEach(function(a){a.visible=
!0;a.children.length&&(b=(b||[]).concat(a.children))});return b});a.setTreeValues(d);a.axisRatio=a.xAxis.len/a.yAxis.len;a.nodeMap[""].pointValues=c={x:0,y:0,width:100,height:100};a.nodeMap[""].values=c=E(c,{width:c.width*a.axisRatio,direction:"vertical"===b.layoutStartingDirection?0:1,val:d.val});a.calculateChildrenAreas(d,c);a.colorAxis||b.colorByPoint||a.setColorRecursive(a.tree);b.allowTraversingTree&&(b=g.pointValues,a.xAxis.setExtremes(b.x,b.x+b.width,!1),a.yAxis.setExtremes(b.y,b.y+b.height,
!1),a.xAxis.setScale(),a.yAxis.setScale());a.setPointValues()},drawDataLabels:function(){var a=this,b=a.mapOptionsToLevel,c,d;a.points.filter(function(a){return a.node.visible}).forEach(function(e){d=b[e.node.level];c={style:{}};e.node.isLeaf||(c.enabled=!1);d&&d.dataLabels&&(c=E(c,d.dataLabels),a._hasPointLabels=!0);e.shapeArgs&&(c.style.width=e.shapeArgs.width,e.dataLabel&&e.dataLabel.css({width:e.shapeArgs.width+"px"}));e.dlOptions=E(c,e.options.dataLabels)});F.prototype.drawDataLabels.call(this)},
alignDataLabel:function(a,b,c){var e=c.style;!r(e.textOverflow)&&b.text&&b.getBBox().width>b.text.textWidth&&b.css({textOverflow:"ellipsis",width:e.width+="px"});H.column.prototype.alignDataLabel.apply(this,arguments);a.dataLabel&&a.dataLabel.attr({zIndex:(a.node.zIndex||0)+1})},pointAttribs:function(a,b){var c=L(this.mapOptionsToLevel)?this.mapOptionsToLevel:{},d=a&&c[a.node.level]||{};c=this.options;var g=b&&c.states[b]||{},f=a&&a.getClassName()||"";a={stroke:a&&a.borderColor||d.borderColor||g.borderColor||
c.borderColor,"stroke-width":t(a&&a.borderWidth,d.borderWidth,g.borderWidth,c.borderWidth),dashstyle:a&&a.borderDashStyle||d.borderDashStyle||g.borderDashStyle||c.borderDashStyle,fill:a&&a.color||this.color};-1!==f.indexOf("highcharts-above-level")?(a.fill="none",a["stroke-width"]=0):-1!==f.indexOf("highcharts-internal-node-interactive")?(b=t(g.opacity,c.opacity),a.fill=v(a.fill).setOpacity(b).get(),a.cursor="pointer"):-1!==f.indexOf("highcharts-internal-node")?a.fill="none":b&&(a.fill=v(a.fill).brighten(g.brightness).get());
return a},drawPoints:function(){var a=this,b=a.chart,c=b.renderer,d=b.styledMode,f=a.options,h=d?{}:f.shadow,k=f.borderRadius,l=b.pointCount<f.animationLimit,p=f.allowTraversingTree;a.points.forEach(function(b){var e=b.node.levelDynamic,g={},m={},q={},n="level-group-"+e,r=!!b.graphic,u=l&&r,t=b.shapeArgs;b.shouldDraw()&&(k&&(m.r=k),E(!0,u?g:m,r?t:{},d?{}:a.pointAttribs(b,b.selected&&"select")),a.colorAttribs&&d&&z(q,a.colorAttribs(b)),a[n]||(a[n]=c.g(n).attr({zIndex:1E3-e}).add(a.group),a[n].survive=
!0));b.draw({animatableAttribs:g,attribs:m,css:q,group:a[n],renderer:c,shadow:h,shapeArgs:t,shapeType:"rect"});p&&b.graphic&&(b.drillId=f.interactByLeaf?a.drillToByLeaf(b):a.drillToByGroup(b))})},onClickDrillToNode:function(a){var b=(a=a.point)&&a.drillId;p(b)&&(a.setState(""),this.setRootNode(b,!0,{trigger:"click"}))},drillToByGroup:function(a){var b=!1;1!==a.node.level-this.nodeMap[this.rootNode].level||a.node.isLeaf||(b=a.id);return b},drillToByLeaf:function(a){var b=!1;if(a.node.parent!==this.rootNode&&
a.node.isLeaf)for(a=a.node;!b;)a=this.nodeMap[a.parent],a.parent===this.rootNode&&(b=a.id);return b},drillUp:function(){var a=this.nodeMap[this.rootNode];a&&p(a.parent)&&this.setRootNode(a.parent,!0,{trigger:"traverseUpButton"})},drillToNode:function(a,b){w("WARNING: treemap.drillToNode has been renamed to treemap.setRootNode, and will be removed in the next major version.");this.setRootNode(a,b)},setRootNode:function(a,b,c){a=z({newRootId:a,previousRootId:this.rootNode,redraw:t(b,!0),series:this},
c);K(this,"setRootNode",a,function(a){var b=a.series;b.idPreviousRoot=a.previousRootId;b.rootNode=a.newRootId;b.isDirty=!0;a.redraw&&b.chart.redraw()})},renderTraverseUpButton:function(a){var b=this,c=b.options.traverseUpButton,d=t(c.text,b.nodeMap[a].name,"< Back");if(""===a)b.drillUpButton&&(b.drillUpButton=b.drillUpButton.destroy());else if(this.drillUpButton)this.drillUpButton.placed=!1,this.drillUpButton.attr({text:d}).align();else{var f=(a=c.theme)&&a.states;this.drillUpButton=this.chart.renderer.button(d,
null,null,function(){b.drillUp()},a,f&&f.hover,f&&f.select).addClass("highcharts-drillup-button").attr({align:c.position.align,zIndex:7}).add().align(c.position,!1,c.relativeTo||"plotBox")}},buildKDTree:h,drawLegendSymbol:n.drawRectangle,getExtremes:function(){var a=F.prototype.getExtremes.call(this,this.colorValueData),b=a.dataMax;this.valueMin=a.dataMin;this.valueMax=b;return F.prototype.getExtremes.call(this)},getExtremesFromAll:!0,setState:function(a){this.options.inactiveOtherPoints=!0;F.prototype.setState.call(this,
a,!1);this.options.inactiveOtherPoints=!1},utils:{recursive:G}},{draw:x,setVisible:H.pie.prototype.pointClass.prototype.setVisible,getClassName:function(){var a=q.prototype.getClassName.call(this),b=this.series,c=b.options;this.node.level<=b.nodeMap[b.rootNode].level?a+=" highcharts-above-level":this.node.isLeaf||t(c.interactByLeaf,!c.allowTraversingTree)?this.node.isLeaf||(a+=" highcharts-internal-node"):a+=" highcharts-internal-node-interactive";return a},isValid:function(){return this.id||A(this.value)},
setState:function(a){q.prototype.setState.call(this,a);this.graphic&&this.graphic.attr({zIndex:"hover"===a?1:0})},shouldDraw:function(){return A(this.plotY)&&null!==this.y}});f(c.Series,"afterBindAxes",function(){var a=this.xAxis,b=this.yAxis;if(a&&b)if(this.is("treemap")){var c={endOnTick:!1,gridLineWidth:0,lineWidth:0,min:0,dataMin:0,minPadding:0,max:100,dataMax:100,maxPadding:0,startOnTick:!1,title:null,tickPositions:[]};z(b.options,c);z(a.options,c);I=!0}else I&&(b.setOptions(b.userOptions),a.setOptions(a.userOptions),
I=!1)});""});w(c,"masters/modules/treemap.src.js",[],function(){})});
//# sourceMappingURL=treemap.js.map