UNPKG

js-pkg

Version:
10 lines 76.2 kB
/*! * filename: ej.treemap.min.js * version : 15.3.0.33 * Copyright Syncfusion Inc. 2001 - 2017. All rights reserved. * Use of this code is subject to the terms of our license. * A copy of the current license can be obtained at any time by e-mailing * licensing@syncfusion.com. Any infringement will be prosecuted under * applicable laws. */ (function(n){typeof define=="function"&&define.amd?define(["./../common/ej.core.min","./../common/ej.data.min"],n):n()})(function(){(function(n,t,i){var r;t.widget({ejTreeMap:"ej.datavisualization.TreeMap"},{validTags:["div"],defaults:{locale:null,enableGroupSeparator:!1,leafItemSettings:{borderThickness:1,borderBrush:"white",showLabels:!1,labelPath:null,gap:0,itemTemplate:null,textOverflow:"none",labelPosition:"topleft",labelVisibilityMode:"visible"},header:null,isHierarchicalDatasource:!1,dataSource:null,groupColorMapping:[],enableDrillDown:!1,drillDownHeaderColor:null,drillDownSelectionColor:"#000000",colorValuePath:null,weightValuePath:null,treeMapItems:[],showLegend:!1,borderBrush:"white",borderThickness:1,enableResize:!0,enableGradient:!1,isResponsive:!0,itemsLayoutMode:"squarified",levels:[],headerTemplateRendering:null,drillStarted:null,drillDownItemSelected:null,treeMapGroupSelected:null,treeMapItemSelected:null,legendSettings:{template:"",iconHeight:15,iconWidth:15,title:"",height:0,width:0,mode:"default",leftLabel:"",rightLabel:"",dockPosition:"top",alignment:"near",columnCount:0},rangeColorMapping:[],uniColorMapping:{color:null},desaturationColorMapping:{from:0,to:0,color:"",rangeMinimum:0,rangeMaximum:0},paletteColorMapping:{colors:[]},highlightOnSelection:!1,selectionMode:"default",highlightGroupOnSelection:!1,groupSelectionMode:"default",draggingOnSelection:!1,draggingGroupOnSelection:!1,showTooltip:!1,tooltipTemplate:null,highlightBorderThickness:5,highlightGroupBorderThickness:4,highlightBorderBrush:"gray",highlightGroupBorderBrush:"gray"},dataTypes:{dataSource:"data",treeMapItems:"array",levels:"array",rangeColorMapping:"array",paletteColorMapping:"object",groupColorMapping:"array"},observables:["dataSource","colorValuePath","weightValuePath","showLegend","enableResize","highlightOnSelection","selectionMode","groupSelectionMode","highlightGroupOnSelection","enableDrillDown","drillDownHeaderColor","drillDownSelectionColor","showTooltip","highlightBorderThickness","highlightBorderBrush","itemsLayoutMode","leafItemSettings.borderThickness","leafItemSettings.borderBrush","leafItemSettings.showLabels","leafItemSettings.labelPath","leafItemSettings.textOverflow","legendSettings.iconWidth","legendSettings.iconHeight","legendSettings.dockPosition","legendSettings.height","legendSettings.width","uniColorMapping.color","desaturationColorMapping.from","desaturationColorMapping.to","desaturationColorMapping.color","desaturationColorMapping.rangeMinimum","desaturationColorMapping.rangeMaximum"],_tags:[{tag:"levels",attr:["groupPath","groupGap","headerHeight","showHeader","groupPadding","showLabels","headerHeight","headerTemplate","headerVisibilityMode","labelPosition","labelTemplate","labelVisibilityMode","groupBackground","groupBorderColor","groupBorderThickness"],singular:"level"},{tag:"rangeColorMapping",attr:["color","legendLabel","from","to"],singular:"rangeColor"},{tag:"groupColorMapping",attr:["groupID",{tag:"groupColorMapping.rangeColorMapping",attr:["color","legendLabel","from","to"],singular:"groupRangeColor"},"uniColorMapping.color","desaturationColorMapping.from","desaturationColorMapping.to","desaturationColorMapping.color","desaturationColorMapping.rangeMinimum","desaturationColorMapping.rangeMaximum"],singular:"groupColor"}],dataSource:t.util.valueFunction("dataSource"),colorValuePath:t.util.valueFunction("colorValuePath"),weightValuePath:t.util.valueFunction("weightValuePath"),showLegend:t.util.valueFunction("showLegend"),enableResize:t.util.valueFunction("enableResize"),highlightOnSelection:t.util.valueFunction("highlightOnSelection"),selectionMode:t.util.valueFunction("selectionMode"),highlightGroupOnSelection:t.util.valueFunction("highlightGroupOnSelection"),groupSelectionMode:t.util.valueFunction("groupSelectionMode"),enableDrillDown:t.util.valueFunction("enableDrillDown"),drillDownHeaderColor:t.util.valueFunction("drillDownHeaderColor"),drillDownSelectionColor:t.util.valueFunction("drillDownSelectionColor"),showTooltip:t.util.valueFunction("showTooltip"),highlightBorderThickness:t.util.valueFunction("highlightBorderThickness"),itemsLayoutMode:t.util.valueFunction("itemsLayoutMode"),highlightBorderBrush:t.util.valueFunction("highlightBorderBrush"),borderThickness:t.util.valueFunction("leafItemSettings.borderThickness"),borderBrush:t.util.valueFunction("leafItemSettings.borderBrush"),showLabels:t.util.valueFunction("leafItemSettings.showLabels"),labelPath:t.util.valueFunction("leafItemSettings.labelPath"),textOverflow:t.util.valueFunction("leafItemSettings.textOverflow"),iconWidth:t.util.valueFunction("legendSettings.iconWidth"),iconHeight:t.util.valueFunction("legendSettings.iconHeight"),dockPosition:t.util.valueFunction("legendSettings.dockPosition"),legendheight:t.util.valueFunction("legendSettings.height"),legendwidth:t.util.valueFunction("legendSettings.width"),itemTemplate:t.util.valueFunction("leafItemSettings.itemTemplate"),uniColor:t.util.valueFunction("uniColorMapping.color"),_color:t.util.valueFunction("desaturationColorMapping.color"),_from:t.util.valueFunction("desaturationColorMapping.from"),_to:t.util.valueFunction("desaturationColorMapping.to"),_rangeMinimum:t.util.valueFunction("desaturationColorMapping.rangeMinimum"),_rangeMaximum:t.util.valueFunction("desaturationColorMapping.rangeMaximum"),_initPrivateProperties:function(){this._svgDocument=null;this._templateDiv=null;this._legenddiv=null;this._drillHeaderDiv=null;this._drillHoverDiv=null;this._legendHeight=0;this._backgroundTile=null;this._tooltipSize={height:0,width:0};this._height=500;this._margintop=null;this._marginleft=null;this._startPoint={x:0,y:0};this._stopPoint={x:0,y:0};this.mouseClickable=!1;this.dragDiv=null;this._initDiv=null;this._width=500;this._svgns="http://www.w3.org/2000/svg";this._prevSelectedItems=[];this._prevSelectedHeaders=[];this._isLevelColors;this.selectedItems==null&&(this.selectedItems=[]);this._browser=null;this._toolTipElement=null;this._rootTreeMapItems=[];this.treemapgroups=[];this._drillHeader=null;this._drilldownItem=null;this._drilldownItems=[];this._treeMapHeaders=[];this._drilldownHeaders=[];this._treeMapLabels=[];this._labelTemplateElements=[];this._itemGroups=[];this._prevSelectedGroupDatas=[];this._interactiveArrow=null;this._legendRects=[]},_setModel:function(n){for(var t in n)switch(t){case"itemsLayoutMode":this.itemsLayoutMode(n[t]);this.refresh()}},_levels:function(){this.refresh()},_rangeColorMapping:function(){this._setColorMappings(this._rootTreeMapItems,this.model)},_groupColorMapping:function(){this._setColorMappings(this._rootTreeMapItems,this.model)},_groupColorMapping_rangeColorMapping:function(){this._setColorMappings(this._rootTreeMapItems,this.model)},_init:function(){this._initPrivateProperties();var t=n("<style>.e-drillGroupRect:hover{ background-color:"+this.drillDownSelectionColor()+";}<\/style>");n("html > head").append(t);this._levelInitialize();this._isSVG()||(document.createStyleSheet().addRule(".vml","behavior:url(#default#VML);display:inline-block"),document.namespaces.add("v","urn:schemas-microsoft-com:vml","#default#VML"));this.refresh()},_destroy:function(){this._unWireEvents();n(this.element).removeClass("e-treemap e-js").find().remove(".e-tooltipelement");n(this.element).empty()},_levelInitialize:function(){var t=this;this.model.levels!=null?n.each(this.model.levels,function(i,u){u=t._checkArrayObject(u,i);var f=new r;n.extend(f,u);n.extend(u,f)}):this.levels.treeMapLevel=new r},_checkArrayObject:function(t,i){var f=["borderBrush","dataSource","groupColorMapping","enableDrillDown","drillDownHeaderColor","drillDownSelectionColor","colorValuePath","weightValuePath","treeMapItems","showLegend","borderBrush","borderThickness","enableResize","enableGradient","isResponsive","itemsLayoutMode","levels","groupBackground","groupBorderColor","groupBorderThickness","groupPadding","groupPath","groupGap","headerHeight","showHeader","showLabels","headerTemplate","labelTemplate","labelPosition","textOverflow","headerVisibilityMode","labelVisibilityMode","color","leafItemSettings","showLabels","labelPath","gap","itemTemplate","legendSettings","template","iconHeight","iconWidth","height","width","mode","leftLabel","rightLabel","dockPosition","alignment","highlightOnSelection","selectionMode","highlightGroupOnSelection","groupSelectionMode","draggingOnSelection","draggingGroupOnSelection","showTooltip","tooltipTemplate","highlightBorderThickness","highlightGroupBorderThickness","highlightBorderBrush","highlightGroupBorderBrush"],u=this;return n.each(t,function(n,t){if(f.indexOf(n)>-1)if(t instanceof Array)u._checkArrayObject(t,n);else if(t!=null&&typeof t=="object"){var e=new r;u._loadIndividualDefaultValues(t,e,typeof n=="number"?i:n)}}),t},_loadIndividualDefaultValues:function(t,i,r){var u=null,f=this;return n.each(i,function(n,t){if(r==n){u=t;return}}),u instanceof Array&&(u=u[0]),n.each(t,function(n,t){t instanceof Array?f._checkArrayObject(t,r):t!=null&&typeof t=="object"&&f._loadIndividualDefaultValues(t,t,typeof n=="number"?r:n)}),n.extend(u,t),n.extend(t,u),t},refresh:function(r){var u;if(document.getElementById(this._id)!=null||document.getElementById(this._id)!=i){this._unWireEvents();r||(this._drilldownItems=[]);this.model.enableResize||this.model.isResponsive?this._drilldownItems.length==0&&this._initPrivateProperties():this._initPrivateProperties();n(this.element).empty();this._svgDocument!=null&&n(this._svgDocument).empty();this._height=this.element.height();this._width=this.element.width();this._height==0&&(this._height=this.element[0].parentElement.clientHeight!=0?this.element[0].parentElement.clientHeight:n(document).height());this._width==0&&(this._width=this.element[0].parentElement.clientWidth!=0?this.element[0].parentElement.clientWidth:n(document).width());this.showLegend()&&this._sizeCalculation();var f=jQuery.uaMatch(navigator.userAgent),e=f.browser.toLowerCase(),o=!!navigator.userAgent.match(/Trident\/7\./);if(this._browser=e,n(this.element).css({position:"relative"}),this._height!=0&&this._width!=0){if(this._templateDiv=n("<div class='e-_templateDiv'><\/div>"),this._templateDiv.css({"pointer-events":"none",overflow:"hidden",float:"left","z-index":"2",height:this._height,width:this._width,"margin-top":this._margintop,"margin-left":this._marginleft,position:"absolute",left:"0",top:"0"}),this.enableDrillDown()&&this._drilldownItems.length==0&&(this._drillHeaderDiv=n("<div class='e-_drillHeaderDiv'><\/div>"),this._drillHeaderDiv.css({overflow:"hidden",float:"left","z-index":"3",position:"absolute",left:"0",top:"0"}),this._drillHoverDiv=n("<div class='e-_drillHoverDiv'><\/div>"),this._drillHoverDiv.css({overflow:"hidden",float:"left","z-index":"3",height:this._height-30,width:this._width,position:"absolute",left:"0",top:"30px"})),this._backgroundTile=n('<div id="backgroundTile" style="overflow:hidden;z-index:0;"><\/div>'),this.showLegend()&&this.model.legendSettings!=null&&this._renderLegend(),this.dataSource()!=null)if(this._drilldownItems.length>0){if(this.enableDrillDown()&&this.model.levels.length>=1&&(this._drilldownItem!=null||this._drilldownItem==null)){for(u=0;u<this._drillHeaderDiv[0].children[0].children.length;u++)this._drillHeaderDiv[0].children[0].children[u].className=="e-drilldownlabel"&&(header=this._drillHeaderDiv[0].children[0].children[u].innerHTML);this._backgroundTile[0].innerHTML="";this._drillHeaderDiv[0].innerHTML="";this._templateDiv[0].innerHTML="";this._drillHoverDiv[0].innerHTML="";this._drillDownHeader(!0,this.model.levels[0],this.model.dataSource);this._groupdrillDownLevels(this._drilldownItems[this._drilldownItems.length-1],this._drilldownItems.length)}this.showLegend()&&this._generateLegend();this._generateToolTip()}else this.model.dataSource instanceof t.DataManager?this._processOData(this):this._renderTreeMap(this.dataSource());(this.enableResize()||this.model.isResponsive)&&this._on(n(window),"resize",this._treeMapResize)}this._selectItemResize();this._trigger("refreshed","")}},_renderTreeMap:function(n){this.model.browserInfo=this.browserInfo();this.showLegend()&&this._generateLegend();this._groupLevels(n);this.renderHeader=!1;this._generateToolTip();this._renderLabels()},_renderLegend:function(){this._legenddiv=n("<div class='e-LegendDiv'/>");this._legenddiv.appendTo(this.element);this._legenddiv.css({"pointer-events":"none",overflow:"hidden",position:"absolute","z-index":"2",height:this._legendSize.height,width:this._legendSize.width})},_processOData:function(n){var t=this,i=n.model.dataSource.executeQuery(n.model.query);i.done(function(n){n.result!=null&&t._renderTreeMap(n.result)})},_treeMapResize:function(n){n.preventDefault();n.stopPropagation();var t=this;this.resizeTO&&clearTimeout(this.resizeTO);this.resizeTO=setTimeout(function(){t.refresh(!0)},500)},_unWireEvents:function(){var n=jQuery.uaMatch(navigator.userAgent),t=n.browser.toLowerCase()},_groupLevels:function(t){var u=null,h=this.model.isHierarchicalDatasource,f,r,i,s,e,o;if(this.enableDrillDown()&&(this._originalHeaders=[],this.renderHeader=!0,this.model.levels.length>0?(this.model.levels[0].groupingLevel=0,this._drilldownHeaders.push(this.model.header||this.model.levels[0].groupPath),this._originalHeaders.push(this.model.levels[0].groupPath),this._drillDownHeader(!1,this.model.levels[0],t)):(this._drilldownHeaders.push(""),this._drillDownHeader(!1))),f=this._getTopGroupitem(this.labelPath(),t,0),u=f,this.model.levels.length==0&&(i=this.model.leafItemSettings,this._rootTreeMapItems=f,this._getTopLevels(f[0].innerItems,i),this._generateTreeMapItems(f[0].innerItems,"gray",this.colorValuePath()),this.showLabels()&&this._generateLabels(f[0].innerItems,i)),this.model.levels.length>0)for(r=0;r<=this.model.levels.length;r++)if(i=this.model.levels[r],i!=null&&(n.isNumeric(i.groupGap)||(i.groupGap=0),n.isNumeric(i.groupPadding)||(i.groupPadding=0),n.isNumeric(i.groupBorderThickness)||(i.groupBorderThickness=0)),r!=0){if(s=u,e=this.model.levels[r-1],u=[],i==null&&(i=this.model.leafItemSettings),this._generateSubItems(s,i,u,e,null,null,r-1),this._rootTreeMapItems=u,this.enableDrillDown()){if(r==1)return this._generateTreeMapItems(u,"gray",e.DisplayPath),!1}else r==this.model.levels.length&&this._generateTreeMapItems(u,"gray",e.DisplayPath);this.showLabels()&&r==this.model.levels.length&&this._generateLabels(u,i)}else o=this._getGroupitem(h?this.labelPath():i.groupPath,f[0].Data,i.headerHeight),this._rootTreeMapItems=o,this._getTopLevels(o,i),u=o},_groupdrillDownLevels:function(t,i){var f=null,c=this.model.isHierarchicalDatasource,s,u,r,h,e,o;if(i==this.model.levels.length-1?this._drillHoverDiv.css("pointer-events","none"):this._drillHoverDiv.css("pointer-events","auto"),this.model.levels.length>0)for(s=!1,u=c?i-1:0;u<this.model.levels.length;u++)r=this.model.levels[u],r!=null&&(n.isNumeric(r.groupGap)||(r.groupGap=0),n.isNumeric(r.groupPadding)||(r.groupPadding=0),n.isNumeric(r.groupBorderThickness)||(r.groupBorderThickness=0)),u!=(c?i-1:0)?(h=f,e=this.model.levels[u-1],f=[],r==null&&(r=this.model.leafItemSettings),u==i+1?this._generateSubItems(h,r,f,e,null,i+1!=u,t.GroupingLevel):this._generateSubItems(h,r,f,e,!0,i+1!=u,t.GroupingLevel),this._rootTreeMapItems=f,u!=i+1&&u!=this.model.levels.length-1||s||(this._generateTreeMapItems(f,"gray",e.DisplayPath),s=!0),i==this.model.levels.length-1&&u==i&&r.showLabels&&this._generateLabels(f,r),this.renderHeader=u==t.GroupingLevel?!0:!1):(o=this._getGroupitem(this.model.isHierarchicalDatasource?null:r.groupPath,t.Data,r.headerHeight),this._rootTreeMapItems=o,this._getTopLevels(o,r),f=o);this.showLegend()&&this._generateLegend();this._renderLabels();this.renderHeader=!1;this._trigger("drillDownItemSelected",{level:i,header:this.getDrillDownHeader(this._drilldownHeaders),prevLevel:i-1})},_getTopLevels:function(n,i){var f=i.groupGap!=null?i.groupGap:i.gap!=null?i.gap:0,e=this.itemsLayoutMode(),r=0,u=0;this.enableDrillDown()&&(u=30);this.showLegend()&&this.model.legendSettings!=null&&(r=r);this._legendHeight=r;this.enableDrillDown()&&(this._drillHeaderDiv.css({top:r}),this._drillHoverDiv.css({top:30+r}));e==t.datavisualization.TreeMap.ItemsLayoutMode.SliceAndDiceHorizontal?this._calculateSliceAndDiceItemSize(n,0,r,this._width,this._height,f,u,!0,r):e==t.datavisualization.TreeMap.ItemsLayoutMode.SliceAndDiceVertical?this._calculateSliceAndDiceItemSize(n,0,r,this._width,this._height,f,u,!1,r):e==t.datavisualization.TreeMap.ItemsLayoutMode.SliceAndDiceAuto?this._calculateSliceAndDiceItemSize(n,0,r,this._width,this._height,f,u,null,r):this._calculateSquarifiedItemSize(n,0,r,this._width,this._height,f,u,r)},_generateSubItems:function(n,r,u,f,e,o,s){var c=f.groupPadding,h,a,l,y,w,p;c==""&&(c=0);var g=this.itemsLayoutMode(),nt=n.length,b=this.model.isHierarchicalDatasource?null:r.groupPath;b==null&&(b=this.labelPath());b==null&&(b=this.weightValuePath());var k=r.groupGap!=null?r.groupGap:r.gap!=null?r.gap:0,d=(f.showHeader||f.showHeader==null)&&!this.enableDrillDown()?f.headerHeight:this.renderHeader&&f.showHeader?f.headerHeight:0,v=0;for(h=0;h<nt;h++){if(a=this._getGroupitem(b,n[h].Data,r.headerHeight,this.model.isHierarchicalDatasource?f.groupPath:null),g==t.datavisualization.TreeMap.ItemsLayoutMode.SliceAndDiceHorizontal?this._calculateSliceAndDiceItemSize(a,n[h].LeftPosition+parseFloat(c),n[h].TopPosition+parseFloat(c),n[h].ItemWidth-(f.groupBorderThickness+2*parseFloat(c)),n[h].ItemHeight-(f.groupBorderThickness+2*parseFloat(c)),parseFloat(k),d,!0,0):g==t.datavisualization.TreeMap.ItemsLayoutMode.SliceAndDiceVertical?this._calculateSliceAndDiceItemSize(a,n[h].LeftPosition+parseFloat(c),n[h].TopPosition+parseFloat(c),n[h].ItemWidth-(f.groupBorderThickness+2*parseFloat(c)),n[h].ItemHeight-(f.groupBorderThickness+2*parseFloat(c)),parseFloat(k),d,!1,0):g==t.datavisualization.TreeMap.ItemsLayoutMode.SliceAndDiceAuto?this._calculateSliceAndDiceItemSize(a,n[h].LeftPosition+parseFloat(c),n[h].TopPosition+parseFloat(c),n[h].ItemWidth-(f.groupBorderThickness+2*parseFloat(c)),n[h].ItemHeight-(f.groupBorderThickness+2*parseFloat(c)),parseFloat(k),d,null,0):this._calculateSquarifiedItemSize(a,n[h].LeftPosition+parseFloat(c),n[h].TopPosition+parseFloat(c),n[h].ItemWidth-(f.groupBorderThickness+2*parseFloat(c)),n[h].ItemHeight-(f.groupBorderThickness+2*parseFloat(c)),parseFloat(k),d,0),l=this._rootTreeMapItems[h],l.headerHeight=f.headerHeight,l.showHeader=f.showHeader,l.headerWidth=n[h].ItemWidth,l.headerTemplate=f.headerTemplate,l.headerLeftPosition=n[h].LeftPosition,l.headerTopPosition=n[h].TopPosition,this.enableDrillDown()&&this._createBackGround(l,f,n[h],o),(f.showHeader||f.showHeader==null)&&(this.enableDrillDown()?(this.renderHeader||(this.previousItem=l),(s==0||s==i||s==null)&&(this.previousItem=null),this.renderHeader&&(this._trigger("headerTemplateRendering",{levelItems:this._rootTreeMapItems,childItems:l.Data,headerItem:l,groupPath:f.groupPath,groupingLevel:t.util.isNullOrUndefined(s)?0:s,prevItem:this.previousItem}),this._generateHeaders(l,f))):(this._createBackGround(l,f,n[h]),this._trigger("headerTemplateRendering",{levelItems:this._rootTreeMapItems,childItems:l.Data,headerItem:l,groupPath:f.groupPath,groupingLevel:s,prevItem:f}),this._generateHeaders(l,f))),n[h].ChildtreeMapItems=a,n[h].GroupingLevel=this.model.levels.indexOf(f)+1,this.model.levels.indexOf(f)==0){if(this.model.groupColorMapping!=null&&this.model.groupColorMapping.length>0)for(this._isLevelColors=!0,y=0;y<this.model.groupColorMapping.length;y++)w=this.model.groupColorMapping[y],w.groupID==l.header&&this._setColorMappings(a,w,!0)}else if(this.model.levels.indexOf(f)>0&&this.model.groupColorMapping!=null&&this.model.groupColorMapping.length>0)for(y=0;y<this.model.groupColorMapping.length;y++)w=this.model.groupColorMapping[y],w.groupID==n[h].ParentHeader&&this._setColorMappings(a,w,!0);for(p=0;p<a.length;p++)u[v]=a[p],a[p].backgroundColor==null&&(a[p].backgroundColor=n[h].backgroundColor),a[p].backgroundOpacity==null&&(a[p].backgroundOpacity=n[h].backgroundOpacity),(this.enableDrillDown()||u[v].ItemHeight<l.ItemHeight-l.headerHeight)&&(u[v].ParentHeader=l.header,u[v].ItemHeight-=c,u[v].ItemWidth-=c,u[v].LeftPosition+=f.groupBorderThickness,u[v].TopPosition+=f.groupBorderThickness),v++}e==i&&f.showLabels&&this._generateLabels(n,f)},_createBackGround:function(t,i,r,u){var f=n("<div />"),o=t.showHeader||t.showHeader==null||this.enableDrillDown()?t.ItemHeight-2*i.groupBorderThickness:0,h=t.showHeader||t.showHeader==null||this.enableDrillDown()?t.TopPosition:0,e,s;f.css({height:o+"px",width:t.ItemWidth-2*i.groupBorderThickness+"px",left:t.LeftPosition+"px",top:h+"px","border-style":"solid","border-width":i.groupBorderThickness+"px",position:"absolute"});i.groupBorderColor!=null&&f.css("border-color",i.groupBorderColor);i.groupBackground!=null&&f.css("background-color",i.groupBackground);this.treemapgroups.push({header:t.header,element:f});f.appendTo(this._backgroundTile);o=parseFloat(f[0].style.top)-30-this._legendHeight+"px";this.enableDrillDown()&&!u&&(e=n("<div class='e-drillGroupRect'/>"),e.css({height:f[0].style.height,width:f[0].style.width,left:f[0].style.left,top:o,position:"absolute",opacity:.2,display:"block"}),this._drillHoverDiv.append(e),n(e).mousedown({treemap:this,level:i,param1:r},this._headerClickFunction),n(e).mouseleave({treemap:this,param1:t.header},this._mouseLeaveFunction),s={data:t.Data,label:t.header,header:t.header},n(e).mousemove({treemap:this,hoverItem:s},this._mouseRectHoverFunction));n(f).mousedown({treemap:this,level:i,param1:r},this._headerClickFunction);n(f).mousemove({treemap:this,hoverItem:t.Data},this._mouseRectHoverFunction)},_mouseRectHoverFunction:function(t){var r=t.data.treemap,l=t.data.hoverItem,i,f,s,h,c,u,e,o;r.showTooltip()&&(i=r._toolTipElement,f=r.model.tooltipTemplate,i!=null&&f!=null&&(n(i).css({left:t.pageX+10,top:t.pageY+10,display:"block"}),s=n("#"+f).render(l),n(i).html(s),h=i[0]!=null?i[0].clientHeight:i.clientHeight,c=i[0]!=null?i[0].clientWidth:i.clientWidth,r._tooltipSize={height:h,width:c}),u=r._tooltipSize,u.width+t.pageX>=r._width&&(e=t.pageX-u.width,e<0&&(e=10)),u.height+t.pageY>=r._height&&(o=t.pageY-u.height,o<0&&(o=10)),i!=null&&(r.enableDrillDown()?n(i).css({left:t.pageX+10,top:t.pageY+10,display:"block"}):n(i).css({left:t.pageX+10,top:t.pageY+10,display:"none"})))},_mouseLeaveFunction:function(t){var i=t.data.treemap;i.showTooltip()&&i._toolTipElement!=null&&n(i._toolTipElement).css("display","none")},_headerClickFunction:function(t){var f=t.data.level,r=t.data.param1,l=t.ctrlKey,i=t.data.treemap,h,o,e,c,u,s;if(i.highlightGroupOnSelection())if(i._browser!="msie"&&(h=i._backgroundTile[0].children[i._backgroundTile[0].children.length-0],i._backgroundTile[0].insertBefore(this,h)),i.groupSelectionMode()=="multiple"&&l)n.inArray(this,i._prevSelectedHeaders)==-1?(n(this).css({"border-width":i.model.highlightGroupBorderThickness,"border-color":i.highlightBorderBrush()}),i._prevSelectedHeaders.push(this),i._prevSelectedGroupDatas.push(t.data.Param1)):(n(this).css({"border-width":f.groupBorderThickness,"border-color":f.groupBorderColor}),o=i._prevSelectedHeaders.indexOf(this),i._prevSelectedHeaders.splice(o,1),i._prevSelectedGroupDatas.splice(o,1));else{for(e=0;e<i._prevSelectedHeaders.length;e++)n(i._prevSelectedHeaders[e]).css({"border-width":f.groupBorderThickness,"border-color":f.groupBorderColor});n.inArray(this,i._prevSelectedHeaders)==-1?(n(this).css({"border-width":i.model.highlightGroupBorderThickness,"border-color":i.highlightBorderBrush()}),i._prevSelectedHeaders=[],i._prevSelectedHeaders.push(this)):i._prevSelectedHeaders=[];i._prevSelectedGroupDatas.push(t.data.Param1)}if(i.enableDrillDown()&&i._trigger("drillStarted",t),i.enableDrillDown()&&i.model.levels.length>1&&(i._drilldownItem!=null&&i._drilldownItem.header!=r.header||i._drilldownItem==null)){for(c="",u=0;u<i._drillHeaderDiv[0].children[0].children.length;u++)i._drillHeaderDiv[0].children[0].children[u].className=="e-drilldownlabel"&&(c=i._drillHeaderDiv[0].children[0].children[u].innerHTML);return i._backgroundTile[0].innerHTML="",i._labelTemplateElements=[],i._drillHeaderDiv[0].innerHTML="",i._templateDiv[0].innerHTML="",i._drillHoverDiv[0].innerHTML="",i._originalHeaders.push(r.header),i._drilldownHeaders.push(r.header),s=i.model.levels[i._drilldownHeaders.length-1],s.groupingLevel=r.GroupingLevel,i._drillDownHeader(!0,s,r.Data),i._drilldownItem=r,i._drilldownItems.push(r),i._groupdrillDownLevels(r,i._drilldownItems.length),!1}},_rectMouseDown:function(n){n.data.treeMap.isTouch(n)&&n.preventDefault()},_docClickFunction:function(t){var u=t.data.treemap,r=this._toolTipElement,i=this;clearTimeout(i.model.timer);r&&(i.model.trackerElement=r,i.model.timer=setTimeout(function(){i.model.trackerElement&&n(i.model.trackerElement).fadeOut(500,function(){i.model.trackerElement=null})},1200))},mousePosition:function(n){return!t.util.isNullOrUndefined(n.pageX)&&n.pageX>0?n:n.originalEvent&&!t.util.isNullOrUndefined(n.originalEvent.pageX)&&n.originalEvent.pageX>0?n.originalEvent:n.originalEvent&&n.originalEvent.changedTouches!=i&&!t.util.isNullOrUndefined(n.originalEvent.changedTouches[0].pageX)&&n.originalEvent.changedTouches[0].pageX>0?n.originalEvent.changedTouches[0]:n},_highlightTreemap:function(t){var i=t.data.treemap,v=t.data.Param1,h=i.model.levels[0],c,a=t.ctrlKey,l,e=i.mousePosition(t),f,r,u,s,o;if(i.highlightGroupOnSelection()){for(f=0;f<i.treemapgroups.length;f++)if(l=i.treemapgroups[f],r=i.treemapgroups[f].element,u=r[0].getBoundingClientRect(),u.left<e.clientX&&u.left+u.width>e.clientX&&u.top<e.clientY&&u.top+u.height>e.clientY){n(r).css({"border-width":i.model.highlightGroupBorderThickness,"border-color":i.highlightBorderBrush(),"box-sizing":"border-box","-moz-box-sizing":"border-box","-webkit-box-sizing":"border-box"});c=!0;break}if(c)if(i.groupSelectionMode()=="multiple"&&a)n.inArray(r,i._prevSelectedHeaders)==-1?(n(r).css({"border-width":i.model.highlightGroupBorderThickness,"border-color":i.highlightBorderBrush()}),i._prevSelectedHeaders.push(l),i._prevSelectedGroupDatas.push(t.data.Param1)):(n(r).css({"border-width":h.groupBorderThickness,"border-color":h.groupBorderColor}),s=i._prevSelectedHeaders.indexOf(l),i._prevSelectedHeaders.splice(s,1),i._prevSelectedGroupDatas.splice(s,1));else{for(o=0;o<i._prevSelectedHeaders.length;o++)n(i._prevSelectedHeaders[o].element).css({"border-width":h.groupBorderThickness,"border-color":h.groupBorderColor});n.inArray(r,i._prevSelectedHeaders)==-1?(n(r).css({"border-width":i.model.highlightGroupBorderThickness,"border-color":i.highlightBorderBrush()}),i._prevSelectedHeaders=[],i._prevSelectedHeaders.push(l)):i._prevSelectedHeaders=[];i._prevSelectedGroupDatas.push(t.data.Param1)}i._trigger("treeMapGroupSelected",{selectedGroups:i._prevSelectedHeaders,orginalEvent:t})}if(i.highlightOnSelection()){for(f=0;f<i._rootTreeMapItems.length;f++)if(r=i._rootTreeMapItems[f],u=r.Rectangle.getBoundingClientRect(),u.left<e.clientX&&u.left+u.width>e.clientX&&u.top<e.clientY&&u.top+u.height>e.clientY){n(r.Rectangle).css({"border-width":i.highlightBorderThickness(),"border-color":i.highlightBorderBrush(),"box-sizing":"border-box","-moz-box-sizing":"border-box","-webkit-box-sizing":"border-box"});c=!0;break}if(c){if(i.selectionMode()=="multiple"&&a)n.inArray(r.Rectangle,i._prevSelectedItems)==-1?(n(r.Rectangle).css({"border-width":i.highlightBorderThickness(),"border-color":i.highlightBorderBrush(),"box-sizing":"border-box","-moz-box-sizing":"border-box","-webkit-box-sizing":"border-box"}),i._prevSelectedItems.push(r.Rectangle),i.selectedItems.push(r.Data)):(n(r.Rectangle).css({"border-width":i.borderThickness(),"border-color":i.borderBrush()}),s=i._prevSelectedItems.indexOf(r.Rectangle),i._prevSelectedItems.splice(s,1),i.selectedItems.splice(s,1));else{for(o=0;o<i._prevSelectedItems.length;o++)n(i._prevSelectedItems[o]).css({"border-width":i.borderThickness(),"border-color":i.borderBrush()});n.inArray(r.Rectangle,i._prevSelectedItems)==-1?(n(r.Rectangle).css({"border-width":i.highlightBorderThickness(),"border-color":i.highlightBorderBrush()}),i._prevSelectedItems=[],i.selectedItems=[],i._prevSelectedItems.push(r.Rectangle),i.selectedItems.push(r.Data)):(i._prevSelectedItems=[],i.selectedItems=[])}i._trigger("treeMapItemSelected",{selectedItems:i.selectedItems,originalEvent:t})}}},doubleTap:function(n){var i=n.targetTouches?n.targetTouches[0]:n,r=i.pageX,u=i.pageY,o=this.model,f=200,t=n.data.treemap,e;t.model.cachedX=t.model.cachedX||r;t.model.cachedY=t.model.cachedY||u;e=(new Date).getTime();Math.abs(r-t.model.cachedX)<f&&Math.abs(u-t.model.cachedY)<f&&t.model.tapNum++},rectClick:function(n){var t=n.data.treemap;t.doubleTap(n);t.isTouch(n)||t._highlightTreemap(n)},dragDown:function(t){var i=t.data.treemap,e=i.model.levels[0],r=i._svgDocument,u,f,o;if(t.type=="mousedown"?(i._startPoint={x:t.pageX-r[0].offsetLeft,y:t.pageY-r[0].offsetTop},i._stopPoint={x:t.pageX-r[0].offsetLeft,y:t.pageY-r[0].offsetTop}):t.type=="touchstart"?(i._startPoint={x:t.originalEvent.changedTouches[0].pageX-r[0].offsetLeft,y:t.originalEvent.changedTouches[0].pageY-r[0].offsetTop},i._stopPoint={x:t.originalEvent.changedTouches[0].pageX-r[0].offsetLeft,y:t.originalEvent.changedTouches[0].pageY-r[0].offsetTop}):t.type=="MSPointerDown"&&(i._startPoint={x:t.originalEvent.pageX-r[0].offsetLeft,y:t.originalEvent.pageY-r[0].offsetTop},i._stopPoint={x:t.originalEvent.pageX-r[0].offsetLeft,y:t.originalEvent.pageY-r[0].offsetTop}),i.mouseClickable=!0,i.model.draggingGroupOnSelection&&i._prevSelectedGroupDatas.length>0){for(u=0;u<i._prevSelectedGroupDatas.length;u++)f=i._prevSelectedGroupDatas[u][0],o=f.getBoundingClientRect(),n.inArray(f,i._prevSelectedGroupDatas[u][0])==-1&&n(i._prevSelectedGroupDatas[u]).css({"border-width":e.groupBorderThickness,"border-color":i.model.highlightGroupBorderBrush});i._prevSelectedGroupDatas=[]}if(i.model.draggingOnSelection&&i._prevSelectedItems.length>0){for(u=0;u<i._prevSelectedItems.length;u++)f=i._prevSelectedItems[u].rectangle,o=f.getBoundingClientRect(),n.inArray(f,i._prevSelectedItems[u].rectangle)==-1&&n(i._prevSelectedItems[u].rectangle).css({"border-width":e.groupBorderThickness,"border-color":i.model.highlightGroupBorderBrush});i._prevSelectedItems=[]}},dragMove:function(t){var f,e,i=t.data.treemap,r=i._svgDocument,u;(i.model.draggingGroupOnSelection||i.model.draggingOnSelection)&&i.mouseClickable&&(t.type=="mousemove"?i._stopPoint={x:t.pageX-r[0].offsetLeft,y:t.pageY-r[0].offsetTop}:t.type=="touchmove"?i._stopPoint={x:t.originalEvent.changedTouches[0].pageX-r[0].offsetLeft,y:t.originalEvent.changedTouches[0].pageY-r[0].offsetTop}:t.type=="MSPointerMove"&&(i._stopPoint={x:t.originalEvent.pageX-r[0].offsetLeft,y:t.originalEvent.pageY-r[0].offsetTop}),n("#dragDiv").remove(),u=n('<div id = "dragDiv"><\/div>'),f=Math.abs(i._stopPoint.x-i._startPoint.x),e=Math.abs(i._stopPoint.y-i._startPoint.y),n(u).css({top:Math.min(i._startPoint.y,i._stopPoint.y),left:Math.min(i._startPoint.x,i._stopPoint.x),width:f,height:e,border:"1px solid green",position:"absolute","z-index":100}),n(u).appendTo("#svgDocument"))},dragUp:function(t){var i=t.data.treemap,o=Math.abs(i._stopPoint.x-i._startPoint.x),s=Math.abs(i._stopPoint.y-i._startPoint.y),e=i._svgDocument,r,f,u;if((i.model.draggingGroupOnSelection||i.model.draggingOnSelection)&&(n("#dragDiv").remove(),n("#dragDiv").css({display:"none"}),i.mouseClickable=!1),i.model.draggingGroupOnSelection){for(r=0;r<i.treemapgroups.length;r++)f=i.treemapgroups[r].element,u=f[0].getBoundingClientRect(),u.left-e[0].offsetLeft+u.width<Math.min(i._startPoint.x,i._stopPoint.x)||Math.min(i._startPoint.x,i._stopPoint.x)+o<u.left-e[0].offsetLeft||u.top-e[0].offsetTop+u.height<Math.min(i._startPoint.y,i._stopPoint.y)||Math.min(i._startPoint.y,i._stopPoint.y)+s<u.top-e[0].offsetTop||i._contains(i._prevSelectedGroupDatas,f)||i._prevSelectedGroupDatas.push(f);for(r=0;r<i._prevSelectedGroupDatas.length;r++)f=i._prevSelectedGroupDatas[r][0],u=f.getBoundingClientRect(),n(f).css({"border-width":i.model.highlightGroupBorderThickness,"border-color":i.model.highlightGroupBorderBrush,"box-sizing":"border-box","-moz-box-sizing":"border-box","-webkit-box-sizing":"border-box"});i.selectedItems.push(i._prevSelectedGroupDatas)}if(i.model.draggingOnSelection){for(r=0;r<i._rootTreeMapItems.length;r++)f=i._rootTreeMapItems[r],u=f.rectangle.getBoundingClientRect(),u.left-e[0].offsetLeft+u.width<Math.min(i._startPoint.x,i._stopPoint.x)||Math.min(i._startPoint.x,i._stopPoint.x)+o<u.left-e[0].offsetLeft||u.top-e[0].offsetTop+u.height<Math.min(i._startPoint.y,i._stopPoint.y)||Math.min(i._startPoint.y,i._stopPoint.y)+s<u.top-e[0].offsetTop||i._contains(i._prevSelectedItems,f)||i._prevSelectedItems.push(f);for(r=0;r<i._prevSelectedItems.length;r++)f=i._prevSelectedItems[r].rectangle,u=f.getBoundingClientRect(),n(f).css({"border-width":i.model.highlightGroupBorderThickness,"border-color":i.model.highlightGroupBorderBrush,"box-sizing":"border-box","-moz-box-sizing":"border-box","-webkit-box-sizing":"border-box"});i.selectedItems.push(i._prevSelectedItems)}},_measureText:function(t,r,u){var h=n(document).find("#measureTex"),f,o,s,e,v;n("#measureTex").css("display","block");h.length==0?(f=document.createElement("text"),n(f).attr({id:"measureTex"}),document.body.appendChild(f)):f=h[0];var c=null,l=null,a=null,y=null;if(typeof t=="string"&&(t.indexOf("<")>-1||t.indexOf(">")>-1)){for(o=t.split(" "),s=0;s<o.length;s++)o[s].indexOf("<br/>")==-1&&(o[s]=o[s].replace(/[<>]/g,"&"));t=o.join(" ")}return f.innerHTML=t,u!=i&&u.size==i&&(e=u,e=e.split(" "),c=e[0],l=e[1],a=e[2],y=e[3]),u!=null&&(f.style.fontSize=u.size>0?u.size+"px":u.size?u.size:l,f.style.fontStyle&&(f.style.fontStyle=u.fontStyle?u.fontStyle:c),f.style.fontFamily=u.fontFamily?u.fontFamily:a),f.style.backgroundColor="white",f.style.position="absolute",f.style.top=-100,f.style.left=0,f.style.visibility="hidden",f.style.whiteSpace="nowrap",r&&(f.style.maxwidth=r+"px"),v={width:f.offsetWidth,height:f.offsetHeight},n("#measureTex").css("display","none"),v},_rowsCalculation:function(n,t,i,r,u,f){var d=this,nt=d.model,l,o=[],y,a,s=n?n.toString():"",g=s.length,w=this._measureText(s,t,u).width,b=this._measureText(s,t,u).height,v=s.split(" "),e=0,h=0,p=Math.round(t),k=v.length,f=f.toLowerCase(),i=f=="centerleft"||f=="center"||f=="centerright"?i/2:i,c;if(r=="wrap"||r=="hide"){if(w>p)for(c=1;c<=s.length;c++)if(n=s.substring(0,c),w=this._measureText(n,t,u).width,w>p){if(h=h+1,n=s.substring(0,c-1),n=="")break;h*b<i&&(o[e]=n);s=s.slice(c-1,g);e++;c=0}return h=h+1,h*b<i&&(o[e]=n),(r=="hide"||r=="wrap"&&(f=="bottomleft"||f=="bottomright"||f=="bottomcenter"))&&(o=o.slice(0,1)),o}if(r=="wrapbyword"){for(e=0;e<k;e++)if(l=v[e],y=this._measureText(l,t,u).width,h=h+1,y<p){while(e<k)if(y=this._measureText(l,t,u).width,a=v[e+1]?this._measureText(v[e+1],t,u).width:0,a=Math.round(a),y+a<p&&a>0)l=l.concat(" "+v[e+1]),e++;else break;h*b<i&&o.push(l)}return(f=="bottomleft"||f=="bottomright"||f=="bottomcenter")&&(o=o.slice(0,1)),o}},getStyleRuleValue:function(n,t){for(var i,r,o,u,e=typeof i!="undefined"?[i]:document.styleSheets,f=0,h=e.length;f<h;f++){i=e[f];try{if(!i.cssRules)continue;for(r=0,o=i.cssRules.length;r<o;r++)if(u=i.cssRules[r],u.selectorText&&u.selectorText.split(",").indexOf(t)!==-1)return u.style[n]}catch(s){if(s.name.toLowerCase()!=="securityerror")throw s;}}return null},_generateLabels:function(r,u){for(var f,tt,it,l,b,k,g,h,o,e,nt,p,a,s,et,c=this.model.leafItemSettings.textOverflow.toLowerCase(),w=0;w<r.length;w++)if(f=r[w],u.labelTemplate!=null&&c!="none"&&(tt=document.getElementById(u.labelTemplate),str=tt.innerHTML,$str1=n(str),text=$str1.find("label").eq(0).text(),labelPath=text.replace(/[.,\/#!$%\^&\*;:{}=\-_`~()]/g,""),labelText=f.Data[labelPath]),u.labelTemplate!=null&&c=="none")it=n("#"+u.labelTemplate),l=n("<div style='overflow:hidden;display:block;position:absolute;pointer-events: none;'><\/div>"),l[0].data=f,f.labelPosition=u.labelPosition,f.labelVisibilityMode=u.labelVisibilityMode,b=n.templates(it.html()),k="",k=f.Data instanceof Array?b.render({data:f.Data}):b.render(f.Data),n(l).html(k),this._templateDiv.append(l),this._labelTemplateElements.push(l);else{var d=8,v=5,y=this.getStyleRuleValue("font-size",".e-treemap-label");if(y=t.util.isNullOrUndefined(y)?"14px":y,g=u.labelTemplate!=null?labelText:f.label,c=this.model.leafItemSettings.textOverflow.toLowerCase(),u.labelTemplate==null)var rt=Math.round(f.ItemWidth-2*d),ut=Math.round(f.ItemHeight-2*v-(f.showHeader?f.headerHeight:0)),ft={fontWeight:"Normal",size:y,color:"black"};else var ft={fontWeight:"Normal",size:"16px",color:"black"},rt=Math.round(f.ItemWidth),ut=Math.round(f.ItemHeight);for(c!="none"?h=this._rowsCalculation(g,rt,ut,c,ft,u.labelPosition):(h=[],h.push(g)),o=[],e=0;e<h.length;e++)o[e]=u.labelTemplate==null?n('<label class="e-treemap-label" >'+h[e]+"<\/label>"):n("<label>"+h[e]+"<\/label>"),this.enableDrillDown()?n(o[e]).css({position:"absolute",color:"black",overflow:"hidden",left:f.LeftPosition+d+"px",top:f.TopPosition+v+"px","font-weight":"normal","pointer-events":"none"}):n(o[e]).css({position:"absolute",color:u.labelTemplate==null?"white":"black",overflow:"hidden",left:f.LeftPosition+d+"px",top:f.TopPosition+v+"px","font-weight":"normal","pointer-events":"none"}),this._treeMapLabels.push(o[e]),this._templateDiv.append(o[e]),nt=0,p=0,u.groupPadding!=i&&(nt=u.groupPadding),u.groupBorderThickness!=i&&(p=u.groupBorderThickness),a=o[e][0].getBoundingClientRect().width>0?o[e][0].getBoundingClientRect().width+nt+p+2:f.label.length*8,s=o[e][0].getBoundingClientRect().height,s==0&&f.ItemHeight>18?s=18:s>0&&s>f.ItemHeight&&(s=f.ItemHeight-v),n(o[e]).css({width:a+"px",height:s+"px"}),f.labelPosition=u.labelPosition,f.labelVisibilityMode=p,f.groupPadding=u.groupPadding,f.groupBorderThickness=u.groupBorderThickness,o[e][0].data=f,u.labelVisibilityMode==t.datavisualization.TreeMap.VisibilityMode.HideOnExceededLength?(a>f.ItemWidth&&(n(o[e]).css({display:"none"}),f.Rectangle!=null&&(f.Rectangle.title=f.label)),et=u.labelVisibilityMode):a<f.ItemWidth?n(o[e]).css({width:a}):n(o[e]).css({width:f.ItemWidth});this._labelTemplateElements.push(o)}},_generateToolTip:function(){var t,i,r;this.showTooltip()&&(t=document.documentMode==8?document.querySelectorAll("e-tooltipelement"):document.getElementsByClassName("e-tooltipelement"+this._id),t!=null&&t.length==0?(i=n("<div><\/div>").attr("class","e-tooltipelement"+this._id).css({position:"absolute","z-index":"1000",display:"none","pointer-events":"none"}),n(document.body).append(i),this._toolTipElement=i):this._toolTipElement=t[0],this.model.tooltipTemplate==null&&(r=this.labelPath()!=null?this.labelPath():this.weightValuePath(),r!=null&&(this.model.tooltipTemplate="defaultTooltip",this.element.append(n('<div id="defaultTooltip" style="display:none;"><div style="margin-left:10px;margin-top:-25px;"><div class="e-defaultToolTip"><p style="margin-top:-4px"><label style="color:rgb(27, 20, 20);font-size:14px;font-weight:normal;font-family:Segoe UI">{{:#data["'+r+'"]}}<\/label><\/p><\/div><\/div><\/div>')))))},_generateLegend:function(){var u,e,r,h,f;if(this.model.rangeColorMapping!=null){if(u=this.model.rangeColorMapping,e=this.model.legendSettings,e.mode!=t.datavisualization.TreeMap.LegendMode.Interactive){var n=0,i=0,o=0,c=this.iconWidth()+5,l=this.iconHeight()+15,s=this.model.legendSettings.columnCount;for(r=0;r<u.length;r++)h=this._calcWidth(u[r].legendLabel),f=this.iconWidth()+10+h,s!=0?r%s!=0?(this._drawLegend(u[r],n,i),n+=f+5):(r!=0&&(i+=this.iconHeight()+18),n=0,this._drawLegend(u[r],n,i),n+=f+5):this.dockPosition()==t.datavisualization.TreeMap.DockPosition.Top||this.dockPosition()==t.datavisualization.TreeMap.DockPosition.Bottom?this._legendSize.width<n+f?(i+=this.iconHeight()+18,n=0,this._drawLegend(u[r],n,i),n+=f):(this._drawLegend(u[r],n,i),n+=f):this._legendSize.height<i+this.iconHeight()?(i=0,n+=o+10,this._drawLegend(u[r],n,i),o=0,i+=this.iconHeight()+18):(this._drawLegend(u[r],n,i),o=Math.max(o,f),i+=this.iconHeight()+18)}else this._drawInteractiveLegend();(this.dockPosition()==t.datavisualization.TreeMap.DockPosition.Top||this.dockPosition()==t.datavisualization.TreeMap.DockPosition.Bottom)&&e.alignment==t.datavisualization.TreeMap.Alignment.Center?this._legenddiv.css({"margin-left":this._width/2-this._legendSize.width/2}):(this.dockPosition()==t.datavisualization.TreeMap.DockPosition.Top||this.dockPosition()==t.datavisualization.TreeMap.DockPosition.Bottom)&&e.alignment==t.datavisualization.TreeMap.Alignment.Far?this._legenddiv.css({"margin-left":this._width-this._legendSize.width}):(this.dockPosition()==t.datavisualization.TreeMap.DockPosition.Left||this.dockPosition()==t.datavisualization.TreeMap.DockPosition.Right)&&e.alignment==t.datavisualization.TreeMap.Alignment.Center?this._legenddiv.css({"margin-top":this._height/2-this._legendSize.height/2}):(this.dockPosition()==t.datavisualization.TreeMap.DockPosition.Left||this.dockPosition()==t.datavisualization.TreeMap.DockPosition.Right)&&e.alignment==t.datavisualization.TreeMap.Alignment.Far&&this._legenddiv.css({"margin-top":this._height-this._legendSize.height});this.dockPosition()==t.datavisualization.TreeMap.DockPosition.Bottom?this._legenddiv.css({"margin-top":this._height+5}):this.dockPosition()==t.datavisualization.TreeMap.DockPosition.Right&&this._legenddiv.css({"margin-left":this._width+5})}},_drawLegend:function(t,i,r){var f,u;f=this.model.legendSettings.template=="Ellipse"?this._getEllipseLegend(this.model.legendSettings,i,r):this._getRectLegend(this.model.legendSettings,i,r);i+=this.iconWidth()+5;n(f).css("background-color",t.color);f.appendTo(this._legenddiv);u=n("<div class='e-treemap-legendLabel'/>");u.css({left:i+"px",top:r+"px",position:"absolute"});u[0].innerHTML=t.legendLabel;u.appendTo(this._legenddiv)},_calcWidth:function(t){var i=n('<span class ="e-treemap-legendLabel" >'+t+"<\/span>"),r;return n("body").append(i),r=i.width(),i.remove(),r},_getEllipseLegend:function(t,i,r){var u=n("<div class='e-mapLegend'/>");return u.css({height:this.iconHeight()+"px",width:this.iconWidth()+"px","border-radius":this.iconHeight()/2+"px",left:i+"px",top:r+"px",position:"absolute"}),u},_getRectLegend:function(t,i,r){var u=n("<div />");return u.css({height:this.iconHeight()+"px",width:this.iconWidth()+"px",left:i+"px",top:r+"px",position:"absolute"}),u},_getPositionFromParent:function(n,t){var i=n.getBoundingClientRect(),r=t.getBoundingClientRect(),u=window.SVGSVGElement?i.width:i.right-i.left,f=window.SVGSVGElement?i.height:i.bottom-i.top;return{left:i.left-r.left,top:i.top-r.top,height:f,width:u}},_renderLabels:function(){for(var u,r=0;r<this._labelTemplateElements.length;r++)for(u=0;u<this._labelTemplateElements[r].length;u++){var f=this._labelTemplateElements[r][u],h=f[0]?f[0]:f,o=this._getPositionFromParent(h,this._templateDiv[0]),i=h.data,e=this._getDockPositionPoint({left:i.LeftPosition,top:i.TopPosition,width:i.ItemWidth,height:i.ItemHeight},o,i),s=i.labelPosition.toLowerCase();(s=="bottomleft"||s=="bottomright"||s=="bottomcenter")&&i.showHeader&&this.enableDrillDown()&&(e.y=e.y+i.headerHeight);n(f).css({left:e.x,top:e.y+18*u,"pointer-events":"none",overflow:"hidden"});i.labelVisibilityMode==t.datavisualization.TreeMap.VisibilityMode.HideOnExceededLength&&(o.height>i.ItemHeight||o.width>i.ItemWidth)&&n(f).css("display","none")}},_generateHeaders:function(i,r){var v=r.headerVisibilityMode,e=!1,s=2,h=2,u,c,o,f,l,a;v==t.datavisualization.TreeMap.VisibilityMode.HideOnExceededLength?(u=n("<span>"+i.header+"<\/span>"),n(document.body).append(u),c=u.outerWidth(),u.remove(),i.headerHeight<i.ItemHeight-2*s&&c<i.ItemWidth-2*h&&(e=!0)):i.headerHeight<i.ItemHeight&&(e=!0);e&&(i.headerTemplate==null?(o=n('<div style="display:block;position:absolute;pointer-events: stroke;overflow: hidden;"><label class="e-treemap-header">'+i.header+"<\/label><\/div>"),n(o).css({left:i.headerLeftPosition+s,top:i.headerTopPosition+h,width:i.headerWidth-r.groupPadding,height:i.headerHeight,"margin-left":r.groupPadding}),this._templateDiv.append(o)):(f=n("<div style='display:block;position:absolute;pointer-events: none;overflow: hidden;'><\/div>"),this._templateDiv.append(f),n(f).css({left:i.headerLeftPosition,width:i.headerWidth,top:i.headerTopPosition,height:i.headerHeight}),l={header:i.header,data:i.Data},a=n("#"+i.headerTemplate).render(l),n(f).html(a)))},getDrillDownHeader:function(n){var i="",t;if(n.length==1)return n[0];for(t=0;t<n.length;t++)i+=n[t],t!=n.length-1&&(i+=".");return i},_drillDownHeader:function(t,i,r){var u,o,e,f;for(this._trigger("headerTemplateRendering",{groupingLevel:i.groupingLevel,groupPath:i.groupPath,childItems:r,levelItems:i,headerItem:{drilldownHeaders:this._drilldownHeaders,originalHeaders:this._originalHeaders}}),u=[],o=[],e=0;e<this._drilldownHeaders.length;e++)u+="<label class='e-drilldownlabel' style='margin-left:-8px'>"+this._drilldownHeaders[e]+"<\/label>",this._drilldownHeaders.length>1&&e<this._drilldownHeaders.length-1&&(u=u+".");f=n("<div class='e-drilldownHeader' style='display:block;overflow: hidden;'><div class='e-drilldownlabel' style='position:absolute;height:30px;position:absolute;margin-top: 5px;top: 0px;'>"+u+"<\/div><\/div>");t&&(f=n("<div class='e-drilldownHeader' style='display:block;overflow: hidden;'><svg class='e-drilldownarrow' style='width:15px;height:15px;margin-top: 10px;'><polyline points='8,0 8,10 0,5 8,0'/><\/svg><label class='e-drilldownlabel' style='left:17px;position:absolute;height:30px;position:absolute;margin-top: 5px;top: 0px;'>"+u+"<\/label><\/div>"));n(f).css({left:"0px",width:this._width+"px",top:0,height:"30px",cursor:"pointer"});this.drillDownHeaderColor()!=null&&n(f).css("background-color",this.drillDownHeaderColor());this._drillHeaderDiv.append(f);n(f).mousedown({treemap:this},this._drilldownfunction);n(".e-drilldownlabel").mousedown({treemap:this},this._drilldownLabel)},_drilldownLabel:function(n){var o=this.innerHTML,i=n.data.treemap,u,s,h,r,f;if(i._drilldownHeaders[0]==o)i._drilldownItems=[],i.refresh();else{for(s="",i._drillHeaderDiv[0].innerHTML="",i._backgroundTile[0].innerHTML="",h="",r=0;r<i._drilldownHeaders.length;r++)o==i._drilldownHeaders[r]&&(u=r+1,i._originalHeaders.splice(r+1),i._drilldownHeaders.splice(r+1));i._labelTemplateElements=[];f=i.model.levels[i._drilldownHeaders.length-1];f.groupingLevel=n.data.treemap._drilldownItem.GroupingLevel;var e=i._drilldownHeaders.length-n.data.treemap._drilldownItems.length,c=n.data.treemap._drilldownItems.length,l=n.data.treemap._drilldownItems.length==1?n.data.treemap._drilldownItems[0].Data:n.data.treemap._drilldownItems[e<0?c+e:e].Data;return i._drillDownHeader(!0,f,l),u&&(i._drilldownItem=i._drilldownItems[u-2],i._drilldownItems.splice(u-1)),i._templateDiv[0].innerHTML="",t.util.isNullOrUndefined(i._drilldownItem)||i._groupdrillDownLevels(i._drilldownItem,i._drilldownItems.length),!1}},_drilldownfunction:function(n){var t=n.data.treemap,r,i,f,e,u;if(t._trigger("drillStarted",n),t._drilldownItems.length>0){if(t._drilldownItems.length==1)t._drilldownItems=[],t.refresh();else{for(r="",i=0;i<t._drillHeaderDiv[0].children[0].children.length;i++)t._drillHeaderDiv[0].children[0].children[i].className=="e-drilldownlabel"&&(r=t._drillHeaderDiv[0].children[0].children[i].innerHTML);f=r.split(".");t._drillHeaderDiv[0].innerHTML="";t._backgroundTile[0].innerHTML="";e="";t._drilldownHeaders.length>1&&t._drilldownHeaders.pop(t._drilldownHeaders.length-1);t._labelTemplateElements=[];u=t.model.levels[t._drilldownHeaders.length-1];u.groupingLevel=n.data.treemap._drilldownItem.GroupingLevel;t._drillDownHeader(!0,u,n.data.treemap._drilldownItem.Data);t._drilldownItem=t._drilldownItems[t._drilldownItems.length-2];t._drilldownItems.pop(t._drilldownItems[t._drilldownItems.length-1]);t._templateDiv[0].innerHTML="";t._groupdrillDownLevels(t._drilldownItem,t._drilldownItems.length)}t._trigger("drillDownItemSelected",{level:t._drilldownItems.length,header:t.getDrillDownHeader(t._drilldownHeaders),prevLevel:t._drilldownItems.length-1})}},_sizeCalculation:function(){var o,n,l;if(this.model.rangeColorMapping!=null){var r=this.model.rangeColorMapping,e=0,h=0,a=this.iconWidth()+5,u=this.iconHeight()+15,f=0,c=this.model.legendSettings.columnCount,s=this.model.legendSettings;if(this.model.legendSettings.mode!=t.datavisualization.TreeMap.LegendMode.Interactive){if(this.legendheight()==0&&this.legendwidth()==0&&c==0){for(n=0;n<r.length;n++)r[n].legendLabel==i&&(r[n].legendLabel=r[n].from+"-"+r[n].to),l=this._calcWidth(r[n].legendLabel),o=a+l+10,this.legendheight()==0&&this.legendwidth()==0?this.dockPosition()==t.datavisualization.TreeMap.DockPosition.Top||this.dockPosition()==t.datavisualization.TreeMap.DockPosition.Bottom?this._width<e+o?(u=this.iconHeight()+15+u,f=Math.max(f,e),e=o):e+=o:this._height<h+this.iconHeight()+15?(f+=e,u=Math.max(u,h),e=o,h=0):(h+=this.iconHeight()+18,e=Math.max(o,e)):(xPos+=_legendlabelwidth+18,xPos+150>=this.legendwidth()&&(xPos=10,yPos+=40));this.dockPosition()==t.datavisualization.TreeMap.DockPosition.Top||this.dockPosition()==t.datavisualization.TreeMap.DockPosition.Bottom?(f=Math.max(f,e),u+=5):(f+=e+15,u=Math.max(u,h))}else if(c==0){for(n=0;n<r.length;n++)r[n].legendLabel==i&&(r[n].legendLabel=r[n].from+"-"+r[n].to);u=this.legendheight().toString().indexOf("%")!=-1?this._height/100*parseInt(this.legendheight().replace("%","")):this.legendheight();f=this.legendwidth().toString().indexOf("%")!=-1?this._width/100*parseInt(this.legendwidth().replace("%","")):this.legendwidth()}if(c!=0)for(n=0;n<r.length;n++)r[n].legendLabel==i&&(r[n].legendLabel=r[n].from+"-"+r[n].