@syncfusion/ej2-treemap 20.1.47 → 20.2.36

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.
@@ -1343,7 +1343,7 @@ function removeClassNames(elements, type, treemap) {
1343
1343
  for (var j = 0; j < elements.length; j++) {
1344
1344
  element = isNullOrUndefined(elements[j].childNodes[0]) ? elements[j] :
1345
1345
  elements[j].childNodes[0];
1346
- options = treemap.layout.renderItems[element.id.split('_')[6]]['options'];
1346
+ options = treemap.layout.renderItems[parseFloat(element.id.split('_Item_Index_')[1])]['options'];
1347
1347
  applyOptions(element, options);
1348
1348
  elements[j].classList.remove(type);
1349
1349
  j -= 1;
@@ -2206,9 +2206,11 @@ var LayoutPanel = /** @__PURE__ @class */ (function () {
2206
2206
  }
2207
2207
  if (template) {
2208
2208
  templateEle = _this.renderTemplate(secondaryEle, groupId, rect, templatePosition, template, item, isLeafItem);
2209
- templateGroup.appendChild(templateEle);
2210
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
2211
- _this.treemap.renderReactTemplates();
2209
+ if (!isNullOrUndefined(templateEle)) {
2210
+ templateGroup.appendChild(templateEle);
2211
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
2212
+ _this.treemap.renderReactTemplates();
2213
+ }
2212
2214
  }
2213
2215
  itemGroup.setAttribute('aria-label', item['name']);
2214
2216
  itemGroup.setAttribute('tabindex', (_this.treemap.tabIndex + i + 2).toString());
@@ -2347,15 +2349,18 @@ var LayoutPanel = /** @__PURE__ @class */ (function () {
2347
2349
  template = template.replace(new RegExp('{{:' + keys[i] + '}}', 'g'), item['data'][keys[i].toString()]);
2348
2350
  }
2349
2351
  }
2350
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
2351
- var templateFn = getTemplateFunction(template);
2352
- var templateElement = templateFn(item['data'], this.treemap, template, this.treemap.element.id + baseTemplateId, false);
2353
- var labelEle = convertElement(templateElement, templateId, item['data']);
2354
- var templateSize = measureElement(labelEle, secondaryEle);
2355
- var templateLocation = findLabelLocation(rect, position, templateSize, 'Template', this.treemap);
2356
- labelEle.style.left = templateLocation.x + 'px';
2357
- labelEle.style.top = templateLocation.y + 'px';
2358
- return labelEle;
2352
+ var labelElement;
2353
+ if (!isNullOrUndefined(document.getElementById(this.treemap.element.id + '_Secondary_Element'))) {
2354
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
2355
+ var templateFn = getTemplateFunction(template);
2356
+ var templateElement = templateFn(item['data'], this.treemap, template, this.treemap.element.id + baseTemplateId, false);
2357
+ labelElement = convertElement(templateElement, templateId, item['data']);
2358
+ var templateSize = measureElement(labelElement, secondaryEle);
2359
+ var templateLocation = findLabelLocation(rect, position, templateSize, 'Template', this.treemap);
2360
+ labelElement.style.left = templateLocation.x + 'px';
2361
+ labelElement.style.top = templateLocation.y + 'px';
2362
+ }
2363
+ return labelElement;
2359
2364
  };
2360
2365
  LayoutPanel.prototype.labelInterSectAction = function (rect, text, textStyle, alignment) {
2361
2366
  var textValue;
@@ -3019,7 +3024,8 @@ var TreeMap = /** @__PURE__ @class */ (function (_super) {
3019
3024
  };
3020
3025
  TreeMap.prototype.elementChange = function () {
3021
3026
  if (this.treeMapLegendModule && this.legendSettings.visible && this.treeMapLegendModule.legendGroup && this.layout.layoutGroup
3022
- && !isNullOrUndefined(this.svgObject)) {
3027
+ && !isNullOrUndefined(this.svgObject) && !isNullOrUndefined(document.getElementById(this.layout.layoutGroup.id))
3028
+ && !isNullOrUndefined(document.getElementById(this.treeMapLegendModule.legendGroup.id))) {
3023
3029
  this.svgObject.insertBefore(this.layout.layoutGroup, this.treeMapLegendModule.legendGroup);
3024
3030
  }
3025
3031
  };
@@ -3477,7 +3483,7 @@ var TreeMap = /** @__PURE__ @class */ (function (_super) {
3477
3483
  this.trigger(click, clickArgs);
3478
3484
  if (targetId.indexOf('_Item_Index') > -1) {
3479
3485
  e.preventDefault();
3480
- itemIndex = parseFloat(targetId.split('_')[6]);
3486
+ itemIndex = parseFloat(targetId.split('_Item_Index_')[1]);
3481
3487
  eventArgs = {
3482
3488
  cancel: false, name: itemClick, treemap: this, item: this.layout.renderItems[itemIndex], mouseEvent: e,
3483
3489
  groupIndex: this.layout.renderItems[itemIndex]['groupIndex'], groupName: this.layout.renderItems[itemIndex]['name'],
@@ -3550,7 +3556,7 @@ var TreeMap = /** @__PURE__ @class */ (function (_super) {
3550
3556
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
3551
3557
  var childItems;
3552
3558
  if (targetId.indexOf('_Item_Index') > -1) {
3553
- item = this.layout.renderItems[parseFloat(targetId.split('_')[6])];
3559
+ item = this.layout.renderItems[parseFloat(targetId.split('_Item_Index_')[1])];
3554
3560
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
3555
3561
  childItems = findChildren(item)['values'];
3556
3562
  this.element.style.cursor = (!item['isLeafItem'] && childItems && childItems.length > 0 && this.enableDrillDown) ?
@@ -3678,7 +3684,7 @@ var TreeMap = /** @__PURE__ @class */ (function (_super) {
3678
3684
  if (e.cancelable) {
3679
3685
  e.preventDefault();
3680
3686
  }
3681
- index = parseFloat(targetId.split('_')[6]);
3687
+ index = parseFloat(targetId.split('_Item_Index_')[1]);
3682
3688
  item = this.layout.renderItems[index];
3683
3689
  var labelText = targetEle.innerHTML;
3684
3690
  if (this.enableBreadcrumb) {
@@ -4890,7 +4896,7 @@ var TreeMapLegend = /** @__PURE__ @class */ (function () {
4890
4896
  var stroke = void 0;
4891
4897
  var strokeWidth = void 0;
4892
4898
  var legendElement = void 0;
4893
- targetItem = treemap.layout.renderItems[parseFloat(target.id.split('_')[6])];
4899
+ targetItem = treemap.layout.renderItems[parseFloat(target.id.split('_Item_Index_')[1])];
4894
4900
  var svgRect = treemap.svgObject.getBoundingClientRect();
4895
4901
  for (var i = 0; i < this.legendCollections.length; i++) {
4896
4902
  currentData = this.legendCollections[i];
@@ -5164,14 +5170,14 @@ var TreeMapHighlight = /** @__PURE__ @class */ (function () {
5164
5170
  if (this.highLightId !== targetId) {
5165
5171
  treeMapElement = document.getElementById(treemap.element.id + '_TreeMap_' + treemap.layoutType + '_Layout');
5166
5172
  var selectionElements = document.getElementsByClassName('treeMapSelection');
5167
- item = this.treemap.layout.renderItems[parseFloat(targetId.split('_')[6])];
5173
+ item = this.treemap.layout.renderItems[parseFloat(targetId.split('_Item_Index_')[1])];
5168
5174
  var index = void 0;
5169
5175
  if (this.treemap.legendSettings.visible) {
5170
5176
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
5171
5177
  var collection = this.treemap.treeMapLegendModule.legendCollections;
5172
5178
  var length_1 = this.treemap.treeMapLegendModule.legendCollections.length;
5173
5179
  index = getLegendIndex(length_1, item, treemap);
5174
- this.shapeElement = this.treemap.legendSettings.mode === 'Default' ? document.getElementById('container_Legend_Shape_Index_' + index) : document.getElementById('container_Legend_Index_' + index);
5180
+ this.shapeElement = this.treemap.legendSettings.mode === 'Default' ? document.getElementById(this.treemap.element.id + '_Legend_Shape_Index_' + index) : document.getElementById(this.treemap.element.id + '_Legend_Index_' + index);
5175
5181
  if (this.shapeElement !== null && (selectionModule ? this.shapeElement.getAttribute('id') !== selectionModule.legendSelectId : true)) {
5176
5182
  if (selectionModule ? this.shapeElement !== selectionModule.shapeElement : true) {
5177
5183
  this.currentElement.push({ currentElement: this.shapeElement });
@@ -5199,7 +5205,7 @@ var TreeMapHighlight = /** @__PURE__ @class */ (function () {
5199
5205
  for (var i = 0; i < treeMapElement.childElementCount; i++) {
5200
5206
  element = treeMapElement.childNodes[i];
5201
5207
  process = true;
5202
- item = treemap.layout.renderItems[element.id.split('_')[6]];
5208
+ item = treemap.layout.renderItems[parseFloat(element.id.split('_Item_Index_')[1])];
5203
5209
  for (var j = 0; j < selectionElements.length; j++) {
5204
5210
  if (element.id === selectionElements[j].id) {
5205
5211
  process = false;
@@ -5237,7 +5243,7 @@ var TreeMapHighlight = /** @__PURE__ @class */ (function () {
5237
5243
  removeLegend(this.legendHighlightCollection, 'highlight');
5238
5244
  }
5239
5245
  this.shapeTarget = 'highlight';
5240
- var index = this.treemap.legendSettings.mode === 'Default' ? parseFloat(targetId.split('_')[4]) : parseFloat(targetId.split('_')[3]);
5246
+ var index = this.treemap.legendSettings.mode === 'Default' ? parseFloat(targetId.split('_Legend_Shape_Index_')[1]) : parseFloat(targetId.split('_Legend_Index_')[1]);
5241
5247
  var dataLength = this.treemap.treeMapLegendModule.legendCollections[index]['legendData'].length;
5242
5248
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
5243
5249
  var collection = this.treemap.treeMapLegendModule.legendCollections;
@@ -5247,7 +5253,7 @@ var TreeMapHighlight = /** @__PURE__ @class */ (function () {
5247
5253
  if (this.treemap.treeMapLegendModule.legendCollections[index]['legendData'][i]['levelOrderName'] === this.treemap.layout.renderItems[j]['levelOrderName']) {
5248
5254
  itemIndex = j;
5249
5255
  groupIndex = this.treemap.layout.renderItems[j]['groupIndex'];
5250
- var nodeEle = document.getElementById('container_Level_Index_' + groupIndex + '_Item_Index_' + itemIndex + '_RectPath');
5256
+ var nodeEle = document.getElementById(this.treemap.element.id + '_Level_Index_' + groupIndex + '_Item_Index_' + itemIndex + '_RectPath');
5251
5257
  if (i === 0) {
5252
5258
  this.legendHighlightCollection = [];
5253
5259
  pushCollection(this.legendHighlightCollection, legendIndex, j, targetEle, nodeEle, this.treemap.layout.renderItems, collection);
@@ -5369,7 +5375,7 @@ var TreeMapSelection = /** @__PURE__ @class */ (function () {
5369
5375
  e.preventDefault();
5370
5376
  if (this.treemap.selectionId !== targetId && this.legendSelect) {
5371
5377
  treeMapElement = document.getElementById(layoutID);
5372
- item = treemap.layout.renderItems[parseFloat(targetId.split('_')[6])];
5378
+ item = treemap.layout.renderItems[parseFloat(targetId.split('_Item_Index_')[1])];
5373
5379
  var index = void 0;
5374
5380
  if (this.treemap.legendSettings.visible) {
5375
5381
  this.shapeSelect = false;
@@ -5383,7 +5389,7 @@ var TreeMapSelection = /** @__PURE__ @class */ (function () {
5383
5389
  highlightModule.shapeHighlightCollection = [];
5384
5390
  }
5385
5391
  index = getLegendIndex(length_3, item, treemap);
5386
- this.shapeElement = this.treemap.legendSettings.mode === 'Default' ? document.getElementById('container_Legend_Shape_Index_' + index) : document.getElementById('container_Legend_Index_' + index);
5392
+ this.shapeElement = this.treemap.legendSettings.mode === 'Default' ? document.getElementById(this.treemap.element.id + '_Legend_Shape_Index_' + index) : document.getElementById(this.treemap.element.id + '_Legend_Index_' + index);
5387
5393
  if (this.shapeElement !== null) {
5388
5394
  this.shapeSelectId = this.shapeElement.getAttribute('id');
5389
5395
  this.shapeSelectionCollection.push({ legendEle: this.shapeElement, oldFill: collection[index]['legendFill'],
@@ -5396,7 +5402,7 @@ var TreeMapSelection = /** @__PURE__ @class */ (function () {
5396
5402
  orders = findHightLightItems(item, [], selection.mode, treemap);
5397
5403
  for (var i = 0; i < treeMapElement.childElementCount; i++) {
5398
5404
  element = treeMapElement.childNodes[i];
5399
- item = treemap.layout.renderItems[element.id.split('_')[6]];
5405
+ item = treemap.layout.renderItems[parseFloat(element.id.split('_Item_Index_')[1])];
5400
5406
  if (orders.indexOf(item['levelOrderName']) > -1) {
5401
5407
  selectionElements.push(element);
5402
5408
  treemap.levelSelection.push(element.id);
@@ -5456,14 +5462,14 @@ var TreeMapSelection = /** @__PURE__ @class */ (function () {
5456
5462
  if (highlightModule) {
5457
5463
  highlightModule.shapeTarget = 'selection';
5458
5464
  }
5459
- var index = this.treemap.legendSettings.mode === 'Default' ? parseFloat(targetId.split('_')[4]) : parseFloat(targetId.split('_')[3]);
5465
+ var index = this.treemap.legendSettings.mode === 'Default' ? parseFloat(targetId.split('_Legend_Shape_Index_')[1]) : parseFloat(targetId.split('_Legend_Index_')[1]);
5460
5466
  var dataLength = this.treemap.treeMapLegendModule.legendCollections[index]['legendData'].length;
5461
5467
  for (var k = 0; k < dataLength; k++) {
5462
5468
  for (var l = 0; l < this.treemap.layout.renderItems.length; l++) {
5463
5469
  if (this.treemap.treeMapLegendModule.legendCollections[index]['legendData'][k]['levelOrderName'] === this.treemap.layout.renderItems[l]['levelOrderName']) {
5464
5470
  itemIndex = l;
5465
5471
  groupIndex = this.treemap.layout.renderItems[l]['groupIndex'];
5466
- var nodeEle = document.getElementById('container_Level_Index_' + groupIndex + '_Item_Index_' + itemIndex + '_RectPath');
5472
+ var nodeEle = document.getElementById(this.treemap.element.id + '_Level_Index_' + groupIndex + '_Item_Index_' + itemIndex + '_RectPath');
5467
5473
  if (k === 0) {
5468
5474
  pushCollection(this.legendSelectionCollection, legendIndex, l, targetEle_1, nodeEle, this.treemap.layout.renderItems, collection);
5469
5475
  length_4 = this.legendSelectionCollection.length;
@@ -5515,7 +5521,7 @@ var TreeMapSelection = /** @__PURE__ @class */ (function () {
5515
5521
  var orders = findHightLightItems(item, [], selection.mode, this.treemap);
5516
5522
  for (var i = 0; i < treeMapElement.childElementCount; i++) {
5517
5523
  element = treeMapElement.childNodes[i];
5518
- item = this.treemap.layout.renderItems[element.id.split('_')[6]];
5524
+ item = this.treemap.layout.renderItems[parseFloat(element.id.split('_Item_Index_')[1])];
5519
5525
  if (orders.indexOf(item['levelOrderName']) > -1) {
5520
5526
  selectionElements.push(element);
5521
5527
  this.treemap.levelSelection.push(element.id);
@@ -5531,7 +5537,7 @@ var TreeMapSelection = /** @__PURE__ @class */ (function () {
5531
5537
  this.shapeElement = undefined;
5532
5538
  removeShape(this.shapeSelectionCollection, 'selection');
5533
5539
  index = getLegendIndex(length_5, items[m], this.treemap);
5534
- this.shapeElement = this.treemap.legendSettings.mode === 'Default' ? document.getElementById('container_Legend_Shape_Index_' + index) : document.getElementById('container_Legend_Index_' + index);
5540
+ this.shapeElement = this.treemap.legendSettings.mode === 'Default' ? document.getElementById(this.treemap.element.id + '_Legend_Shape_Index_' + index) : document.getElementById(this.treemap.element.id + '_Legend_Index_' + index);
5535
5541
  if (this.shapeElement !== null) {
5536
5542
  this.shapeSelectId = this.shapeElement.getAttribute('id');
5537
5543
  this.treemap.legendId.push(this.shapeSelectId);
@@ -5674,7 +5680,7 @@ var TreeMapTooltip = /** @__PURE__ @class */ (function () {
5674
5680
  var tooltipContent = [];
5675
5681
  var markerFill;
5676
5682
  if (targetId.indexOf('_Item_Index') > -1) {
5677
- item = this.treemap.layout.renderItems[parseFloat(targetId.split('_')[6])];
5683
+ item = this.treemap.layout.renderItems[parseFloat(targetId.split('_Item_Index_')[1])];
5678
5684
  if (!isNullOrUndefined(item)) {
5679
5685
  toolTipHeader = item['name'];
5680
5686
  value = item['weight'];