@syncfusion/ej2-treemap 27.1.55 → 28.1.33

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.
@@ -1,4 +1,4 @@
1
- import { Browser } from '@syncfusion/ej2-base';
1
+ import { Browser, isNullOrUndefined } from '@syncfusion/ej2-base';
2
2
  import { itemHighlight, itemSelected } from '../model/constants';
3
3
  import { findHightLightItems, removeClassNames, applyOptions, removeShape, removeLegend, removeSelectionWithHighlight, setColor, getLegendIndex, pushCollection, setItemTemplateContent } from '../utils/helper';
4
4
  /**
@@ -40,7 +40,21 @@ var TreeMapHighlight = /** @class */ (function () {
40
40
  var element;
41
41
  var orders;
42
42
  var selectionModule = this.treemap.treeMapSelectionModule;
43
- if (targetId.indexOf('_Item_Index') > -1 && (selectionModule ? this.treemap.selectionId !== targetId : true)) {
43
+ var shapeSelected = false;
44
+ if (selectionModule && selectionModule.legendSelectionCollection.length > 0) {
45
+ for (var i = 0; i < selectionModule.legendSelectionCollection.length; i++) {
46
+ for (var j = 0; j < selectionModule.legendSelectionCollection[i]['ShapeCollection']['Elements'].length; j++) {
47
+ var selectedElementIndex = parseFloat(selectionModule.legendSelectionCollection[i]['ShapeCollection']['Elements'][j].id.split('Item_Index_')[1].split('_')[0]);
48
+ var targetElementIndex = targetId.indexOf('_Item_Index_') > -1 ? parseFloat(targetId.split('Item_Index_')[1].split('_')[0]) : null;
49
+ if (selectionModule.legendSelectionCollection[i]['ShapeCollection']['Elements'][j].id === targetId ||
50
+ selectedElementIndex === targetElementIndex) {
51
+ shapeSelected = true;
52
+ break;
53
+ }
54
+ }
55
+ }
56
+ }
57
+ if (targetId.indexOf('_Item_Index') > -1 && !shapeSelected) {
44
58
  if (this.highLightId !== targetId) {
45
59
  treeMapElement = document.getElementById(treemap.element.id + '_TreeMap_' + treemap.layoutType + '_Layout');
46
60
  var selectionElements = document.getElementsByClassName('treeMapSelection');
@@ -50,16 +64,22 @@ var TreeMapHighlight = /** @class */ (function () {
50
64
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
51
65
  var collection = this.treemap.treeMapLegendModule.legendCollections;
52
66
  var length_1 = this.treemap.treeMapLegendModule.legendCollections.length;
53
- index = getLegendIndex(length_1, item, treemap);
67
+ index = (!treemap.legendSettings.removeDuplicateLegend && treemap.palette && treemap.palette.length > 0 &&
68
+ treemap.leafItemSettings.colorMapping.length === 0 && treemap.levels.length === 0) ?
69
+ parseFloat(targetId.split('_Item_Index_')[1]) : getLegendIndex(length_1, item, treemap);
54
70
  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);
55
71
  if (this.shapeElement !== null && (selectionModule ? this.shapeElement.getAttribute('id') !== selectionModule.legendSelectId : true)) {
56
- if (selectionModule ? this.shapeElement !== selectionModule.shapeElement : true) {
72
+ var legendShapeElement = selectionModule ? selectionModule.shapeElement : null;
73
+ if (selectionModule ? this.shapeElement !== legendShapeElement : true) {
57
74
  this.currentElement.push({ currentElement: this.shapeElement });
58
- removeShape(this.shapeHighlightCollection);
75
+ removeLegend(this.shapeHighlightCollection, treemap);
59
76
  this.shapeHighlightCollection.push({ legendEle: this.shapeElement, oldFill: collection[index]['legendFill'],
60
77
  oldOpacity: collection[index]['opacity'], oldBorderColor: collection[index]['borderColor'],
61
78
  oldBorderWidth: collection[index]['borderWidth']
62
79
  });
80
+ var legendText = this.treemap.legendSettings.mode === 'Default' ? document.getElementById(this.treemap.element.id + '_Legend_Text_Index_' + index)
81
+ : document.getElementById(this.treemap.element.id + '_Legend_Index_' + index + '_Text');
82
+ setColor(legendText, highlight.fill, highlight.opacity, highlight.border.color, highlight.border.width.toString());
63
83
  setColor(this.shapeElement, highlight.fill, highlight.opacity, highlight.border.color, highlight.border.width.toString());
64
84
  this.target = 'highlight';
65
85
  }
@@ -71,6 +91,9 @@ var TreeMapHighlight = /** @class */ (function () {
71
91
  else if (this.currentElement.length > 0 && this.currentElement[this.currentElement.length - 1]['currentElement'] !== this.shapeElement) {
72
92
  removeSelectionWithHighlight(this.shapeHighlightCollection, this.currentElement, treemap);
73
93
  this.highLightId = '';
94
+ if (this.treemap.legendSettings.mode === 'Interactive') {
95
+ this.treemap.treeMapLegendModule.removeInteractivePointer();
96
+ }
74
97
  }
75
98
  }
76
99
  orders = findHightLightItems(item, [], highlight.mode, treemap);
@@ -80,6 +103,9 @@ var TreeMapHighlight = /** @class */ (function () {
80
103
  for (var i = 0; i < treeMapElement.childElementCount; i++) {
81
104
  element = treeMapElement.childNodes[i];
82
105
  process = true;
106
+ var valuePath = treemap.rangeColorValuePath;
107
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
108
+ var targetItem = treemap.layout.renderItems[parseFloat(targetId.split('_Item_Index_')[1])];
83
109
  item = treemap.layout.renderItems[parseFloat(element.id.split('_Item_Index_')[1])];
84
110
  for (var j = 0; j < selectionElements.length; j++) {
85
111
  if (element.id === selectionElements[j].id) {
@@ -87,7 +113,9 @@ var TreeMapHighlight = /** @class */ (function () {
87
113
  break;
88
114
  }
89
115
  }
90
- if (orders.indexOf(item['levelOrderName']) > -1 && process) {
116
+ if (orders.indexOf(item['levelOrderName']) > -1 && process &&
117
+ (!isNullOrUndefined(valuePath) && valuePath !== '' ?
118
+ item['data'][valuePath] === targetItem['data'][valuePath] : true)) {
91
119
  highLightElements.push(element);
92
120
  items.push(item);
93
121
  }
@@ -108,35 +136,83 @@ var TreeMapHighlight = /** @class */ (function () {
108
136
  }
109
137
  }
110
138
  }
111
- else if (targetId.indexOf('_Legend_Shape') > -1 || targetId.indexOf('_Legend_Index') > -1) {
112
- if (this.treemap.legendSettings.visible && (selectionModule ? selectionModule.legendSelectId !== targetId : true)
113
- && (selectionModule ? selectionModule.shapeSelectId !== targetId : true)) {
139
+ else if (targetId.indexOf('_Legend_Shape') > -1 || targetId.indexOf('_Legend_Index') > -1 || targetId.indexOf('_Legend_Text_Index') > -1) {
140
+ if (!isNullOrUndefined(selectionModule)) {
141
+ selectionModule.legendSelectId = !isNullOrUndefined(treemap.legendId[0]) ? treemap.legendId[0] : null;
142
+ }
143
+ var selectedLegendIndex = selectionModule && selectionModule.legendSelectId ?
144
+ parseFloat(selectionModule.legendSelectId.split('Index_')[1]) :
145
+ (selectionModule && selectionModule.shapeSelectId ? parseFloat(selectionModule.shapeSelectId.split('Index_')[1]) : null);
146
+ var targetIndex = this.treemap.legendSettings.mode === 'Default' ? (targetId.indexOf('Text') === -1 ? parseFloat(targetId.split('_Legend_Shape_Index_')[1]) : parseFloat(targetId.split('_Legend_Text_Index_')[1]))
147
+ : parseFloat(targetId.split('_Legend_Index_')[1]);
148
+ if (this.treemap.legendSettings.visible && targetIndex !== selectedLegendIndex) {
114
149
  var itemIndex = void 0;
115
150
  var groupIndex = void 0;
116
151
  var length_2;
152
+ var valuePath = treemap.rangeColorValuePath;
117
153
  var targetEle = document.getElementById(targetId);
118
154
  if (this.shapeTarget === 'highlight') {
119
- removeLegend(this.legendHighlightCollection);
155
+ removeLegend(this.legendHighlightCollection, this.treemap);
156
+ this.legendHighlightCollection = [];
120
157
  }
121
158
  this.shapeTarget = 'highlight';
122
- var index = this.treemap.legendSettings.mode === 'Default' ? parseFloat(targetId.split('_Legend_Shape_Index_')[1]) : parseFloat(targetId.split('_Legend_Index_')[1]);
123
- var dataLength = this.treemap.treeMapLegendModule.legendCollections[index]['legendData'].length;
159
+ var dataLength = this.treemap.treeMapLegendModule.legendCollections[targetIndex]['legendData'].length;
124
160
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
125
161
  var collection = this.treemap.treeMapLegendModule.legendCollections;
126
- var legendIndex = parseInt(targetId[targetId.length - 1], 10);
127
162
  for (var i = 0; i < dataLength; i++) {
128
163
  for (var j = 0; j < this.treemap.layout.renderItems.length; j++) {
129
- if (this.treemap.treeMapLegendModule.legendCollections[index]['legendData'][i]['levelOrderName'] === this.treemap.layout.renderItems[j]['levelOrderName']) {
164
+ if ((!isNullOrUndefined(valuePath) && valuePath !== '' && treemap.leafItemSettings.colorMapping.length > 0)
165
+ ? treemap.treeMapLegendModule.legendCollections[targetIndex]['legendData'][i]['data'][valuePath] === treemap.layout.renderItems[j]['data'][valuePath]
166
+ : (treemap.treeMapLegendModule.legendCollections[targetIndex]['legendData'][i]['levelOrderName'] === treemap.layout.renderItems[j]['levelOrderName'])) {
130
167
  itemIndex = j;
131
168
  groupIndex = this.treemap.layout.renderItems[j]['groupIndex'];
132
169
  var nodeEle = document.getElementById(this.treemap.element.id + '_Level_Index_' + groupIndex + '_Item_Index_' + itemIndex + '_RectPath');
133
- if (i === 0) {
170
+ if (i === 0 || this.legendHighlightCollection.length === 0) {
134
171
  this.legendHighlightCollection = [];
135
- pushCollection(this.legendHighlightCollection, legendIndex, j, targetEle, nodeEle, this.treemap.layout.renderItems, collection);
172
+ pushCollection(this.legendHighlightCollection, targetIndex, j, targetEle, nodeEle, this.treemap.layout.renderItems, collection);
136
173
  length_2 = this.legendHighlightCollection.length;
137
174
  this.legendHighlightCollection[length_2 - 1]['ShapeCollection'] = { Elements: [] };
138
175
  }
139
176
  setColor(targetEle, highlight.fill, highlight.opacity, highlight.border.color, highlight.border.width.toString());
177
+ var legendItem = void 0;
178
+ if (targetEle.id.indexOf('Text') > -1) {
179
+ legendItem = this.treemap.legendSettings.mode === 'Interactive' ? document.getElementById(targetEle.id.replace('_Text', ''))
180
+ : document.getElementById(this.treemap.element.id + '_Legend_Shape_Index_' + targetIndex);
181
+ }
182
+ else {
183
+ legendItem = this.treemap.legendSettings.mode === 'Interactive' ? document.getElementById(targetEle.id + '_Text')
184
+ : document.getElementById(this.treemap.element.id + '_Legend_Text_Index_' + targetIndex);
185
+ }
186
+ setColor(legendItem, highlight.fill, highlight.opacity, highlight.border.color, highlight.border.width.toString());
187
+ setColor(nodeEle, highlight.fill, highlight.opacity, highlight.border.color, highlight.border.width.toString());
188
+ length_2 = this.legendHighlightCollection.length;
189
+ this.legendHighlightCollection[length_2 - 1]['ShapeCollection']['Elements'].push(nodeEle);
190
+ }
191
+ }
192
+ }
193
+ if (dataLength === 0 && this.treemap.palette && this.treemap.palette.length > 0) {
194
+ for (var j = 0; j < this.treemap.layout.renderItems.length; j++) {
195
+ if ((this.treemap.treeMapLegendModule.legendCollections[targetIndex]['levelOrderName'] === this.treemap.layout.renderItems[j]['levelOrderName'] ||
196
+ this.treemap.layout.renderItems[j]['levelOrderName'].indexOf(this.treemap.treeMapLegendModule.legendCollections[targetIndex]['levelOrderName']) > -1) &&
197
+ ((!this.treemap.legendSettings.removeDuplicateLegend && treemap.palette && treemap.palette.length > 0) ?
198
+ targetIndex === j : true)) {
199
+ itemIndex = j;
200
+ groupIndex = this.treemap.layout.renderItems[j]['groupIndex'];
201
+ var nodeEle = document.getElementById(this.treemap.element.id + '_Level_Index_' + groupIndex + '_Item_Index_' + itemIndex + '_RectPath');
202
+ pushCollection(this.legendHighlightCollection, targetIndex, j, targetEle, nodeEle, this.treemap.layout.renderItems, collection);
203
+ length_2 = this.legendHighlightCollection.length;
204
+ this.legendHighlightCollection[length_2 - 1]['ShapeCollection'] = { Elements: [] };
205
+ var legendItem = void 0;
206
+ if (targetEle.id.indexOf('Text') > -1) {
207
+ legendItem = this.treemap.legendSettings.mode === 'Interactive' ? document.getElementById(targetEle.id.replace('_Text', ''))
208
+ : document.getElementById(this.treemap.element.id + '_Legend_Shape_Index_' + targetIndex);
209
+ }
210
+ else {
211
+ legendItem = this.treemap.legendSettings.mode === 'Interactive' ? document.getElementById(targetEle.id + '_Text')
212
+ : document.getElementById(this.treemap.element.id + '_Legend_Text_Index_' + targetIndex);
213
+ }
214
+ setColor(legendItem, highlight.fill, highlight.opacity, highlight.border.color, highlight.border.width.toString());
215
+ setColor(targetEle, highlight.fill, highlight.opacity, highlight.border.color, highlight.border.width.toString());
140
216
  setColor(nodeEle, highlight.fill, highlight.opacity, highlight.border.color, highlight.border.width.toString());
141
217
  length_2 = this.legendHighlightCollection.length;
142
218
  this.legendHighlightCollection[length_2 - 1]['ShapeCollection']['Elements'].push(nodeEle);
@@ -155,13 +231,13 @@ var TreeMapHighlight = /** @class */ (function () {
155
231
  if (selectionModule ? this.shapeElement ? this.shapeElement.getAttribute('id') !== selectionModule.legendSelectId : true : true) {
156
232
  if (selectionModule ? this.shapeElement !== selectionModule.shapeElement : true && selectionModule ?
157
233
  selectionModule.legendSelect : true) {
158
- removeShape(this.shapeHighlightCollection);
234
+ removeLegend(this.shapeHighlightCollection, treemap);
159
235
  this.shapeHighlightCollection = [];
160
236
  }
161
237
  }
162
238
  }
163
239
  if (this.shapeTarget === 'highlight' && this.treemap.legendSettings.visible) {
164
- removeLegend(this.legendHighlightCollection);
240
+ removeLegend(this.legendHighlightCollection, this.treemap);
165
241
  }
166
242
  this.highLightId = '';
167
243
  processHighlight = false;
@@ -240,7 +316,6 @@ var TreeMapSelection = /** @class */ (function () {
240
316
  var targetEle = e.target;
241
317
  var eventArgs;
242
318
  var treemap = this.treemap;
243
- treemap.levelSelection = [];
244
319
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
245
320
  var items = [];
246
321
  var targetId = targetEle.id;
@@ -254,11 +329,18 @@ var TreeMapSelection = /** @class */ (function () {
254
329
  var selection = treemap.selectionSettings;
255
330
  var highlightModule = this.treemap.treeMapHighlightModule;
256
331
  var layoutID = treemap.element.id + '_TreeMap_' + treemap.layoutType + '_Layout';
257
- if (targetId.indexOf('_Item_Index') > -1) {
332
+ item = treemap.layout.renderItems[parseFloat(targetId.split('_Item_Index_')[1])];
333
+ var isDrillItem = (item && !item.isLeafItem && treemap.enableDrillDown) &&
334
+ (targetEle.nextSibling.textContent.indexOf('[+]') > -1 || targetEle.nextSibling.textContent.indexOf('[-]') > -1);
335
+ if (targetId.indexOf('_Item_Index') > -1 && !isDrillItem) {
258
336
  e.preventDefault();
259
- if (this.treemap.selectionId !== targetId && this.legendSelect) {
337
+ if (this.treemap.selectionId !== targetId) {
338
+ treemap.levelSelection = [];
339
+ treemap.legendId = [];
340
+ this.shapeSelectId = '';
341
+ removeLegend(this.legendSelectionCollection, treemap);
342
+ this.legendSelectionCollection = [];
260
343
  treeMapElement = document.getElementById(layoutID);
261
- item = treemap.layout.renderItems[parseFloat(targetId.split('_Item_Index_')[1])];
262
344
  var index = void 0;
263
345
  if (this.treemap.legendSettings.visible) {
264
346
  this.shapeSelect = false;
@@ -266,12 +348,15 @@ var TreeMapSelection = /** @class */ (function () {
266
348
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
267
349
  var collection = this.treemap.treeMapLegendModule.legendCollections;
268
350
  this.shapeElement = undefined;
269
- removeShape(this.shapeSelectionCollection);
351
+ removeLegend(this.shapeSelectionCollection, treemap);
270
352
  if (highlightModule) {
271
353
  highlightModule.shapeTarget = 'selection';
272
354
  highlightModule.shapeHighlightCollection = [];
273
355
  }
274
- index = getLegendIndex(length_3, item, treemap);
356
+ index = (!treemap.legendSettings.removeDuplicateLegend && treemap.palette && treemap.palette.length > 0 &&
357
+ treemap.leafItemSettings.colorMapping.length === 0
358
+ && treemap.levels.length === 0) ?
359
+ parseFloat(targetId.split('_Item_Index_')[1]) : getLegendIndex(length_3, item, treemap);
275
360
  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);
276
361
  if (this.shapeElement !== null) {
277
362
  this.shapeSelectId = this.shapeElement.getAttribute('id');
@@ -279,16 +364,28 @@ var TreeMapSelection = /** @class */ (function () {
279
364
  oldOpacity: collection[index]['opacity'], oldBorderColor: collection[index]['borderColor'],
280
365
  oldBorderWidth: collection[index]['borderWidth']
281
366
  });
367
+ var legendText = this.treemap.legendSettings.mode === 'Default' ? document.getElementById(this.treemap.element.id + '_Legend_Text_Index_' + index)
368
+ : document.getElementById(this.treemap.element.id + '_Legend_Index_' + index + '_Text');
369
+ setColor(legendText, selection.fill, selection.opacity, selection.border.color, selection.border.width.toString());
282
370
  setColor(this.shapeElement, selection.fill, selection.opacity, selection.border.color, selection.border.width.toString());
371
+ treemap.legendId.push(this.shapeElement.id);
372
+ treemap.legendId.push(legendText.id);
283
373
  }
284
374
  }
285
375
  orders = findHightLightItems(item, [], selection.mode, treemap);
286
376
  for (var i = 0; i < treeMapElement.childElementCount; i++) {
287
377
  element = treeMapElement.childNodes[i];
378
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
379
+ var targetItem = treemap.layout.renderItems[parseFloat(targetId.split('_Item_Index_')[1])];
288
380
  item = treemap.layout.renderItems[parseFloat(element.id.split('_Item_Index_')[1])];
289
- if (orders.indexOf(item['levelOrderName']) > -1) {
381
+ var valuePath = treemap.rangeColorValuePath;
382
+ if (orders.indexOf(item['levelOrderName']) > -1 &&
383
+ (!isNullOrUndefined(valuePath) && valuePath !== '' ?
384
+ item['data'][valuePath] === targetItem['data'][valuePath] : true)) {
290
385
  selectionElements.push(element);
291
- treemap.levelSelection.push(element.id);
386
+ if (targetId.indexOf('_RectPath') > -1) {
387
+ treemap.levelSelection.push(targetId);
388
+ }
292
389
  items.push(item);
293
390
  }
294
391
  }
@@ -320,46 +417,125 @@ var TreeMapSelection = /** @class */ (function () {
320
417
  }
321
418
  }
322
419
  else {
323
- removeShape(this.shapeSelectionCollection);
420
+ removeLegend(this.shapeSelectionCollection, treemap);
421
+ this.treemap.legendId = [];
324
422
  this.shapeSelectionCollection = [];
325
423
  this.shapeElement = undefined;
326
424
  this.shapeSelect = true;
327
425
  this.shapeSelectId = '';
328
- this.treemap.legendId = [];
329
- removeClassNames(document.getElementsByClassName('treeMapSelection'), 'treeMapSelection', treemap);
330
- this.treemap.selectionId = '';
426
+ this.treemap.levelSelection = [];
427
+ if (this.legendSelect) {
428
+ removeClassNames(document.getElementsByClassName('treeMapSelection'), 'treeMapSelection', treemap);
429
+ this.treemap.selectionId = '';
430
+ }
331
431
  }
332
432
  }
333
- else if (targetId.indexOf('_Legend_Shape') > -1 || targetId.indexOf('_Legend_Index') > -1) {
433
+ else if (targetId.indexOf('_Legend_Shape') > -1 || targetId.indexOf('_Legend_Index') > -1 || targetId.indexOf('_Legend_Text_') > -1) {
334
434
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
335
435
  var collection = this.treemap.treeMapLegendModule.legendCollections;
336
- if (this.treemap.legendSettings.visible && this.legendSelectId !== targetId && this.shapeSelect) {
436
+ var legendSelectIdIndex = !isNullOrUndefined(this.legendSelectId) ? parseFloat(this.legendSelectId.split('_Index_')[1]) : null;
437
+ if (this.treemap.legendSettings.visible && (legendSelectIdIndex !== parseFloat(targetId.split('_Index_')[1]))) {
337
438
  var itemIndex = void 0;
338
439
  var groupIndex = void 0;
339
440
  var length_4;
441
+ treemap.legendId = [];
442
+ treemap.levelSelection = [];
340
443
  this.legendSelectId = targetId;
341
444
  this.legendSelect = false;
342
- var legendIndex = parseInt(targetId[targetId.length - 1], 10);
445
+ var legendIndex = !isNaN(parseInt(targetId[targetId.length - 1], 10)) ?
446
+ parseInt(targetId[targetId.length - 1], 10) :
447
+ parseInt(targetId[targetId.length - 6], 10);
343
448
  var targetEle_1 = document.getElementById(targetId);
344
- removeLegend(this.legendSelectionCollection);
449
+ removeLegend(this.legendSelectionCollection, treemap);
450
+ removeClassNames(document.getElementsByClassName('treeMapSelection'), 'treeMapSelection', treemap);
451
+ removeLegend(this.shapeSelectionCollection, treemap);
452
+ this.legendSelectionCollection = [];
345
453
  if (highlightModule) {
346
454
  highlightModule.shapeTarget = 'selection';
455
+ highlightModule.legendHighlightCollection = [];
347
456
  }
348
- var index = this.treemap.legendSettings.mode === 'Default' ? parseFloat(targetId.split('_Legend_Shape_Index_')[1]) : parseFloat(targetId.split('_Legend_Index_')[1]);
457
+ var valuePath = treemap.rangeColorValuePath;
458
+ var index = this.treemap.legendSettings.mode === 'Default' ? (targetId.indexOf('Text') === -1 ? parseFloat(targetId.split('_Legend_Shape_Index_')[1]) : parseFloat(targetId.split('_Legend_Text_Index_')[1]))
459
+ : parseFloat(targetId.split('_Legend_Index_')[1]);
349
460
  var dataLength = this.treemap.treeMapLegendModule.legendCollections[index]['legendData'].length;
350
461
  for (var k = 0; k < dataLength; k++) {
351
462
  for (var l = 0; l < this.treemap.layout.renderItems.length; l++) {
352
- if (this.treemap.treeMapLegendModule.legendCollections[index]['legendData'][k]['levelOrderName'] === this.treemap.layout.renderItems[l]['levelOrderName']) {
463
+ if ((!isNullOrUndefined(valuePath) && valuePath !== '' && treemap.leafItemSettings.colorMapping.length > 0) ?
464
+ (treemap.treeMapLegendModule.legendCollections[index]['legendData'][k]['data'][valuePath] === treemap.layout.renderItems[l]['data'][valuePath])
465
+ : (this.treemap.treeMapLegendModule.legendCollections[index]['legendData'][k]['levelOrderName'] === this.treemap.layout.renderItems[l]['levelOrderName'])) {
353
466
  itemIndex = l;
354
467
  groupIndex = this.treemap.layout.renderItems[l]['groupIndex'];
355
468
  var nodeEle = document.getElementById(this.treemap.element.id + '_Level_Index_' + groupIndex + '_Item_Index_' + itemIndex + '_RectPath');
356
- if (k === 0) {
469
+ this.treemap.selectionId = nodeEle.id;
470
+ if (k === 0 || this.legendSelectionCollection.length === 0) {
357
471
  pushCollection(this.legendSelectionCollection, legendIndex, l, targetEle_1, nodeEle, this.treemap.layout.renderItems, collection);
358
472
  length_4 = this.legendSelectionCollection.length;
359
473
  this.legendSelectionCollection[length_4 - 1]['ShapeCollection'] = { Elements: [] };
360
474
  }
475
+ this.treemap.selectionId = nodeEle.id;
476
+ var legendItem = void 0;
477
+ if (targetEle_1.id.indexOf('Text') > -1) {
478
+ legendItem = this.treemap.legendSettings.mode === 'Interactive' ? document.getElementById(targetEle_1.id.replace('_Text', ''))
479
+ : document.getElementById(this.treemap.element.id + '_Legend_Shape_Index_' + index);
480
+ this.legendSelectId = legendItem.id;
481
+ this.shapeElement = legendItem;
482
+ }
483
+ else {
484
+ legendItem = this.treemap.legendSettings.mode === 'Interactive' ? document.getElementById(targetEle_1.id + '_Text')
485
+ : document.getElementById(this.treemap.element.id + '_Legend_Text_Index_' + index);
486
+ this.shapeElement = targetEle_1;
487
+ }
488
+ setColor(legendItem, selection.fill, selection.opacity, selection.border.color, selection.border.width.toString());
489
+ setColor(targetEle_1, selection.fill, selection.opacity, selection.border.color, selection.border.width.toString());
490
+ setColor(nodeEle, selection.fill, selection.opacity, selection.border.color, selection.border.width.toString());
491
+ length_4 = this.legendSelectionCollection.length;
492
+ treemap.levelSelection.push(nodeEle.id);
493
+ if (treemap.legendId.indexOf(targetEle_1.id) === -1) {
494
+ treemap.legendId.push(targetEle_1.id);
495
+ }
496
+ if (treemap.legendId.indexOf(legendItem.id) === -1) {
497
+ treemap.legendId.push(legendItem.id);
498
+ }
499
+ this.legendSelectionCollection[length_4 - 1]['ShapeCollection']['Elements'].push(nodeEle);
500
+ }
501
+ }
502
+ }
503
+ if (dataLength === 0 && this.treemap.palette && this.treemap.palette.length > 0) {
504
+ for (var j = 0; j < this.treemap.layout.renderItems.length; j++) {
505
+ if ((this.treemap.treeMapLegendModule.legendCollections[index]['levelOrderName'] === this.treemap.layout.renderItems[j]['levelOrderName'] ||
506
+ this.treemap.layout.renderItems[j]['levelOrderName'].indexOf(this.treemap.treeMapLegendModule.legendCollections[index]['levelOrderName']) > -1) &&
507
+ ((!this.treemap.legendSettings.removeDuplicateLegend && treemap.palette && treemap.palette.length > 0) ?
508
+ index === j : true)) {
509
+ itemIndex = j;
510
+ groupIndex = this.treemap.layout.renderItems[j]['groupIndex'];
511
+ var nodeEle = document.getElementById(this.treemap.element.id + '_Level_Index_' + groupIndex + '_Item_Index_' + itemIndex + '_RectPath');
512
+ pushCollection(this.legendSelectionCollection, index, j, targetEle_1, nodeEle, this.treemap.layout.renderItems, collection);
513
+ this.treemap.selectionId = nodeEle.id;
514
+ length_4 = this.legendSelectionCollection.length;
515
+ this.legendSelectionCollection[length_4 - 1]['ShapeCollection'] = { Elements: [] };
516
+ var legendItem = void 0;
517
+ if (targetEle_1.id.indexOf('Text') > -1) {
518
+ legendItem = this.treemap.legendSettings.mode === 'Interactive' ? document.getElementById(targetEle_1.id.replace('_Text', ''))
519
+ : document.getElementById(this.treemap.element.id + '_Legend_Shape_Index_' + index);
520
+ this.legendSelectId = legendItem.id;
521
+ this.shapeElement = legendItem;
522
+ }
523
+ else {
524
+ legendItem = this.treemap.legendSettings.mode === 'Interactive' ? document.getElementById(targetEle_1.id + '_Text')
525
+ : document.getElementById(this.treemap.element.id + '_Legend_Text_Index_' + index);
526
+ this.legendSelectId = targetId;
527
+ this.shapeElement = targetEle_1;
528
+ }
529
+ setColor(legendItem, selection.fill, selection.opacity, selection.border.color, selection.border.width.toString());
361
530
  setColor(targetEle_1, selection.fill, selection.opacity, selection.border.color, selection.border.width.toString());
362
531
  setColor(nodeEle, selection.fill, selection.opacity, selection.border.color, selection.border.width.toString());
532
+ treemap.levelSelection.push(nodeEle.id);
533
+ if (treemap.legendId.indexOf(legendItem.id) === -1) {
534
+ treemap.legendId.push(legendItem.id);
535
+ }
536
+ if (treemap.legendId.indexOf(targetEle_1.id) === -1) {
537
+ treemap.legendId.push(targetEle_1.id);
538
+ }
363
539
  length_4 = this.legendSelectionCollection.length;
364
540
  this.legendSelectionCollection[length_4 - 1]['ShapeCollection']['Elements'].push(nodeEle);
365
541
  }
@@ -367,14 +543,25 @@ var TreeMapSelection = /** @class */ (function () {
367
543
  }
368
544
  }
369
545
  else {
370
- removeLegend(this.legendSelectionCollection);
546
+ removeLegend(this.legendSelectionCollection, this.treemap);
547
+ this.legendSelectionCollection = [];
371
548
  if (highlightModule) {
372
549
  highlightModule.shapeTarget = 'highlight';
373
550
  }
374
551
  this.legendSelect = true;
375
552
  this.legendSelectId = '';
553
+ this.treemap.legendId = [];
554
+ this.treemap.levelSelection = [];
376
555
  }
377
556
  }
557
+ else if (isDrillItem) {
558
+ removeLegend(this.legendSelectionCollection, this.treemap);
559
+ this.legendSelectionCollection = [];
560
+ this.legendSelect = true;
561
+ this.legendSelectId = '';
562
+ this.treemap.legendId = [];
563
+ this.treemap.levelSelection = [];
564
+ }
378
565
  };
379
566
  /**
380
567
  * @param {string} levelOrder - Specifies the level order of treemap item
@@ -8,7 +8,7 @@ var __rest = (this && this.__rest) || function (s, e) {
8
8
  return t;
9
9
  };
10
10
  import { Tooltip } from '@syncfusion/ej2-svg-base';
11
- import { Browser, createElement, isNullOrUndefined } from '@syncfusion/ej2-base';
11
+ import { Browser, createElement, isNullOrUndefined, SanitizeHtmlHelper } from '@syncfusion/ej2-base';
12
12
  import { getMousePosition, textFormatter, formatValue } from '../utils/helper';
13
13
  import { tooltipRendering } from '../model/constants';
14
14
  /**
@@ -93,6 +93,11 @@ var TreeMapTooltip = /** @class */ (function () {
93
93
  width: this.tooltipSettings.border.width || this.treemap.themeStyle.tooltipBorderWidth || 0,
94
94
  color: this.tooltipSettings.border.color || this.treemap.themeStyle.tooltipBorderColor || 'transparent'
95
95
  };
96
+ if (this.treemap.enableHtmlSanitizer) {
97
+ for (var a = 0; a < tooltipContent.length; a++) {
98
+ tooltipContent[a] = SanitizeHtmlHelper.sanitize(tooltipContent[a]);
99
+ }
100
+ }
96
101
  tootipArgs = {
97
102
  cancel: false, name: tooltipRendering, item: item,
98
103
  options: {
@@ -194,6 +194,10 @@ export declare type TreeMapTheme =
194
194
  'Tailwind' |
195
195
  /** Render a treemap with TailwindDark theme. */
196
196
  'TailwindDark' |
197
+ /** Render a treemap with Tailwind3 theme. */
198
+ 'Tailwind3' |
199
+ /** Render a treemap with Tailwind3Dark theme. */
200
+ 'Tailwind3Dark' |
197
201
  /** Render a treemap with Bootstrap5 theme. */
198
202
  'Bootstrap5' |
199
203
  /** Render a treemap with Bootstrap5 dark theme. */
@@ -481,10 +481,11 @@ export declare function removeShape(collection: any[]): void;
481
481
  /**
482
482
  *
483
483
  * @param {any[]} collection - Specifies the legend collection.
484
+ * @param {TreeMap} treeMap - Specifies the treemap instance.
484
485
  * @returns {void}
485
486
  * @private
486
487
  */
487
- export declare function removeLegend(collection: any[]): void;
488
+ export declare function removeLegend(collection: any[], treeMap: TreeMap): void;
488
489
  /**
489
490
  *
490
491
  * @param {Element} element - Specifies the selected element.
@@ -889,7 +889,8 @@ export function maintainSelection(treemap, element, className) {
889
889
  var elementId = treemap.levelSelection;
890
890
  if (elementId) {
891
891
  for (var index = 0; index < elementId.length; index++) {
892
- if (element.getAttribute('id') === elementId[index]) {
892
+ if (element.getAttribute('id') === elementId[index] ||
893
+ element.children[0].id === elementId[index]) {
893
894
  if (element.childElementCount > 0) {
894
895
  element.children[0].setAttribute('class', className);
895
896
  applyOptions(element.childNodes[0], {
@@ -914,13 +915,25 @@ export function legendMaintain(treemap, legendGroup) {
914
915
  var elementId = treemap.legendId;
915
916
  if (elementId) {
916
917
  for (var i = 0; i < elementId.length; i++) {
917
- for (var j = 0; j < legendGroup.childElementCount; j++) {
918
- if (legendGroup.childNodes[j]['id'] === elementId[i]) {
919
- var treemapSVGRectElement = legendGroup.childNodes[j];
920
- treemapSVGRectElement.setAttribute('fill', treemap.selectionSettings.fill);
921
- treemapSVGRectElement.setAttribute('stroke', treemap.selectionSettings.border.color);
922
- treemapSVGRectElement.setAttribute('stroke-width', (treemap.selectionSettings.border.width).toString());
923
- treemapSVGRectElement.setAttribute('opacity', treemap.selectionSettings.opacity);
918
+ if (treemap.legendSettings.mode === 'Interactive') {
919
+ for (var j = 0; j < legendGroup.childElementCount; j++) {
920
+ if (legendGroup.childNodes[j]['id'] === elementId[i] ||
921
+ parseFloat(legendGroup.childNodes[j]['id'].split('Index_')[1]) === parseFloat(elementId[i].split('Index_')[1])) {
922
+ var treemapSVGRectElement = legendGroup.childNodes[j];
923
+ treemapSVGRectElement.setAttribute('fill', treemap.selectionSettings.fill);
924
+ treemapSVGRectElement.setAttribute('stroke', treemap.selectionSettings.border.color);
925
+ treemapSVGRectElement.setAttribute('stroke-width', (treemap.selectionSettings.border.width).toString());
926
+ treemapSVGRectElement.setAttribute('opacity', treemap.selectionSettings.opacity);
927
+ }
928
+ }
929
+ }
930
+ else {
931
+ var legendItem = document.getElementById(elementId[i]);
932
+ if (!isNullOrUndefined(legendItem)) {
933
+ legendItem.setAttribute('fill', treemap.selectionSettings.fill);
934
+ legendItem.setAttribute('stroke', treemap.selectionSettings.border.color);
935
+ legendItem.setAttribute('stroke-width', (treemap.selectionSettings.border.width).toString());
936
+ legendItem.setAttribute('opacity', treemap.selectionSettings.opacity);
924
937
  }
925
938
  }
926
939
  }
@@ -956,6 +969,9 @@ export function applyOptions(element, options) {
956
969
  if (!isNullOrUndefined(options['fill'])) {
957
970
  element.setAttribute('fill', options['fill']);
958
971
  }
972
+ else {
973
+ element.setAttribute('fill', 'black');
974
+ }
959
975
  element.setAttribute('stroke', options['border']['color']);
960
976
  element.setAttribute('stroke-width', options['border']['width']);
961
977
  }
@@ -1207,17 +1223,35 @@ export function removeShape(collection) {
1207
1223
  /**
1208
1224
  *
1209
1225
  * @param {any[]} collection - Specifies the legend collection.
1226
+ * @param {TreeMap} treeMap - Specifies the treemap instance.
1210
1227
  * @returns {void}
1211
1228
  * @private
1212
1229
  */
1213
- export function removeLegend(collection) {
1230
+ export function removeLegend(collection, treeMap) {
1214
1231
  if (collection.length > 0) {
1215
1232
  for (var j = 0; j < collection.length; j++) {
1216
1233
  var item = collection[j];
1217
- setColor(item['legendEle'], item['oldFill'], item['oldOpacity'], item['oldBorderColor'], item['oldBorderWidth']);
1218
- var dataCount = item['ShapeCollection']['Elements'].length;
1234
+ var legendIndex = parseFloat(item['legendEle'].id.split('_Index_')[1]);
1235
+ var isText = item['legendEle'].id.indexOf('Text') > -1;
1236
+ var shapeId = isText ? item['legendEle'].id.replace('_Text', '') : item['legendEle'].id;
1237
+ var legendShape = treeMap.legendSettings.mode === 'Interactive'
1238
+ ? document.getElementById(shapeId)
1239
+ : document.getElementById(treeMap.element.id + '_Legend_Shape_Index_' + legendIndex);
1240
+ var legendText = treeMap.legendSettings.mode === 'Interactive'
1241
+ ? document.getElementById(shapeId + '_Text')
1242
+ : document.getElementById(treeMap.element.id + '_Legend_Text_Index_' + legendIndex);
1243
+ if (!isNullOrUndefined(legendShape)) {
1244
+ setColor(legendShape, item['oldFill'], item['oldOpacity'], item['oldBorderColor'], item['oldBorderWidth']);
1245
+ }
1246
+ if (!isNullOrUndefined(legendText)) {
1247
+ setColor(legendText, treeMap.legendSettings.textStyle.color, item['oldOpacity'], item['oldBorderColor'], item['oldBorderWidth']);
1248
+ }
1249
+ var dataCount = !isNullOrUndefined(item['ShapeCollection']) ? item['ShapeCollection']['Elements'].length : 0;
1219
1250
  for (var k = 0; k < dataCount; k++) {
1220
- setColor(item['ShapeCollection']['Elements'][k], item['shapeOldFill'], item['shapeOldOpacity'], item['shapeOldBorderColor'], item['shapeOldBorderWidth']);
1251
+ var shapeElement = document.getElementById(item['ShapeCollection']['Elements'][k].id);
1252
+ if (!isNullOrUndefined(shapeElement)) {
1253
+ setColor(shapeElement, item['shapeOldFill'], item['shapeOldOpacity'], item['shapeOldBorderColor'], item['shapeOldBorderWidth']);
1254
+ }
1221
1255
  }
1222
1256
  }
1223
1257
  }
@@ -1245,7 +1279,7 @@ export function setColor(element, fill, opacity, borderColor, borderWidth) {
1245
1279
  * @returns {void}
1246
1280
  */
1247
1281
  export function removeSelectionWithHighlight(collection, element, treemap) {
1248
- removeShape(collection);
1282
+ removeLegend(collection, treemap);
1249
1283
  element = [];
1250
1284
  removeClassNames(document.getElementsByClassName('treeMapHighLight'), 'treeMapHighLight', treemap);
1251
1285
  }
@@ -1258,10 +1292,24 @@ export function removeSelectionWithHighlight(collection, element, treemap) {
1258
1292
  */
1259
1293
  export function getLegendIndex(length, item, treemap) {
1260
1294
  var index;
1295
+ var valuePath = treemap.rangeColorValuePath;
1261
1296
  for (var i = 0; i < length; i++) {
1262
1297
  var dataLength = treemap.treeMapLegendModule.legendCollections[i]['legendData'].length;
1263
- for (var j = 0; j < dataLength; j++) {
1264
- if (treemap.treeMapLegendModule.legendCollections[i]['legendData'][j]['levelOrderName'] === item['levelOrderName']) {
1298
+ if (dataLength > 0) {
1299
+ for (var j = 0; j < dataLength; j++) {
1300
+ if ((!isNullOrUndefined(valuePath) && valuePath !== '' && treemap.leafItemSettings.colorMapping.length > 0 ?
1301
+ (treemap.treeMapLegendModule.legendCollections[i]['legendData'][j]['data'][valuePath] === item['data'][valuePath])
1302
+ : treemap.treeMapLegendModule.legendCollections[i]['legendData'][j]['levelOrderName'] === item['levelOrderName']
1303
+ || item['levelOrderName'].indexOf(treemap.treeMapLegendModule.legendCollections[i]['legendName']) > -1)) {
1304
+ index = i;
1305
+ break;
1306
+ }
1307
+ }
1308
+ }
1309
+ else if (treemap.palette && treemap.palette.length > 0) {
1310
+ if ((treemap.treeMapLegendModule.legendCollections[i]['levelOrderName'] === item['levelOrderName'] ||
1311
+ (item['levelOrderName'].indexOf(treemap.treeMapLegendModule.legendCollections[i]['levelOrderName'])) > -1)
1312
+ && treemap.treeMapLegendModule.legendCollections[i]['legendName'] === item['name']) {
1265
1313
  index = i;
1266
1314
  break;
1267
1315
  }