@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.
@@ -1252,7 +1252,7 @@ function removeClassNames(elements, type, treemap) {
1252
1252
  for (let j = 0; j < elements.length; j++) {
1253
1253
  element = isNullOrUndefined(elements[j].childNodes[0]) ? elements[j] :
1254
1254
  elements[j].childNodes[0];
1255
- options = treemap.layout.renderItems[element.id.split('_')[6]]['options'];
1255
+ options = treemap.layout.renderItems[parseFloat(element.id.split('_Item_Index_')[1])]['options'];
1256
1256
  applyOptions(element, options);
1257
1257
  elements[j].classList.remove(type);
1258
1258
  j -= 1;
@@ -2111,9 +2111,11 @@ class LayoutPanel {
2111
2111
  }
2112
2112
  if (template) {
2113
2113
  templateEle = this.renderTemplate(secondaryEle, groupId, rect, templatePosition, template, item, isLeafItem);
2114
- templateGroup.appendChild(templateEle);
2115
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
2116
- this.treemap.renderReactTemplates();
2114
+ if (!isNullOrUndefined(templateEle)) {
2115
+ templateGroup.appendChild(templateEle);
2116
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
2117
+ this.treemap.renderReactTemplates();
2118
+ }
2117
2119
  }
2118
2120
  itemGroup.setAttribute('aria-label', item['name']);
2119
2121
  itemGroup.setAttribute('tabindex', (this.treemap.tabIndex + i + 2).toString());
@@ -2248,15 +2250,18 @@ class LayoutPanel {
2248
2250
  template = template.replace(new RegExp('{{:' + keys[i] + '}}', 'g'), item['data'][keys[i].toString()]);
2249
2251
  }
2250
2252
  }
2251
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
2252
- const templateFn = getTemplateFunction(template);
2253
- const templateElement = templateFn(item['data'], this.treemap, template, this.treemap.element.id + baseTemplateId, false);
2254
- const labelEle = convertElement(templateElement, templateId, item['data']);
2255
- const templateSize = measureElement(labelEle, secondaryEle);
2256
- const templateLocation = findLabelLocation(rect, position, templateSize, 'Template', this.treemap);
2257
- labelEle.style.left = templateLocation.x + 'px';
2258
- labelEle.style.top = templateLocation.y + 'px';
2259
- return labelEle;
2253
+ let labelElement;
2254
+ if (!isNullOrUndefined(document.getElementById(this.treemap.element.id + '_Secondary_Element'))) {
2255
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
2256
+ const templateFn = getTemplateFunction(template);
2257
+ const templateElement = templateFn(item['data'], this.treemap, template, this.treemap.element.id + baseTemplateId, false);
2258
+ labelElement = convertElement(templateElement, templateId, item['data']);
2259
+ const templateSize = measureElement(labelElement, secondaryEle);
2260
+ const templateLocation = findLabelLocation(rect, position, templateSize, 'Template', this.treemap);
2261
+ labelElement.style.left = templateLocation.x + 'px';
2262
+ labelElement.style.top = templateLocation.y + 'px';
2263
+ }
2264
+ return labelElement;
2260
2265
  }
2261
2266
  labelInterSectAction(rect, text, textStyle, alignment) {
2262
2267
  let textValue;
@@ -2896,7 +2901,8 @@ let TreeMap = class TreeMap extends Component {
2896
2901
  }
2897
2902
  elementChange() {
2898
2903
  if (this.treeMapLegendModule && this.legendSettings.visible && this.treeMapLegendModule.legendGroup && this.layout.layoutGroup
2899
- && !isNullOrUndefined(this.svgObject)) {
2904
+ && !isNullOrUndefined(this.svgObject) && !isNullOrUndefined(document.getElementById(this.layout.layoutGroup.id))
2905
+ && !isNullOrUndefined(document.getElementById(this.treeMapLegendModule.legendGroup.id))) {
2900
2906
  this.svgObject.insertBefore(this.layout.layoutGroup, this.treeMapLegendModule.legendGroup);
2901
2907
  }
2902
2908
  }
@@ -3344,7 +3350,7 @@ let TreeMap = class TreeMap extends Component {
3344
3350
  this.trigger(click, clickArgs);
3345
3351
  if (targetId.indexOf('_Item_Index') > -1) {
3346
3352
  e.preventDefault();
3347
- itemIndex = parseFloat(targetId.split('_')[6]);
3353
+ itemIndex = parseFloat(targetId.split('_Item_Index_')[1]);
3348
3354
  eventArgs = {
3349
3355
  cancel: false, name: itemClick, treemap: this, item: this.layout.renderItems[itemIndex], mouseEvent: e,
3350
3356
  groupIndex: this.layout.renderItems[itemIndex]['groupIndex'], groupName: this.layout.renderItems[itemIndex]['name'],
@@ -3417,7 +3423,7 @@ let TreeMap = class TreeMap extends Component {
3417
3423
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
3418
3424
  let childItems;
3419
3425
  if (targetId.indexOf('_Item_Index') > -1) {
3420
- item = this.layout.renderItems[parseFloat(targetId.split('_')[6])];
3426
+ item = this.layout.renderItems[parseFloat(targetId.split('_Item_Index_')[1])];
3421
3427
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
3422
3428
  childItems = findChildren(item)['values'];
3423
3429
  this.element.style.cursor = (!item['isLeafItem'] && childItems && childItems.length > 0 && this.enableDrillDown) ?
@@ -3542,7 +3548,7 @@ let TreeMap = class TreeMap extends Component {
3542
3548
  if (e.cancelable) {
3543
3549
  e.preventDefault();
3544
3550
  }
3545
- index = parseFloat(targetId.split('_')[6]);
3551
+ index = parseFloat(targetId.split('_Item_Index_')[1]);
3546
3552
  item = this.layout.renderItems[index];
3547
3553
  const labelText = targetEle.innerHTML;
3548
3554
  if (this.enableBreadcrumb) {
@@ -4741,7 +4747,7 @@ class TreeMapLegend {
4741
4747
  let stroke;
4742
4748
  let strokeWidth;
4743
4749
  let legendElement;
4744
- targetItem = treemap.layout.renderItems[parseFloat(target.id.split('_')[6])];
4750
+ targetItem = treemap.layout.renderItems[parseFloat(target.id.split('_Item_Index_')[1])];
4745
4751
  const svgRect = treemap.svgObject.getBoundingClientRect();
4746
4752
  for (let i = 0; i < this.legendCollections.length; i++) {
4747
4753
  currentData = this.legendCollections[i];
@@ -5014,14 +5020,14 @@ class TreeMapHighlight {
5014
5020
  if (this.highLightId !== targetId) {
5015
5021
  treeMapElement = document.getElementById(treemap.element.id + '_TreeMap_' + treemap.layoutType + '_Layout');
5016
5022
  const selectionElements = document.getElementsByClassName('treeMapSelection');
5017
- item = this.treemap.layout.renderItems[parseFloat(targetId.split('_')[6])];
5023
+ item = this.treemap.layout.renderItems[parseFloat(targetId.split('_Item_Index_')[1])];
5018
5024
  let index;
5019
5025
  if (this.treemap.legendSettings.visible) {
5020
5026
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
5021
5027
  const collection = this.treemap.treeMapLegendModule.legendCollections;
5022
5028
  const length = this.treemap.treeMapLegendModule.legendCollections.length;
5023
5029
  index = getLegendIndex(length, item, treemap);
5024
- this.shapeElement = this.treemap.legendSettings.mode === 'Default' ? document.getElementById('container_Legend_Shape_Index_' + index) : document.getElementById('container_Legend_Index_' + index);
5030
+ 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);
5025
5031
  if (this.shapeElement !== null && (selectionModule ? this.shapeElement.getAttribute('id') !== selectionModule.legendSelectId : true)) {
5026
5032
  if (selectionModule ? this.shapeElement !== selectionModule.shapeElement : true) {
5027
5033
  this.currentElement.push({ currentElement: this.shapeElement });
@@ -5049,7 +5055,7 @@ class TreeMapHighlight {
5049
5055
  for (let i = 0; i < treeMapElement.childElementCount; i++) {
5050
5056
  element = treeMapElement.childNodes[i];
5051
5057
  process = true;
5052
- item = treemap.layout.renderItems[element.id.split('_')[6]];
5058
+ item = treemap.layout.renderItems[parseFloat(element.id.split('_Item_Index_')[1])];
5053
5059
  for (let j = 0; j < selectionElements.length; j++) {
5054
5060
  if (element.id === selectionElements[j].id) {
5055
5061
  process = false;
@@ -5087,7 +5093,7 @@ class TreeMapHighlight {
5087
5093
  removeLegend(this.legendHighlightCollection, 'highlight');
5088
5094
  }
5089
5095
  this.shapeTarget = 'highlight';
5090
- const index = this.treemap.legendSettings.mode === 'Default' ? parseFloat(targetId.split('_')[4]) : parseFloat(targetId.split('_')[3]);
5096
+ const index = this.treemap.legendSettings.mode === 'Default' ? parseFloat(targetId.split('_Legend_Shape_Index_')[1]) : parseFloat(targetId.split('_Legend_Index_')[1]);
5091
5097
  const dataLength = this.treemap.treeMapLegendModule.legendCollections[index]['legendData'].length;
5092
5098
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
5093
5099
  const collection = this.treemap.treeMapLegendModule.legendCollections;
@@ -5097,7 +5103,7 @@ class TreeMapHighlight {
5097
5103
  if (this.treemap.treeMapLegendModule.legendCollections[index]['legendData'][i]['levelOrderName'] === this.treemap.layout.renderItems[j]['levelOrderName']) {
5098
5104
  itemIndex = j;
5099
5105
  groupIndex = this.treemap.layout.renderItems[j]['groupIndex'];
5100
- const nodeEle = document.getElementById('container_Level_Index_' + groupIndex + '_Item_Index_' + itemIndex + '_RectPath');
5106
+ const nodeEle = document.getElementById(this.treemap.element.id + '_Level_Index_' + groupIndex + '_Item_Index_' + itemIndex + '_RectPath');
5101
5107
  if (i === 0) {
5102
5108
  this.legendHighlightCollection = [];
5103
5109
  pushCollection(this.legendHighlightCollection, legendIndex, j, targetEle, nodeEle, this.treemap.layout.renderItems, collection);
@@ -5218,7 +5224,7 @@ class TreeMapSelection {
5218
5224
  e.preventDefault();
5219
5225
  if (this.treemap.selectionId !== targetId && this.legendSelect) {
5220
5226
  treeMapElement = document.getElementById(layoutID);
5221
- item = treemap.layout.renderItems[parseFloat(targetId.split('_')[6])];
5227
+ item = treemap.layout.renderItems[parseFloat(targetId.split('_Item_Index_')[1])];
5222
5228
  let index;
5223
5229
  if (this.treemap.legendSettings.visible) {
5224
5230
  this.shapeSelect = false;
@@ -5232,7 +5238,7 @@ class TreeMapSelection {
5232
5238
  highlightModule.shapeHighlightCollection = [];
5233
5239
  }
5234
5240
  index = getLegendIndex(length, item, treemap);
5235
- this.shapeElement = this.treemap.legendSettings.mode === 'Default' ? document.getElementById('container_Legend_Shape_Index_' + index) : document.getElementById('container_Legend_Index_' + index);
5241
+ 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);
5236
5242
  if (this.shapeElement !== null) {
5237
5243
  this.shapeSelectId = this.shapeElement.getAttribute('id');
5238
5244
  this.shapeSelectionCollection.push({ legendEle: this.shapeElement, oldFill: collection[index]['legendFill'],
@@ -5245,7 +5251,7 @@ class TreeMapSelection {
5245
5251
  orders = findHightLightItems(item, [], selection.mode, treemap);
5246
5252
  for (let i = 0; i < treeMapElement.childElementCount; i++) {
5247
5253
  element = treeMapElement.childNodes[i];
5248
- item = treemap.layout.renderItems[element.id.split('_')[6]];
5254
+ item = treemap.layout.renderItems[parseFloat(element.id.split('_Item_Index_')[1])];
5249
5255
  if (orders.indexOf(item['levelOrderName']) > -1) {
5250
5256
  selectionElements.push(element);
5251
5257
  treemap.levelSelection.push(element.id);
@@ -5305,14 +5311,14 @@ class TreeMapSelection {
5305
5311
  if (highlightModule) {
5306
5312
  highlightModule.shapeTarget = 'selection';
5307
5313
  }
5308
- const index = this.treemap.legendSettings.mode === 'Default' ? parseFloat(targetId.split('_')[4]) : parseFloat(targetId.split('_')[3]);
5314
+ const index = this.treemap.legendSettings.mode === 'Default' ? parseFloat(targetId.split('_Legend_Shape_Index_')[1]) : parseFloat(targetId.split('_Legend_Index_')[1]);
5309
5315
  const dataLength = this.treemap.treeMapLegendModule.legendCollections[index]['legendData'].length;
5310
5316
  for (let k = 0; k < dataLength; k++) {
5311
5317
  for (let l = 0; l < this.treemap.layout.renderItems.length; l++) {
5312
5318
  if (this.treemap.treeMapLegendModule.legendCollections[index]['legendData'][k]['levelOrderName'] === this.treemap.layout.renderItems[l]['levelOrderName']) {
5313
5319
  itemIndex = l;
5314
5320
  groupIndex = this.treemap.layout.renderItems[l]['groupIndex'];
5315
- const nodeEle = document.getElementById('container_Level_Index_' + groupIndex + '_Item_Index_' + itemIndex + '_RectPath');
5321
+ const nodeEle = document.getElementById(this.treemap.element.id + '_Level_Index_' + groupIndex + '_Item_Index_' + itemIndex + '_RectPath');
5316
5322
  if (k === 0) {
5317
5323
  pushCollection(this.legendSelectionCollection, legendIndex, l, targetEle, nodeEle, this.treemap.layout.renderItems, collection);
5318
5324
  length = this.legendSelectionCollection.length;
@@ -5364,7 +5370,7 @@ class TreeMapSelection {
5364
5370
  const orders = findHightLightItems(item, [], selection.mode, this.treemap);
5365
5371
  for (let i = 0; i < treeMapElement.childElementCount; i++) {
5366
5372
  element = treeMapElement.childNodes[i];
5367
- item = this.treemap.layout.renderItems[element.id.split('_')[6]];
5373
+ item = this.treemap.layout.renderItems[parseFloat(element.id.split('_Item_Index_')[1])];
5368
5374
  if (orders.indexOf(item['levelOrderName']) > -1) {
5369
5375
  selectionElements.push(element);
5370
5376
  this.treemap.levelSelection.push(element.id);
@@ -5380,7 +5386,7 @@ class TreeMapSelection {
5380
5386
  this.shapeElement = undefined;
5381
5387
  removeShape(this.shapeSelectionCollection, 'selection');
5382
5388
  index = getLegendIndex(length, items[m], this.treemap);
5383
- this.shapeElement = this.treemap.legendSettings.mode === 'Default' ? document.getElementById('container_Legend_Shape_Index_' + index) : document.getElementById('container_Legend_Index_' + index);
5389
+ 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);
5384
5390
  if (this.shapeElement !== null) {
5385
5391
  this.shapeSelectId = this.shapeElement.getAttribute('id');
5386
5392
  this.treemap.legendId.push(this.shapeSelectId);
@@ -5521,7 +5527,7 @@ class TreeMapTooltip {
5521
5527
  let tooltipContent = [];
5522
5528
  let markerFill;
5523
5529
  if (targetId.indexOf('_Item_Index') > -1) {
5524
- item = this.treemap.layout.renderItems[parseFloat(targetId.split('_')[6])];
5530
+ item = this.treemap.layout.renderItems[parseFloat(targetId.split('_Item_Index_')[1])];
5525
5531
  if (!isNullOrUndefined(item)) {
5526
5532
  toolTipHeader = item['name'];
5527
5533
  value = item['weight'];