@mescius/wijmo.chart.hierarchical 5.20232.939 → 5.20241.3-rc

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,4 +1,4 @@
1
- [English](#wijmo) | [日本語](#wijmo-jp) | [中文](#wijmo-cn) | [한국어](#wijmo-kr)
1
+ [English](#wijmo) | [日本語](#wijmo-jp) | [한국어](#wijmo-kr)
2
2
 
3
3
  # Wijmo
4
4
 
@@ -59,19 +59,19 @@ Sample source code available with our [Wijmo Developer Pack](https://developer.m
59
59
  ### To install latest release version:
60
60
 
61
61
  ```sh
62
- npm install @grapecity/wijmo.all
62
+ npm install @mescius/wijmo.all
63
63
  ```
64
64
 
65
65
  ### To install latest nightly build:
66
66
 
67
67
  ```sh
68
- npm install @grapecity/wijmo.all@nightly
68
+ npm install @mescius/wijmo.all@nightly
69
69
  ```
70
70
 
71
71
  ### To install latest RC build:
72
72
 
73
73
  ```sh
74
- npm install @grapecity/wijmo.all@rc
74
+ npm install @mescius/wijmo.all@rc
75
75
  ```
76
76
 
77
77
  ## Documentation
@@ -159,99 +159,6 @@ Submit questions to our team of [Wijmo Experts](https://developer.mescius.com/fo
159
159
  - [サポート&サービス](https://developer.mescius.jp/support)
160
160
  - [サブスクリプションサービス利用規約](https://download.mescius.jp/license/other/componentone-subscriptionservice.pdf)
161
161
 
162
- ## Wijmo CN
163
-
164
- Wijmo 是一套完整的企业级 JavaScript UI 开发组件。 它包括强大的表格、图表、数据透视、输入等组件,并且可以支持各类主流前端框架,包括 Angular、React 和 Vue。
165
-
166
- Wijmo 的轻量级、高性能 JavaScript UI 组件可以将您的开发时间缩短一半。
167
-
168
- 查看我们 [FlexGrid 表格](https://demo.grapecity.com.cn/wijmo/demos/Grid/Overview/purejs) 组件.
169
-
170
-
171
- ---
172
-
173
- ## 从 NPM 获取您所缺少的开发包!
174
-
175
- 请务必下载 Wijmo 以获得完整的开发包。 NPM 仅包含我们的 JS 组件,但我们的开发包包含数百个示例,其中包含每个 JS 框架的源代码、实际参考应用程序等等!
176
-
177
- **[下载 Wijmo 开发包](https://www.grapecity.com.cn/developer/wijmojs/download) 以启动您的项目。**
178
-
179
- ---
180
-
181
- ## 示例
182
-
183
- 每种 JavaScript 框架中都提供超过 450 个功能示例
184
-
185
- - [JavaScript 示例](https://demo.grapecity.com.cn/wijmo/demos/Grid/Overview/purejs)
186
- - [Vue 示例](https://demo.grapecity.com.cn/wijmo/demos/Grid/Overview/vue)
187
- - [Angular 示例](https://demo.grapecity.com.cn/wijmo/demos/Grid/Overview/angular)
188
- - [React 示例](https://demo.grapecity.com.cn/wijmo/demos/Grid/Overview/react)
189
-
190
- 我们还提供了 JavaScript 框架中可用的实际应用示例
191
-
192
-
193
- - [Vue 参考应用](https://www.grapecity.com/wijmo/demos/reference-samples/#GeoDashboard)
194
- - [Angular 参考应用](https://demos.wijmo.com/5/SampleExplorer/SampleExplorer/Sample/WealthHealth)
195
- - [React 参考应用](https://www.grapecity.com/wijmo/demos/reference-samples/#GeoDashboard)
196
- - [React Redux 参考应用](https://www.grapecity.com/wijmo/demos/reference-samples/#CryptoCurrencyTracking)
197
-
198
- [Wijmo 开发包](https://www.grapecity.com.cn/developer/wijmojs/download) 中提供了示例源代码。
199
-
200
- ## 安装
201
-
202
- ### 安装最新版本:
203
-
204
- ```sh
205
- npm install @grapecity/wijmo.all
206
- ```
207
-
208
- ### 安装最新的 nightly 版本:
209
- ```sh
210
- npm install @grapecity/wijmo.all@nightly
211
- ```
212
-
213
- ### 安装最新的 RC 版本:
214
-
215
- ```sh
216
- npm install @grapecity/wijmo.all@rc
217
- ```
218
-
219
- ## 文档
220
-
221
- 在线文档可在此处获取:
222
-
223
- - [API Reference](https://demo.grapecity.com.cn/wijmo/api/)
224
- - [Documentation Guides](https://demo.grapecity.com.cn/wijmo/docs/GettingStarted/Introduction)
225
-
226
- ## 许可
227
-
228
- Wijmo授权由开发授权和部署授权组成
229
-
230
- 了解 [WijmoJS 价格与授权方式](https://www.grapecity.com.cn/developer/wijmojs#price).
231
-
232
- ## 资源
233
-
234
- - [快速入门指南](https://demo.grapecity.com.cn/wijmo/docs/GettingStarted/QuickStart/QuickStart-PureJS)
235
- - [Wijmo 产品介绍](https://www.grapecity.com.cn/developer/wijmojs)
236
- - [博客](https://www.grapecity.com.cn/blogs/tags/wijmo)
237
- - [论坛](https://gcdn.grapecity.com.cn/showforum-140-1.html)
238
-
239
- Wijmo 开发包可以从 [这里](https://www.grapecity.com.cn/developer/wijmojs/download) 下载
240
-
241
- ## 支持
242
-
243
- **Wijmo 随时为您提供支持**
244
-
245
- 提供多种售前支持方式。您可以通过电话热线、邮件、售前顾问、在线咨询、添加企业微信等方式获取获取售前咨询、产品解决方案、产品选型等1V1服务。帮您快速了解产品特性,助您POC验证成功,节省时间成本。
246
-
247
- - [联系我们](https://www.grapecity.com.cn/support#goumaizixun)
248
-
249
-
250
- ## 问题反馈
251
-
252
- 我们重视您的反馈并利用建议来帮助创建产品路线图。 告诉我们你的想法。
253
-
254
- [提交您的问题和反馈建议](https://gcdn.grapecity.com.cn/showforum-173-1.html)
255
162
 
256
163
  # Wijmo KR
257
164
 
@@ -302,19 +209,19 @@ Wijmo는 또한 NPM을 지원합니다. 이를 통해 최신 버전의 Wijmo 라
302
209
  **[최신 정식 버전]**
303
210
 
304
211
  ```sh
305
- npm install @grapecity/wijmo.all
212
+ npm install @mescius/wijmo.all
306
213
  ```
307
214
 
308
215
  **[Nightly 버전]**
309
216
 
310
217
  ```sh
311
- npm install @grapecity/wijmo.all@nightly
218
+ npm install @mescius/wijmo.all@nightly
312
219
  ```
313
220
 
314
221
  **[RC 버전]**
315
222
 
316
223
  ```sh
317
- npm install @grapecity/wijmo.all@rc
224
+ npm install @mescius/wijmo.all@rc
318
225
  ```
319
226
 
320
227
  ## 빠른시작 가이드
@@ -1,6 +1,6 @@
1
1
  /*!
2
2
  *
3
- * Wijmo Library 5.20232.939
3
+ * Wijmo Library 5.20241.3
4
4
  * https://developer.mescius.com/wijmo
5
5
  *
6
6
  * Copyright(c) MESCIUS inc. All rights reserved.
package/es2015-esm.js CHANGED
@@ -1,6 +1,6 @@
1
1
  /*!
2
2
  *
3
- * Wijmo Library 5.20232.939
3
+ * Wijmo Library 5.20241.3
4
4
  * https://developer.mescius.com/wijmo
5
5
  *
6
6
  * Copyright(c) MESCIUS inc. All rights reserved.
package/es5-esm.js CHANGED
@@ -1,6 +1,6 @@
1
1
  /*!
2
2
  *
3
- * Wijmo Library 5.20232.939
3
+ * Wijmo Library 5.20241.3
4
4
  * https://developer.mescius.com/wijmo
5
5
  *
6
6
  * Copyright(c) MESCIUS inc. All rights reserved.
@@ -11,4 +11,4 @@
11
11
  *
12
12
  */
13
13
 
14
- var __extends=this&&this.__extends||function(){var extendStatics=function(e,t){return(extendStatics=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var i in t)t.hasOwnProperty(i)&&(e[i]=t[i])})(e,t)};return function(e,t){extendStatics(e,t);function __(){this.constructor=e}e.prototype=null===t?Object.create(t):(__.prototype=t.prototype,new __)}}();import{isString,isArray,CollectionView,Aggregate,assert,asEnum,Rect,Color,asBoolean,isFunction,Point,Size,isNumber,asNumber,asString,asArray,_registerModule}from"@mescius/wijmo";import{FlexPie,_DataPoint,HitTestInfo,SelectionMode,FlexChartBase,DataLabel,_KeyWords,FlexChart,ChartElement,Series,LabelPosition,DataLabelRenderEventArgs,RenderEventArgs,_RectArea,ChartTooltip,_SvgRenderEngine,Legend,Position}from"@mescius/wijmo.chart";import*as selfModule from"@mescius/wijmo.chart.hierarchical";var HierarchicalUtil=function(){function HierarchicalUtil(){}HierarchicalUtil.parseDataToHierarchical=function(e,t,i,r){var a,o=[];if(e instanceof CollectionView&&e.groups.length>0)o=HierarchicalUtil.parseGroupCV(e,t);else if(e.length>0){isString(i)&&i.indexOf(",")>-1&&(i=i.split(","));if(r)o=HierarchicalUtil.parseItems(e,t,i,r);else{a=HierarchicalUtil.convertFlatData(e,t,i);o=HierarchicalUtil.parseItems(a,"value",i,"items")}}return o};HierarchicalUtil.parseGroupCV=function(e,t){for(var i=[],r=0,a=e.groups.length;r<a;r++){var o=this.parseGroups(e.groups[r],t);i.push(o)}return i};HierarchicalUtil.parseGroups=function(e,t){var i={};i.name=e.name;i.nameField=e.groupDescription.propertyName;i.item=e.items;if(e.groups&&e.groups.length){i.items=[];for(var r=0,a=e.groups.length;r<a;r++){var o=this.parseGroups(e.groups[r],t);i.items.push(o)}}else e.isBottomLevel&&(i.value=e.getAggregate(Aggregate.Sum,t));return i};HierarchicalUtil.parseItems=function(e,t,i,r){var a,o=[],n=e.length;for(a=0;a<n;a++)o.push(HierarchicalUtil.parseItem(e[a],t,i,r));return o};HierarchicalUtil.isFlatItem=function(e,t){return!isArray(e[t])};HierarchicalUtil.convertFlatData=function(e,t,i){var r,a,o=[],n={},l=e.length;for(r=0;r<l;r++){a=e[r];HierarchicalUtil.convertFlatItem(n,a,t,isArray(i)?i:[i])}HierarchicalUtil.convertFlatToHierarchical(o,n);return o};HierarchicalUtil.convertFlatToHierarchical=function(e,t){var i=t.flatDataOrder;i&&i.forEach((function(i){var r,a={},o=t[i];a[t.field]=i;if(o.flatDataOrder){r=[];HierarchicalUtil.convertFlatToHierarchical(r,o);a.items=r}else a.value=o;e.push(a)}))};HierarchicalUtil.convertFlatItem=function(e,t,i,r){var a,o,n,l;o=(a=r.slice()).shift();if(null==(n=null==(o=isString(o)?o.trim():o)?i:t[o]))return!1;if(0===a.length){e[n]=t[i]||0;e.flatDataOrder?e.flatDataOrder.push(n):e.flatDataOrder=[n];e.field=o}else{if(null==e[n]){e[n]={};e.flatDataOrder?e.flatDataOrder.push(n):e.flatDataOrder=[n];e.field=o}l=e[n];HierarchicalUtil.convertFlatItem(l,t,i,a)||(e[n]=t[i])}return!0};HierarchicalUtil.parseItem=function(e,t,i,r){var a,o,n,l,s,h={};if(isArray(r))l=(s=r.slice()).length?s.shift().trim():"";else{s=r;l=r}if(isArray(i)){o=null==(o=(a=i.slice()).shift())?o:o.trim();h.nameField=null==o?t:o;h.name=null==o?e[t]:e[o];n=e[l];0===a.length?h.value=e[t]:n&&isArray(n)&&n.length>0?h.items=HierarchicalUtil.parseItems(n,t,a,s):h.value=e[t]||0}else{h.nameField=null==i?t:i;h.name=null==i?e[t]:e[i];null!=(n=e[l])&&isArray(n)&&n.length>0?h.items=HierarchicalUtil.parseItems(n,t,i,s):h.value=e[t]}h.item=e;return h};HierarchicalUtil.parseFlatItem=function(e,t,i,r){e.items||(e.items=[])};return HierarchicalUtil}();export{HierarchicalUtil};export var TreeMapType;!function(e){e[e.Squarified=0]="Squarified";e[e.Horizontal=1]="Horizontal";e[e.Vertical=2]="Vertical"}(TreeMapType||(TreeMapType={}));var TreeMap=function(e){__extends(TreeMap,e);function TreeMap(t,i){var r=e.call(this,t,null,!0)||this;r._values=[];r._labels=[];r._areas=[];r._sum=0;r._keywords=new _KeyWords;r._processedData=[];r._depth=1;r._itemIndex=0;r._processedItem=[];r._maxDepth=-1;r._tmItems=[];r._colRowLens=[];r._defPalette=[{titleColor:"#033884",maxColor:"#1450a7",minColor:"#83b3f9"},{titleColor:"#a83100",maxColor:"#dc4a0d",minColor:"#ffb190"},{titleColor:"#006658",maxColor:"#008d7a",minColor:"#7deddf"},{titleColor:"#a10046",maxColor:"#df0061",minColor:"#ff8cbe"},{titleColor:"#784d08",maxColor:"#99681a",minColor:"#efc989"},{titleColor:"#54156f",maxColor:"#722a90",minColor:"#cf95e7"},{titleColor:"#998605",maxColor:"#c2ac19",minColor:"#ffef8b"},{titleColor:"#9a0005",maxColor:"#c80c14",minColor:"#ff888d"}];r.applyTemplate("wj-control wj-flexchart wj-treemap",null,null);r._currentRenderEngine=new _SvgRenderEngine(r.hostElement);r._legend=new Legend(r);r._legend.position=Position.None;r._tooltip=new ChartTooltip;r._tooltip.content="<b>{name}</b><br/>{value}";r._tooltip.showDelay=0;r._lbl=new DataLabel;r._lbl.position=LabelPosition.Center;r._lbl._chart=r;r.hostElement.addEventListener("mousemove",(function(e){r.isTouching||r._toogleTooltip(e)}));r.hostElement.addEventListener("click",(function(e){var t=!0;if(r.maxDepth>0){var i=r.hitTest(e),a=FlexChart._SELECTION_THRESHOLD;r.tooltip&&r.tooltip.threshold&&(a=r.tooltip.threshold);if(i.distance<=a&&i.pointIndex>=-1&&i.pointIndex<r._areas.length){var o=r._areas[i.pointIndex];if(r._currentItem!=o.item){r._currentItem=o.item;r._refreshChart();t=!1}}}t&&r.isTouching&&r._toogleTooltip(e)}));r.hostElement.addEventListener("contextmenu",(function(e){if(r.maxDepth>0){var t=r.hitTest(e),i=FlexChart._SELECTION_THRESHOLD;r.tooltip&&r.tooltip.threshold&&(i=r.tooltip.threshold);t.distance<=i&&r._rollUp()}e.preventDefault();return!1}));r.hostElement.addEventListener("mouseleave",(function(){r._hideToolTip()}));r.deferUpdate((function(){return r.initialize(i)}));return r}TreeMap.prototype._rollUp=function(){this._currentItem=this._currentItem&&this._currentItem.parent?this._currentItem.parent:null;this._refreshChart()};TreeMap.prototype._toogleTooltip=function(e){var t=this._tooltip;if(t.content){var i=this.hitTest(e);if(i.distance<=t.threshold){var r=this._getLabelContent(i,this.tooltip.content);this._showToolTip(r,new Rect(e.clientX,e.clientY,5,5))}else this._hideToolTip()}};Object.defineProperty(TreeMap.prototype,"selectionMode",{get:function(){return SelectionMode.None},set:function(e){},enumerable:!0,configurable:!0});Object.defineProperty(TreeMap.prototype,"_treeMapItems",{get:function(){return this._tmItems},enumerable:!0,configurable:!0});Object.defineProperty(TreeMap.prototype,"tooltip",{get:function(){return this._tooltip},enumerable:!0,configurable:!0});Object.defineProperty(TreeMap.prototype,"binding",{get:function(){return this._binding},set:function(e){if(e!=this._binding){this._binding=asString(e,!0);this._bindChart()}},enumerable:!0,configurable:!0});Object.defineProperty(TreeMap.prototype,"type",{get:function(){return null==this._type?TreeMapType.Squarified:this._type},set:function(e){if((e=asEnum(e,TreeMapType))!=this._type){this._type=e;this.invalidate()}},enumerable:!0,configurable:!0});Object.defineProperty(TreeMap.prototype,"bindingName",{get:function(){return this._bindingName},set:function(e){if(e!=this._bindingName){assert(null==e||isArray(e)||isString(e),"bindingName should be an array or a string.");this._bindingName=e;this._bindChart()}},enumerable:!0,configurable:!0});Object.defineProperty(TreeMap.prototype,"dataLabel",{get:function(){return this._lbl},set:function(e){if(e!=this._lbl){this._lbl=e;this._lbl&&(this._lbl._chart=this)}},enumerable:!0,configurable:!0});Object.defineProperty(TreeMap.prototype,"childItemsPath",{get:function(){return this._childItemsPath},set:function(e){if(e!=this._childItemsPath){assert(null==e||isArray(e)||isString(e),"childItemsPath should be an array or a string.");this._childItemsPath=e;this._bindChart()}},enumerable:!0,configurable:!0});Object.defineProperty(TreeMap.prototype,"maxDepth",{get:function(){return this._maxDepth},set:function(e){if(e!=this._maxDepth){this._maxDepth=asNumber(e,!0);this.invalidate()}},enumerable:!0,configurable:!0});Object.defineProperty(TreeMap.prototype,"palette",{get:function(){return this._palette},set:function(e){if(e!=this._palette){this._palette=asArray(e);this._tmItems&&this._tmItems.length>0&&this._calculateColorForItems(this._tmItems);this.invalidate()}},enumerable:!0,configurable:!0});TreeMap.prototype._initData=function(){this._sum=0;this._tmItems=[];this._currentItem=null;this._values=[];this._labels=[];this._processedData=[];this._depth=1;this._processedItem=[]};TreeMap.prototype._performBind=function(){var e;this._initData();if(this._cv){e=this._cv.items;this._cv.groups&&this._cv.groups.length?this._processedData=HierarchicalUtil.parseDataToHierarchical(this._cv,this.binding,this.bindingName,this.childItemsPath):e&&(this._processedData=HierarchicalUtil.parseDataToHierarchical(e,this.binding,this.bindingName,this.childItemsPath));if(this._processedData&&this._processedData.length){this._sum=this._calculateValueAndDepth(this._processedData,1);this._sortData(this._processedData);this._values=[];this._getTMItemsAndLabelsAndValues(this._processedData,this._tmItems,1,null);this._calculateColorForItems(this._tmItems)}}};TreeMap.prototype._sortData=function(e){var t=this;e.forEach((function(e){e.items&&t._sortData(e.items)}));e.sort((function(e,t){return t.value-e.value}))};TreeMap.prototype._getTMItemsAndLabelsAndValues=function(e,t,i,r,a){var o=this;e&&e.length>0&&e.forEach((function(e,a){var n,l=new _TreeMapItem;l.items=[];l.parent=r;l.depth=i;e.items&&o._getTMItemsAndLabelsAndValues(e.items,l.items,i+1,l);n=e.name?e.name:e.value.toString();l.label=n;l.value=e.value;if(null!=r){e.value>r.maxValue&&(r.maxValue=e.value);e.value<r.minValue&&(r.minValue=e.value)}t.push(l);o._labels.push(n);o._values.push(e.value)}))};TreeMap.prototype._calculateColorForItems=function(e,t,i){var r=this,a=i;e.forEach((function(e,i){var o=t;1===e.depth&&(o=r._getColor(i));e.palette=o;var n=e.palette;if(isString(n)){var l=n,s=r._getLightColor(l);e.titleFill=l;e.titleStroke=l;e.fill=s;e.stroke=l}else if(n.maxColor&&n.minColor&&n.titleColor){e.titleFill=n.titleColor;e.titleStroke=n.titleColor;if(null==e.parent){e.fill=n.maxColor;e.stroke=n.maxColor}else{null==a&&(a=new _ColorConverter(n.minColor,e.minValue,n.maxColor,e.maxValue));var h=a._calculateColorByVal(e.value,!0).toString();e.fill=h;e.stroke=h}}if(e.items&&e.items.length>0){var c=new _ColorConverter(n.minColor,e.minValue,n.maxColor,e.maxValue);r._calculateColorForItems(e.items,o,c)}}))};TreeMap.prototype._getBindData=function(e,t,i){var r,a=0;i&&(r=e[i]);a=0;isNumber(r)?a=asNumber(r):r&&(a=parseFloat(r.toString()));if(!isNaN(a)&&isFinite(a))t.push(a);else{a=0;t.push(a)}return a};TreeMap.prototype._calculateValueAndDepth=function(e,t){var i=this,r=0,a=this._values;this._depth<t&&(this._depth=t);e.forEach((function(e){var o;if(e.items){o=i._calculateValueAndDepth(e.items,t+1);e.value=o;a.push(o)}else{o=i._getBindData(e,a,"value");e.value=o}r+=o}));return r};TreeMap.prototype._prepareRender=function(){this._areas=[]};TreeMap.prototype._renderChart=function(e,t,i){var r,a,o,n=this._rectChart.clone();new Size(n.width,n.height);this.onRendering(new RenderEventArgs(e));var l=t.width,s=t.height;this._tmGroup=e.startGroup(null,null,!0);var h=this._parseMargin(this.plotMargin);this.dataLabel;isNaN(h.left)&&(h.left=TreeMap._MARGIN);isNaN(h.right)&&(h.right=TreeMap._MARGIN);isNaN(h.top)&&(h.top=TreeMap._MARGIN);isNaN(h.bottom)&&(h.bottom=TreeMap._MARGIN);t.top+=h.top;s=t.height-(h.top+h.bottom);t.height=s>0?s:24;t.left+=h.left;l=t.width-(h.left+h.right);t.width=l>0?l:24;this._plotRect=t;r=this._currentItem?[this._currentItem]:this._tmItems;a=null==this._currentItem||this.maxDepth<1?this.maxDepth:this._currentItem&&this._currentItem.items&&this._currentItem.items.length&&this.maxDepth>1?this.maxDepth:this.maxDepth+1;o=this._currentItem?this._currentItem.value:this._sum;this._renderTreeMap(e,t,this._tmGroup,r,o,a);e.endGroup();this.dataLabel.content&&this.dataLabel.position!=LabelPosition.None&&this._renderLabels(e);this.onRendered(new RenderEventArgs(e))};TreeMap.prototype._renderTreeMap=function(e,t,i,r,a,o){if(a>0){this._itemIndex=0;this._resetItemRects(this._tmItems);this._calculateItemRects(t,r,a,1,o);this._renderHierarchicalTreeMapItems(e,i,t,this._tmItems,a,1,o)}};TreeMap.prototype._resetItemRects=function(e){var t=this;e.forEach((function(e){e.rect=new Rect(0,0,0,0);e.isTitle=!1;e.type=t.type;e.items&&e.items.length&&t._resetItemRects(e.items)}))};TreeMap.prototype._calculateItemRects=function(e,t,i,r,a){var o=this;switch(this.type){case TreeMapType.Horizontal:_TreeMapUtils.horizontal(t,e,i);break;case TreeMapType.Vertical:_TreeMapUtils.vertical(t,e,i);break;case TreeMapType.Squarified:_TreeMapUtils.squarified(t,e,i)}t.forEach((function(e,t){e.rect.clone();if(e.items&&e.items.length)if(r===a);else if(r>a&&a>=1);else{e.isTitle=!0;o._calculateItemRects(e.itemsRect,e.items,e.value,r+1,a)}}))};TreeMap.prototype._renderHierarchicalTreeMapItems=function(e,t,i,r,a,o,n){var l,s,h,c,u,p=r.length;this.type;if(0!==p)for(var _=0;_<p;_++){l=e.startGroup(TreeMap._CSS_ITEMDEPTH+o);s=r[_];h=Math.abs(s.value);c=s.rect;s.draw(e);u=new _RectArea(c);s.items&&this._renderHierarchicalTreeMapItems(e,l,s.itemsRect,s.items,h,o+1,n);u.tag=this._itemIndex;u.name=s.label;u.value=h;u.item=s;this._areas.push(u);this._itemIndex++;e.endGroup()}};TreeMap.prototype._renderLabels=function(e){var t,i=this._areas.length,r=this.dataLabel,a=r.position,o=r.connectingLine,n=r.border,l=r.offset||0;e.stroke="null";e.fill="transparent";e.strokeWidth=1;e.startGroup("wj-data-labels");for(var s=0;s<i;s++){var h=this._areas[s];if(h){var c=h.rect,u=new HitTestInfo(this,t);u._setData(null,s);var p=this._getLabelContent(u,r.content);t=new Point(c.left+c.width/2,c.top+c.height/2);if(p&&c.width>0&&c.height>0){var _=new DataLabelRenderEventArgs(e,u,t,p);if(r.onRendering(_)){p=_.text;t=_.point;this._renderLabelAndBorder(e,h,c,p,a,l,t,o,2,n)}}}}e.endGroup()};TreeMap.prototype._renderLabelAndBorder=function(e,t,i,r,a,o,n,l,s,h){var c,u="wj-data-label",p="wj-data-label-line";switch(a){case LabelPosition.Top:l&&e.drawLine(n.x,n.y,n.x,n.y-o,p);n.y-=s+o;c=this._renderText(e,t,i,r,n,1,2,u);break;case LabelPosition.Bottom:l&&e.drawLine(n.x,n.y,n.x,n.y+o,p);n.y+=s+o;c=this._renderText(e,t,i,r,n,1,0,u);break;case LabelPosition.Left:l&&e.drawLine(n.x,n.y,n.x-o,n.y,p);n.x-=s+o;c=this._renderText(e,t,i,r,n,2,1,u);break;case LabelPosition.Right:l&&e.drawLine(n.x,n.y,n.x+o,n.y,p);n.x+=s+o;c=this._renderText(e,t,i,r,n,0,1,u);break;case LabelPosition.Center:c=this._renderText(e,t,i,r,n,1,1,u)}h&&c&&e.drawRect(c.left-s,c.top-s,c.width+2*s,c.height+2*s,"wj-data-label-border");return c};TreeMap.prototype._renderText=function(e,t,i,r,a,o,n,l){var s,h=r,c=t.item;s=e.measureString(r,l);if(this.type===TreeMapType.Horizontal&&c.isTitle){s.width>i.height&&(h=this._cutText(r,s.width,i.height));FlexChart._renderRotatedText(e,h,a,o,n,a,-90,l);return null}s.width>i.width&&(h=this._cutText(r,s.width,i.width));return FlexChart._renderText(e,h,a,o,n,l)};TreeMap.prototype._cutText=function(e,t,i){var r="",a=e.length,o=Math.floor((1-(t-i)/t)*a);e.length>0&&(r=e[0]+(o>1?e.substring(1,o-1)+"..":""));return r};TreeMap.prototype._measureLegendItem=function(e,t){var i=new Size;i.width=Series._LEGEND_ITEM_WIDTH;i.height=Series._LEGEND_ITEM_HEIGHT;if(t){var r=e.measureString(t,FlexChart._CSS_LABEL,FlexChart._CSS_LEGEND);i.width+=r.width;i.height<r.height&&(i.height=r.height)}i.width+=3*Series._LEGEND_ITEM_MARGIN;i.height+=2*Series._LEGEND_ITEM_MARGIN;return i};TreeMap.prototype._getDesiredLegendSize=function(e,t,i,r){var a=new Size,o=(new Size(i,r),this._tmItems.length),n=0,l=0;this._colRowLens=[];for(var s=0;s<o;s++){var h=this._measureLegendItem(e,this._tmItems[s].label);if(t){if(l+h.height>r){a.height=r;this._colRowLens.push(n);n=0;l=0}n<h.width&&(n=h.width);l+=h.height}else{if(n+h.width>i){a.width=i;this._colRowLens.push(l);l=0;n=0}l<h.height&&(l=h.height);n+=h.width}}if(t){a.height<l&&(a.height=l);this._colRowLens.push(n);a.width=this._colRowLens.reduce((function(e,t){return e+t}),0);a.width=this._getLegendSize(i,a.width)}else{a.width<n&&(a.width=n);this._colRowLens.push(l);a.height=this._colRowLens.reduce((function(e,t){return e+t}),0);a.height=this._getLegendSize(r,a.height)}return a};TreeMap.prototype._renderLegend=function(e,t,i,r,a,o){for(var n,l=this._rectLegend,s=this._tmItems.length,h=0,c=t.clone(),u=0;u<s;u++){n=this._tmItems[u].label;var p=this._measureLegendItem(e,n);if(r){if(c.y+p.height>l.top+l.height+1){c.x+=this._colRowLens[h];h++;c.y=t.y}}else if(c.x+p.width>l.left+l.width+1){c.y+=this._colRowLens[h];h++;c.x=t.x}var _=new Rect(c.x,c.y,p.width,p.height);this._drawLegendItem(e,_,u,n);i.push(_);r?c.y+=p.height:c.x+=p.width}};TreeMap.prototype._drawLegendItem=function(e,t,i,r){e.strokeWidth=1;var a=Series._LEGEND_ITEM_MARGIN,o=this._getColor(i),n=o&&o.maxColor?o.maxColor:o,l=this._getLightColor(n);e.fill=n;e.stroke=l;var s=t.top+.5*t.height,h=Series._LEGEND_ITEM_WIDTH,c=Series._LEGEND_ITEM_HEIGHT;e.drawRect(t.left+a,s-.5*c,h,c,null);r&&FlexChart._renderText(e,r,new Point(t.left+c+2*a,s),0,1,FlexChart._CSS_LABEL)};TreeMap.prototype._getLabelContent=function(e,t){return isString(t)?this._keywords.replace(t,e):isFunction(t)?t(e):null};TreeMap.prototype.hitTest=function(e,t){var i=this._toControl(e,t),r=new HitTestInfo(this,i),a=null;if(FlexChart._contains(this._rectHeader,i))r._chartElement=ChartElement.Header;else if(FlexChart._contains(this._rectFooter,i))r._chartElement=ChartElement.Footer;else if(FlexChart._contains(this._rectLegend,i)){r._chartElement=ChartElement.Legend;null!==(a=this.legend._hitTest(i))&&a>=0&&a<this._areas.length&&r._setData(null,a)}else if(FlexChart._contains(this._rectChart,i)){for(var o,n=this._areas.length,l=NaN,s=0;s<n;s++){var h=i.clone(),c=this._areas[s];if(c.contains(h)){r._setData(null,c.tag);r._dist=0}var u=c.distance(h);if(void 0!==u&&(isNaN(l)||u<l)){l=u;o=c}}if(0!==r._dist&&null!=o){r._setData(null,o.tag);r._dist=l}r._chartElement=ChartElement.ChartArea}else r._chartElement=ChartElement.None;return r};TreeMap.prototype._getHitTestItem=function(e){var t=null,i=null;(t=null!=this._cv?this._cv.items:this.itemsSource)&&e<t.length&&(i=t[e]);return i};TreeMap.prototype._getHitTestValue=function(e){return this._values[e]};TreeMap.prototype._getHitTestLabel=function(e){return this._labels[e]};TreeMap._CSS_ITEMDEPTH="wj-treemap-item-depth";TreeMap._MARGIN=0;return TreeMap}(FlexChartBase);export{TreeMap};var _TreeMapItem=function(){function _TreeMapItem(){this.items=[];this.maxValue=Number.MIN_VALUE;this.minValue=Number.MAX_VALUE}_TreeMapItem.prototype.draw=function(e){var t=this.rect;e.strokeWidth=0;if(this.isTitle){e.fill=this.titleFill;e.stroke=this.titleStroke}else{e.fill=this.fill;e.stroke=this.stroke}e.drawRect(t.left,t.top,t.width,t.height,_TreeMapItem._CLASSNAME)};Object.defineProperty(_TreeMapItem.prototype,"itemsRect",{get:function(){var e=this.rect,t=this._rect,i=1===this.depth?2:.5;return this.isTitle?this.type===TreeMapType.Horizontal?new Rect(e.left+e.width+1,e.top,t.width-e.width-2*i,e.height+1):new Rect(e.left,e.top+e.height+1,e.width+1,t.height-e.height-2*i):new Rect(0,0,0,0)},enumerable:!0,configurable:!0});Object.defineProperty(_TreeMapItem.prototype,"rect",{get:function(){var e=this._rect,t=1===this.depth?2:.5,i=e.width,r=e.height,a=e.left,o=e.top;if(this.isTitle){if(this.type===TreeMapType.Horizontal){i=e.width>20?20:i;i=Math.max(20,i-2*t);r=r>2*t?r-2*t:0}else{r=e.height>20?20:r;r=Math.max(20,r-2*t);i=i>2*t?i-2*t:0}a+=t;o+=t}else{i=i>2*t?i-2*t:0;r=r>2*t?r-2*t:0}return new Rect(a,o,i,r)},set:function(e){e!=this._rect&&(this._rect=e)},enumerable:!0,configurable:!0});Object.defineProperty(_TreeMapItem.prototype,"isTitle",{get:function(){return this._isTitle},set:function(e){var t=asBoolean(e,!0);t!==this._isTitle&&(this._isTitle=t)},enumerable:!0,configurable:!0});_TreeMapItem._CLASSNAME="wj-treemap-item";return _TreeMapItem}(),_ColorConverter=function(){function _ColorConverter(e,t,i,r,a,o){this.minColor=new Color(e);this.minColorValue=t;this.maxColor=new Color(i);this.maxColorValue=r;this.midColorValue=this.originalMidColorValue=o;this._calculateMidColorValue();this.midColor=this.originalMidColor=new Color(a);this._calculateMidColor()}_ColorConverter.prototype._resetminColor=function(e){this.minColor=new Color(e);this._calculateMidColor()};_ColorConverter.prototype._resetmidColor=function(e){this.midColor=this.originalMidColor=new Color(e);this._calculateMidColor()};_ColorConverter.prototype._resetmaxColor=function(e){this.maxColor=new Color(e);this._calculateMidColor()};_ColorConverter.prototype._resetminColorValue=function(e){this.minColorValue=e;this._calculateMidColorValue()};_ColorConverter.prototype._resetmidColorValue=function(e){this.midColorValue=this.originalMidColorValue=e;this._calculateMidColorValue()};_ColorConverter.prototype._resetmaxColorValue=function(e){this.maxColorValue=e;this._calculateMidColorValue()};_ColorConverter.prototype._calculateMidColorValue=function(){null==this.originalMidColorValue&&(this.midColorValue=(this.maxColorValue+this.minColorValue)/2)};_ColorConverter.prototype._calculateMidColor=function(){null==this.originalMidColor&&(this.midColor=this._calculateColorByVal(this.midColorValue,!0))};_ColorConverter.prototype._calculateColorByVal=function(e,t){void 0===t&&(t=!1);var i=this.maxColor,r=this.minColor,a=this.maxColorValue,o=this.minColorValue;if(e>=this.maxColorValue)return new Color(i.toString());if(e<=this.minColorValue)return new Color(r.toString());if(!t){if(e===this.midColorValue)return new Color(this.midColor.toString());if(e<this.midColorValue){i=this.midColor;a=this.midColorValue}else{r=this.midColor;o=this.midColorValue}}return this._getColor(e,i,a,r,o)};_ColorConverter.prototype._getColor=function(e,t,i,r,a){return Color.fromRgba(this._getValueByRatio(e,t.r,i,r.r,a),this._getValueByRatio(e,t.g,i,r.g,a),this._getValueByRatio(e,t.b,i,r.b,a),this._getValueByRatio(e,t.a,i,r.a,a))};_ColorConverter.prototype._getValueByRatio=function(e,t,i,r,a){return Math.abs(r+Math.round((e-a)*(t-r)/(i-a)))};return _ColorConverter}(),_TreeMapUtils=function(){function _TreeMapUtils(){}_TreeMapUtils.squarified=function(e,t,i){var r=e.slice(),a=t.clone(),o=a.width*a.height/i;do{var n=_TreeMapUtils.getRowedItems(r,a,o);_TreeMapUtils.layoutRowedItems(t,n,a,a.width>a.height)}while(r.length)};_TreeMapUtils.horizontal=function(e,t,i){var r=t.clone();e.forEach((function(e){var a=[{item:e,val:e.value*t.width*t.height/i}];_TreeMapUtils.layoutRowedItems(t,a,r,!1)}))};_TreeMapUtils.vertical=function(e,t,i){var r=t.clone();e.forEach((function(e){var a=[{item:e,val:e.value*t.width*t.height/i}];_TreeMapUtils.layoutRowedItems(t,a,r,!0)}))};_TreeMapUtils.getNarrowLen=function(e){return Math.min(e.width,e.height)};_TreeMapUtils.getRowedItem=function(e,t,i){return{item:e,val:i*e.value}};_TreeMapUtils.getRowedItems=function(e,t,i){var r=e.shift(),a=[],o=[],n=_TreeMapUtils.getNarrowLen(t),l=_TreeMapUtils.getRowedItem(r,t,i);a.push(l);o.push(l);if(e.length>0)do{o.push(_TreeMapUtils.getRowedItem(e[0],t,i));if(!(_TreeMapUtils.worst(a,n)>_TreeMapUtils.worst(o,n)))break;a=o.slice();e.shift()}while(e.length);return a};_TreeMapUtils.layoutRowedItems=function(e,t,i,r){var a,o=i.left,n=i.top,l=o+i.width,s=n+i.height,h=_TreeMapUtils.sumRowedArray(t);if(r){a=0===i.height?0:h/i.height;o+a>=l&&(a=l-o);t.forEach((function(e,i){var r=0===a?0:e.val/a;(n+r>s||i===t.length-1)&&(r=s-n);var l=new Rect(o,n,a,r);e.item.rect=l;n+=r}));i.left+=a;i.width-=a}else{a=0===i.width?0:h/i.width;n+a>=s&&(a=s-n);t.forEach((function(e,i){var r=0===a?0:e.val/a;(o+r>l||i===t.length-1)&&(r=l-o);var s=new Rect(o,n,r,a);e.item.rect=s;o+=r}));i.top+=a;i.height-=a}};_TreeMapUtils.sumRowedArray=function(e){for(var t=0,i=e.length,r=0;r<i;r++)t+=e[r].val;return t};_TreeMapUtils.worst=function(e,t){var i,r,a=_TreeMapUtils.sumRowedArray(e),o=a*a,n=t*t;i=r=e[0].val;e.forEach((function(e,t){e.val>i?i=e.val:e.val<r&&(r=e.val)}));return Math.max(n*i/o,o/(n*r))};return _TreeMapUtils}(),Sunburst=function(e){__extends(Sunburst,e);function Sunburst(t,i){var r=e.call(this,t,i)||this;r._selectionIndex=0;r.applyTemplate("wj-sunburst",null,null);r.initialize(i);r.refresh();return r}Object.defineProperty(Sunburst.prototype,"bindingName",{get:function(){return this._bindName},set:function(e){if(e!=this._bindName){assert(null==e||isArray(e)||isString(e),"bindingName should be an array or a string.");this._bindName=e;this._bindChart()}},enumerable:!0,configurable:!0});Object.defineProperty(Sunburst.prototype,"childItemsPath",{get:function(){return this._childItemsPath},set:function(e){if(e!=this._childItemsPath){assert(null==e||isArray(e)||isString(e),"childItemsPath should be an array or a string.");this._childItemsPath=e;this._bindChart()}},enumerable:!0,configurable:!0});Sunburst.prototype._initData=function(){e.prototype._initData.call(this);this._processedData=[];this._level=1;this._legendLabels=[];this._processedItem=[];this._values[0]=[]};Sunburst.prototype._performBind=function(){var e,t=this;this._initData();if(this._cv){e=this._cv.items;this._cv.groups&&this._cv.groups.length?this._processedData=HierarchicalUtil.parseDataToHierarchical(this._cv,this.binding,this.bindingName,this.childItemsPath):e&&(this._processedData=HierarchicalUtil.parseDataToHierarchical(e,this.binding,this.bindingName,this.childItemsPath));if(this._processedData&&this._processedData.length){this._sums[0]=this._sum=this._calculateValueAndLevel(this._processedData,1);this._processedData.forEach((function(e){t._legendLabels.push(e.name)}))}}};Sunburst.prototype._calculateValueAndLevel=function(e,t){var i=this,r=0,a=this._values[0],o=this._labels;this._level<t&&(this._level=t);e.forEach((function(e){var n;if(e.items){n=i._calculateValueAndLevel(e.items,t+1);e.value=n;a.push(n);o.push(e.name)}else{n=i._getBindData(e,a,o,"value","name");e.value=n}r+=n}));return r};Sunburst.prototype._renderPie=function(e,t,i,r,a,o){var n=this._getCenter();this._sliceIndex=0;this._parentRef={};this._renderHierarchicalSlices(e,n.x,n.y,this._processedData,this._sum,i,r,a,2*Math.PI,o,1)};Sunburst.prototype._renderHierarchicalSlices=function(e,t,i,r,a,o,n,l,s,h,c){var u,p,_,d,m,f,g,v,C,T,b=r.length,y=l,M=1==this.reversed;_=(o-n)/this._level;u=o-(this._level-c)*_;p=n+(c-1)*_;for(var I=0;I<b;I++){v=t;C=i;g=e.startGroup("wj-slice slice-level"+c);if(1===c){e.fill=this._getColorLight(I);e.stroke=this._getColor(I)}m=r[I];f=Math.abs(m.value);d=Math.abs(f-a)<1e-10?s:s*f/a;T=M?y-.5*d:y+.5*d;if(h>0&&d<s){v+=h*Math.cos(T);C+=h*Math.sin(T)}if(m.items){var w=this._sliceIndex;this._renderHierarchicalSlices(e,v,C,m.items,f,o,n,y,d,0,c+1);for(;w<this._sliceIndex;w++)null==this._parentRef[w]&&(this._parentRef[w]=this._sliceIndex)}this._renderSlice(e,v,C,T,0,this._sliceIndex,u,p,y,d,s);this._processedItem.push(m.item);this._sliceIndex++;M?y-=d:y+=d;e.endGroup();this._pels.push(g)}};Sunburst.prototype._getLabelsForLegend=function(){return this._legendLabels||[]};Sunburst.prototype._highlightCurrent=function(){this.selectionMode!=SelectionMode.None&&this._highlight(!0,this._selectionIndex)};Sunburst.prototype.hitTest=function(t,i){var r=e.prototype.hitTest.call(this,t,i),a=this._toControl(t,i);if(FlexChartBase._contains(this._rectChart,a)){var o=r.pointIndex,n=this._processedItem[o],l=new _DataPoint(null,o,null,null);l.item=n;r._setDataPoint(l)}return r};Sunburst.prototype._getSelectedItemOffset=function(e,t){var i=0,r=0,a=0;if(this.selectedItemOffset>0)if(e==this.selectedIndex)a=this.selectedItemOffset;else{var o=this._getSelectedParentIndex(e);if(null!=o){var n=this._areas[o];this.dataLabel.position;a=this.selectedItemOffset;t=((t=n.langle+this._rotationAngles[0])%360+360)%360;t*=Math.PI/180}}if(a>0){i=Math.cos(t)*a*this._radius;r=Math.sin(t)*a*this._radius}return{x:i,y:r}};Sunburst.prototype._getSelectedParentIndex=function(e){var t=this._parentRef[e];return null!=t?t===this.selectedIndex?t:this._getSelectedParentIndex(t):null};return Sunburst}(FlexPie);export{Sunburst};_registerModule("wijmo.chart.hierarchical",selfModule);
14
+ var __extends=this&&this.__extends||function(){var extendStatics=function(e,t){return(extendStatics=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var i in t)t.hasOwnProperty(i)&&(e[i]=t[i])})(e,t)};return function(e,t){extendStatics(e,t);function __(){this.constructor=e}e.prototype=null===t?Object.create(t):(__.prototype=t.prototype,new __)}}();import{isString,isArray,CollectionView,Aggregate,assert,asEnum,Rect,Color,asBoolean,isFunction,Point,Size,isNumber,asNumber,asString,asArray,_registerModule}from"@mescius/wijmo";import{FlexPie,_DataPoint,HitTestInfo,SelectionMode,FlexChartBase,DataLabel,_KeyWords,FlexChart,ChartElement,Series,LabelPosition,DataLabelRenderEventArgs,RenderEventArgs,_RectArea,ChartTooltip,_SvgRenderEngine,Legend,Position}from"@mescius/wijmo.chart";import*as selfModule from"@mescius/wijmo.chart.hierarchical";var HierarchicalUtil=function(){function HierarchicalUtil(){}HierarchicalUtil.parseDataToHierarchical=function(e,t,i,r){var a,o=[];if(e instanceof CollectionView&&e.groups.length>0)o=HierarchicalUtil.parseGroupCV(e,t);else if(e.length>0){isString(i)&&i.indexOf(",")>-1&&(i=i.split(","));if(r)o=HierarchicalUtil.parseItems(e,t,i,r);else{a=HierarchicalUtil.convertFlatData(e,t,i);o=HierarchicalUtil.parseItems(a,"value",i,"items")}}return o};HierarchicalUtil.parseGroupCV=function(e,t){for(var i=[],r=0,a=e.groups.length;r<a;r++){var o=this.parseGroups(e.groups[r],t);i.push(o)}return i};HierarchicalUtil.parseGroups=function(e,t){var i={};i.name=e.name;i.nameField=e.groupDescription.propertyName;i.item=e.items;if(e.groups&&e.groups.length){i.items=[];for(var r=0,a=e.groups.length;r<a;r++){var o=this.parseGroups(e.groups[r],t);i.items.push(o)}}else e.isBottomLevel&&(i.value=e.getAggregate(Aggregate.Sum,t));return i};HierarchicalUtil.parseItems=function(e,t,i,r){var a,o=[],n=e.length;for(a=0;a<n;a++)o.push(HierarchicalUtil.parseItem(e[a],t,i,r));return o};HierarchicalUtil.isFlatItem=function(e,t){return!isArray(e[t])};HierarchicalUtil.convertFlatData=function(e,t,i){var r,a,o=[],n={},l=e.length;for(r=0;r<l;r++){a=e[r];HierarchicalUtil.convertFlatItem(n,a,t,isArray(i)?i:[i])}HierarchicalUtil.convertFlatToHierarchical(o,n);return o};HierarchicalUtil.convertFlatToHierarchical=function(e,t){var i=t.flatDataOrder;i&&i.forEach((function(i){var r,a={},o=t[i];a[t.field]=i;if(o.flatDataOrder){r=[];HierarchicalUtil.convertFlatToHierarchical(r,o);a.items=r}else a.value=o;e.push(a)}))};HierarchicalUtil.convertFlatItem=function(e,t,i,r){var a,o,n,l;o=(a=r.slice()).shift();if(null==(n=null==(o=isString(o)?o.trim():o)?i:t[o]))return!1;if(0===a.length){e[n]=t[i]||0;e.flatDataOrder?e.flatDataOrder.push(n):e.flatDataOrder=[n];e.field=o}else{if(null==e[n]){e[n]={};e.flatDataOrder?e.flatDataOrder.push(n):e.flatDataOrder=[n];e.field=o}l=e[n];HierarchicalUtil.convertFlatItem(l,t,i,a)||(e[n]=t[i])}return!0};HierarchicalUtil.parseItem=function(e,t,i,r){var a,o,n,l,s,h={};if(isArray(r))l=(s=r.slice()).length?s.shift().trim():"";else{s=r;l=r}if(isArray(i)){o=null==(o=(a=i.slice()).shift())?o:o.trim();h.nameField=null==o?t:o;h.name=null==o?e[t]:e[o];n=e[l];0===a.length?h.value=e[t]:n&&isArray(n)&&n.length>0?h.items=HierarchicalUtil.parseItems(n,t,a,s):h.value=e[t]||0}else{h.nameField=null==i?t:i;h.name=null==i?e[t]:e[i];null!=(n=e[l])&&isArray(n)&&n.length>0?h.items=HierarchicalUtil.parseItems(n,t,i,s):h.value=e[t]}h.item=e;return h};HierarchicalUtil.parseFlatItem=function(e,t,i,r){e.items||(e.items=[])};return HierarchicalUtil}();export{HierarchicalUtil};export var TreeMapType;!function(e){e[e.Squarified=0]="Squarified";e[e.Horizontal=1]="Horizontal";e[e.Vertical=2]="Vertical"}(TreeMapType||(TreeMapType={}));var TreeMap=function(e){__extends(TreeMap,e);function TreeMap(t,i){var r=e.call(this,t,null,!0)||this;r._values=[];r._labels=[];r._areas=[];r._sum=0;r._keywords=new _KeyWords;r._processedData=[];r._depth=1;r._itemIndex=0;r._processedItem=[];r._maxDepth=-1;r._tmItems=[];r._colRowLens=[];r._defPalette=[{titleColor:"#033884",maxColor:"#1450a7",minColor:"#83b3f9"},{titleColor:"#a83100",maxColor:"#dc4a0d",minColor:"#ffb190"},{titleColor:"#006658",maxColor:"#008d7a",minColor:"#7deddf"},{titleColor:"#a10046",maxColor:"#df0061",minColor:"#ff8cbe"},{titleColor:"#784d08",maxColor:"#99681a",minColor:"#efc989"},{titleColor:"#54156f",maxColor:"#722a90",minColor:"#cf95e7"},{titleColor:"#998605",maxColor:"#c2ac19",minColor:"#ffef8b"},{titleColor:"#9a0005",maxColor:"#c80c14",minColor:"#ff888d"}];r.applyTemplate("wj-control wj-flexchart wj-treemap",null,null);r._currentRenderEngine=new _SvgRenderEngine(r.hostElement);r._legend=new Legend(r);r._legend.position=Position.None;r._tooltip=new ChartTooltip;r._tooltip.content="<b>{name}</b><br/>{value}";r._tooltip.showDelay=0;r._lbl=new DataLabel;r._lbl.position=LabelPosition.Center;r._lbl._chart=r;r.hostElement.addEventListener("mousemove",(function(e){r.isTouching||r._toogleTooltip(e)}));r.hostElement.addEventListener("click",(function(e){var t=!0;if(r.maxDepth>0){var i=r.hitTest(e),a=FlexChart._SELECTION_THRESHOLD;r.tooltip&&r.tooltip.threshold&&(a=r.tooltip.threshold);if(i.distance<=a&&i.pointIndex>=-1&&i.pointIndex<r._areas.length){var o=r._areas[i.pointIndex];if(r._currentItem!=o.item){r._currentItem=o.item;r._refreshChart();t=!1}}}t&&r.isTouching&&r._toogleTooltip(e)}));r.hostElement.addEventListener("contextmenu",(function(e){if(r.maxDepth>0){var t=r.hitTest(e),i=FlexChart._SELECTION_THRESHOLD;r.tooltip&&r.tooltip.threshold&&(i=r.tooltip.threshold);t.distance<=i&&r._rollUp()}e.preventDefault();return!1}));r.hostElement.addEventListener("mouseleave",(function(){r._hideToolTip()}));r.deferUpdate((function(){return r.initialize(i)}));return r}TreeMap.prototype._rollUp=function(){this._currentItem=this._currentItem&&this._currentItem.parent?this._currentItem.parent:null;this._refreshChart()};TreeMap.prototype._toogleTooltip=function(e){var t=this._tooltip;if(t.content){var i=this.hitTest(e);if(i.distance<=t.threshold){var r=this._getLabelContent(i,this.tooltip.content);this._showToolTip(r,new Rect(e.clientX,e.clientY,5,5))}else this._hideToolTip()}};Object.defineProperty(TreeMap.prototype,"selectionMode",{get:function(){return SelectionMode.None},set:function(e){},enumerable:!0,configurable:!0});Object.defineProperty(TreeMap.prototype,"_treeMapItems",{get:function(){return this._tmItems},enumerable:!0,configurable:!0});Object.defineProperty(TreeMap.prototype,"tooltip",{get:function(){return this._tooltip},enumerable:!0,configurable:!0});Object.defineProperty(TreeMap.prototype,"binding",{get:function(){return this._binding},set:function(e){if(e!=this._binding){this._binding=asString(e,!0);this._bindChart()}},enumerable:!0,configurable:!0});Object.defineProperty(TreeMap.prototype,"type",{get:function(){return null==this._type?TreeMapType.Squarified:this._type},set:function(e){if((e=asEnum(e,TreeMapType))!=this._type){this._type=e;this.invalidate()}},enumerable:!0,configurable:!0});Object.defineProperty(TreeMap.prototype,"bindingName",{get:function(){return this._bindingName},set:function(e){if(e!=this._bindingName){assert(null==e||isArray(e)||isString(e),"bindingName should be an array or a string.");this._bindingName=e;this._bindChart()}},enumerable:!0,configurable:!0});Object.defineProperty(TreeMap.prototype,"dataLabel",{get:function(){return this._lbl},set:function(e){if(e!=this._lbl){this._lbl=e;this._lbl&&(this._lbl._chart=this)}},enumerable:!0,configurable:!0});Object.defineProperty(TreeMap.prototype,"childItemsPath",{get:function(){return this._childItemsPath},set:function(e){if(e!=this._childItemsPath){assert(null==e||isArray(e)||isString(e),"childItemsPath should be an array or a string.");this._childItemsPath=e;this._bindChart()}},enumerable:!0,configurable:!0});Object.defineProperty(TreeMap.prototype,"maxDepth",{get:function(){return this._maxDepth},set:function(e){if(e!=this._maxDepth){this._maxDepth=asNumber(e,!0);this.invalidate()}},enumerable:!0,configurable:!0});Object.defineProperty(TreeMap.prototype,"palette",{get:function(){return this._palette},set:function(e){if(e!=this._palette){this._palette=asArray(e);this._tmItems&&this._tmItems.length>0&&this._calculateColorForItems(this._tmItems);this.invalidate()}},enumerable:!0,configurable:!0});TreeMap.prototype._initData=function(){this._sum=0;this._tmItems=[];this._currentItem=null;this._values=[];this._labels=[];this._processedData=[];this._depth=1;this._processedItem=[]};TreeMap.prototype._performBind=function(){var e;this._initData();if(this._cv){e=this._cv.items;this._cv.groups&&this._cv.groups.length?this._processedData=HierarchicalUtil.parseDataToHierarchical(this._cv,this.binding,this.bindingName,this.childItemsPath):e&&(this._processedData=HierarchicalUtil.parseDataToHierarchical(e,this.binding,this.bindingName,this.childItemsPath));if(this._processedData&&this._processedData.length){this._sum=this._calculateValueAndDepth(this._processedData,1);this._sortData(this._processedData);this._values=[];this._getTMItemsAndLabelsAndValues(this._processedData,this._tmItems,1,null);this._calculateColorForItems(this._tmItems)}}};TreeMap.prototype._sortData=function(e){var t=this;e.forEach((function(e){e.items&&t._sortData(e.items)}));e.sort((function(e,t){return t.value-e.value}))};TreeMap.prototype._getTMItemsAndLabelsAndValues=function(e,t,i,r,a){var o=this;e&&e.length>0&&e.forEach((function(e,a){var n,l=new _TreeMapItem;l.items=[];l.parent=r;l.depth=i;e.items&&o._getTMItemsAndLabelsAndValues(e.items,l.items,i+1,l);n=e.name?e.name:e.value.toString();l.label=n;l.value=e.value;if(null!=r){e.value>r.maxValue&&(r.maxValue=e.value);e.value<r.minValue&&(r.minValue=e.value)}t.push(l);o._labels.push(n);o._values.push(e.value)}))};TreeMap.prototype._calculateColorForItems=function(e,t,i){var r=this,a=i;e.forEach((function(e,i){var o=t;1===e.depth&&(o=r._getColor(i));e.palette=o;var n=e.palette;if(isString(n)){var l=n,s=r._getLightColor(l);e.titleFill=l;e.titleStroke=l;e.fill=s;e.stroke=l}else if(n.maxColor&&n.minColor&&n.titleColor){e.titleFill=n.titleColor;e.titleStroke=n.titleColor;if(null==e.parent){e.fill=n.maxColor;e.stroke=n.maxColor}else{null==a&&(a=new _ColorConverter(n.minColor,e.minValue,n.maxColor,e.maxValue));var h=a._calculateColorByVal(e.value,!0).toString();e.fill=h;e.stroke=h}}if(e.items&&e.items.length>0){var u=new _ColorConverter(n.minColor,e.minValue,n.maxColor,e.maxValue);r._calculateColorForItems(e.items,o,u)}}))};TreeMap.prototype._getBindData=function(e,t,i){var r,a=0;i&&(r=e[i]);a=0;isNumber(r)?a=asNumber(r):r&&(a=parseFloat(r.toString()));if(!isNaN(a)&&isFinite(a))t.push(a);else{a=0;t.push(a)}return a};TreeMap.prototype._calculateValueAndDepth=function(e,t){var i=this,r=0,a=this._values;this._depth<t&&(this._depth=t);e.forEach((function(e){var o;if(e.items){o=i._calculateValueAndDepth(e.items,t+1);e.value=o;a.push(o)}else{o=i._getBindData(e,a,"value");e.value=o}r+=o}));return r};TreeMap.prototype._prepareRender=function(){this._areas=[]};TreeMap.prototype._renderChart=function(e,t,i){var r,a,o,n=this._rectChart.clone();new Size(n.width,n.height);this.onRendering(new RenderEventArgs(e));var l=t.width,s=t.height;this._tmGroup=e.startGroup(null,null,!0);var h=this._parseMargin(this.plotMargin);this.dataLabel;isNaN(h.left)&&(h.left=TreeMap._MARGIN);isNaN(h.right)&&(h.right=TreeMap._MARGIN);isNaN(h.top)&&(h.top=TreeMap._MARGIN);isNaN(h.bottom)&&(h.bottom=TreeMap._MARGIN);t.top+=h.top;s=t.height-(h.top+h.bottom);t.height=s>0?s:24;t.left+=h.left;l=t.width-(h.left+h.right);t.width=l>0?l:24;this._plotRect=t;r=this._currentItem?[this._currentItem]:this._tmItems;a=null==this._currentItem||this.maxDepth<1?this.maxDepth:this._currentItem&&this._currentItem.items&&this._currentItem.items.length&&this.maxDepth>1?this.maxDepth:this.maxDepth+1;o=this._currentItem?this._currentItem.value:this._sum;this._renderTreeMap(e,t,this._tmGroup,r,o,a);e.endGroup();this.dataLabel.content&&this.dataLabel.position!=LabelPosition.None&&this._renderLabels(e);this.onRendered(new RenderEventArgs(e))};TreeMap.prototype._renderTreeMap=function(e,t,i,r,a,o){if(a>0){this._itemIndex=0;this._resetItemRects(this._tmItems);this._calculateItemRects(t,r,a,1,o);this._renderHierarchicalTreeMapItems(e,i,t,this._tmItems,a,1,o)}};TreeMap.prototype._resetItemRects=function(e){var t=this;e.forEach((function(e){e.rect=new Rect(0,0,0,0);e.isTitle=!1;e.type=t.type;e.items&&e.items.length&&t._resetItemRects(e.items)}))};TreeMap.prototype._calculateItemRects=function(e,t,i,r,a){var o=this;switch(this.type){case TreeMapType.Horizontal:_TreeMapUtils.horizontal(t,e,i);break;case TreeMapType.Vertical:_TreeMapUtils.vertical(t,e,i);break;case TreeMapType.Squarified:_TreeMapUtils.squarified(t,e,i)}t.forEach((function(e,t){e.rect.clone();if(e.items&&e.items.length)if(r===a);else if(r>a&&a>=1);else{e.isTitle=!0;o._calculateItemRects(e.itemsRect,e.items,e.value,r+1,a)}}))};TreeMap.prototype._renderHierarchicalTreeMapItems=function(e,t,i,r,a,o,n){var l,s,h,u,c,p=r.length;this.type;if(0!==p)for(var _=0;_<p;_++){l=e.startGroup(TreeMap._CSS_ITEMDEPTH+o);s=r[_];h=Math.abs(s.value);u=s.rect;s.draw(e);c=new _RectArea(u);s.items&&this._renderHierarchicalTreeMapItems(e,l,s.itemsRect,s.items,h,o+1,n);c.tag=this._itemIndex;c.name=s.label;c.value=h;c.item=s;this._areas.push(c);this._itemIndex++;e.endGroup()}};TreeMap.prototype._renderLabels=function(e){var t,i=this._areas.length,r=this.dataLabel,a=r.position,o=r.connectingLine,n=r.border,l=r.offset||0;e.stroke="null";e.fill="transparent";e.strokeWidth=1;e.startGroup("wj-data-labels");for(var s=0;s<i;s++){var h=this._areas[s];if(h){var u=h.rect,c=new HitTestInfo(this,t);c._setData(null,s);var p=this._getLabelContent(c,r.content);t=new Point(u.left+u.width/2,u.top+u.height/2);if(p&&u.width>0&&u.height>0){var _=new DataLabelRenderEventArgs(e,c,t,p);if(r.onRendering(_)){p=_.text;t=_.point;this._renderLabelAndBorder(e,h,u,p,a,l,t,o,2,n)}}}}e.endGroup()};TreeMap.prototype._renderLabelAndBorder=function(e,t,i,r,a,o,n,l,s,h){var u,c="wj-data-label",p="wj-data-label-line";switch(a){case LabelPosition.Top:l&&e.drawLine(n.x,n.y,n.x,n.y-o,p);n.y-=s+o;u=this._renderText(e,t,i,r,n,1,2,c);break;case LabelPosition.Bottom:l&&e.drawLine(n.x,n.y,n.x,n.y+o,p);n.y+=s+o;u=this._renderText(e,t,i,r,n,1,0,c);break;case LabelPosition.Left:l&&e.drawLine(n.x,n.y,n.x-o,n.y,p);n.x-=s+o;u=this._renderText(e,t,i,r,n,2,1,c);break;case LabelPosition.Right:l&&e.drawLine(n.x,n.y,n.x+o,n.y,p);n.x+=s+o;u=this._renderText(e,t,i,r,n,0,1,c);break;case LabelPosition.Center:u=this._renderText(e,t,i,r,n,1,1,c)}h&&u&&e.drawRect(u.left-s,u.top-s,u.width+2*s,u.height+2*s,"wj-data-label-border");return u};TreeMap.prototype._renderText=function(e,t,i,r,a,o,n,l){var s,h=r,u=t.item;s=e.measureString(r,l);if(this.type===TreeMapType.Horizontal&&u.isTitle){s.width>i.height&&(h=this._cutText(r,s.width,i.height));FlexChart._renderRotatedText(e,h,a,o,n,a,-90,l);return null}s.width>i.width&&(h=this._cutText(r,s.width,i.width));return FlexChart._renderText(e,h,a,o,n,l)};TreeMap.prototype._cutText=function(e,t,i){var r="",a=e.length,o=Math.floor((1-(t-i)/t)*a);e.length>0&&(r=e[0]+(o>1?e.substring(1,o-1)+"..":""));return r};TreeMap.prototype._measureLegendItem=function(e,t){var i=new Size;i.width=Series._LEGEND_ITEM_WIDTH;i.height=Series._LEGEND_ITEM_HEIGHT;if(t){var r=e.measureString(t,FlexChart._CSS_LABEL,FlexChart._CSS_LEGEND);i.width+=r.width;i.height<r.height&&(i.height=r.height)}i.width+=3*Series._LEGEND_ITEM_MARGIN;i.height+=2*Series._LEGEND_ITEM_MARGIN;return i};TreeMap.prototype._getDesiredLegendSize=function(e,t,i,r){var a=new Size,o=(new Size(i,r),this._tmItems.length),n=0,l=0;this._colRowLens=[];for(var s=0;s<o;s++){var h=this._measureLegendItem(e,this._tmItems[s].label);if(t){if(l+h.height>r){a.height=r;this._colRowLens.push(n);n=0;l=0}n<h.width&&(n=h.width);l+=h.height}else{if(n+h.width>i){a.width=i;this._colRowLens.push(l);l=0;n=0}l<h.height&&(l=h.height);n+=h.width}}if(t){a.height<l&&(a.height=l);this._colRowLens.push(n);a.width=this._colRowLens.reduce((function(e,t){return e+t}),0);a.width=this._getLegendSize(i,a.width)}else{a.width<n&&(a.width=n);this._colRowLens.push(l);a.height=this._colRowLens.reduce((function(e,t){return e+t}),0);a.height=this._getLegendSize(r,a.height)}return a};TreeMap.prototype._renderLegend=function(e,t,i,r,a,o){for(var n,l=this._rectLegend,s=this._tmItems.length,h=0,u=t.clone(),c=0;c<s;c++){n=this._tmItems[c].label;var p=this._measureLegendItem(e,n);if(r){if(u.y+p.height>l.top+l.height+1){u.x+=this._colRowLens[h];h++;u.y=t.y}}else if(u.x+p.width>l.left+l.width+1){u.y+=this._colRowLens[h];h++;u.x=t.x}var _=new Rect(u.x,u.y,p.width,p.height);this._drawLegendItem(e,_,c,n);i.push(_);r?u.y+=p.height:u.x+=p.width}};TreeMap.prototype._drawLegendItem=function(e,t,i,r){e.strokeWidth=1;var a=Series._LEGEND_ITEM_MARGIN,o=this._getColor(i),n=o&&o.maxColor?o.maxColor:o,l=this._getLightColor(n);e.fill=n;e.stroke=l;var s=t.top+.5*t.height,h=Series._LEGEND_ITEM_WIDTH,u=Series._LEGEND_ITEM_HEIGHT;e.drawRect(t.left+a,s-.5*u,h,u,null);r&&FlexChart._renderText(e,r,new Point(t.left+u+2*a,s),0,1,FlexChart._CSS_LABEL)};TreeMap.prototype._getLabelContent=function(e,t){return isString(t)?this._keywords.replace(t,e):isFunction(t)?t(e):null};TreeMap.prototype.hitTest=function(e,t){var i=this._toControl(e,t),r=new HitTestInfo(this,i),a=null;if(FlexChart._contains(this._rectHeader,i))r._chartElement=ChartElement.Header;else if(FlexChart._contains(this._rectFooter,i))r._chartElement=ChartElement.Footer;else if(FlexChart._contains(this._rectLegend,i)){r._chartElement=ChartElement.Legend;null!==(a=this.legend._hitTest(i))&&a>=0&&a<this._areas.length&&r._setData(null,a)}else if(FlexChart._contains(this._rectChart,i)){for(var o,n=this._areas.length,l=NaN,s=0;s<n;s++){var h=i.clone(),u=this._areas[s];if(u.contains(h)){r._setData(null,u.tag);r._dist=0}var c=u.distance(h);if(void 0!==c&&(isNaN(l)||c<l)){l=c;o=u}}if(0!==r._dist&&null!=o){r._setData(null,o.tag);r._dist=l}r._chartElement=ChartElement.ChartArea}else r._chartElement=ChartElement.None;return r};TreeMap.prototype._getHitTestItem=function(e){var t=null,i=null;(t=null!=this._cv?this._cv.items:this.itemsSource)&&e<t.length&&(i=t[e]);return i};TreeMap.prototype._getHitTestValue=function(e){return this._values[e]};TreeMap.prototype._getHitTestLabel=function(e){return this._labels[e]};TreeMap._CSS_ITEMDEPTH="wj-treemap-item-depth";TreeMap._MARGIN=0;return TreeMap}(FlexChartBase);export{TreeMap};var _TreeMapItem=function(){function _TreeMapItem(){this.items=[];this.maxValue=Number.MIN_VALUE;this.minValue=Number.MAX_VALUE}_TreeMapItem.prototype.draw=function(e){var t=this.rect;e.strokeWidth=0;if(this.isTitle){e.fill=this.titleFill;e.stroke=this.titleStroke}else{e.fill=this.fill;e.stroke=this.stroke}e.drawRect(t.left,t.top,t.width,t.height,_TreeMapItem._CLASSNAME)};Object.defineProperty(_TreeMapItem.prototype,"itemsRect",{get:function(){var e=this.rect,t=this._rect,i=1===this.depth?2:.5;return this.isTitle?this.type===TreeMapType.Horizontal?new Rect(e.left+e.width+1,e.top,t.width-e.width-2*i,e.height+1):new Rect(e.left,e.top+e.height+1,e.width+1,t.height-e.height-2*i):new Rect(0,0,0,0)},enumerable:!0,configurable:!0});Object.defineProperty(_TreeMapItem.prototype,"rect",{get:function(){var e=this._rect,t=1===this.depth?2:.5,i=e.width,r=e.height,a=e.left,o=e.top;if(this.isTitle){if(this.type===TreeMapType.Horizontal){i=e.width>20?20:i;i=Math.max(20,i-2*t);r=r>2*t?r-2*t:0}else{r=e.height>20?20:r;r=Math.max(20,r-2*t);i=i>2*t?i-2*t:0}a+=t;o+=t}else{i=i>2*t?i-2*t:0;r=r>2*t?r-2*t:0}return new Rect(a,o,i,r)},set:function(e){e!=this._rect&&(this._rect=e)},enumerable:!0,configurable:!0});Object.defineProperty(_TreeMapItem.prototype,"isTitle",{get:function(){return this._isTitle},set:function(e){var t=asBoolean(e,!0);t!==this._isTitle&&(this._isTitle=t)},enumerable:!0,configurable:!0});_TreeMapItem._CLASSNAME="wj-treemap-item";return _TreeMapItem}(),_ColorConverter=function(){function _ColorConverter(e,t,i,r,a,o){this.minColor=new Color(e);this.minColorValue=t;this.maxColor=new Color(i);this.maxColorValue=r;this.midColorValue=this.originalMidColorValue=o;this._calculateMidColorValue();this.midColor=this.originalMidColor=new Color(a);this._calculateMidColor()}_ColorConverter.prototype._resetminColor=function(e){this.minColor=new Color(e);this._calculateMidColor()};_ColorConverter.prototype._resetmidColor=function(e){this.midColor=this.originalMidColor=new Color(e);this._calculateMidColor()};_ColorConverter.prototype._resetmaxColor=function(e){this.maxColor=new Color(e);this._calculateMidColor()};_ColorConverter.prototype._resetminColorValue=function(e){this.minColorValue=e;this._calculateMidColorValue()};_ColorConverter.prototype._resetmidColorValue=function(e){this.midColorValue=this.originalMidColorValue=e;this._calculateMidColorValue()};_ColorConverter.prototype._resetmaxColorValue=function(e){this.maxColorValue=e;this._calculateMidColorValue()};_ColorConverter.prototype._calculateMidColorValue=function(){null==this.originalMidColorValue&&(this.midColorValue=(this.maxColorValue+this.minColorValue)/2)};_ColorConverter.prototype._calculateMidColor=function(){null==this.originalMidColor&&(this.midColor=this._calculateColorByVal(this.midColorValue,!0))};_ColorConverter.prototype._calculateColorByVal=function(e,t){void 0===t&&(t=!1);var i=this.maxColor,r=this.minColor,a=this.maxColorValue,o=this.minColorValue;if(e>=this.maxColorValue)return new Color(i.toString());if(e<=this.minColorValue)return new Color(r.toString());if(!t){if(e===this.midColorValue)return new Color(this.midColor.toString());if(e<this.midColorValue){i=this.midColor;a=this.midColorValue}else{r=this.midColor;o=this.midColorValue}}return this._getColor(e,i,a,r,o)};_ColorConverter.prototype._getColor=function(e,t,i,r,a){return Color.fromRgba(this._getValueByRatio(e,t.r,i,r.r,a),this._getValueByRatio(e,t.g,i,r.g,a),this._getValueByRatio(e,t.b,i,r.b,a),this._getValueByRatio(e,t.a,i,r.a,a))};_ColorConverter.prototype._getValueByRatio=function(e,t,i,r,a){return Math.abs(r+Math.round((e-a)*(t-r)/(i-a)))};return _ColorConverter}(),_TreeMapUtils=function(){function _TreeMapUtils(){}_TreeMapUtils.squarified=function(e,t,i){var r=e.slice(),a=t.clone(),o=a.width*a.height/i;do{var n=_TreeMapUtils.getRowedItems(r,a,o);_TreeMapUtils.layoutRowedItems(t,n,a,a.width>a.height)}while(r.length)};_TreeMapUtils.horizontal=function(e,t,i){var r=t.clone();e.forEach((function(e){var a=[{item:e,val:e.value*t.width*t.height/i}];_TreeMapUtils.layoutRowedItems(t,a,r,!1)}))};_TreeMapUtils.vertical=function(e,t,i){var r=t.clone();e.forEach((function(e){var a=[{item:e,val:e.value*t.width*t.height/i}];_TreeMapUtils.layoutRowedItems(t,a,r,!0)}))};_TreeMapUtils.getNarrowLen=function(e){return Math.min(e.width,e.height)};_TreeMapUtils.getRowedItem=function(e,t,i){return{item:e,val:i*e.value}};_TreeMapUtils.getRowedItems=function(e,t,i){var r=e.shift(),a=[],o=[],n=_TreeMapUtils.getNarrowLen(t),l=_TreeMapUtils.getRowedItem(r,t,i);a.push(l);o.push(l);if(e.length>0)do{o.push(_TreeMapUtils.getRowedItem(e[0],t,i));if(!(_TreeMapUtils.worst(a,n)>_TreeMapUtils.worst(o,n)))break;a=o.slice();e.shift()}while(e.length);return a};_TreeMapUtils.layoutRowedItems=function(e,t,i,r){var a,o=i.left,n=i.top,l=o+i.width,s=n+i.height,h=_TreeMapUtils.sumRowedArray(t);if(r){a=0===i.height?0:h/i.height;o+a>=l&&(a=l-o);t.forEach((function(e,i){var r=0===a?0:e.val/a;(n+r>s||i===t.length-1)&&(r=s-n);var l=new Rect(o,n,a,r);e.item.rect=l;n+=r}));i.left+=a;i.width-=a}else{a=0===i.width?0:h/i.width;n+a>=s&&(a=s-n);t.forEach((function(e,i){var r=0===a?0:e.val/a;(o+r>l||i===t.length-1)&&(r=l-o);var s=new Rect(o,n,r,a);e.item.rect=s;o+=r}));i.top+=a;i.height-=a}};_TreeMapUtils.sumRowedArray=function(e){for(var t=0,i=e.length,r=0;r<i;r++)t+=e[r].val;return t};_TreeMapUtils.worst=function(e,t){var i,r,a=_TreeMapUtils.sumRowedArray(e),o=a*a,n=t*t;i=r=e[0].val;e.forEach((function(e,t){e.val>i?i=e.val:e.val<r&&(r=e.val)}));return Math.max(n*i/o,o/(n*r))};return _TreeMapUtils}(),Sunburst=function(e){__extends(Sunburst,e);function Sunburst(t,i){var r=e.call(this,t,i)||this;r._selectionIndex=0;r.applyTemplate("wj-sunburst",null,null);r.initialize(i);r.refresh();return r}Object.defineProperty(Sunburst.prototype,"bindingName",{get:function(){return this._bindName},set:function(e){if(e!=this._bindName){assert(null==e||isArray(e)||isString(e),"bindingName should be an array or a string.");this._bindName=e;this._bindChart()}},enumerable:!0,configurable:!0});Object.defineProperty(Sunburst.prototype,"childItemsPath",{get:function(){return this._childItemsPath},set:function(e){if(e!=this._childItemsPath){assert(null==e||isArray(e)||isString(e),"childItemsPath should be an array or a string.");this._childItemsPath=e;this._bindChart()}},enumerable:!0,configurable:!0});Sunburst.prototype._initData=function(){e.prototype._initData.call(this);this._processedData=[];this._level=1;this._legendLabels=[];this._processedItem=[];this._values[0]=[]};Sunburst.prototype._performBind=function(){var e,t=this;this._initData();if(this._cv){e=this._cv.items;this._cv.groups&&this._cv.groups.length?this._processedData=HierarchicalUtil.parseDataToHierarchical(this._cv,this.binding,this.bindingName,this.childItemsPath):e&&(this._processedData=HierarchicalUtil.parseDataToHierarchical(e,this.binding,this.bindingName,this.childItemsPath));if(this._processedData&&this._processedData.length){this._sums[0]=this._sum=this._calculateValueAndLevel(this._processedData,1);this._processedData.forEach((function(e){t._legendLabels.push(e.name)}))}}};Sunburst.prototype._calculateValueAndLevel=function(e,t){var i=this,r=0,a=this._values[0],o=this._labels;this._level<t&&(this._level=t);e.forEach((function(e){var n;if(e.items){n=i._calculateValueAndLevel(e.items,t+1);e.value=n;a.push(n);o.push(e.name)}else{n=i._getBindData(e,a,o,"value","name");e.value=n}r+=n}));return r};Sunburst.prototype._renderPie=function(e,t,i,r,a,o){var n=this._getCenter();this._sliceIndex=0;this._parentRef={};this._renderHierarchicalSlices(e,n.x,n.y,this._processedData,this._sum,i,r,a,2*Math.PI,o,1)};Sunburst.prototype._renderHierarchicalSlices=function(e,t,i,r,a,o,n,l,s,h,u){var c,p,_,d,m,f,g,v,C,T,b=r.length,M=l,y=1==this.reversed;_=(o-n)/this._level;c=o-(this._level-u)*_;p=n+(u-1)*_;for(var I=0;I<b;I++){v=t;C=i;g=e.startGroup("wj-slice slice-level"+u);if(1===u){e.fill=this._getColorLight(I);e.stroke=this._getColor(I)}m=r[I];f=Math.abs(m.value);d=Math.abs(f-a)<1e-10?s:s*f/a;T=y?M-.5*d:M+.5*d;if(h>0&&d<s){v+=h*Math.cos(T);C+=h*Math.sin(T)}if(m.items){var w=this._sliceIndex;this._renderHierarchicalSlices(e,v,C,m.items,f,o,n,M,d,0,u+1);for(;w<this._sliceIndex;w++)null==this._parentRef[w]&&(this._parentRef[w]=this._sliceIndex)}this._renderSlice(e,v,C,T,0,this._sliceIndex,c,p,M,d,s);this._processedItem.push(m.item);this._sliceIndex++;y?M-=d:M+=d;e.endGroup();this._pels.push(g)}};Sunburst.prototype._getLabelsForLegend=function(){return this._legendLabels||[]};Sunburst.prototype._highlightCurrent=function(){this.selectionMode!=SelectionMode.None&&this._highlight(!0,this._selectionIndex)};Sunburst.prototype.hitTest=function(t,i){var r=e.prototype.hitTest.call(this,t,i),a=this._toControl(t,i);if(FlexChartBase._contains(this._rectChart,a)){var o=r.pointIndex,n=this._processedItem[o],l=new _DataPoint(null,o,null,null);l.item=n;r._setDataPoint(l)}return r};Sunburst.prototype._getSelectedItemOffset=function(e,t){var i=0,r=0,a=0;if(this.selectedItemOffset>0)if(e==this.selectedIndex)a=this.selectedItemOffset;else{var o=this._getSelectedParentIndex(e);if(null!=o){var n=this._areas[o];this.dataLabel.position;a=this.selectedItemOffset;t=((t=n.langle+this._rotationAngles[0])%360+360)%360;t*=Math.PI/180}}if(a>0){i=Math.cos(t)*a*this._radius;r=Math.sin(t)*a*this._radius}return{x:i,y:r}};Sunburst.prototype._getSelectedParentIndex=function(e){var t=this._parentRef[e];return null!=t?t===this.selectedIndex?t:this._getSelectedParentIndex(t):null};return Sunburst}(FlexPie);export{Sunburst};_registerModule("wijmo.chart.hierarchical",selfModule);
package/index.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  /*!
2
2
  *
3
- * Wijmo Library 5.20232.939
3
+ * Wijmo Library 5.20241.3
4
4
  * https://developer.mescius.com/wijmo
5
5
  *
6
6
  * Copyright(c) MESCIUS inc. All rights reserved.
@@ -18,8 +18,8 @@
18
18
  *
19
19
  */
20
20
  export declare var ___keepComment: any;
21
- import { Rect, Point, Size } from '@grapecity/wijmo';
22
- import { FlexPie, HitTestInfo, SelectionMode, FlexChartBase, IRenderEngine, DataLabel, ChartTooltip } from '@grapecity/wijmo.chart';
21
+ import { Rect, Point, Size } from '@mescius/wijmo';
22
+ import { FlexPie, HitTestInfo, SelectionMode, FlexChartBase, IRenderEngine, DataLabel, ChartTooltip } from '@mescius/wijmo.chart';
23
23
  export declare class HierarchicalUtil {
24
24
  static parseDataToHierarchical(data: any, binding: any, bindingName: any, childItemsPath: any): any[];
25
25
  private static parseGroupCV;
package/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  /*!
2
2
  *
3
- * Wijmo Library 5.20232.939
3
+ * Wijmo Library 5.20241.3
4
4
  * https://developer.mescius.com/wijmo
5
5
  *
6
6
  * Copyright(c) MESCIUS inc. All rights reserved.
@@ -11,4 +11,4 @@
11
11
  *
12
12
  */
13
13
 
14
- "use strict";var __extends=this&&this.__extends||function(){var extendStatics=function(e,t){return(extendStatics=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var i in t)t.hasOwnProperty(i)&&(e[i]=t[i])})(e,t)};return function(e,t){extendStatics(e,t);function __(){this.constructor=e}e.prototype=null===t?Object.create(t):(__.prototype=t.prototype,new __)}}(),__importStar=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var i in e)Object.hasOwnProperty.call(e,i)&&(t[i]=e[i]);t.default=e;return t};Object.defineProperty(exports,"__esModule",{value:!0});var TreeMapType,wijmo_1=require("@mescius/wijmo"),wijmo_chart_1=require("@mescius/wijmo.chart"),selfModule=__importStar(require("@mescius/wijmo.chart.hierarchical")),HierarchicalUtil=function(){function HierarchicalUtil(){}HierarchicalUtil.parseDataToHierarchical=function(e,t,i,r){var a,o=[];if(e instanceof wijmo_1.CollectionView&&e.groups.length>0)o=HierarchicalUtil.parseGroupCV(e,t);else if(e.length>0){wijmo_1.isString(i)&&i.indexOf(",")>-1&&(i=i.split(","));if(r)o=HierarchicalUtil.parseItems(e,t,i,r);else{a=HierarchicalUtil.convertFlatData(e,t,i);o=HierarchicalUtil.parseItems(a,"value",i,"items")}}return o};HierarchicalUtil.parseGroupCV=function(e,t){for(var i=[],r=0,a=e.groups.length;r<a;r++){var o=this.parseGroups(e.groups[r],t);i.push(o)}return i};HierarchicalUtil.parseGroups=function(e,t){var i={};i.name=e.name;i.nameField=e.groupDescription.propertyName;i.item=e.items;if(e.groups&&e.groups.length){i.items=[];for(var r=0,a=e.groups.length;r<a;r++){var o=this.parseGroups(e.groups[r],t);i.items.push(o)}}else e.isBottomLevel&&(i.value=e.getAggregate(wijmo_1.Aggregate.Sum,t));return i};HierarchicalUtil.parseItems=function(e,t,i,r){var a,o=[],n=e.length;for(a=0;a<n;a++)o.push(HierarchicalUtil.parseItem(e[a],t,i,r));return o};HierarchicalUtil.isFlatItem=function(e,t){return!wijmo_1.isArray(e[t])};HierarchicalUtil.convertFlatData=function(e,t,i){var r,a,o=[],n={},l=e.length;for(r=0;r<l;r++){a=e[r];HierarchicalUtil.convertFlatItem(n,a,t,wijmo_1.isArray(i)?i:[i])}HierarchicalUtil.convertFlatToHierarchical(o,n);return o};HierarchicalUtil.convertFlatToHierarchical=function(e,t){var i=t.flatDataOrder;i&&i.forEach((function(i){var r,a={},o=t[i];a[t.field]=i;if(o.flatDataOrder){r=[];HierarchicalUtil.convertFlatToHierarchical(r,o);a.items=r}else a.value=o;e.push(a)}))};HierarchicalUtil.convertFlatItem=function(e,t,i,r){var a,o,n,l;o=(a=r.slice()).shift();if(null==(n=null==(o=wijmo_1.isString(o)?o.trim():o)?i:t[o]))return!1;if(0===a.length){e[n]=t[i]||0;e.flatDataOrder?e.flatDataOrder.push(n):e.flatDataOrder=[n];e.field=o}else{if(null==e[n]){e[n]={};e.flatDataOrder?e.flatDataOrder.push(n):e.flatDataOrder=[n];e.field=o}l=e[n];HierarchicalUtil.convertFlatItem(l,t,i,a)||(e[n]=t[i])}return!0};HierarchicalUtil.parseItem=function(e,t,i,r){var a,o,n,l,s,h={};if(wijmo_1.isArray(r))l=(s=r.slice()).length?s.shift().trim():"";else{s=r;l=r}if(wijmo_1.isArray(i)){o=null==(o=(a=i.slice()).shift())?o:o.trim();h.nameField=null==o?t:o;h.name=null==o?e[t]:e[o];n=e[l];0===a.length?h.value=e[t]:n&&wijmo_1.isArray(n)&&n.length>0?h.items=HierarchicalUtil.parseItems(n,t,a,s):h.value=e[t]||0}else{h.nameField=null==i?t:i;h.name=null==i?e[t]:e[i];null!=(n=e[l])&&wijmo_1.isArray(n)&&n.length>0?h.items=HierarchicalUtil.parseItems(n,t,i,s):h.value=e[t]}h.item=e;return h};HierarchicalUtil.parseFlatItem=function(e,t,i,r){e.items||(e.items=[])};return HierarchicalUtil}();exports.HierarchicalUtil=HierarchicalUtil;!function(e){e[e.Squarified=0]="Squarified";e[e.Horizontal=1]="Horizontal";e[e.Vertical=2]="Vertical"}(TreeMapType=exports.TreeMapType||(exports.TreeMapType={}));var TreeMap=function(e){__extends(TreeMap,e);function TreeMap(t,i){var r=e.call(this,t,null,!0)||this;r._values=[];r._labels=[];r._areas=[];r._sum=0;r._keywords=new wijmo_chart_1._KeyWords;r._processedData=[];r._depth=1;r._itemIndex=0;r._processedItem=[];r._maxDepth=-1;r._tmItems=[];r._colRowLens=[];r._defPalette=[{titleColor:"#033884",maxColor:"#1450a7",minColor:"#83b3f9"},{titleColor:"#a83100",maxColor:"#dc4a0d",minColor:"#ffb190"},{titleColor:"#006658",maxColor:"#008d7a",minColor:"#7deddf"},{titleColor:"#a10046",maxColor:"#df0061",minColor:"#ff8cbe"},{titleColor:"#784d08",maxColor:"#99681a",minColor:"#efc989"},{titleColor:"#54156f",maxColor:"#722a90",minColor:"#cf95e7"},{titleColor:"#998605",maxColor:"#c2ac19",minColor:"#ffef8b"},{titleColor:"#9a0005",maxColor:"#c80c14",minColor:"#ff888d"}];r.applyTemplate("wj-control wj-flexchart wj-treemap",null,null);r._currentRenderEngine=new wijmo_chart_1._SvgRenderEngine(r.hostElement);r._legend=new wijmo_chart_1.Legend(r);r._legend.position=wijmo_chart_1.Position.None;r._tooltip=new wijmo_chart_1.ChartTooltip;r._tooltip.content="<b>{name}</b><br/>{value}";r._tooltip.showDelay=0;r._lbl=new wijmo_chart_1.DataLabel;r._lbl.position=wijmo_chart_1.LabelPosition.Center;r._lbl._chart=r;r.hostElement.addEventListener("mousemove",(function(e){r.isTouching||r._toogleTooltip(e)}));r.hostElement.addEventListener("click",(function(e){var t=!0;if(r.maxDepth>0){var i=r.hitTest(e),a=wijmo_chart_1.FlexChart._SELECTION_THRESHOLD;r.tooltip&&r.tooltip.threshold&&(a=r.tooltip.threshold);if(i.distance<=a&&i.pointIndex>=-1&&i.pointIndex<r._areas.length){var o=r._areas[i.pointIndex];if(r._currentItem!=o.item){r._currentItem=o.item;r._refreshChart();t=!1}}}t&&r.isTouching&&r._toogleTooltip(e)}));r.hostElement.addEventListener("contextmenu",(function(e){if(r.maxDepth>0){var t=r.hitTest(e),i=wijmo_chart_1.FlexChart._SELECTION_THRESHOLD;r.tooltip&&r.tooltip.threshold&&(i=r.tooltip.threshold);t.distance<=i&&r._rollUp()}e.preventDefault();return!1}));r.hostElement.addEventListener("mouseleave",(function(){r._hideToolTip()}));r.deferUpdate((function(){return r.initialize(i)}));return r}TreeMap.prototype._rollUp=function(){this._currentItem=this._currentItem&&this._currentItem.parent?this._currentItem.parent:null;this._refreshChart()};TreeMap.prototype._toogleTooltip=function(e){var t=this._tooltip;if(t.content){var i=this.hitTest(e);if(i.distance<=t.threshold){var r=this._getLabelContent(i,this.tooltip.content);this._showToolTip(r,new wijmo_1.Rect(e.clientX,e.clientY,5,5))}else this._hideToolTip()}};Object.defineProperty(TreeMap.prototype,"selectionMode",{get:function(){return wijmo_chart_1.SelectionMode.None},set:function(e){},enumerable:!0,configurable:!0});Object.defineProperty(TreeMap.prototype,"_treeMapItems",{get:function(){return this._tmItems},enumerable:!0,configurable:!0});Object.defineProperty(TreeMap.prototype,"tooltip",{get:function(){return this._tooltip},enumerable:!0,configurable:!0});Object.defineProperty(TreeMap.prototype,"binding",{get:function(){return this._binding},set:function(e){if(e!=this._binding){this._binding=wijmo_1.asString(e,!0);this._bindChart()}},enumerable:!0,configurable:!0});Object.defineProperty(TreeMap.prototype,"type",{get:function(){return null==this._type?TreeMapType.Squarified:this._type},set:function(e){if((e=wijmo_1.asEnum(e,TreeMapType))!=this._type){this._type=e;this.invalidate()}},enumerable:!0,configurable:!0});Object.defineProperty(TreeMap.prototype,"bindingName",{get:function(){return this._bindingName},set:function(e){if(e!=this._bindingName){wijmo_1.assert(null==e||wijmo_1.isArray(e)||wijmo_1.isString(e),"bindingName should be an array or a string.");this._bindingName=e;this._bindChart()}},enumerable:!0,configurable:!0});Object.defineProperty(TreeMap.prototype,"dataLabel",{get:function(){return this._lbl},set:function(e){if(e!=this._lbl){this._lbl=e;this._lbl&&(this._lbl._chart=this)}},enumerable:!0,configurable:!0});Object.defineProperty(TreeMap.prototype,"childItemsPath",{get:function(){return this._childItemsPath},set:function(e){if(e!=this._childItemsPath){wijmo_1.assert(null==e||wijmo_1.isArray(e)||wijmo_1.isString(e),"childItemsPath should be an array or a string.");this._childItemsPath=e;this._bindChart()}},enumerable:!0,configurable:!0});Object.defineProperty(TreeMap.prototype,"maxDepth",{get:function(){return this._maxDepth},set:function(e){if(e!=this._maxDepth){this._maxDepth=wijmo_1.asNumber(e,!0);this.invalidate()}},enumerable:!0,configurable:!0});Object.defineProperty(TreeMap.prototype,"palette",{get:function(){return this._palette},set:function(e){if(e!=this._palette){this._palette=wijmo_1.asArray(e);this._tmItems&&this._tmItems.length>0&&this._calculateColorForItems(this._tmItems);this.invalidate()}},enumerable:!0,configurable:!0});TreeMap.prototype._initData=function(){this._sum=0;this._tmItems=[];this._currentItem=null;this._values=[];this._labels=[];this._processedData=[];this._depth=1;this._processedItem=[]};TreeMap.prototype._performBind=function(){var e;this._initData();if(this._cv){e=this._cv.items;this._cv.groups&&this._cv.groups.length?this._processedData=HierarchicalUtil.parseDataToHierarchical(this._cv,this.binding,this.bindingName,this.childItemsPath):e&&(this._processedData=HierarchicalUtil.parseDataToHierarchical(e,this.binding,this.bindingName,this.childItemsPath));if(this._processedData&&this._processedData.length){this._sum=this._calculateValueAndDepth(this._processedData,1);this._sortData(this._processedData);this._values=[];this._getTMItemsAndLabelsAndValues(this._processedData,this._tmItems,1,null);this._calculateColorForItems(this._tmItems)}}};TreeMap.prototype._sortData=function(e){var t=this;e.forEach((function(e){e.items&&t._sortData(e.items)}));e.sort((function(e,t){return t.value-e.value}))};TreeMap.prototype._getTMItemsAndLabelsAndValues=function(e,t,i,r,a){var o=this;e&&e.length>0&&e.forEach((function(e,a){var n,l=new _TreeMapItem;l.items=[];l.parent=r;l.depth=i;e.items&&o._getTMItemsAndLabelsAndValues(e.items,l.items,i+1,l);n=e.name?e.name:e.value.toString();l.label=n;l.value=e.value;if(null!=r){e.value>r.maxValue&&(r.maxValue=e.value);e.value<r.minValue&&(r.minValue=e.value)}t.push(l);o._labels.push(n);o._values.push(e.value)}))};TreeMap.prototype._calculateColorForItems=function(e,t,i){var r=this,a=i;e.forEach((function(e,i){var o=t;1===e.depth&&(o=r._getColor(i));e.palette=o;var n=e.palette;if(wijmo_1.isString(n)){var l=n,s=r._getLightColor(l);e.titleFill=l;e.titleStroke=l;e.fill=s;e.stroke=l}else if(n.maxColor&&n.minColor&&n.titleColor){e.titleFill=n.titleColor;e.titleStroke=n.titleColor;if(null==e.parent){e.fill=n.maxColor;e.stroke=n.maxColor}else{null==a&&(a=new _ColorConverter(n.minColor,e.minValue,n.maxColor,e.maxValue));var h=a._calculateColorByVal(e.value,!0).toString();e.fill=h;e.stroke=h}}if(e.items&&e.items.length>0){var _=new _ColorConverter(n.minColor,e.minValue,n.maxColor,e.maxValue);r._calculateColorForItems(e.items,o,_)}}))};TreeMap.prototype._getBindData=function(e,t,i){var r,a=0;i&&(r=e[i]);a=0;wijmo_1.isNumber(r)?a=wijmo_1.asNumber(r):r&&(a=parseFloat(r.toString()));if(!isNaN(a)&&isFinite(a))t.push(a);else{a=0;t.push(a)}return a};TreeMap.prototype._calculateValueAndDepth=function(e,t){var i=this,r=0,a=this._values;this._depth<t&&(this._depth=t);e.forEach((function(e){var o;if(e.items){o=i._calculateValueAndDepth(e.items,t+1);e.value=o;a.push(o)}else{o=i._getBindData(e,a,"value");e.value=o}r+=o}));return r};TreeMap.prototype._prepareRender=function(){this._areas=[]};TreeMap.prototype._renderChart=function(e,t,i){var r,a,o,n=this._rectChart.clone();new wijmo_1.Size(n.width,n.height);this.onRendering(new wijmo_chart_1.RenderEventArgs(e));var l=t.width,s=t.height;this._tmGroup=e.startGroup(null,null,!0);var h=this._parseMargin(this.plotMargin);this.dataLabel;isNaN(h.left)&&(h.left=TreeMap._MARGIN);isNaN(h.right)&&(h.right=TreeMap._MARGIN);isNaN(h.top)&&(h.top=TreeMap._MARGIN);isNaN(h.bottom)&&(h.bottom=TreeMap._MARGIN);t.top+=h.top;s=t.height-(h.top+h.bottom);t.height=s>0?s:24;t.left+=h.left;l=t.width-(h.left+h.right);t.width=l>0?l:24;this._plotRect=t;r=this._currentItem?[this._currentItem]:this._tmItems;a=null==this._currentItem||this.maxDepth<1?this.maxDepth:this._currentItem&&this._currentItem.items&&this._currentItem.items.length&&this.maxDepth>1?this.maxDepth:this.maxDepth+1;o=this._currentItem?this._currentItem.value:this._sum;this._renderTreeMap(e,t,this._tmGroup,r,o,a);e.endGroup();this.dataLabel.content&&this.dataLabel.position!=wijmo_chart_1.LabelPosition.None&&this._renderLabels(e);this.onRendered(new wijmo_chart_1.RenderEventArgs(e))};TreeMap.prototype._renderTreeMap=function(e,t,i,r,a,o){if(a>0){this._itemIndex=0;this._resetItemRects(this._tmItems);this._calculateItemRects(t,r,a,1,o);this._renderHierarchicalTreeMapItems(e,i,t,this._tmItems,a,1,o)}};TreeMap.prototype._resetItemRects=function(e){var t=this;e.forEach((function(e){e.rect=new wijmo_1.Rect(0,0,0,0);e.isTitle=!1;e.type=t.type;e.items&&e.items.length&&t._resetItemRects(e.items)}))};TreeMap.prototype._calculateItemRects=function(e,t,i,r,a){var o=this;switch(this.type){case TreeMapType.Horizontal:_TreeMapUtils.horizontal(t,e,i);break;case TreeMapType.Vertical:_TreeMapUtils.vertical(t,e,i);break;case TreeMapType.Squarified:_TreeMapUtils.squarified(t,e,i)}t.forEach((function(e,t){e.rect.clone();if(e.items&&e.items.length)if(r===a);else if(r>a&&a>=1);else{e.isTitle=!0;o._calculateItemRects(e.itemsRect,e.items,e.value,r+1,a)}}))};TreeMap.prototype._renderHierarchicalTreeMapItems=function(e,t,i,r,a,o,n){var l,s,h,_,c,u=r.length;this.type;if(0!==u)for(var p=0;p<u;p++){l=e.startGroup(TreeMap._CSS_ITEMDEPTH+o);s=r[p];h=Math.abs(s.value);_=s.rect;s.draw(e);c=new wijmo_chart_1._RectArea(_);s.items&&this._renderHierarchicalTreeMapItems(e,l,s.itemsRect,s.items,h,o+1,n);c.tag=this._itemIndex;c.name=s.label;c.value=h;c.item=s;this._areas.push(c);this._itemIndex++;e.endGroup()}};TreeMap.prototype._renderLabels=function(e){var t,i=this._areas.length,r=this.dataLabel,a=r.position,o=r.connectingLine,n=r.border,l=r.offset||0;e.stroke="null";e.fill="transparent";e.strokeWidth=1;e.startGroup("wj-data-labels");for(var s=0;s<i;s++){var h=this._areas[s];if(h){var _=h.rect,c=new wijmo_chart_1.HitTestInfo(this,t);c._setData(null,s);var u=this._getLabelContent(c,r.content);t=new wijmo_1.Point(_.left+_.width/2,_.top+_.height/2);if(u&&_.width>0&&_.height>0){var p=new wijmo_chart_1.DataLabelRenderEventArgs(e,c,t,u);if(r.onRendering(p)){u=p.text;t=p.point;this._renderLabelAndBorder(e,h,_,u,a,l,t,o,2,n)}}}}e.endGroup()};TreeMap.prototype._renderLabelAndBorder=function(e,t,i,r,a,o,n,l,s,h){var _,c="wj-data-label",u="wj-data-label-line";switch(a){case wijmo_chart_1.LabelPosition.Top:l&&e.drawLine(n.x,n.y,n.x,n.y-o,u);n.y-=s+o;_=this._renderText(e,t,i,r,n,1,2,c);break;case wijmo_chart_1.LabelPosition.Bottom:l&&e.drawLine(n.x,n.y,n.x,n.y+o,u);n.y+=s+o;_=this._renderText(e,t,i,r,n,1,0,c);break;case wijmo_chart_1.LabelPosition.Left:l&&e.drawLine(n.x,n.y,n.x-o,n.y,u);n.x-=s+o;_=this._renderText(e,t,i,r,n,2,1,c);break;case wijmo_chart_1.LabelPosition.Right:l&&e.drawLine(n.x,n.y,n.x+o,n.y,u);n.x+=s+o;_=this._renderText(e,t,i,r,n,0,1,c);break;case wijmo_chart_1.LabelPosition.Center:_=this._renderText(e,t,i,r,n,1,1,c)}h&&_&&e.drawRect(_.left-s,_.top-s,_.width+2*s,_.height+2*s,"wj-data-label-border");return _};TreeMap.prototype._renderText=function(e,t,i,r,a,o,n,l){var s,h=r,_=t.item;s=e.measureString(r,l);if(this.type===TreeMapType.Horizontal&&_.isTitle){s.width>i.height&&(h=this._cutText(r,s.width,i.height));wijmo_chart_1.FlexChart._renderRotatedText(e,h,a,o,n,a,-90,l);return null}s.width>i.width&&(h=this._cutText(r,s.width,i.width));return wijmo_chart_1.FlexChart._renderText(e,h,a,o,n,l)};TreeMap.prototype._cutText=function(e,t,i){var r="",a=e.length,o=Math.floor((1-(t-i)/t)*a);e.length>0&&(r=e[0]+(o>1?e.substring(1,o-1)+"..":""));return r};TreeMap.prototype._measureLegendItem=function(e,t){var i=new wijmo_1.Size;i.width=wijmo_chart_1.Series._LEGEND_ITEM_WIDTH;i.height=wijmo_chart_1.Series._LEGEND_ITEM_HEIGHT;if(t){var r=e.measureString(t,wijmo_chart_1.FlexChart._CSS_LABEL,wijmo_chart_1.FlexChart._CSS_LEGEND);i.width+=r.width;i.height<r.height&&(i.height=r.height)}i.width+=3*wijmo_chart_1.Series._LEGEND_ITEM_MARGIN;i.height+=2*wijmo_chart_1.Series._LEGEND_ITEM_MARGIN;return i};TreeMap.prototype._getDesiredLegendSize=function(e,t,i,r){var a=new wijmo_1.Size,o=(new wijmo_1.Size(i,r),this._tmItems.length),n=0,l=0;this._colRowLens=[];for(var s=0;s<o;s++){var h=this._measureLegendItem(e,this._tmItems[s].label);if(t){if(l+h.height>r){a.height=r;this._colRowLens.push(n);n=0;l=0}n<h.width&&(n=h.width);l+=h.height}else{if(n+h.width>i){a.width=i;this._colRowLens.push(l);l=0;n=0}l<h.height&&(l=h.height);n+=h.width}}if(t){a.height<l&&(a.height=l);this._colRowLens.push(n);a.width=this._colRowLens.reduce((function(e,t){return e+t}),0);a.width=this._getLegendSize(i,a.width)}else{a.width<n&&(a.width=n);this._colRowLens.push(l);a.height=this._colRowLens.reduce((function(e,t){return e+t}),0);a.height=this._getLegendSize(r,a.height)}return a};TreeMap.prototype._renderLegend=function(e,t,i,r,a,o){for(var n,l=this._rectLegend,s=this._tmItems.length,h=0,_=t.clone(),c=0;c<s;c++){n=this._tmItems[c].label;var u=this._measureLegendItem(e,n);if(r){if(_.y+u.height>l.top+l.height+1){_.x+=this._colRowLens[h];h++;_.y=t.y}}else if(_.x+u.width>l.left+l.width+1){_.y+=this._colRowLens[h];h++;_.x=t.x}var p=new wijmo_1.Rect(_.x,_.y,u.width,u.height);this._drawLegendItem(e,p,c,n);i.push(p);r?_.y+=u.height:_.x+=u.width}};TreeMap.prototype._drawLegendItem=function(e,t,i,r){e.strokeWidth=1;var a=wijmo_chart_1.Series._LEGEND_ITEM_MARGIN,o=this._getColor(i),n=o&&o.maxColor?o.maxColor:o,l=this._getLightColor(n);e.fill=n;e.stroke=l;var s=t.top+.5*t.height,h=wijmo_chart_1.Series._LEGEND_ITEM_WIDTH,_=wijmo_chart_1.Series._LEGEND_ITEM_HEIGHT;e.drawRect(t.left+a,s-.5*_,h,_,null);r&&wijmo_chart_1.FlexChart._renderText(e,r,new wijmo_1.Point(t.left+_+2*a,s),0,1,wijmo_chart_1.FlexChart._CSS_LABEL)};TreeMap.prototype._getLabelContent=function(e,t){return wijmo_1.isString(t)?this._keywords.replace(t,e):wijmo_1.isFunction(t)?t(e):null};TreeMap.prototype.hitTest=function(e,t){var i=this._toControl(e,t),r=new wijmo_chart_1.HitTestInfo(this,i),a=null;if(wijmo_chart_1.FlexChart._contains(this._rectHeader,i))r._chartElement=wijmo_chart_1.ChartElement.Header;else if(wijmo_chart_1.FlexChart._contains(this._rectFooter,i))r._chartElement=wijmo_chart_1.ChartElement.Footer;else if(wijmo_chart_1.FlexChart._contains(this._rectLegend,i)){r._chartElement=wijmo_chart_1.ChartElement.Legend;null!==(a=this.legend._hitTest(i))&&a>=0&&a<this._areas.length&&r._setData(null,a)}else if(wijmo_chart_1.FlexChart._contains(this._rectChart,i)){for(var o,n=this._areas.length,l=NaN,s=0;s<n;s++){var h=i.clone(),_=this._areas[s];if(_.contains(h)){r._setData(null,_.tag);r._dist=0}var c=_.distance(h);if(void 0!==c&&(isNaN(l)||c<l)){l=c;o=_}}if(0!==r._dist&&null!=o){r._setData(null,o.tag);r._dist=l}r._chartElement=wijmo_chart_1.ChartElement.ChartArea}else r._chartElement=wijmo_chart_1.ChartElement.None;return r};TreeMap.prototype._getHitTestItem=function(e){var t=null,i=null;(t=null!=this._cv?this._cv.items:this.itemsSource)&&e<t.length&&(i=t[e]);return i};TreeMap.prototype._getHitTestValue=function(e){return this._values[e]};TreeMap.prototype._getHitTestLabel=function(e){return this._labels[e]};TreeMap._CSS_ITEMDEPTH="wj-treemap-item-depth";TreeMap._MARGIN=0;return TreeMap}(wijmo_chart_1.FlexChartBase);exports.TreeMap=TreeMap;var _TreeMapItem=function(){function _TreeMapItem(){this.items=[];this.maxValue=Number.MIN_VALUE;this.minValue=Number.MAX_VALUE}_TreeMapItem.prototype.draw=function(e){var t=this.rect;e.strokeWidth=0;if(this.isTitle){e.fill=this.titleFill;e.stroke=this.titleStroke}else{e.fill=this.fill;e.stroke=this.stroke}e.drawRect(t.left,t.top,t.width,t.height,_TreeMapItem._CLASSNAME)};Object.defineProperty(_TreeMapItem.prototype,"itemsRect",{get:function(){var e=this.rect,t=this._rect,i=1===this.depth?2:.5;return this.isTitle?this.type===TreeMapType.Horizontal?new wijmo_1.Rect(e.left+e.width+1,e.top,t.width-e.width-2*i,e.height+1):new wijmo_1.Rect(e.left,e.top+e.height+1,e.width+1,t.height-e.height-2*i):new wijmo_1.Rect(0,0,0,0)},enumerable:!0,configurable:!0});Object.defineProperty(_TreeMapItem.prototype,"rect",{get:function(){var e=this._rect,t=1===this.depth?2:.5,i=e.width,r=e.height,a=e.left,o=e.top;if(this.isTitle){if(this.type===TreeMapType.Horizontal){i=e.width>20?20:i;i=Math.max(20,i-2*t);r=r>2*t?r-2*t:0}else{r=e.height>20?20:r;r=Math.max(20,r-2*t);i=i>2*t?i-2*t:0}a+=t;o+=t}else{i=i>2*t?i-2*t:0;r=r>2*t?r-2*t:0}return new wijmo_1.Rect(a,o,i,r)},set:function(e){e!=this._rect&&(this._rect=e)},enumerable:!0,configurable:!0});Object.defineProperty(_TreeMapItem.prototype,"isTitle",{get:function(){return this._isTitle},set:function(e){var t=wijmo_1.asBoolean(e,!0);t!==this._isTitle&&(this._isTitle=t)},enumerable:!0,configurable:!0});_TreeMapItem._CLASSNAME="wj-treemap-item";return _TreeMapItem}(),_ColorConverter=function(){function _ColorConverter(e,t,i,r,a,o){this.minColor=new wijmo_1.Color(e);this.minColorValue=t;this.maxColor=new wijmo_1.Color(i);this.maxColorValue=r;this.midColorValue=this.originalMidColorValue=o;this._calculateMidColorValue();this.midColor=this.originalMidColor=new wijmo_1.Color(a);this._calculateMidColor()}_ColorConverter.prototype._resetminColor=function(e){this.minColor=new wijmo_1.Color(e);this._calculateMidColor()};_ColorConverter.prototype._resetmidColor=function(e){this.midColor=this.originalMidColor=new wijmo_1.Color(e);this._calculateMidColor()};_ColorConverter.prototype._resetmaxColor=function(e){this.maxColor=new wijmo_1.Color(e);this._calculateMidColor()};_ColorConverter.prototype._resetminColorValue=function(e){this.minColorValue=e;this._calculateMidColorValue()};_ColorConverter.prototype._resetmidColorValue=function(e){this.midColorValue=this.originalMidColorValue=e;this._calculateMidColorValue()};_ColorConverter.prototype._resetmaxColorValue=function(e){this.maxColorValue=e;this._calculateMidColorValue()};_ColorConverter.prototype._calculateMidColorValue=function(){null==this.originalMidColorValue&&(this.midColorValue=(this.maxColorValue+this.minColorValue)/2)};_ColorConverter.prototype._calculateMidColor=function(){null==this.originalMidColor&&(this.midColor=this._calculateColorByVal(this.midColorValue,!0))};_ColorConverter.prototype._calculateColorByVal=function(e,t){void 0===t&&(t=!1);var i=this.maxColor,r=this.minColor,a=this.maxColorValue,o=this.minColorValue;if(e>=this.maxColorValue)return new wijmo_1.Color(i.toString());if(e<=this.minColorValue)return new wijmo_1.Color(r.toString());if(!t){if(e===this.midColorValue)return new wijmo_1.Color(this.midColor.toString());if(e<this.midColorValue){i=this.midColor;a=this.midColorValue}else{r=this.midColor;o=this.midColorValue}}return this._getColor(e,i,a,r,o)};_ColorConverter.prototype._getColor=function(e,t,i,r,a){return wijmo_1.Color.fromRgba(this._getValueByRatio(e,t.r,i,r.r,a),this._getValueByRatio(e,t.g,i,r.g,a),this._getValueByRatio(e,t.b,i,r.b,a),this._getValueByRatio(e,t.a,i,r.a,a))};_ColorConverter.prototype._getValueByRatio=function(e,t,i,r,a){return Math.abs(r+Math.round((e-a)*(t-r)/(i-a)))};return _ColorConverter}(),_TreeMapUtils=function(){function _TreeMapUtils(){}_TreeMapUtils.squarified=function(e,t,i){var r=e.slice(),a=t.clone(),o=a.width*a.height/i;do{var n=_TreeMapUtils.getRowedItems(r,a,o);_TreeMapUtils.layoutRowedItems(t,n,a,a.width>a.height)}while(r.length)};_TreeMapUtils.horizontal=function(e,t,i){var r=t.clone();e.forEach((function(e){var a=[{item:e,val:e.value*t.width*t.height/i}];_TreeMapUtils.layoutRowedItems(t,a,r,!1)}))};_TreeMapUtils.vertical=function(e,t,i){var r=t.clone();e.forEach((function(e){var a=[{item:e,val:e.value*t.width*t.height/i}];_TreeMapUtils.layoutRowedItems(t,a,r,!0)}))};_TreeMapUtils.getNarrowLen=function(e){return Math.min(e.width,e.height)};_TreeMapUtils.getRowedItem=function(e,t,i){return{item:e,val:i*e.value}};_TreeMapUtils.getRowedItems=function(e,t,i){var r=e.shift(),a=[],o=[],n=_TreeMapUtils.getNarrowLen(t),l=_TreeMapUtils.getRowedItem(r,t,i);a.push(l);o.push(l);if(e.length>0)do{o.push(_TreeMapUtils.getRowedItem(e[0],t,i));if(!(_TreeMapUtils.worst(a,n)>_TreeMapUtils.worst(o,n)))break;a=o.slice();e.shift()}while(e.length);return a};_TreeMapUtils.layoutRowedItems=function(e,t,i,r){var a,o=i.left,n=i.top,l=o+i.width,s=n+i.height,h=_TreeMapUtils.sumRowedArray(t);if(r){a=0===i.height?0:h/i.height;o+a>=l&&(a=l-o);t.forEach((function(e,i){var r=0===a?0:e.val/a;(n+r>s||i===t.length-1)&&(r=s-n);var l=new wijmo_1.Rect(o,n,a,r);e.item.rect=l;n+=r}));i.left+=a;i.width-=a}else{a=0===i.width?0:h/i.width;n+a>=s&&(a=s-n);t.forEach((function(e,i){var r=0===a?0:e.val/a;(o+r>l||i===t.length-1)&&(r=l-o);var s=new wijmo_1.Rect(o,n,r,a);e.item.rect=s;o+=r}));i.top+=a;i.height-=a}};_TreeMapUtils.sumRowedArray=function(e){for(var t=0,i=e.length,r=0;r<i;r++)t+=e[r].val;return t};_TreeMapUtils.worst=function(e,t){var i,r,a=_TreeMapUtils.sumRowedArray(e),o=a*a,n=t*t;i=r=e[0].val;e.forEach((function(e,t){e.val>i?i=e.val:e.val<r&&(r=e.val)}));return Math.max(n*i/o,o/(n*r))};return _TreeMapUtils}(),Sunburst=function(e){__extends(Sunburst,e);function Sunburst(t,i){var r=e.call(this,t,i)||this;r._selectionIndex=0;r.applyTemplate("wj-sunburst",null,null);r.initialize(i);r.refresh();return r}Object.defineProperty(Sunburst.prototype,"bindingName",{get:function(){return this._bindName},set:function(e){if(e!=this._bindName){wijmo_1.assert(null==e||wijmo_1.isArray(e)||wijmo_1.isString(e),"bindingName should be an array or a string.");this._bindName=e;this._bindChart()}},enumerable:!0,configurable:!0});Object.defineProperty(Sunburst.prototype,"childItemsPath",{get:function(){return this._childItemsPath},set:function(e){if(e!=this._childItemsPath){wijmo_1.assert(null==e||wijmo_1.isArray(e)||wijmo_1.isString(e),"childItemsPath should be an array or a string.");this._childItemsPath=e;this._bindChart()}},enumerable:!0,configurable:!0});Sunburst.prototype._initData=function(){e.prototype._initData.call(this);this._processedData=[];this._level=1;this._legendLabels=[];this._processedItem=[];this._values[0]=[]};Sunburst.prototype._performBind=function(){var e,t=this;this._initData();if(this._cv){e=this._cv.items;this._cv.groups&&this._cv.groups.length?this._processedData=HierarchicalUtil.parseDataToHierarchical(this._cv,this.binding,this.bindingName,this.childItemsPath):e&&(this._processedData=HierarchicalUtil.parseDataToHierarchical(e,this.binding,this.bindingName,this.childItemsPath));if(this._processedData&&this._processedData.length){this._sums[0]=this._sum=this._calculateValueAndLevel(this._processedData,1);this._processedData.forEach((function(e){t._legendLabels.push(e.name)}))}}};Sunburst.prototype._calculateValueAndLevel=function(e,t){var i=this,r=0,a=this._values[0],o=this._labels;this._level<t&&(this._level=t);e.forEach((function(e){var n;if(e.items){n=i._calculateValueAndLevel(e.items,t+1);e.value=n;a.push(n);o.push(e.name)}else{n=i._getBindData(e,a,o,"value","name");e.value=n}r+=n}));return r};Sunburst.prototype._renderPie=function(e,t,i,r,a,o){var n=this._getCenter();this._sliceIndex=0;this._parentRef={};this._renderHierarchicalSlices(e,n.x,n.y,this._processedData,this._sum,i,r,a,2*Math.PI,o,1)};Sunburst.prototype._renderHierarchicalSlices=function(e,t,i,r,a,o,n,l,s,h,_){var c,u,p,m,d,f,g,w,v,C,T=r.length,b=l,y=1==this.reversed;p=(o-n)/this._level;c=o-(this._level-_)*p;u=n+(_-1)*p;for(var M=0;M<T;M++){w=t;v=i;g=e.startGroup("wj-slice slice-level"+_);if(1===_){e.fill=this._getColorLight(M);e.stroke=this._getColor(M)}d=r[M];f=Math.abs(d.value);m=Math.abs(f-a)<1e-10?s:s*f/a;C=y?b-.5*m:b+.5*m;if(h>0&&m<s){w+=h*Math.cos(C);v+=h*Math.sin(C)}if(d.items){var I=this._sliceIndex;this._renderHierarchicalSlices(e,w,v,d.items,f,o,n,b,m,0,_+1);for(;I<this._sliceIndex;I++)null==this._parentRef[I]&&(this._parentRef[I]=this._sliceIndex)}this._renderSlice(e,w,v,C,0,this._sliceIndex,c,u,b,m,s);this._processedItem.push(d.item);this._sliceIndex++;y?b-=m:b+=m;e.endGroup();this._pels.push(g)}};Sunburst.prototype._getLabelsForLegend=function(){return this._legendLabels||[]};Sunburst.prototype._highlightCurrent=function(){this.selectionMode!=wijmo_chart_1.SelectionMode.None&&this._highlight(!0,this._selectionIndex)};Sunburst.prototype.hitTest=function(t,i){var r=e.prototype.hitTest.call(this,t,i),a=this._toControl(t,i);if(wijmo_chart_1.FlexChartBase._contains(this._rectChart,a)){var o=r.pointIndex,n=this._processedItem[o],l=new wijmo_chart_1._DataPoint(null,o,null,null);l.item=n;r._setDataPoint(l)}return r};Sunburst.prototype._getSelectedItemOffset=function(e,t){var i=0,r=0,a=0;if(this.selectedItemOffset>0)if(e==this.selectedIndex)a=this.selectedItemOffset;else{var o=this._getSelectedParentIndex(e);if(null!=o){var n=this._areas[o];this.dataLabel.position;a=this.selectedItemOffset;t=((t=n.langle+this._rotationAngles[0])%360+360)%360;t*=Math.PI/180}}if(a>0){i=Math.cos(t)*a*this._radius;r=Math.sin(t)*a*this._radius}return{x:i,y:r}};Sunburst.prototype._getSelectedParentIndex=function(e){var t=this._parentRef[e];return null!=t?t===this.selectedIndex?t:this._getSelectedParentIndex(t):null};return Sunburst}(wijmo_chart_1.FlexPie);exports.Sunburst=Sunburst;wijmo_1._registerModule("wijmo.chart.hierarchical",selfModule);
14
+ "use strict";var __extends=this&&this.__extends||function(){var extendStatics=function(e,t){return(extendStatics=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var i in t)t.hasOwnProperty(i)&&(e[i]=t[i])})(e,t)};return function(e,t){extendStatics(e,t);function __(){this.constructor=e}e.prototype=null===t?Object.create(t):(__.prototype=t.prototype,new __)}}(),__importStar=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var i in e)Object.hasOwnProperty.call(e,i)&&(t[i]=e[i]);t.default=e;return t};Object.defineProperty(exports,"__esModule",{value:!0});var TreeMapType,wijmo_1=require("@mescius/wijmo"),wijmo_chart_1=require("@mescius/wijmo.chart"),selfModule=__importStar(require("@mescius/wijmo.chart.hierarchical")),HierarchicalUtil=function(){function HierarchicalUtil(){}HierarchicalUtil.parseDataToHierarchical=function(e,t,i,r){var a,o=[];if(e instanceof wijmo_1.CollectionView&&e.groups.length>0)o=HierarchicalUtil.parseGroupCV(e,t);else if(e.length>0){wijmo_1.isString(i)&&i.indexOf(",")>-1&&(i=i.split(","));if(r)o=HierarchicalUtil.parseItems(e,t,i,r);else{a=HierarchicalUtil.convertFlatData(e,t,i);o=HierarchicalUtil.parseItems(a,"value",i,"items")}}return o};HierarchicalUtil.parseGroupCV=function(e,t){for(var i=[],r=0,a=e.groups.length;r<a;r++){var o=this.parseGroups(e.groups[r],t);i.push(o)}return i};HierarchicalUtil.parseGroups=function(e,t){var i={};i.name=e.name;i.nameField=e.groupDescription.propertyName;i.item=e.items;if(e.groups&&e.groups.length){i.items=[];for(var r=0,a=e.groups.length;r<a;r++){var o=this.parseGroups(e.groups[r],t);i.items.push(o)}}else e.isBottomLevel&&(i.value=e.getAggregate(wijmo_1.Aggregate.Sum,t));return i};HierarchicalUtil.parseItems=function(e,t,i,r){var a,o=[],n=e.length;for(a=0;a<n;a++)o.push(HierarchicalUtil.parseItem(e[a],t,i,r));return o};HierarchicalUtil.isFlatItem=function(e,t){return!wijmo_1.isArray(e[t])};HierarchicalUtil.convertFlatData=function(e,t,i){var r,a,o=[],n={},l=e.length;for(r=0;r<l;r++){a=e[r];HierarchicalUtil.convertFlatItem(n,a,t,wijmo_1.isArray(i)?i:[i])}HierarchicalUtil.convertFlatToHierarchical(o,n);return o};HierarchicalUtil.convertFlatToHierarchical=function(e,t){var i=t.flatDataOrder;i&&i.forEach((function(i){var r,a={},o=t[i];a[t.field]=i;if(o.flatDataOrder){r=[];HierarchicalUtil.convertFlatToHierarchical(r,o);a.items=r}else a.value=o;e.push(a)}))};HierarchicalUtil.convertFlatItem=function(e,t,i,r){var a,o,n,l;o=(a=r.slice()).shift();if(null==(n=null==(o=wijmo_1.isString(o)?o.trim():o)?i:t[o]))return!1;if(0===a.length){e[n]=t[i]||0;e.flatDataOrder?e.flatDataOrder.push(n):e.flatDataOrder=[n];e.field=o}else{if(null==e[n]){e[n]={};e.flatDataOrder?e.flatDataOrder.push(n):e.flatDataOrder=[n];e.field=o}l=e[n];HierarchicalUtil.convertFlatItem(l,t,i,a)||(e[n]=t[i])}return!0};HierarchicalUtil.parseItem=function(e,t,i,r){var a,o,n,l,s,h={};if(wijmo_1.isArray(r))l=(s=r.slice()).length?s.shift().trim():"";else{s=r;l=r}if(wijmo_1.isArray(i)){o=null==(o=(a=i.slice()).shift())?o:o.trim();h.nameField=null==o?t:o;h.name=null==o?e[t]:e[o];n=e[l];0===a.length?h.value=e[t]:n&&wijmo_1.isArray(n)&&n.length>0?h.items=HierarchicalUtil.parseItems(n,t,a,s):h.value=e[t]||0}else{h.nameField=null==i?t:i;h.name=null==i?e[t]:e[i];null!=(n=e[l])&&wijmo_1.isArray(n)&&n.length>0?h.items=HierarchicalUtil.parseItems(n,t,i,s):h.value=e[t]}h.item=e;return h};HierarchicalUtil.parseFlatItem=function(e,t,i,r){e.items||(e.items=[])};return HierarchicalUtil}();exports.HierarchicalUtil=HierarchicalUtil;!function(e){e[e.Squarified=0]="Squarified";e[e.Horizontal=1]="Horizontal";e[e.Vertical=2]="Vertical"}(TreeMapType=exports.TreeMapType||(exports.TreeMapType={}));var TreeMap=function(e){__extends(TreeMap,e);function TreeMap(t,i){var r=e.call(this,t,null,!0)||this;r._values=[];r._labels=[];r._areas=[];r._sum=0;r._keywords=new wijmo_chart_1._KeyWords;r._processedData=[];r._depth=1;r._itemIndex=0;r._processedItem=[];r._maxDepth=-1;r._tmItems=[];r._colRowLens=[];r._defPalette=[{titleColor:"#033884",maxColor:"#1450a7",minColor:"#83b3f9"},{titleColor:"#a83100",maxColor:"#dc4a0d",minColor:"#ffb190"},{titleColor:"#006658",maxColor:"#008d7a",minColor:"#7deddf"},{titleColor:"#a10046",maxColor:"#df0061",minColor:"#ff8cbe"},{titleColor:"#784d08",maxColor:"#99681a",minColor:"#efc989"},{titleColor:"#54156f",maxColor:"#722a90",minColor:"#cf95e7"},{titleColor:"#998605",maxColor:"#c2ac19",minColor:"#ffef8b"},{titleColor:"#9a0005",maxColor:"#c80c14",minColor:"#ff888d"}];r.applyTemplate("wj-control wj-flexchart wj-treemap",null,null);r._currentRenderEngine=new wijmo_chart_1._SvgRenderEngine(r.hostElement);r._legend=new wijmo_chart_1.Legend(r);r._legend.position=wijmo_chart_1.Position.None;r._tooltip=new wijmo_chart_1.ChartTooltip;r._tooltip.content="<b>{name}</b><br/>{value}";r._tooltip.showDelay=0;r._lbl=new wijmo_chart_1.DataLabel;r._lbl.position=wijmo_chart_1.LabelPosition.Center;r._lbl._chart=r;r.hostElement.addEventListener("mousemove",(function(e){r.isTouching||r._toogleTooltip(e)}));r.hostElement.addEventListener("click",(function(e){var t=!0;if(r.maxDepth>0){var i=r.hitTest(e),a=wijmo_chart_1.FlexChart._SELECTION_THRESHOLD;r.tooltip&&r.tooltip.threshold&&(a=r.tooltip.threshold);if(i.distance<=a&&i.pointIndex>=-1&&i.pointIndex<r._areas.length){var o=r._areas[i.pointIndex];if(r._currentItem!=o.item){r._currentItem=o.item;r._refreshChart();t=!1}}}t&&r.isTouching&&r._toogleTooltip(e)}));r.hostElement.addEventListener("contextmenu",(function(e){if(r.maxDepth>0){var t=r.hitTest(e),i=wijmo_chart_1.FlexChart._SELECTION_THRESHOLD;r.tooltip&&r.tooltip.threshold&&(i=r.tooltip.threshold);t.distance<=i&&r._rollUp()}e.preventDefault();return!1}));r.hostElement.addEventListener("mouseleave",(function(){r._hideToolTip()}));r.deferUpdate((function(){return r.initialize(i)}));return r}TreeMap.prototype._rollUp=function(){this._currentItem=this._currentItem&&this._currentItem.parent?this._currentItem.parent:null;this._refreshChart()};TreeMap.prototype._toogleTooltip=function(e){var t=this._tooltip;if(t.content){var i=this.hitTest(e);if(i.distance<=t.threshold){var r=this._getLabelContent(i,this.tooltip.content);this._showToolTip(r,new wijmo_1.Rect(e.clientX,e.clientY,5,5))}else this._hideToolTip()}};Object.defineProperty(TreeMap.prototype,"selectionMode",{get:function(){return wijmo_chart_1.SelectionMode.None},set:function(e){},enumerable:!0,configurable:!0});Object.defineProperty(TreeMap.prototype,"_treeMapItems",{get:function(){return this._tmItems},enumerable:!0,configurable:!0});Object.defineProperty(TreeMap.prototype,"tooltip",{get:function(){return this._tooltip},enumerable:!0,configurable:!0});Object.defineProperty(TreeMap.prototype,"binding",{get:function(){return this._binding},set:function(e){if(e!=this._binding){this._binding=wijmo_1.asString(e,!0);this._bindChart()}},enumerable:!0,configurable:!0});Object.defineProperty(TreeMap.prototype,"type",{get:function(){return null==this._type?TreeMapType.Squarified:this._type},set:function(e){if((e=wijmo_1.asEnum(e,TreeMapType))!=this._type){this._type=e;this.invalidate()}},enumerable:!0,configurable:!0});Object.defineProperty(TreeMap.prototype,"bindingName",{get:function(){return this._bindingName},set:function(e){if(e!=this._bindingName){wijmo_1.assert(null==e||wijmo_1.isArray(e)||wijmo_1.isString(e),"bindingName should be an array or a string.");this._bindingName=e;this._bindChart()}},enumerable:!0,configurable:!0});Object.defineProperty(TreeMap.prototype,"dataLabel",{get:function(){return this._lbl},set:function(e){if(e!=this._lbl){this._lbl=e;this._lbl&&(this._lbl._chart=this)}},enumerable:!0,configurable:!0});Object.defineProperty(TreeMap.prototype,"childItemsPath",{get:function(){return this._childItemsPath},set:function(e){if(e!=this._childItemsPath){wijmo_1.assert(null==e||wijmo_1.isArray(e)||wijmo_1.isString(e),"childItemsPath should be an array or a string.");this._childItemsPath=e;this._bindChart()}},enumerable:!0,configurable:!0});Object.defineProperty(TreeMap.prototype,"maxDepth",{get:function(){return this._maxDepth},set:function(e){if(e!=this._maxDepth){this._maxDepth=wijmo_1.asNumber(e,!0);this.invalidate()}},enumerable:!0,configurable:!0});Object.defineProperty(TreeMap.prototype,"palette",{get:function(){return this._palette},set:function(e){if(e!=this._palette){this._palette=wijmo_1.asArray(e);this._tmItems&&this._tmItems.length>0&&this._calculateColorForItems(this._tmItems);this.invalidate()}},enumerable:!0,configurable:!0});TreeMap.prototype._initData=function(){this._sum=0;this._tmItems=[];this._currentItem=null;this._values=[];this._labels=[];this._processedData=[];this._depth=1;this._processedItem=[]};TreeMap.prototype._performBind=function(){var e;this._initData();if(this._cv){e=this._cv.items;this._cv.groups&&this._cv.groups.length?this._processedData=HierarchicalUtil.parseDataToHierarchical(this._cv,this.binding,this.bindingName,this.childItemsPath):e&&(this._processedData=HierarchicalUtil.parseDataToHierarchical(e,this.binding,this.bindingName,this.childItemsPath));if(this._processedData&&this._processedData.length){this._sum=this._calculateValueAndDepth(this._processedData,1);this._sortData(this._processedData);this._values=[];this._getTMItemsAndLabelsAndValues(this._processedData,this._tmItems,1,null);this._calculateColorForItems(this._tmItems)}}};TreeMap.prototype._sortData=function(e){var t=this;e.forEach((function(e){e.items&&t._sortData(e.items)}));e.sort((function(e,t){return t.value-e.value}))};TreeMap.prototype._getTMItemsAndLabelsAndValues=function(e,t,i,r,a){var o=this;e&&e.length>0&&e.forEach((function(e,a){var n,l=new _TreeMapItem;l.items=[];l.parent=r;l.depth=i;e.items&&o._getTMItemsAndLabelsAndValues(e.items,l.items,i+1,l);n=e.name?e.name:e.value.toString();l.label=n;l.value=e.value;if(null!=r){e.value>r.maxValue&&(r.maxValue=e.value);e.value<r.minValue&&(r.minValue=e.value)}t.push(l);o._labels.push(n);o._values.push(e.value)}))};TreeMap.prototype._calculateColorForItems=function(e,t,i){var r=this,a=i;e.forEach((function(e,i){var o=t;1===e.depth&&(o=r._getColor(i));e.palette=o;var n=e.palette;if(wijmo_1.isString(n)){var l=n,s=r._getLightColor(l);e.titleFill=l;e.titleStroke=l;e.fill=s;e.stroke=l}else if(n.maxColor&&n.minColor&&n.titleColor){e.titleFill=n.titleColor;e.titleStroke=n.titleColor;if(null==e.parent){e.fill=n.maxColor;e.stroke=n.maxColor}else{null==a&&(a=new _ColorConverter(n.minColor,e.minValue,n.maxColor,e.maxValue));var h=a._calculateColorByVal(e.value,!0).toString();e.fill=h;e.stroke=h}}if(e.items&&e.items.length>0){var _=new _ColorConverter(n.minColor,e.minValue,n.maxColor,e.maxValue);r._calculateColorForItems(e.items,o,_)}}))};TreeMap.prototype._getBindData=function(e,t,i){var r,a=0;i&&(r=e[i]);a=0;wijmo_1.isNumber(r)?a=wijmo_1.asNumber(r):r&&(a=parseFloat(r.toString()));if(!isNaN(a)&&isFinite(a))t.push(a);else{a=0;t.push(a)}return a};TreeMap.prototype._calculateValueAndDepth=function(e,t){var i=this,r=0,a=this._values;this._depth<t&&(this._depth=t);e.forEach((function(e){var o;if(e.items){o=i._calculateValueAndDepth(e.items,t+1);e.value=o;a.push(o)}else{o=i._getBindData(e,a,"value");e.value=o}r+=o}));return r};TreeMap.prototype._prepareRender=function(){this._areas=[]};TreeMap.prototype._renderChart=function(e,t,i){var r,a,o,n=this._rectChart.clone();new wijmo_1.Size(n.width,n.height);this.onRendering(new wijmo_chart_1.RenderEventArgs(e));var l=t.width,s=t.height;this._tmGroup=e.startGroup(null,null,!0);var h=this._parseMargin(this.plotMargin);this.dataLabel;isNaN(h.left)&&(h.left=TreeMap._MARGIN);isNaN(h.right)&&(h.right=TreeMap._MARGIN);isNaN(h.top)&&(h.top=TreeMap._MARGIN);isNaN(h.bottom)&&(h.bottom=TreeMap._MARGIN);t.top+=h.top;s=t.height-(h.top+h.bottom);t.height=s>0?s:24;t.left+=h.left;l=t.width-(h.left+h.right);t.width=l>0?l:24;this._plotRect=t;r=this._currentItem?[this._currentItem]:this._tmItems;a=null==this._currentItem||this.maxDepth<1?this.maxDepth:this._currentItem&&this._currentItem.items&&this._currentItem.items.length&&this.maxDepth>1?this.maxDepth:this.maxDepth+1;o=this._currentItem?this._currentItem.value:this._sum;this._renderTreeMap(e,t,this._tmGroup,r,o,a);e.endGroup();this.dataLabel.content&&this.dataLabel.position!=wijmo_chart_1.LabelPosition.None&&this._renderLabels(e);this.onRendered(new wijmo_chart_1.RenderEventArgs(e))};TreeMap.prototype._renderTreeMap=function(e,t,i,r,a,o){if(a>0){this._itemIndex=0;this._resetItemRects(this._tmItems);this._calculateItemRects(t,r,a,1,o);this._renderHierarchicalTreeMapItems(e,i,t,this._tmItems,a,1,o)}};TreeMap.prototype._resetItemRects=function(e){var t=this;e.forEach((function(e){e.rect=new wijmo_1.Rect(0,0,0,0);e.isTitle=!1;e.type=t.type;e.items&&e.items.length&&t._resetItemRects(e.items)}))};TreeMap.prototype._calculateItemRects=function(e,t,i,r,a){var o=this;switch(this.type){case TreeMapType.Horizontal:_TreeMapUtils.horizontal(t,e,i);break;case TreeMapType.Vertical:_TreeMapUtils.vertical(t,e,i);break;case TreeMapType.Squarified:_TreeMapUtils.squarified(t,e,i)}t.forEach((function(e,t){e.rect.clone();if(e.items&&e.items.length)if(r===a);else if(r>a&&a>=1);else{e.isTitle=!0;o._calculateItemRects(e.itemsRect,e.items,e.value,r+1,a)}}))};TreeMap.prototype._renderHierarchicalTreeMapItems=function(e,t,i,r,a,o,n){var l,s,h,_,c,u=r.length;this.type;if(0!==u)for(var p=0;p<u;p++){l=e.startGroup(TreeMap._CSS_ITEMDEPTH+o);s=r[p];h=Math.abs(s.value);_=s.rect;s.draw(e);c=new wijmo_chart_1._RectArea(_);s.items&&this._renderHierarchicalTreeMapItems(e,l,s.itemsRect,s.items,h,o+1,n);c.tag=this._itemIndex;c.name=s.label;c.value=h;c.item=s;this._areas.push(c);this._itemIndex++;e.endGroup()}};TreeMap.prototype._renderLabels=function(e){var t,i=this._areas.length,r=this.dataLabel,a=r.position,o=r.connectingLine,n=r.border,l=r.offset||0;e.stroke="null";e.fill="transparent";e.strokeWidth=1;e.startGroup("wj-data-labels");for(var s=0;s<i;s++){var h=this._areas[s];if(h){var _=h.rect,c=new wijmo_chart_1.HitTestInfo(this,t);c._setData(null,s);var u=this._getLabelContent(c,r.content);t=new wijmo_1.Point(_.left+_.width/2,_.top+_.height/2);if(u&&_.width>0&&_.height>0){var p=new wijmo_chart_1.DataLabelRenderEventArgs(e,c,t,u);if(r.onRendering(p)){u=p.text;t=p.point;this._renderLabelAndBorder(e,h,_,u,a,l,t,o,2,n)}}}}e.endGroup()};TreeMap.prototype._renderLabelAndBorder=function(e,t,i,r,a,o,n,l,s,h){var _,c="wj-data-label",u="wj-data-label-line";switch(a){case wijmo_chart_1.LabelPosition.Top:l&&e.drawLine(n.x,n.y,n.x,n.y-o,u);n.y-=s+o;_=this._renderText(e,t,i,r,n,1,2,c);break;case wijmo_chart_1.LabelPosition.Bottom:l&&e.drawLine(n.x,n.y,n.x,n.y+o,u);n.y+=s+o;_=this._renderText(e,t,i,r,n,1,0,c);break;case wijmo_chart_1.LabelPosition.Left:l&&e.drawLine(n.x,n.y,n.x-o,n.y,u);n.x-=s+o;_=this._renderText(e,t,i,r,n,2,1,c);break;case wijmo_chart_1.LabelPosition.Right:l&&e.drawLine(n.x,n.y,n.x+o,n.y,u);n.x+=s+o;_=this._renderText(e,t,i,r,n,0,1,c);break;case wijmo_chart_1.LabelPosition.Center:_=this._renderText(e,t,i,r,n,1,1,c)}h&&_&&e.drawRect(_.left-s,_.top-s,_.width+2*s,_.height+2*s,"wj-data-label-border");return _};TreeMap.prototype._renderText=function(e,t,i,r,a,o,n,l){var s,h=r,_=t.item;s=e.measureString(r,l);if(this.type===TreeMapType.Horizontal&&_.isTitle){s.width>i.height&&(h=this._cutText(r,s.width,i.height));wijmo_chart_1.FlexChart._renderRotatedText(e,h,a,o,n,a,-90,l);return null}s.width>i.width&&(h=this._cutText(r,s.width,i.width));return wijmo_chart_1.FlexChart._renderText(e,h,a,o,n,l)};TreeMap.prototype._cutText=function(e,t,i){var r="",a=e.length,o=Math.floor((1-(t-i)/t)*a);e.length>0&&(r=e[0]+(o>1?e.substring(1,o-1)+"..":""));return r};TreeMap.prototype._measureLegendItem=function(e,t){var i=new wijmo_1.Size;i.width=wijmo_chart_1.Series._LEGEND_ITEM_WIDTH;i.height=wijmo_chart_1.Series._LEGEND_ITEM_HEIGHT;if(t){var r=e.measureString(t,wijmo_chart_1.FlexChart._CSS_LABEL,wijmo_chart_1.FlexChart._CSS_LEGEND);i.width+=r.width;i.height<r.height&&(i.height=r.height)}i.width+=3*wijmo_chart_1.Series._LEGEND_ITEM_MARGIN;i.height+=2*wijmo_chart_1.Series._LEGEND_ITEM_MARGIN;return i};TreeMap.prototype._getDesiredLegendSize=function(e,t,i,r){var a=new wijmo_1.Size,o=(new wijmo_1.Size(i,r),this._tmItems.length),n=0,l=0;this._colRowLens=[];for(var s=0;s<o;s++){var h=this._measureLegendItem(e,this._tmItems[s].label);if(t){if(l+h.height>r){a.height=r;this._colRowLens.push(n);n=0;l=0}n<h.width&&(n=h.width);l+=h.height}else{if(n+h.width>i){a.width=i;this._colRowLens.push(l);l=0;n=0}l<h.height&&(l=h.height);n+=h.width}}if(t){a.height<l&&(a.height=l);this._colRowLens.push(n);a.width=this._colRowLens.reduce((function(e,t){return e+t}),0);a.width=this._getLegendSize(i,a.width)}else{a.width<n&&(a.width=n);this._colRowLens.push(l);a.height=this._colRowLens.reduce((function(e,t){return e+t}),0);a.height=this._getLegendSize(r,a.height)}return a};TreeMap.prototype._renderLegend=function(e,t,i,r,a,o){for(var n,l=this._rectLegend,s=this._tmItems.length,h=0,_=t.clone(),c=0;c<s;c++){n=this._tmItems[c].label;var u=this._measureLegendItem(e,n);if(r){if(_.y+u.height>l.top+l.height+1){_.x+=this._colRowLens[h];h++;_.y=t.y}}else if(_.x+u.width>l.left+l.width+1){_.y+=this._colRowLens[h];h++;_.x=t.x}var p=new wijmo_1.Rect(_.x,_.y,u.width,u.height);this._drawLegendItem(e,p,c,n);i.push(p);r?_.y+=u.height:_.x+=u.width}};TreeMap.prototype._drawLegendItem=function(e,t,i,r){e.strokeWidth=1;var a=wijmo_chart_1.Series._LEGEND_ITEM_MARGIN,o=this._getColor(i),n=o&&o.maxColor?o.maxColor:o,l=this._getLightColor(n);e.fill=n;e.stroke=l;var s=t.top+.5*t.height,h=wijmo_chart_1.Series._LEGEND_ITEM_WIDTH,_=wijmo_chart_1.Series._LEGEND_ITEM_HEIGHT;e.drawRect(t.left+a,s-.5*_,h,_,null);r&&wijmo_chart_1.FlexChart._renderText(e,r,new wijmo_1.Point(t.left+_+2*a,s),0,1,wijmo_chart_1.FlexChart._CSS_LABEL)};TreeMap.prototype._getLabelContent=function(e,t){return wijmo_1.isString(t)?this._keywords.replace(t,e):wijmo_1.isFunction(t)?t(e):null};TreeMap.prototype.hitTest=function(e,t){var i=this._toControl(e,t),r=new wijmo_chart_1.HitTestInfo(this,i),a=null;if(wijmo_chart_1.FlexChart._contains(this._rectHeader,i))r._chartElement=wijmo_chart_1.ChartElement.Header;else if(wijmo_chart_1.FlexChart._contains(this._rectFooter,i))r._chartElement=wijmo_chart_1.ChartElement.Footer;else if(wijmo_chart_1.FlexChart._contains(this._rectLegend,i)){r._chartElement=wijmo_chart_1.ChartElement.Legend;null!==(a=this.legend._hitTest(i))&&a>=0&&a<this._areas.length&&r._setData(null,a)}else if(wijmo_chart_1.FlexChart._contains(this._rectChart,i)){for(var o,n=this._areas.length,l=NaN,s=0;s<n;s++){var h=i.clone(),_=this._areas[s];if(_.contains(h)){r._setData(null,_.tag);r._dist=0}var c=_.distance(h);if(void 0!==c&&(isNaN(l)||c<l)){l=c;o=_}}if(0!==r._dist&&null!=o){r._setData(null,o.tag);r._dist=l}r._chartElement=wijmo_chart_1.ChartElement.ChartArea}else r._chartElement=wijmo_chart_1.ChartElement.None;return r};TreeMap.prototype._getHitTestItem=function(e){var t=null,i=null;(t=null!=this._cv?this._cv.items:this.itemsSource)&&e<t.length&&(i=t[e]);return i};TreeMap.prototype._getHitTestValue=function(e){return this._values[e]};TreeMap.prototype._getHitTestLabel=function(e){return this._labels[e]};TreeMap._CSS_ITEMDEPTH="wj-treemap-item-depth";TreeMap._MARGIN=0;return TreeMap}(wijmo_chart_1.FlexChartBase);exports.TreeMap=TreeMap;var _TreeMapItem=function(){function _TreeMapItem(){this.items=[];this.maxValue=Number.MIN_VALUE;this.minValue=Number.MAX_VALUE}_TreeMapItem.prototype.draw=function(e){var t=this.rect;e.strokeWidth=0;if(this.isTitle){e.fill=this.titleFill;e.stroke=this.titleStroke}else{e.fill=this.fill;e.stroke=this.stroke}e.drawRect(t.left,t.top,t.width,t.height,_TreeMapItem._CLASSNAME)};Object.defineProperty(_TreeMapItem.prototype,"itemsRect",{get:function(){var e=this.rect,t=this._rect,i=1===this.depth?2:.5;return this.isTitle?this.type===TreeMapType.Horizontal?new wijmo_1.Rect(e.left+e.width+1,e.top,t.width-e.width-2*i,e.height+1):new wijmo_1.Rect(e.left,e.top+e.height+1,e.width+1,t.height-e.height-2*i):new wijmo_1.Rect(0,0,0,0)},enumerable:!0,configurable:!0});Object.defineProperty(_TreeMapItem.prototype,"rect",{get:function(){var e=this._rect,t=1===this.depth?2:.5,i=e.width,r=e.height,a=e.left,o=e.top;if(this.isTitle){if(this.type===TreeMapType.Horizontal){i=e.width>20?20:i;i=Math.max(20,i-2*t);r=r>2*t?r-2*t:0}else{r=e.height>20?20:r;r=Math.max(20,r-2*t);i=i>2*t?i-2*t:0}a+=t;o+=t}else{i=i>2*t?i-2*t:0;r=r>2*t?r-2*t:0}return new wijmo_1.Rect(a,o,i,r)},set:function(e){e!=this._rect&&(this._rect=e)},enumerable:!0,configurable:!0});Object.defineProperty(_TreeMapItem.prototype,"isTitle",{get:function(){return this._isTitle},set:function(e){var t=wijmo_1.asBoolean(e,!0);t!==this._isTitle&&(this._isTitle=t)},enumerable:!0,configurable:!0});_TreeMapItem._CLASSNAME="wj-treemap-item";return _TreeMapItem}(),_ColorConverter=function(){function _ColorConverter(e,t,i,r,a,o){this.minColor=new wijmo_1.Color(e);this.minColorValue=t;this.maxColor=new wijmo_1.Color(i);this.maxColorValue=r;this.midColorValue=this.originalMidColorValue=o;this._calculateMidColorValue();this.midColor=this.originalMidColor=new wijmo_1.Color(a);this._calculateMidColor()}_ColorConverter.prototype._resetminColor=function(e){this.minColor=new wijmo_1.Color(e);this._calculateMidColor()};_ColorConverter.prototype._resetmidColor=function(e){this.midColor=this.originalMidColor=new wijmo_1.Color(e);this._calculateMidColor()};_ColorConverter.prototype._resetmaxColor=function(e){this.maxColor=new wijmo_1.Color(e);this._calculateMidColor()};_ColorConverter.prototype._resetminColorValue=function(e){this.minColorValue=e;this._calculateMidColorValue()};_ColorConverter.prototype._resetmidColorValue=function(e){this.midColorValue=this.originalMidColorValue=e;this._calculateMidColorValue()};_ColorConverter.prototype._resetmaxColorValue=function(e){this.maxColorValue=e;this._calculateMidColorValue()};_ColorConverter.prototype._calculateMidColorValue=function(){null==this.originalMidColorValue&&(this.midColorValue=(this.maxColorValue+this.minColorValue)/2)};_ColorConverter.prototype._calculateMidColor=function(){null==this.originalMidColor&&(this.midColor=this._calculateColorByVal(this.midColorValue,!0))};_ColorConverter.prototype._calculateColorByVal=function(e,t){void 0===t&&(t=!1);var i=this.maxColor,r=this.minColor,a=this.maxColorValue,o=this.minColorValue;if(e>=this.maxColorValue)return new wijmo_1.Color(i.toString());if(e<=this.minColorValue)return new wijmo_1.Color(r.toString());if(!t){if(e===this.midColorValue)return new wijmo_1.Color(this.midColor.toString());if(e<this.midColorValue){i=this.midColor;a=this.midColorValue}else{r=this.midColor;o=this.midColorValue}}return this._getColor(e,i,a,r,o)};_ColorConverter.prototype._getColor=function(e,t,i,r,a){return wijmo_1.Color.fromRgba(this._getValueByRatio(e,t.r,i,r.r,a),this._getValueByRatio(e,t.g,i,r.g,a),this._getValueByRatio(e,t.b,i,r.b,a),this._getValueByRatio(e,t.a,i,r.a,a))};_ColorConverter.prototype._getValueByRatio=function(e,t,i,r,a){return Math.abs(r+Math.round((e-a)*(t-r)/(i-a)))};return _ColorConverter}(),_TreeMapUtils=function(){function _TreeMapUtils(){}_TreeMapUtils.squarified=function(e,t,i){var r=e.slice(),a=t.clone(),o=a.width*a.height/i;do{var n=_TreeMapUtils.getRowedItems(r,a,o);_TreeMapUtils.layoutRowedItems(t,n,a,a.width>a.height)}while(r.length)};_TreeMapUtils.horizontal=function(e,t,i){var r=t.clone();e.forEach((function(e){var a=[{item:e,val:e.value*t.width*t.height/i}];_TreeMapUtils.layoutRowedItems(t,a,r,!1)}))};_TreeMapUtils.vertical=function(e,t,i){var r=t.clone();e.forEach((function(e){var a=[{item:e,val:e.value*t.width*t.height/i}];_TreeMapUtils.layoutRowedItems(t,a,r,!0)}))};_TreeMapUtils.getNarrowLen=function(e){return Math.min(e.width,e.height)};_TreeMapUtils.getRowedItem=function(e,t,i){return{item:e,val:i*e.value}};_TreeMapUtils.getRowedItems=function(e,t,i){var r=e.shift(),a=[],o=[],n=_TreeMapUtils.getNarrowLen(t),l=_TreeMapUtils.getRowedItem(r,t,i);a.push(l);o.push(l);if(e.length>0)do{o.push(_TreeMapUtils.getRowedItem(e[0],t,i));if(!(_TreeMapUtils.worst(a,n)>_TreeMapUtils.worst(o,n)))break;a=o.slice();e.shift()}while(e.length);return a};_TreeMapUtils.layoutRowedItems=function(e,t,i,r){var a,o=i.left,n=i.top,l=o+i.width,s=n+i.height,h=_TreeMapUtils.sumRowedArray(t);if(r){a=0===i.height?0:h/i.height;o+a>=l&&(a=l-o);t.forEach((function(e,i){var r=0===a?0:e.val/a;(n+r>s||i===t.length-1)&&(r=s-n);var l=new wijmo_1.Rect(o,n,a,r);e.item.rect=l;n+=r}));i.left+=a;i.width-=a}else{a=0===i.width?0:h/i.width;n+a>=s&&(a=s-n);t.forEach((function(e,i){var r=0===a?0:e.val/a;(o+r>l||i===t.length-1)&&(r=l-o);var s=new wijmo_1.Rect(o,n,r,a);e.item.rect=s;o+=r}));i.top+=a;i.height-=a}};_TreeMapUtils.sumRowedArray=function(e){for(var t=0,i=e.length,r=0;r<i;r++)t+=e[r].val;return t};_TreeMapUtils.worst=function(e,t){var i,r,a=_TreeMapUtils.sumRowedArray(e),o=a*a,n=t*t;i=r=e[0].val;e.forEach((function(e,t){e.val>i?i=e.val:e.val<r&&(r=e.val)}));return Math.max(n*i/o,o/(n*r))};return _TreeMapUtils}(),Sunburst=function(e){__extends(Sunburst,e);function Sunburst(t,i){var r=e.call(this,t,i)||this;r._selectionIndex=0;r.applyTemplate("wj-sunburst",null,null);r.initialize(i);r.refresh();return r}Object.defineProperty(Sunburst.prototype,"bindingName",{get:function(){return this._bindName},set:function(e){if(e!=this._bindName){wijmo_1.assert(null==e||wijmo_1.isArray(e)||wijmo_1.isString(e),"bindingName should be an array or a string.");this._bindName=e;this._bindChart()}},enumerable:!0,configurable:!0});Object.defineProperty(Sunburst.prototype,"childItemsPath",{get:function(){return this._childItemsPath},set:function(e){if(e!=this._childItemsPath){wijmo_1.assert(null==e||wijmo_1.isArray(e)||wijmo_1.isString(e),"childItemsPath should be an array or a string.");this._childItemsPath=e;this._bindChart()}},enumerable:!0,configurable:!0});Sunburst.prototype._initData=function(){e.prototype._initData.call(this);this._processedData=[];this._level=1;this._legendLabels=[];this._processedItem=[];this._values[0]=[]};Sunburst.prototype._performBind=function(){var e,t=this;this._initData();if(this._cv){e=this._cv.items;this._cv.groups&&this._cv.groups.length?this._processedData=HierarchicalUtil.parseDataToHierarchical(this._cv,this.binding,this.bindingName,this.childItemsPath):e&&(this._processedData=HierarchicalUtil.parseDataToHierarchical(e,this.binding,this.bindingName,this.childItemsPath));if(this._processedData&&this._processedData.length){this._sums[0]=this._sum=this._calculateValueAndLevel(this._processedData,1);this._processedData.forEach((function(e){t._legendLabels.push(e.name)}))}}};Sunburst.prototype._calculateValueAndLevel=function(e,t){var i=this,r=0,a=this._values[0],o=this._labels;this._level<t&&(this._level=t);e.forEach((function(e){var n;if(e.items){n=i._calculateValueAndLevel(e.items,t+1);e.value=n;a.push(n);o.push(e.name)}else{n=i._getBindData(e,a,o,"value","name");e.value=n}r+=n}));return r};Sunburst.prototype._renderPie=function(e,t,i,r,a,o){var n=this._getCenter();this._sliceIndex=0;this._parentRef={};this._renderHierarchicalSlices(e,n.x,n.y,this._processedData,this._sum,i,r,a,2*Math.PI,o,1)};Sunburst.prototype._renderHierarchicalSlices=function(e,t,i,r,a,o,n,l,s,h,_){var c,u,p,m,d,f,g,w,v,C,T=r.length,b=l,M=1==this.reversed;p=(o-n)/this._level;c=o-(this._level-_)*p;u=n+(_-1)*p;for(var y=0;y<T;y++){w=t;v=i;g=e.startGroup("wj-slice slice-level"+_);if(1===_){e.fill=this._getColorLight(y);e.stroke=this._getColor(y)}d=r[y];f=Math.abs(d.value);m=Math.abs(f-a)<1e-10?s:s*f/a;C=M?b-.5*m:b+.5*m;if(h>0&&m<s){w+=h*Math.cos(C);v+=h*Math.sin(C)}if(d.items){var I=this._sliceIndex;this._renderHierarchicalSlices(e,w,v,d.items,f,o,n,b,m,0,_+1);for(;I<this._sliceIndex;I++)null==this._parentRef[I]&&(this._parentRef[I]=this._sliceIndex)}this._renderSlice(e,w,v,C,0,this._sliceIndex,c,u,b,m,s);this._processedItem.push(d.item);this._sliceIndex++;M?b-=m:b+=m;e.endGroup();this._pels.push(g)}};Sunburst.prototype._getLabelsForLegend=function(){return this._legendLabels||[]};Sunburst.prototype._highlightCurrent=function(){this.selectionMode!=wijmo_chart_1.SelectionMode.None&&this._highlight(!0,this._selectionIndex)};Sunburst.prototype.hitTest=function(t,i){var r=e.prototype.hitTest.call(this,t,i),a=this._toControl(t,i);if(wijmo_chart_1.FlexChartBase._contains(this._rectChart,a)){var o=r.pointIndex,n=this._processedItem[o],l=new wijmo_chart_1._DataPoint(null,o,null,null);l.item=n;r._setDataPoint(l)}return r};Sunburst.prototype._getSelectedItemOffset=function(e,t){var i=0,r=0,a=0;if(this.selectedItemOffset>0)if(e==this.selectedIndex)a=this.selectedItemOffset;else{var o=this._getSelectedParentIndex(e);if(null!=o){var n=this._areas[o];this.dataLabel.position;a=this.selectedItemOffset;t=((t=n.langle+this._rotationAngles[0])%360+360)%360;t*=Math.PI/180}}if(a>0){i=Math.cos(t)*a*this._radius;r=Math.sin(t)*a*this._radius}return{x:i,y:r}};Sunburst.prototype._getSelectedParentIndex=function(e){var t=this._parentRef[e];return null!=t?t===this.selectedIndex?t:this._getSelectedParentIndex(t):null};return Sunburst}(wijmo_chart_1.FlexPie);exports.Sunburst=Sunburst;wijmo_1._registerModule("wijmo.chart.hierarchical",selfModule);
package/package.json CHANGED
@@ -1,14 +1,14 @@
1
1
  {
2
2
  "name": "@mescius/wijmo.chart.hierarchical",
3
- "version": "5.20232.939",
3
+ "version": "5.20241.3-rc",
4
4
  "description": "UI library for pure JS, Angular, React, Vue and more...",
5
5
  "author": "MESCIUS inc",
6
6
  "license": "Commercial",
7
7
  "main": "./index.js",
8
8
  "types": "./index.d.ts",
9
9
  "dependencies": {
10
- "@mescius/wijmo": "5.20232.939",
11
- "@mescius/wijmo.chart": "5.20232.939"
10
+ "@mescius/wijmo": "5.20241.3-rc",
11
+ "@mescius/wijmo.chart": "5.20241.3-rc"
12
12
  },
13
13
  "homepage": "https://developer.mescius.com/wijmo",
14
14
  "bugs": {