/*
 Highcharts JS v5.0.0 (2016-09-29)

 (c) 2014 Highsoft AS
 Authors: Jon Arild Nygard / Oystein Moseng

 License: www.highcharts.com/license
*/
(function(p){"object"===typeof module&&module.exports?module.exports=p:p(Highcharts)})(function(p){(function(g){var p=g.seriesType,t=g.seriesTypes,D=g.map,w=g.merge,z=g.extend,A=g.noop,m=g.each,y=g.grep,k=g.pick,u=g.Series,E=g.stableSort,F=function(a,b,c){var d;c=c||this;for(d in a)a.hasOwnProperty(d)&&b.call(c,a[d],d,a)},B=function(a,b,c,d){d=d||this;a=a||[];m(a,function(e,f){c=b.call(d,c,e,f,a)});return c},x=function(a,b,c){c=c||this;a=b.call(c,a);!1!==a&&x(a,b,c)};p("treemap","scatter",{showInLegend:!1,
marker:!1,dataLabels:{enabled:!0,defer:!1,verticalAlign:"middle",formatter:function(){return this.point.name||this.point.id},inside:!0},tooltip:{headerFormat:"",pointFormat:"<b>{point.name}</b>: {point.value}</b><br/>"},layoutAlgorithm:"sliceAndDice",layoutStartingDirection:"vertical",alternateStartingDirection:!1,levelIsConstant:!0,drillUpButton:{position:{align:"right",x:-10,y:10}}},{pointArrayMap:["value"],axisTypes:t.heatmap?["xAxis","yAxis","colorAxis"]:["xAxis","yAxis"],optionalAxis:"colorAxis",
getSymbol:A,parallelArrays:["x","y","value","colorValue"],colorKey:"colorValue",translateColors:t.heatmap&&t.heatmap.prototype.translateColors,trackerGroups:["group","dataLabelsGroup"],getListOfParents:function(a,b){var c=B(a,function(a,c,b){c=k(c.parent,"");void 0===a[c]&&(a[c]=[]);a[c].push(b);return a},{});F(c,function(a,c,f){""!==c&&-1===g.inArray(c,b)&&(m(a,function(a){f[""].push(a)}),delete f[c])});return c},getTree:function(){var a,b=this;a=D(this.data,function(a){return a.id});a=b.getListOfParents(this.data,
a);b.nodeMap=[];a=b.buildNode("",-1,0,a,null);x(this.nodeMap[this.rootNode],function(a){var d=!1,e=a.parent;a.visible=!0;if(e||""===e)d=b.nodeMap[e];return d});x(this.nodeMap[this.rootNode].children,function(a){var b=!1;m(a,function(a){a.visible=!0;a.children.length&&(b=(b||[]).concat(a.children))});return b});this.setTreeValues(a);return a},init:function(a,b){u.prototype.init.call(this,a,b);this.options.allowDrillToNode&&this.drillTo()},buildNode:function(a,b,c,d,e){var f=this,h=[],C=f.points[b],
v;m(d[a]||[],function(b){v=f.buildNode(f.points[b].id,b,c+1,d,a);h.push(v)});b={id:a,i:b,children:h,level:c,parent:e,visible:!1};f.nodeMap[b.id]=b;C&&(C.node=b);return b},setTreeValues:function(a){var b=this,c=b.options,d=0,e=[],f,h=b.points[a.i];m(a.children,function(a){a=b.setTreeValues(a);e.push(a);a.ignore?x(a.children,function(a){var b=!1;m(a,function(a){z(a,{ignore:!0,isLeaf:!1,visible:!1});a.children.length&&(b=(b||[]).concat(a.children))});return b}):d+=a.val});E(e,function(a,b){return a.sortIndex-
b.sortIndex});f=k(h&&h.options.value,d);h&&(h.value=f);z(a,{children:e,childrenTotal:d,ignore:!(k(h&&h.visible,!0)&&0<f),isLeaf:a.visible&&!d,levelDynamic:c.levelIsConstant?a.level:a.level-b.nodeMap[b.rootNode].level,name:k(h&&h.name,""),sortIndex:k(h&&h.sortIndex,-f),val:f});return a},calculateChildrenAreas:function(a,b){var c=this,d=c.options,e=this.levelMap[a.levelDynamic+1],f=k(c[e&&e.layoutAlgorithm]&&e.layoutAlgorithm,d.layoutAlgorithm),h=d.alternateStartingDirection,g=[],d=y(a.children,function(a){return!a.ignore});
e&&e.layoutStartingDirection&&(b.direction="vertical"===e.layoutStartingDirection?0:1);g=c[f](b,d);m(d,function(a,e){var d=g[e];a.values=w(d,{val:a.childrenTotal,direction:h?1-b.direction:b.direction});a.pointValues=w(d,{x:d.x/c.axisRatio,width:d.width/c.axisRatio});a.children.length&&c.calculateChildrenAreas(a,a.values)})},setPointValues:function(){var a=this.xAxis,b=this.yAxis;m(this.points,function(c){var d=c.node,e=d.pointValues,f,h;e&&d.visible?(d=Math.round(a.translate(e.x,0,0,0,1))-.5,f=Math.round(a.translate(e.x+
e.width,0,0,0,1))-.5,h=Math.round(b.translate(e.y,0,0,0,1))-.5,e=Math.round(b.translate(e.y+e.height,0,0,0,1))-.5,c.shapeType="rect",c.shapeArgs={x:Math.min(d,f),y:Math.min(h,e),width:Math.abs(f-d),height:Math.abs(e-h)},c.plotX=c.shapeArgs.x+c.shapeArgs.width/2,c.plotY=c.shapeArgs.y+c.shapeArgs.height/2):(delete c.plotX,delete c.plotY)})},setColorRecursive:function(a,b,c){var d=this,e,f;a&&(e=d.points[a.i],f=d.levelMap[a.levelDynamic],b=k(e&&e.options.color,f&&f.color,b),c=k(e&&e.options.colorIndex,
f&&f.colorIndex,c),e&&(e.color=b,e.colorIndex=c),a.children.length&&m(a.children,function(a){d.setColorRecursive(a,b,c)}))},algorithmGroup:function(a,b,c,d){this.height=a;this.width=b;this.plot=d;this.startDirection=this.direction=c;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,c,d){var e,f,h,g,v=c.lW,n=c.lH,l=c.plot,k,q=0,r=c.elArr.length-1;b?(v=c.nW,n=c.nH):k=c.elArr[c.elArr.length-1];m(c.elArr,function(a){if(b||q<r)0===c.direction?(e=l.x,f=l.y,h=v,g=a/h):(e=l.x,f=l.y,g=n,h=a/g),d.push({x:e,y:f,width:h,height:g}),0===c.direction?l.y+=g:l.x+=h;q+=1});c.reset();0===c.direction?c.width-=v:c.height-=n;l.y=l.parent.y+(l.parent.height-c.height);l.x=l.parent.x+(l.parent.width-c.width);a&&(c.direction=1-c.direction);b||c.addElement(k)},algorithmLowAspectRatio:function(a,
b,c){var d=[],e=this,f,h={x:b.x,y:b.y,parent:b},g=0,k=c.length-1,n=new this.algorithmGroup(b.height,b.width,b.direction,h);m(c,function(c){f=c.val/b.val*b.height*b.width;n.addElement(f);n.lP.nR>n.lP.lR&&e.algorithmCalcPoints(a,!1,n,d,h);g===k&&e.algorithmCalcPoints(a,!0,n,d,h);g+=1});return d},algorithmFill:function(a,b,c){var d=[],e,f=b.direction,h=b.x,g=b.y,k=b.width,n=b.height,l,p,q,r;m(c,function(c){e=c.val/b.val*b.height*b.width;l=h;p=g;0===f?(r=n,q=e/r,k-=q,h+=q):(q=k,r=e/q,n-=r,g+=r);d.push({x:l,
y:p,width:q,height:r});a&&(f=1-f)});return d},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,b;u.prototype.translate.call(this);this.rootNode=k(this.options.rootId,"");this.levelMap=B(this.options.levels,function(a,b){a[b.level]=b;return a},{});b=this.tree=this.getTree();
this.axisRatio=this.xAxis.len/this.yAxis.len;this.nodeMap[""].pointValues=a={x:0,y:0,width:100,height:100};this.nodeMap[""].values=a=w(a,{width:a.width*this.axisRatio,direction:"vertical"===this.options.layoutStartingDirection?0:1,val:b.val});this.calculateChildrenAreas(b,a);this.colorAxis?this.translateColors():this.options.colorByPoint||this.setColorRecursive(this.tree);this.options.allowDrillToNode&&(b=this.nodeMap[this.rootNode].pointValues,this.xAxis.setExtremes(b.x,b.x+b.width,!1),this.yAxis.setExtremes(b.y,
b.y+b.height,!1),this.xAxis.setScale(),this.yAxis.setScale());this.setPointValues()},drawDataLabels:function(){var a=this,b=y(a.points,function(a){return a.node.visible}),c,d;m(b,function(b){d=a.levelMap[b.node.levelDynamic];c={style:{}};b.node.isLeaf||(c.enabled=!1);d&&d.dataLabels&&(c=w(c,d.dataLabels),a._hasPointLabels=!0);b.shapeArgs&&(c.style.width=b.shapeArgs.width,b.dataLabel&&b.dataLabel.css({width:b.shapeArgs.width+"px"}));b.dlOptions=w(c,b.options.dataLabels)});u.prototype.drawDataLabels.call(this)},
alignDataLabel:function(a){t.column.prototype.alignDataLabel.apply(this,arguments);a.dataLabel&&a.dataLabel.attr({zIndex:a.node.zIndex+1})},drawPoints:function(){var a=this,b=y(a.points,function(a){return a.node.visible});m(b,function(b){var d="levelGroup-"+b.node.levelDynamic;a[d]||(a[d]=a.chart.renderer.g(d).attr({zIndex:1E3-b.node.levelDynamic}).add(a.group));b.group=a[d]});t.column.prototype.drawPoints.call(this);a.options.allowDrillToNode&&m(b,function(b){b.graphic&&(b.drillId=a.options.interactByLeaf?
a.drillToByLeaf(b):a.drillToByGroup(b))})},drillTo:function(){var a=this;g.addEvent(a,"click",function(b){b=b.point;var c=b.drillId,d;c&&(d=a.nodeMap[a.rootNode].name||a.rootNode,b.setState(""),a.drillToNode(c),a.showDrillUpButton(d))})},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=null;this.rootNode&&(a=this.nodeMap[this.rootNode],a=null!==a.parent?this.nodeMap[a.parent]:this.nodeMap[""]);null!==a&&(this.drillToNode(a.id),""===a.id?this.drillUpButton=this.drillUpButton.destroy():(a=this.nodeMap[a.parent],this.showDrillUpButton(a.name||a.id)))},drillToNode:function(a){this.options.rootId=a;this.isDirty=!0;this.chart.redraw()},showDrillUpButton:function(a){var b=this;a=a||"< Back";var c=b.options.drillUpButton,d,e;c.text&&(a=c.text);
this.drillUpButton?this.drillUpButton.attr({text:a}).align():(e=(d=c.theme)&&d.states,this.drillUpButton=this.chart.renderer.button(a,null,null,function(){b.drillUp()},d,e&&e.hover,e&&e.select).attr({align:c.position.align,zIndex:7}).add().align(c.position,!1,c.relativeTo||"plotBox"))},buildKDTree:A,drawLegendSymbol:g.LegendSymbolMixin.drawRectangle,getExtremes:function(){u.prototype.getExtremes.call(this,this.colorValueData);this.valueMin=this.dataMin;this.valueMax=this.dataMax;u.prototype.getExtremes.call(this)},
getExtremesFromAll:!0,bindAxes:function(){var a={endOnTick:!1,gridLineWidth:0,lineWidth:0,min:0,dataMin:0,minPadding:0,max:100,dataMax:100,maxPadding:0,startOnTick:!1,title:null,tickPositions:[]};u.prototype.bindAxes.call(this);g.extend(this.yAxis.options,a);g.extend(this.xAxis.options,a)}},{getClassName:function(){var a=g.Point.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||k(c.interactByLeaf,
!c.allowDrillToNode)?this.node.isLeaf||(a+=" highcharts-internal-node"):a+=" highcharts-internal-node-interactive";return a},setState:function(a){g.Point.prototype.setState.call(this,a);this.graphic.attr({zIndex:"hover"===a?1:0})},setVisible:t.pie.prototype.pointClass.prototype.setVisible})})(p)});
