@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.
@@ -1386,7 +1386,8 @@ function maintainSelection(treemap, element, className) {
1386
1386
  const elementId = treemap.levelSelection;
1387
1387
  if (elementId) {
1388
1388
  for (let index = 0; index < elementId.length; index++) {
1389
- if (element.getAttribute('id') === elementId[index]) {
1389
+ if (element.getAttribute('id') === elementId[index] ||
1390
+ element.children[0].id === elementId[index]) {
1390
1391
  if (element.childElementCount > 0) {
1391
1392
  element.children[0].setAttribute('class', className);
1392
1393
  applyOptions(element.childNodes[0], {
@@ -1411,13 +1412,25 @@ function legendMaintain(treemap, legendGroup) {
1411
1412
  const elementId = treemap.legendId;
1412
1413
  if (elementId) {
1413
1414
  for (let i = 0; i < elementId.length; i++) {
1414
- for (let j = 0; j < legendGroup.childElementCount; j++) {
1415
- if (legendGroup.childNodes[j]['id'] === elementId[i]) {
1416
- const treemapSVGRectElement = legendGroup.childNodes[j];
1417
- treemapSVGRectElement.setAttribute('fill', treemap.selectionSettings.fill);
1418
- treemapSVGRectElement.setAttribute('stroke', treemap.selectionSettings.border.color);
1419
- treemapSVGRectElement.setAttribute('stroke-width', (treemap.selectionSettings.border.width).toString());
1420
- treemapSVGRectElement.setAttribute('opacity', treemap.selectionSettings.opacity);
1415
+ if (treemap.legendSettings.mode === 'Interactive') {
1416
+ for (let j = 0; j < legendGroup.childElementCount; j++) {
1417
+ if (legendGroup.childNodes[j]['id'] === elementId[i] ||
1418
+ parseFloat(legendGroup.childNodes[j]['id'].split('Index_')[1]) === parseFloat(elementId[i].split('Index_')[1])) {
1419
+ const treemapSVGRectElement = legendGroup.childNodes[j];
1420
+ treemapSVGRectElement.setAttribute('fill', treemap.selectionSettings.fill);
1421
+ treemapSVGRectElement.setAttribute('stroke', treemap.selectionSettings.border.color);
1422
+ treemapSVGRectElement.setAttribute('stroke-width', (treemap.selectionSettings.border.width).toString());
1423
+ treemapSVGRectElement.setAttribute('opacity', treemap.selectionSettings.opacity);
1424
+ }
1425
+ }
1426
+ }
1427
+ else {
1428
+ const legendItem = document.getElementById(elementId[i]);
1429
+ if (!isNullOrUndefined(legendItem)) {
1430
+ legendItem.setAttribute('fill', treemap.selectionSettings.fill);
1431
+ legendItem.setAttribute('stroke', treemap.selectionSettings.border.color);
1432
+ legendItem.setAttribute('stroke-width', (treemap.selectionSettings.border.width).toString());
1433
+ legendItem.setAttribute('opacity', treemap.selectionSettings.opacity);
1421
1434
  }
1422
1435
  }
1423
1436
  }
@@ -1453,6 +1466,9 @@ function applyOptions(element, options) {
1453
1466
  if (!isNullOrUndefined(options['fill'])) {
1454
1467
  element.setAttribute('fill', options['fill']);
1455
1468
  }
1469
+ else {
1470
+ element.setAttribute('fill', 'black');
1471
+ }
1456
1472
  element.setAttribute('stroke', options['border']['color']);
1457
1473
  element.setAttribute('stroke-width', options['border']['width']);
1458
1474
  }
@@ -1699,17 +1715,35 @@ function removeShape(collection) {
1699
1715
  /**
1700
1716
  *
1701
1717
  * @param {any[]} collection - Specifies the legend collection.
1718
+ * @param {TreeMap} treeMap - Specifies the treemap instance.
1702
1719
  * @returns {void}
1703
1720
  * @private
1704
1721
  */
1705
- function removeLegend(collection) {
1722
+ function removeLegend(collection, treeMap) {
1706
1723
  if (collection.length > 0) {
1707
1724
  for (let j = 0; j < collection.length; j++) {
1708
1725
  const item = collection[j];
1709
- setColor(item['legendEle'], item['oldFill'], item['oldOpacity'], item['oldBorderColor'], item['oldBorderWidth']);
1710
- const dataCount = item['ShapeCollection']['Elements'].length;
1726
+ const legendIndex = parseFloat(item['legendEle'].id.split('_Index_')[1]);
1727
+ const isText = item['legendEle'].id.indexOf('Text') > -1;
1728
+ const shapeId = isText ? item['legendEle'].id.replace('_Text', '') : item['legendEle'].id;
1729
+ const legendShape = treeMap.legendSettings.mode === 'Interactive'
1730
+ ? document.getElementById(shapeId)
1731
+ : document.getElementById(treeMap.element.id + '_Legend_Shape_Index_' + legendIndex);
1732
+ const legendText = treeMap.legendSettings.mode === 'Interactive'
1733
+ ? document.getElementById(shapeId + '_Text')
1734
+ : document.getElementById(treeMap.element.id + '_Legend_Text_Index_' + legendIndex);
1735
+ if (!isNullOrUndefined(legendShape)) {
1736
+ setColor(legendShape, item['oldFill'], item['oldOpacity'], item['oldBorderColor'], item['oldBorderWidth']);
1737
+ }
1738
+ if (!isNullOrUndefined(legendText)) {
1739
+ setColor(legendText, treeMap.legendSettings.textStyle.color, item['oldOpacity'], item['oldBorderColor'], item['oldBorderWidth']);
1740
+ }
1741
+ const dataCount = !isNullOrUndefined(item['ShapeCollection']) ? item['ShapeCollection']['Elements'].length : 0;
1711
1742
  for (let k = 0; k < dataCount; k++) {
1712
- setColor(item['ShapeCollection']['Elements'][k], item['shapeOldFill'], item['shapeOldOpacity'], item['shapeOldBorderColor'], item['shapeOldBorderWidth']);
1743
+ const shapeElement = document.getElementById(item['ShapeCollection']['Elements'][k].id);
1744
+ if (!isNullOrUndefined(shapeElement)) {
1745
+ setColor(shapeElement, item['shapeOldFill'], item['shapeOldOpacity'], item['shapeOldBorderColor'], item['shapeOldBorderWidth']);
1746
+ }
1713
1747
  }
1714
1748
  }
1715
1749
  }
@@ -1737,7 +1771,7 @@ function setColor(element, fill, opacity, borderColor, borderWidth) {
1737
1771
  * @returns {void}
1738
1772
  */
1739
1773
  function removeSelectionWithHighlight(collection, element, treemap) {
1740
- removeShape(collection);
1774
+ removeLegend(collection, treemap);
1741
1775
  removeClassNames(document.getElementsByClassName('treeMapHighLight'), 'treeMapHighLight', treemap);
1742
1776
  }
1743
1777
  /**
@@ -1749,10 +1783,24 @@ function removeSelectionWithHighlight(collection, element, treemap) {
1749
1783
  */
1750
1784
  function getLegendIndex(length, item, treemap) {
1751
1785
  let index;
1786
+ const valuePath = treemap.rangeColorValuePath;
1752
1787
  for (let i = 0; i < length; i++) {
1753
1788
  const dataLength = treemap.treeMapLegendModule.legendCollections[i]['legendData'].length;
1754
- for (let j = 0; j < dataLength; j++) {
1755
- if (treemap.treeMapLegendModule.legendCollections[i]['legendData'][j]['levelOrderName'] === item['levelOrderName']) {
1789
+ if (dataLength > 0) {
1790
+ for (let j = 0; j < dataLength; j++) {
1791
+ if ((!isNullOrUndefined(valuePath) && valuePath !== '' && treemap.leafItemSettings.colorMapping.length > 0 ?
1792
+ (treemap.treeMapLegendModule.legendCollections[i]['legendData'][j]['data'][valuePath] === item['data'][valuePath])
1793
+ : treemap.treeMapLegendModule.legendCollections[i]['legendData'][j]['levelOrderName'] === item['levelOrderName']
1794
+ || item['levelOrderName'].indexOf(treemap.treeMapLegendModule.legendCollections[i]['legendName']) > -1)) {
1795
+ index = i;
1796
+ break;
1797
+ }
1798
+ }
1799
+ }
1800
+ else if (treemap.palette && treemap.palette.length > 0) {
1801
+ if ((treemap.treeMapLegendModule.legendCollections[i]['levelOrderName'] === item['levelOrderName'] ||
1802
+ (item['levelOrderName'].indexOf(treemap.treeMapLegendModule.legendCollections[i]['levelOrderName'])) > -1)
1803
+ && treemap.treeMapLegendModule.legendCollections[i]['legendName'] === item['name']) {
1756
1804
  index = i;
1757
1805
  break;
1758
1806
  }
@@ -2283,7 +2331,8 @@ class LayoutPanel {
2283
2331
  groupId = elementID + '_Level_Index_' + index + '_Item_Index_' + i;
2284
2332
  itemGroup = this.renderer.createGroup({ id: groupId + '_Group' });
2285
2333
  gap = (isLeafItem ? leaf.gap : levels[index].groupGap) / 2;
2286
- const treemapItemRect = this.treemap.totalRect ? convertToContainer(this.treemap.totalRect) : this.treemap.areaRect;
2334
+ const treemapItemRect = this.treemap.totalRect ? (treeMap.legendSettings.visible ? this.treemap.totalRect
2335
+ : convertToContainer(this.treemap.totalRect)) : this.treemap.areaRect;
2287
2336
  if (treeMap.layoutType === 'Squarified') {
2288
2337
  rect.width = Math.abs(rect.x - rect.width) - gap;
2289
2338
  rect.height = Math.abs(rect.y - rect.height) - gap;
@@ -2326,6 +2375,9 @@ class LayoutPanel {
2326
2375
  renderText = !isLeafItem && childItems && childItems.length > 0 && this.treemap.enableDrillDown ?
2327
2376
  !item['isDrilled'] ? treeMap.enableRtl ? renderText + ' [+]' : '[+] ' + renderText :
2328
2377
  treeMap.enableRtl ? renderText + ' [-]' : '[-] ' + renderText : renderText;
2378
+ if (treeMap.enableHtmlSanitizer) {
2379
+ renderText = SanitizeHtmlHelper.sanitize(renderText);
2380
+ }
2329
2381
  let fontFamily = (isLeafItem ? leaf.labelStyle.fontFamily : levels[index].headerStyle.fontFamily);
2330
2382
  fontFamily = fontFamily || this.treemap.themeStyle.labelFontFamily;
2331
2383
  let size = (isLeafItem ? leaf.labelStyle.size : levels[index].headerStyle.size);
@@ -2390,6 +2442,7 @@ class LayoutPanel {
2390
2442
  secondaryEle.appendChild(templateGroup);
2391
2443
  }
2392
2444
  this.treemap.svgObject.appendChild(this.layoutGroup);
2445
+ maintainSelection(this.treemap, this.layoutGroup, 'treeMapSelection');
2393
2446
  }
2394
2447
  renderItemText(text, parentElement, textStyle, rect, interSectAction, groupId, fill, position, connectorText) {
2395
2448
  const padding = 5;
@@ -2479,7 +2532,8 @@ class LayoutPanel {
2479
2532
  for (let i = 0; i < parentData.length; i++) {
2480
2533
  if (parentData[i]['levelOrderName'] === item['levelOrderName'].split('#')[0]) {
2481
2534
  itemFill = !isNullOrUndefined(itemFill) ? itemFill : !isNullOrUndefined(treemap.colorValuePath) ?
2482
- parentData[i]['data'][treemap.colorValuePath] : (!isNullOrUndefined(treemap.palette) && treemap.palette.length > 0) ?
2535
+ parentData[i]['data'][treemap.colorValuePath] : !isNullOrUndefined(item['options']) ?
2536
+ item['options'].fill : (!isNullOrUndefined(treemap.palette) && treemap.palette.length > 0) ?
2483
2537
  treemap.palette[i % treemap.palette.length] : '#808080';
2484
2538
  }
2485
2539
  }
@@ -2512,6 +2566,9 @@ class LayoutPanel {
2512
2566
  template = template.replace(new regExp('{{:' + keys[i] + '}}', 'g'), item['data'][keys[i].toString()]);
2513
2567
  }
2514
2568
  }
2569
+ if (this.treemap.enableHtmlSanitizer && typeof template === 'string') {
2570
+ template = SanitizeHtmlHelper.sanitize(template);
2571
+ }
2515
2572
  let labelElement;
2516
2573
  if (!isNullOrUndefined(document.getElementById(this.treemap.element.id + '_Secondary_Element'))) {
2517
2574
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
@@ -2637,9 +2694,9 @@ function getThemeStyle(theme) {
2637
2694
  fontWeight: 'Normal',
2638
2695
  subtitleFontSize: '14px',
2639
2696
  legendFontSize: '13px',
2697
+ labelFontFamily: defaultFont,
2640
2698
  fontFamily: 'Roboto, Noto, Sans-serif',
2641
2699
  labelFontSize: '12px',
2642
- labelFontFamily: defaultFont,
2643
2700
  legendBorderColor: '#000000',
2644
2701
  legendBorderWidth: 0
2645
2702
  };
@@ -2716,6 +2773,54 @@ function getThemeStyle(theme) {
2716
2773
  legendBorderWidth: 0
2717
2774
  };
2718
2775
  break;
2776
+ case 'tailwind3':
2777
+ style = {
2778
+ backgroundColor: 'transparent',
2779
+ titleFontColor: '#111827',
2780
+ titleFontWeight: '600',
2781
+ subTitleFontColor: '#111827',
2782
+ tooltipFillColor: '#111827',
2783
+ tooltipFontColor: '#F9FAFB',
2784
+ tooltipFontSize: '12px',
2785
+ tooltipFillOpacity: 1,
2786
+ tooltipTextOpacity: 1,
2787
+ legendTitleColor: '#111827',
2788
+ legendTextColor: '#111827',
2789
+ fontFamily: 'Inter',
2790
+ fontSize: '14px',
2791
+ fontWeight: '400',
2792
+ subtitleFontSize: '12px',
2793
+ legendFontSize: '12px',
2794
+ labelFontFamily: 'Inter',
2795
+ labelFontSize: '12px',
2796
+ legendBorderColor: '#000000',
2797
+ legendBorderWidth: 0
2798
+ };
2799
+ break;
2800
+ case 'tailwind3dark':
2801
+ style = {
2802
+ backgroundColor: 'transparent',
2803
+ titleFontColor: '#FFFFFF',
2804
+ titleFontWeight: '600',
2805
+ subTitleFontColor: '#FFFFFF',
2806
+ tooltipFillColor: '#F9FAFB',
2807
+ tooltipFontColor: '#1F2937',
2808
+ tooltipFontSize: '12px',
2809
+ tooltipFillOpacity: 1,
2810
+ tooltipTextOpacity: 1,
2811
+ legendTitleColor: '#FFFFFF',
2812
+ legendTextColor: '#FFFFFF',
2813
+ fontFamily: 'Inter',
2814
+ fontWeight: '400',
2815
+ fontSize: '14px',
2816
+ subtitleFontSize: '12px',
2817
+ legendFontSize: '12px',
2818
+ labelFontFamily: 'Inter',
2819
+ labelFontSize: '12px',
2820
+ legendBorderColor: '#000000',
2821
+ legendBorderWidth: 0
2822
+ };
2823
+ break;
2719
2824
  case 'bootstrap5':
2720
2825
  style = {
2721
2826
  backgroundColor: 'transparent',
@@ -2947,9 +3052,9 @@ function getThemeStyle(theme) {
2947
3052
  fontWeight: 'Normal',
2948
3053
  subtitleFontSize: '14px',
2949
3054
  legendFontSize: '13px',
2950
- labelFontFamily: defaultFont,
2951
3055
  fontFamily: 'Roboto, Noto, Sans-serif',
2952
3056
  labelFontSize: '12px',
3057
+ labelFontFamily: defaultFont,
2953
3058
  legendBorderColor: '#000000',
2954
3059
  legendBorderWidth: 0
2955
3060
  };
@@ -3024,12 +3129,12 @@ class Print {
3024
3129
  backgroundElement = backgroundElement.childNodes[0];
3025
3130
  if (!isNullOrUndefined(backgroundElement)) {
3026
3131
  const backgroundColor = backgroundElement.getAttribute('fill');
3027
- if ((treeMap.theme === 'Tailwind' || treeMap.theme === 'Bootstrap5' || treeMap.theme === 'Fluent' || treeMap.theme === 'Material3' ||
3132
+ if ((treeMap.theme === 'Tailwind' || treeMap.theme === 'Tailwind3' || treeMap.theme === 'Bootstrap5' || treeMap.theme === 'Fluent' || treeMap.theme === 'Material3' ||
3028
3133
  treeMap.theme === 'Fluent2')
3029
3134
  && (backgroundColor === 'rgba(255,255,255, 0.0)' || backgroundColor === 'transparent')) {
3030
3135
  backgroundElement.setAttribute('fill', 'rgba(255,255,255, 1)');
3031
3136
  }
3032
- else if ((treeMap.theme === 'TailwindDark' || treeMap.theme === 'Bootstrap5Dark' || treeMap.theme === 'FluentDark' || treeMap.theme === 'Material3Dark' ||
3137
+ else if ((treeMap.theme === 'TailwindDark' || treeMap.theme === 'Tailwind3Dark' || treeMap.theme === 'Bootstrap5Dark' || treeMap.theme === 'FluentDark' || treeMap.theme === 'Material3Dark' ||
3033
3138
  treeMap.theme === 'Fluent2Dark' || treeMap.theme === 'Fluent2HighContrast')
3034
3139
  && (backgroundColor === 'rgba(255,255,255, 0.0)' || backgroundColor === 'transparent')) {
3035
3140
  backgroundElement.setAttribute('fill', 'rgba(0, 0, 0, 1)');
@@ -3097,12 +3202,12 @@ class ImageExport {
3097
3202
  const backgroundElement = exportElement.childNodes[0];
3098
3203
  if (!isNullOrUndefined(backgroundElement)) {
3099
3204
  const backgroundColor = backgroundElement.getAttribute('fill');
3100
- if ((treeMap.theme === 'Tailwind' || treeMap.theme === 'Bootstrap5' || treeMap.theme === 'Fluent' || treeMap.theme === 'Material3' ||
3205
+ if ((treeMap.theme === 'Tailwind' || treeMap.theme === 'Tailwind3' || treeMap.theme === 'Bootstrap5' || treeMap.theme === 'Fluent' || treeMap.theme === 'Material3' ||
3101
3206
  treeMap.theme === 'Fluent2')
3102
3207
  && (backgroundColor === 'rgba(255,255,255, 0.0)' || backgroundColor === 'transparent')) {
3103
3208
  exportElement.childNodes[0].setAttribute('fill', 'rgba(255,255,255, 1)');
3104
3209
  }
3105
- else if ((treeMap.theme === 'TailwindDark' || treeMap.theme === 'Bootstrap5Dark' || treeMap.theme === 'FluentDark' || treeMap.theme === 'Material3Dark' ||
3210
+ else if ((treeMap.theme === 'TailwindDark' || treeMap.theme === 'Tailwind3Dark' || treeMap.theme === 'Bootstrap5Dark' || treeMap.theme === 'FluentDark' || treeMap.theme === 'Material3Dark' ||
3106
3211
  treeMap.theme === 'Fluent2Dark' || treeMap.theme === 'Fluent2HighContrast')
3107
3212
  && (backgroundColor === 'rgba(255,255,255, 0.0)' || backgroundColor === 'transparent')) {
3108
3213
  exportElement.childNodes[0].setAttribute('fill', 'rgba(0, 0, 0, 1)');
@@ -3199,12 +3304,12 @@ class PdfExport {
3199
3304
  const backgroundElement = exportElement.childNodes[0];
3200
3305
  if (!isNullOrUndefined(backgroundElement)) {
3201
3306
  const backgroundColor = backgroundElement.getAttribute('fill');
3202
- if ((treeMap.theme === 'Tailwind' || treeMap.theme === 'Bootstrap5' || treeMap.theme === 'Fluent' || treeMap.theme === 'Material3' ||
3307
+ if ((treeMap.theme === 'Tailwind' || treeMap.theme === 'Tailwind3' || treeMap.theme === 'Bootstrap5' || treeMap.theme === 'Fluent' || treeMap.theme === 'Material3' ||
3203
3308
  treeMap.theme === 'Fluent2')
3204
3309
  && (backgroundColor === 'rgba(255,255,255, 0.0)' || backgroundColor === 'transparent')) {
3205
3310
  exportElement.childNodes[0].setAttribute('fill', 'rgba(255,255,255, 1)');
3206
3311
  }
3207
- else if ((treeMap.theme === 'TailwindDark' || treeMap.theme === 'Bootstrap5Dark' || treeMap.theme === 'FluentDark' || treeMap.theme === 'Material3Dark' ||
3312
+ else if ((treeMap.theme === 'TailwindDark' || treeMap.theme === 'Tailwind3Dark' || treeMap.theme === 'Bootstrap5Dark' || treeMap.theme === 'FluentDark' || treeMap.theme === 'Material3Dark' ||
3208
3313
  treeMap.theme === 'Fluent2Dark' || treeMap.theme === 'Fluent2HighContrast')
3209
3314
  && (backgroundColor === 'rgba(255,255,255, 0.0)' || backgroundColor === 'transparent')) {
3210
3315
  exportElement.childNodes[0].setAttribute('fill', 'rgba(0, 0, 0, 1)');
@@ -3368,6 +3473,9 @@ let TreeMap = class TreeMap extends Component {
3368
3473
  }
3369
3474
  this.layout.processLayoutPanel();
3370
3475
  this.element.appendChild(this.svgObject);
3476
+ if (!isNullOrUndefined(this.treeMapLegendModule) && this.legendSettings.visible) {
3477
+ legendMaintain(this, this.treeMapLegendModule.legendGroup);
3478
+ }
3371
3479
  this.elementChange();
3372
3480
  this.trigger(loaded, { treemap: this, isResized: this.isResize });
3373
3481
  this.isResize = false;
@@ -3463,14 +3571,15 @@ let TreeMap = class TreeMap extends Component {
3463
3571
  if (isNullOrUndefined(groupEle)) {
3464
3572
  groupEle = this.renderer.createGroup({ id: this.element.id + '_Title_Group' });
3465
3573
  }
3466
- const trimmedTitle = textTrim(width, title.text, style);
3574
+ const titleText = this.enableHtmlSanitizer ? (SanitizeHtmlHelper.sanitize(title.text)) : title.text;
3575
+ const trimmedTitle = textTrim(width, titleText, style);
3467
3576
  const elementSize = measureText(trimmedTitle, style);
3468
3577
  const rect = (isNullOrUndefined(bounds)) ? new Rect(this.margin.left, this.margin.top, this.availableSize.width, this.availableSize.height) : bounds;
3469
3578
  const location = findPosition(rect, title.alignment, elementSize, type);
3470
3579
  const options = new TextOption(this.element.id + '_TreeMap_' + type, location.x, location.y, 'start', trimmedTitle);
3471
3580
  const titleBounds = new Rect(location.x, location.y, elementSize.width, elementSize.height);
3472
3581
  const element = renderTextElement(options, style, style.color || (type === 'title' ? this.themeStyle.titleFontColor : this.themeStyle.subTitleFontColor), groupEle);
3473
- element.setAttribute('aria-label', title.description || title.text);
3582
+ element.setAttribute('aria-label', title.description || titleText);
3474
3583
  element.setAttribute('role', 'region');
3475
3584
  element.setAttribute('tabindex', this.tabIndex.toString());
3476
3585
  if ((type === 'title' && !title.subtitleSettings.text) || (type === 'subtitle')) {
@@ -4246,7 +4355,7 @@ let TreeMap = class TreeMap extends Component {
4246
4355
  }
4247
4356
  removeClassNames(document.getElementsByClassName('treeMapHighLight'), 'treeMapHighLight', this);
4248
4357
  if (this.treeMapHighlightModule) {
4249
- removeShape(this.treeMapHighlightModule.shapeHighlightCollection);
4358
+ removeLegend(this.treeMapHighlightModule.shapeHighlightCollection, this);
4250
4359
  this.treeMapHighlightModule.highLightId = '';
4251
4360
  }
4252
4361
  }
@@ -4494,6 +4603,9 @@ __decorate$1([
4494
4603
  __decorate$1([
4495
4604
  Property(false)
4496
4605
  ], TreeMap.prototype, "drillDownView", void 0);
4606
+ __decorate$1([
4607
+ Property(false)
4608
+ ], TreeMap.prototype, "enableHtmlSanitizer", void 0);
4497
4609
  __decorate$1([
4498
4610
  Complex({}, InitialDrillSettings)
4499
4611
  ], TreeMap.prototype, "initialDrillDown", void 0);
@@ -4663,7 +4775,7 @@ class TreeMapLegend {
4663
4775
  const defaultSize = 25;
4664
4776
  const textPadding = 10;
4665
4777
  const position = legend.position;
4666
- const legendTitle = legend.title.text;
4778
+ const legendTitle = treemap.enableHtmlSanitizer ? SanitizeHtmlHelper.sanitize(legend.title.text) : legend.title.text;
4667
4779
  const titleTextStyle = legend.titleStyle;
4668
4780
  const legendMode = legend.mode;
4669
4781
  let shapeX = 0;
@@ -4705,7 +4817,8 @@ class TreeMapLegend {
4705
4817
  if (isNullOrUndefined(this.totalPages[this.page])) {
4706
4818
  this.totalPages[this.page] = { Page: (this.page + 1), Collection: [] };
4707
4819
  }
4708
- const legendTextSize = measureText(legendItem['legendName'], itemTextStyle);
4820
+ const legendTextSize = measureText(treemap.enableHtmlSanitizer ?
4821
+ SanitizeHtmlHelper.sanitize(legendItem['legendName']) : legendItem['legendName'], itemTextStyle);
4709
4822
  this.textMaxWidth = Math.max(this.textMaxWidth, legendTextSize.width);
4710
4823
  if (i === 0) {
4711
4824
  startX = shapeX = (leftPadding + (shapeWidth / 2));
@@ -4913,7 +5026,16 @@ class TreeMapLegend {
4913
5026
  if (this.treemap.enableDrillDown && !isNullOrUndefined(this.treemap.drilledLegendItems)) {
4914
5027
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
4915
5028
  const childElement = this.treemap.drilledLegendItems;
4916
- legendFillColor = childElement['data']['options']['fill'];
5029
+ if (!isNullOrUndefined(childElement['data']['options'])) {
5030
+ legendFillColor = childElement['data']['options']['fill'];
5031
+ }
5032
+ else {
5033
+ for (let k = 0; k < childElement.length; k++) {
5034
+ legendFillColor = this.treemap.palette.length > 0 ? this.treemap.palette[k % this.treemap.palette.length] :
5035
+ childElement[k]['data'][this.treemap.colorValuePath];
5036
+ break;
5037
+ }
5038
+ }
4917
5039
  if (childElement['data']['isDrilled']) {
4918
5040
  child = findChildren(childElement['data'])['values'];
4919
5041
  }
@@ -4943,7 +5065,8 @@ class TreeMapLegend {
4943
5065
  ? legendFillColor : this.treemap.palette[i % this.treemap.palette.length] :
4944
5066
  child[i]['data'][this.treemap.colorValuePath],
4945
5067
  legendData: [],
4946
- itemArea: child[i]['weight']
5068
+ itemArea: child[i]['weight'],
5069
+ levelOrderName: child[i]['levelOrderName']
4947
5070
  });
4948
5071
  }
4949
5072
  }
@@ -5069,7 +5192,7 @@ class TreeMapLegend {
5069
5192
  this.legendCollections[this.legendCollections.length - 1]['legendData'].push(data[i]);
5070
5193
  legendIndex++;
5071
5194
  }
5072
- else if (colorMapProcess && !isDuplicate) {
5195
+ else if (colorMapProcess) {
5073
5196
  colorMapProcess = false;
5074
5197
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
5075
5198
  this.legendCollections[isAddData['value']]['legendData'].push(data[i]);
@@ -5087,14 +5210,19 @@ class TreeMapLegend {
5087
5210
  if (isNullOrUndefined(this.outOfRangeLegend) && !isDuplicate) {
5088
5211
  this.legendCollections.push({
5089
5212
  actualValue: labelLegend, legendData: [],
5090
- legendName: labelLegend, legendFill: outfill
5213
+ legendName: labelLegend, legendFill: outfill, groupIndex: (!isLeafItem || groupIndex > -1) ? groupIndex : -1
5091
5214
  });
5092
5215
  otherIndex = this.legendCollections.length;
5093
5216
  this.outOfRangeLegend = this.legendCollections[otherIndex - 1];
5094
5217
  legendIndex++;
5095
5218
  }
5096
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
5097
- this.legendCollections[this.legendCollections.length - 1]['legendData'].push(data[i]);
5219
+ for (let k = this.legendCollections.length - 1; k >= 0; k--) {
5220
+ if (this.legendCollections[k]['groupIndex'] === data[i]['groupIndex']) {
5221
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
5222
+ this.legendCollections[k]['legendData'].push(data[i]);
5223
+ break;
5224
+ }
5225
+ }
5098
5226
  }
5099
5227
  }
5100
5228
  }
@@ -5183,7 +5311,8 @@ class TreeMapLegend {
5183
5311
  - this.translate.x - Math.abs(this.legendBorderRect.x - textLocation.x);
5184
5312
  }
5185
5313
  }
5186
- textOptions = new TextOption(textId, textLocation.x, textLocation.y, 'middle', item['text'], '', '');
5314
+ const text = this.treemap.enableHtmlSanitizer ? (SanitizeHtmlHelper.sanitize(item['text'])) : item['text'];
5315
+ textOptions = new TextOption(textId, textLocation.x, textLocation.y, 'middle', text, '', '');
5187
5316
  renderTextElement(textOptions, textFont, textFont.color || this.treemap.themeStyle.legendTextColor, this.legendGroup);
5188
5317
  this.legendGroup.appendChild(render.drawRectangle(rectOptions));
5189
5318
  }
@@ -5232,7 +5361,7 @@ class TreeMapLegend {
5232
5361
  for (let i = 0; i < this.totalPages[page]['Collection'].length; i++) {
5233
5362
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
5234
5363
  const collection = this.totalPages[page]['Collection'][i];
5235
- const legendText = collection['DisplayText'];
5364
+ const legendText = this.treemap.enableHtmlSanitizer ? SanitizeHtmlHelper.sanitize(collection['DisplayText']) : collection['DisplayText'];
5236
5365
  const legendElement = render.createGroup({ id: treemap.element.id + '_Legend_Index_' + i });
5237
5366
  legendElement.setAttribute('aria-label', legendText + ' Legend');
5238
5367
  legendElement.setAttribute('role', 'region');
@@ -5336,7 +5465,7 @@ class TreeMapLegend {
5336
5465
  renderLegendTitle() {
5337
5466
  const legend = this.treemap.legendSettings;
5338
5467
  const textStyle = legend.titleStyle;
5339
- const legendTitle = legend.title.text;
5468
+ const legendTitle = this.treemap.enableHtmlSanitizer ? (SanitizeHtmlHelper.sanitize(legend.title.text)) : legend.title.text;
5340
5469
  let textOptions;
5341
5470
  const spacing = 10;
5342
5471
  const trimTitle = textTrim((this.legendItemRect.width + (spacing * 2)), legendTitle, textStyle);
@@ -5360,6 +5489,7 @@ class TreeMapLegend {
5360
5489
  const treemap = this.treemap;
5361
5490
  let target = e.target;
5362
5491
  const interactiveId = treemap.element.id + '_Interactive_Legend';
5492
+ let pointerDrawn = false;
5363
5493
  target = !(e.type.indexOf('touch') > -1) ? target :
5364
5494
  document.elementFromPoint(e.changedTouches[0].clientX, e.changedTouches[0].clientY);
5365
5495
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
@@ -5377,7 +5507,7 @@ class TreeMapLegend {
5377
5507
  let legendElement;
5378
5508
  targetItem = treemap.layout.renderItems[parseFloat(target.id.split('_Item_Index_')[1])];
5379
5509
  const svgRect = treemap.svgObject.getBoundingClientRect();
5380
- for (let i = 0; i < this.legendCollections.length; i++) {
5510
+ for (let i = 0; i < this.legendCollections.length && !pointerDrawn; i++) {
5381
5511
  currentData = this.legendCollections[i];
5382
5512
  legendElement = document.getElementById(treemap.element.id + '_Legend_Index_' + i);
5383
5513
  legendRect = legendElement.getBoundingClientRect();
@@ -5385,16 +5515,33 @@ class TreeMapLegend {
5385
5515
  fill = legendElement.getAttribute('fill');
5386
5516
  stroke = legend.shapeBorder.color;
5387
5517
  strokeWidth = legend.shapeBorder.width;
5388
- if (!isNullOrUndefined(currentData['legendData'])) {
5518
+ if (!isNullOrUndefined(currentData['legendData']) && currentData['legendData'].length > 0) {
5389
5519
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
5390
5520
  data = currentData['legendData'];
5391
- for (let j = 0; j < data.length; j++) {
5392
- if (data[j]['levelOrderName'] === targetItem['levelOrderName']) {
5393
- this.drawInteractivePointer(legend, fill, stroke, interactiveId, strokeWidth, rect);
5394
- break;
5521
+ const valuePath = treemap.rangeColorValuePath;
5522
+ if (targetItem['levelOrderName'].indexOf(this.legendCollections[i]['legendName']) > -1) {
5523
+ this.drawInteractivePointer(legend, fill, stroke, interactiveId, strokeWidth, rect);
5524
+ pointerDrawn = true;
5525
+ }
5526
+ else {
5527
+ for (let j = 0; j < data.length; j++) {
5528
+ if ((treemap.rangeColorValuePath && treemap.leafItemSettings.colorMapping.length > 0)
5529
+ ? data[j]['data'][valuePath] === targetItem['data'][valuePath]
5530
+ : (data[j]['levelOrderName'] === targetItem['levelOrderName'] ||
5531
+ data[j]['levelOrderName'].indexOf(targetItem['levelOrderName']) > -1)) {
5532
+ this.drawInteractivePointer(legend, fill, stroke, interactiveId, strokeWidth, rect);
5533
+ pointerDrawn = true;
5534
+ break;
5535
+ }
5395
5536
  }
5396
5537
  }
5397
5538
  }
5539
+ else if (this.treemap.leafItemSettings.colorMapping.length === 0 && this.treemap.palette) {
5540
+ if (targetItem['levelOrderName'].indexOf(currentData['levelOrderName']) > -1) {
5541
+ this.drawInteractivePointer(legend, fill, stroke, interactiveId, strokeWidth, rect);
5542
+ pointerDrawn = true;
5543
+ }
5544
+ }
5398
5545
  }
5399
5546
  }
5400
5547
  else {
@@ -5683,7 +5830,21 @@ class TreeMapHighlight {
5683
5830
  let element;
5684
5831
  let orders;
5685
5832
  const selectionModule = this.treemap.treeMapSelectionModule;
5686
- if (targetId.indexOf('_Item_Index') > -1 && (selectionModule ? this.treemap.selectionId !== targetId : true)) {
5833
+ let shapeSelected = false;
5834
+ if (selectionModule && selectionModule.legendSelectionCollection.length > 0) {
5835
+ for (let i = 0; i < selectionModule.legendSelectionCollection.length; i++) {
5836
+ for (let j = 0; j < selectionModule.legendSelectionCollection[i]['ShapeCollection']['Elements'].length; j++) {
5837
+ const selectedElementIndex = parseFloat(selectionModule.legendSelectionCollection[i]['ShapeCollection']['Elements'][j].id.split('Item_Index_')[1].split('_')[0]);
5838
+ const targetElementIndex = targetId.indexOf('_Item_Index_') > -1 ? parseFloat(targetId.split('Item_Index_')[1].split('_')[0]) : null;
5839
+ if (selectionModule.legendSelectionCollection[i]['ShapeCollection']['Elements'][j].id === targetId ||
5840
+ selectedElementIndex === targetElementIndex) {
5841
+ shapeSelected = true;
5842
+ break;
5843
+ }
5844
+ }
5845
+ }
5846
+ }
5847
+ if (targetId.indexOf('_Item_Index') > -1 && !shapeSelected) {
5687
5848
  if (this.highLightId !== targetId) {
5688
5849
  treeMapElement = document.getElementById(treemap.element.id + '_TreeMap_' + treemap.layoutType + '_Layout');
5689
5850
  const selectionElements = document.getElementsByClassName('treeMapSelection');
@@ -5693,16 +5854,22 @@ class TreeMapHighlight {
5693
5854
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
5694
5855
  const collection = this.treemap.treeMapLegendModule.legendCollections;
5695
5856
  const length = this.treemap.treeMapLegendModule.legendCollections.length;
5696
- index = getLegendIndex(length, item, treemap);
5857
+ index = (!treemap.legendSettings.removeDuplicateLegend && treemap.palette && treemap.palette.length > 0 &&
5858
+ treemap.leafItemSettings.colorMapping.length === 0 && treemap.levels.length === 0) ?
5859
+ parseFloat(targetId.split('_Item_Index_')[1]) : getLegendIndex(length, item, treemap);
5697
5860
  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);
5698
5861
  if (this.shapeElement !== null && (selectionModule ? this.shapeElement.getAttribute('id') !== selectionModule.legendSelectId : true)) {
5699
- if (selectionModule ? this.shapeElement !== selectionModule.shapeElement : true) {
5862
+ const legendShapeElement = selectionModule ? selectionModule.shapeElement : null;
5863
+ if (selectionModule ? this.shapeElement !== legendShapeElement : true) {
5700
5864
  this.currentElement.push({ currentElement: this.shapeElement });
5701
- removeShape(this.shapeHighlightCollection);
5865
+ removeLegend(this.shapeHighlightCollection, treemap);
5702
5866
  this.shapeHighlightCollection.push({ legendEle: this.shapeElement, oldFill: collection[index]['legendFill'],
5703
5867
  oldOpacity: collection[index]['opacity'], oldBorderColor: collection[index]['borderColor'],
5704
5868
  oldBorderWidth: collection[index]['borderWidth']
5705
5869
  });
5870
+ const legendText = this.treemap.legendSettings.mode === 'Default' ? document.getElementById(this.treemap.element.id + '_Legend_Text_Index_' + index)
5871
+ : document.getElementById(this.treemap.element.id + '_Legend_Index_' + index + '_Text');
5872
+ setColor(legendText, highlight.fill, highlight.opacity, highlight.border.color, highlight.border.width.toString());
5706
5873
  setColor(this.shapeElement, highlight.fill, highlight.opacity, highlight.border.color, highlight.border.width.toString());
5707
5874
  this.target = 'highlight';
5708
5875
  }
@@ -5714,6 +5881,9 @@ class TreeMapHighlight {
5714
5881
  else if (this.currentElement.length > 0 && this.currentElement[this.currentElement.length - 1]['currentElement'] !== this.shapeElement) {
5715
5882
  removeSelectionWithHighlight(this.shapeHighlightCollection, this.currentElement, treemap);
5716
5883
  this.highLightId = '';
5884
+ if (this.treemap.legendSettings.mode === 'Interactive') {
5885
+ this.treemap.treeMapLegendModule.removeInteractivePointer();
5886
+ }
5717
5887
  }
5718
5888
  }
5719
5889
  orders = findHightLightItems(item, [], highlight.mode, treemap);
@@ -5723,6 +5893,9 @@ class TreeMapHighlight {
5723
5893
  for (let i = 0; i < treeMapElement.childElementCount; i++) {
5724
5894
  element = treeMapElement.childNodes[i];
5725
5895
  process = true;
5896
+ const valuePath = treemap.rangeColorValuePath;
5897
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
5898
+ const targetItem = treemap.layout.renderItems[parseFloat(targetId.split('_Item_Index_')[1])];
5726
5899
  item = treemap.layout.renderItems[parseFloat(element.id.split('_Item_Index_')[1])];
5727
5900
  for (let j = 0; j < selectionElements.length; j++) {
5728
5901
  if (element.id === selectionElements[j].id) {
@@ -5730,7 +5903,9 @@ class TreeMapHighlight {
5730
5903
  break;
5731
5904
  }
5732
5905
  }
5733
- if (orders.indexOf(item['levelOrderName']) > -1 && process) {
5906
+ if (orders.indexOf(item['levelOrderName']) > -1 && process &&
5907
+ (!isNullOrUndefined(valuePath) && valuePath !== '' ?
5908
+ item['data'][valuePath] === targetItem['data'][valuePath] : true)) {
5734
5909
  highLightElements.push(element);
5735
5910
  items.push(item);
5736
5911
  }
@@ -5751,35 +5926,83 @@ class TreeMapHighlight {
5751
5926
  }
5752
5927
  }
5753
5928
  }
5754
- else if (targetId.indexOf('_Legend_Shape') > -1 || targetId.indexOf('_Legend_Index') > -1) {
5755
- if (this.treemap.legendSettings.visible && (selectionModule ? selectionModule.legendSelectId !== targetId : true)
5756
- && (selectionModule ? selectionModule.shapeSelectId !== targetId : true)) {
5929
+ else if (targetId.indexOf('_Legend_Shape') > -1 || targetId.indexOf('_Legend_Index') > -1 || targetId.indexOf('_Legend_Text_Index') > -1) {
5930
+ if (!isNullOrUndefined(selectionModule)) {
5931
+ selectionModule.legendSelectId = !isNullOrUndefined(treemap.legendId[0]) ? treemap.legendId[0] : null;
5932
+ }
5933
+ const selectedLegendIndex = selectionModule && selectionModule.legendSelectId ?
5934
+ parseFloat(selectionModule.legendSelectId.split('Index_')[1]) :
5935
+ (selectionModule && selectionModule.shapeSelectId ? parseFloat(selectionModule.shapeSelectId.split('Index_')[1]) : null);
5936
+ const targetIndex = this.treemap.legendSettings.mode === 'Default' ? (targetId.indexOf('Text') === -1 ? parseFloat(targetId.split('_Legend_Shape_Index_')[1]) : parseFloat(targetId.split('_Legend_Text_Index_')[1]))
5937
+ : parseFloat(targetId.split('_Legend_Index_')[1]);
5938
+ if (this.treemap.legendSettings.visible && targetIndex !== selectedLegendIndex) {
5757
5939
  let itemIndex;
5758
5940
  let groupIndex;
5759
5941
  let length;
5942
+ const valuePath = treemap.rangeColorValuePath;
5760
5943
  const targetEle = document.getElementById(targetId);
5761
5944
  if (this.shapeTarget === 'highlight') {
5762
- removeLegend(this.legendHighlightCollection);
5945
+ removeLegend(this.legendHighlightCollection, this.treemap);
5946
+ this.legendHighlightCollection = [];
5763
5947
  }
5764
5948
  this.shapeTarget = 'highlight';
5765
- const index = this.treemap.legendSettings.mode === 'Default' ? parseFloat(targetId.split('_Legend_Shape_Index_')[1]) : parseFloat(targetId.split('_Legend_Index_')[1]);
5766
- const dataLength = this.treemap.treeMapLegendModule.legendCollections[index]['legendData'].length;
5949
+ const dataLength = this.treemap.treeMapLegendModule.legendCollections[targetIndex]['legendData'].length;
5767
5950
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
5768
5951
  const collection = this.treemap.treeMapLegendModule.legendCollections;
5769
- const legendIndex = parseInt(targetId[targetId.length - 1], 10);
5770
5952
  for (let i = 0; i < dataLength; i++) {
5771
5953
  for (let j = 0; j < this.treemap.layout.renderItems.length; j++) {
5772
- if (this.treemap.treeMapLegendModule.legendCollections[index]['legendData'][i]['levelOrderName'] === this.treemap.layout.renderItems[j]['levelOrderName']) {
5954
+ if ((!isNullOrUndefined(valuePath) && valuePath !== '' && treemap.leafItemSettings.colorMapping.length > 0)
5955
+ ? treemap.treeMapLegendModule.legendCollections[targetIndex]['legendData'][i]['data'][valuePath] === treemap.layout.renderItems[j]['data'][valuePath]
5956
+ : (treemap.treeMapLegendModule.legendCollections[targetIndex]['legendData'][i]['levelOrderName'] === treemap.layout.renderItems[j]['levelOrderName'])) {
5773
5957
  itemIndex = j;
5774
5958
  groupIndex = this.treemap.layout.renderItems[j]['groupIndex'];
5775
5959
  const nodeEle = document.getElementById(this.treemap.element.id + '_Level_Index_' + groupIndex + '_Item_Index_' + itemIndex + '_RectPath');
5776
- if (i === 0) {
5960
+ if (i === 0 || this.legendHighlightCollection.length === 0) {
5777
5961
  this.legendHighlightCollection = [];
5778
- pushCollection(this.legendHighlightCollection, legendIndex, j, targetEle, nodeEle, this.treemap.layout.renderItems, collection);
5962
+ pushCollection(this.legendHighlightCollection, targetIndex, j, targetEle, nodeEle, this.treemap.layout.renderItems, collection);
5779
5963
  length = this.legendHighlightCollection.length;
5780
5964
  this.legendHighlightCollection[length - 1]['ShapeCollection'] = { Elements: [] };
5781
5965
  }
5782
5966
  setColor(targetEle, highlight.fill, highlight.opacity, highlight.border.color, highlight.border.width.toString());
5967
+ let legendItem;
5968
+ if (targetEle.id.indexOf('Text') > -1) {
5969
+ legendItem = this.treemap.legendSettings.mode === 'Interactive' ? document.getElementById(targetEle.id.replace('_Text', ''))
5970
+ : document.getElementById(this.treemap.element.id + '_Legend_Shape_Index_' + targetIndex);
5971
+ }
5972
+ else {
5973
+ legendItem = this.treemap.legendSettings.mode === 'Interactive' ? document.getElementById(targetEle.id + '_Text')
5974
+ : document.getElementById(this.treemap.element.id + '_Legend_Text_Index_' + targetIndex);
5975
+ }
5976
+ setColor(legendItem, highlight.fill, highlight.opacity, highlight.border.color, highlight.border.width.toString());
5977
+ setColor(nodeEle, highlight.fill, highlight.opacity, highlight.border.color, highlight.border.width.toString());
5978
+ length = this.legendHighlightCollection.length;
5979
+ this.legendHighlightCollection[length - 1]['ShapeCollection']['Elements'].push(nodeEle);
5980
+ }
5981
+ }
5982
+ }
5983
+ if (dataLength === 0 && this.treemap.palette && this.treemap.palette.length > 0) {
5984
+ for (let j = 0; j < this.treemap.layout.renderItems.length; j++) {
5985
+ if ((this.treemap.treeMapLegendModule.legendCollections[targetIndex]['levelOrderName'] === this.treemap.layout.renderItems[j]['levelOrderName'] ||
5986
+ this.treemap.layout.renderItems[j]['levelOrderName'].indexOf(this.treemap.treeMapLegendModule.legendCollections[targetIndex]['levelOrderName']) > -1) &&
5987
+ ((!this.treemap.legendSettings.removeDuplicateLegend && treemap.palette && treemap.palette.length > 0) ?
5988
+ targetIndex === j : true)) {
5989
+ itemIndex = j;
5990
+ groupIndex = this.treemap.layout.renderItems[j]['groupIndex'];
5991
+ const nodeEle = document.getElementById(this.treemap.element.id + '_Level_Index_' + groupIndex + '_Item_Index_' + itemIndex + '_RectPath');
5992
+ pushCollection(this.legendHighlightCollection, targetIndex, j, targetEle, nodeEle, this.treemap.layout.renderItems, collection);
5993
+ length = this.legendHighlightCollection.length;
5994
+ this.legendHighlightCollection[length - 1]['ShapeCollection'] = { Elements: [] };
5995
+ let legendItem;
5996
+ if (targetEle.id.indexOf('Text') > -1) {
5997
+ legendItem = this.treemap.legendSettings.mode === 'Interactive' ? document.getElementById(targetEle.id.replace('_Text', ''))
5998
+ : document.getElementById(this.treemap.element.id + '_Legend_Shape_Index_' + targetIndex);
5999
+ }
6000
+ else {
6001
+ legendItem = this.treemap.legendSettings.mode === 'Interactive' ? document.getElementById(targetEle.id + '_Text')
6002
+ : document.getElementById(this.treemap.element.id + '_Legend_Text_Index_' + targetIndex);
6003
+ }
6004
+ setColor(legendItem, highlight.fill, highlight.opacity, highlight.border.color, highlight.border.width.toString());
6005
+ setColor(targetEle, highlight.fill, highlight.opacity, highlight.border.color, highlight.border.width.toString());
5783
6006
  setColor(nodeEle, highlight.fill, highlight.opacity, highlight.border.color, highlight.border.width.toString());
5784
6007
  length = this.legendHighlightCollection.length;
5785
6008
  this.legendHighlightCollection[length - 1]['ShapeCollection']['Elements'].push(nodeEle);
@@ -5798,13 +6021,13 @@ class TreeMapHighlight {
5798
6021
  if (selectionModule ? this.shapeElement ? this.shapeElement.getAttribute('id') !== selectionModule.legendSelectId : true : true) {
5799
6022
  if (selectionModule ? this.shapeElement !== selectionModule.shapeElement : selectionModule ?
5800
6023
  selectionModule.legendSelect : true) {
5801
- removeShape(this.shapeHighlightCollection);
6024
+ removeLegend(this.shapeHighlightCollection, treemap);
5802
6025
  this.shapeHighlightCollection = [];
5803
6026
  }
5804
6027
  }
5805
6028
  }
5806
6029
  if (this.shapeTarget === 'highlight' && this.treemap.legendSettings.visible) {
5807
- removeLegend(this.legendHighlightCollection);
6030
+ removeLegend(this.legendHighlightCollection, this.treemap);
5808
6031
  }
5809
6032
  this.highLightId = '';
5810
6033
  processHighlight = false;
@@ -5881,7 +6104,6 @@ class TreeMapSelection {
5881
6104
  const targetEle = e.target;
5882
6105
  let eventArgs;
5883
6106
  const treemap = this.treemap;
5884
- treemap.levelSelection = [];
5885
6107
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
5886
6108
  const items = [];
5887
6109
  const targetId = targetEle.id;
@@ -5895,11 +6117,18 @@ class TreeMapSelection {
5895
6117
  const selection = treemap.selectionSettings;
5896
6118
  const highlightModule = this.treemap.treeMapHighlightModule;
5897
6119
  const layoutID = treemap.element.id + '_TreeMap_' + treemap.layoutType + '_Layout';
5898
- if (targetId.indexOf('_Item_Index') > -1) {
6120
+ item = treemap.layout.renderItems[parseFloat(targetId.split('_Item_Index_')[1])];
6121
+ const isDrillItem = (item && !item.isLeafItem && treemap.enableDrillDown) &&
6122
+ (targetEle.nextSibling.textContent.indexOf('[+]') > -1 || targetEle.nextSibling.textContent.indexOf('[-]') > -1);
6123
+ if (targetId.indexOf('_Item_Index') > -1 && !isDrillItem) {
5899
6124
  e.preventDefault();
5900
- if (this.treemap.selectionId !== targetId && this.legendSelect) {
6125
+ if (this.treemap.selectionId !== targetId) {
6126
+ treemap.levelSelection = [];
6127
+ treemap.legendId = [];
6128
+ this.shapeSelectId = '';
6129
+ removeLegend(this.legendSelectionCollection, treemap);
6130
+ this.legendSelectionCollection = [];
5901
6131
  treeMapElement = document.getElementById(layoutID);
5902
- item = treemap.layout.renderItems[parseFloat(targetId.split('_Item_Index_')[1])];
5903
6132
  let index;
5904
6133
  if (this.treemap.legendSettings.visible) {
5905
6134
  this.shapeSelect = false;
@@ -5907,12 +6136,15 @@ class TreeMapSelection {
5907
6136
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
5908
6137
  const collection = this.treemap.treeMapLegendModule.legendCollections;
5909
6138
  this.shapeElement = undefined;
5910
- removeShape(this.shapeSelectionCollection);
6139
+ removeLegend(this.shapeSelectionCollection, treemap);
5911
6140
  if (highlightModule) {
5912
6141
  highlightModule.shapeTarget = 'selection';
5913
6142
  highlightModule.shapeHighlightCollection = [];
5914
6143
  }
5915
- index = getLegendIndex(length, item, treemap);
6144
+ index = (!treemap.legendSettings.removeDuplicateLegend && treemap.palette && treemap.palette.length > 0 &&
6145
+ treemap.leafItemSettings.colorMapping.length === 0
6146
+ && treemap.levels.length === 0) ?
6147
+ parseFloat(targetId.split('_Item_Index_')[1]) : getLegendIndex(length, item, treemap);
5916
6148
  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);
5917
6149
  if (this.shapeElement !== null) {
5918
6150
  this.shapeSelectId = this.shapeElement.getAttribute('id');
@@ -5920,16 +6152,28 @@ class TreeMapSelection {
5920
6152
  oldOpacity: collection[index]['opacity'], oldBorderColor: collection[index]['borderColor'],
5921
6153
  oldBorderWidth: collection[index]['borderWidth']
5922
6154
  });
6155
+ const legendText = this.treemap.legendSettings.mode === 'Default' ? document.getElementById(this.treemap.element.id + '_Legend_Text_Index_' + index)
6156
+ : document.getElementById(this.treemap.element.id + '_Legend_Index_' + index + '_Text');
6157
+ setColor(legendText, selection.fill, selection.opacity, selection.border.color, selection.border.width.toString());
5923
6158
  setColor(this.shapeElement, selection.fill, selection.opacity, selection.border.color, selection.border.width.toString());
6159
+ treemap.legendId.push(this.shapeElement.id);
6160
+ treemap.legendId.push(legendText.id);
5924
6161
  }
5925
6162
  }
5926
6163
  orders = findHightLightItems(item, [], selection.mode, treemap);
5927
6164
  for (let i = 0; i < treeMapElement.childElementCount; i++) {
5928
6165
  element = treeMapElement.childNodes[i];
6166
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
6167
+ const targetItem = treemap.layout.renderItems[parseFloat(targetId.split('_Item_Index_')[1])];
5929
6168
  item = treemap.layout.renderItems[parseFloat(element.id.split('_Item_Index_')[1])];
5930
- if (orders.indexOf(item['levelOrderName']) > -1) {
6169
+ const valuePath = treemap.rangeColorValuePath;
6170
+ if (orders.indexOf(item['levelOrderName']) > -1 &&
6171
+ (!isNullOrUndefined(valuePath) && valuePath !== '' ?
6172
+ item['data'][valuePath] === targetItem['data'][valuePath] : true)) {
5931
6173
  selectionElements.push(element);
5932
- treemap.levelSelection.push(element.id);
6174
+ if (targetId.indexOf('_RectPath') > -1) {
6175
+ treemap.levelSelection.push(targetId);
6176
+ }
5933
6177
  items.push(item);
5934
6178
  }
5935
6179
  }
@@ -5961,61 +6205,151 @@ class TreeMapSelection {
5961
6205
  }
5962
6206
  }
5963
6207
  else {
5964
- removeShape(this.shapeSelectionCollection);
6208
+ removeLegend(this.shapeSelectionCollection, treemap);
6209
+ this.treemap.legendId = [];
5965
6210
  this.shapeSelectionCollection = [];
5966
6211
  this.shapeElement = undefined;
5967
6212
  this.shapeSelect = true;
5968
6213
  this.shapeSelectId = '';
5969
- this.treemap.legendId = [];
5970
- removeClassNames(document.getElementsByClassName('treeMapSelection'), 'treeMapSelection', treemap);
5971
- this.treemap.selectionId = '';
6214
+ this.treemap.levelSelection = [];
6215
+ if (this.legendSelect) {
6216
+ removeClassNames(document.getElementsByClassName('treeMapSelection'), 'treeMapSelection', treemap);
6217
+ this.treemap.selectionId = '';
6218
+ }
5972
6219
  }
5973
6220
  }
5974
- else if (targetId.indexOf('_Legend_Shape') > -1 || targetId.indexOf('_Legend_Index') > -1) {
6221
+ else if (targetId.indexOf('_Legend_Shape') > -1 || targetId.indexOf('_Legend_Index') > -1 || targetId.indexOf('_Legend_Text_') > -1) {
5975
6222
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
5976
6223
  const collection = this.treemap.treeMapLegendModule.legendCollections;
5977
- if (this.treemap.legendSettings.visible && this.legendSelectId !== targetId && this.shapeSelect) {
6224
+ const legendSelectIdIndex = !isNullOrUndefined(this.legendSelectId) ? parseFloat(this.legendSelectId.split('_Index_')[1]) : null;
6225
+ if (this.treemap.legendSettings.visible && (legendSelectIdIndex !== parseFloat(targetId.split('_Index_')[1]))) {
5978
6226
  let itemIndex;
5979
6227
  let groupIndex;
5980
6228
  let length;
6229
+ treemap.legendId = [];
6230
+ treemap.levelSelection = [];
5981
6231
  this.legendSelectId = targetId;
5982
6232
  this.legendSelect = false;
5983
- const legendIndex = parseInt(targetId[targetId.length - 1], 10);
6233
+ const legendIndex = !isNaN(parseInt(targetId[targetId.length - 1], 10)) ?
6234
+ parseInt(targetId[targetId.length - 1], 10) :
6235
+ parseInt(targetId[targetId.length - 6], 10);
5984
6236
  const targetEle = document.getElementById(targetId);
5985
- removeLegend(this.legendSelectionCollection);
6237
+ removeLegend(this.legendSelectionCollection, treemap);
6238
+ removeClassNames(document.getElementsByClassName('treeMapSelection'), 'treeMapSelection', treemap);
6239
+ removeLegend(this.shapeSelectionCollection, treemap);
6240
+ this.legendSelectionCollection = [];
5986
6241
  if (highlightModule) {
5987
6242
  highlightModule.shapeTarget = 'selection';
6243
+ highlightModule.legendHighlightCollection = [];
5988
6244
  }
5989
- const index = this.treemap.legendSettings.mode === 'Default' ? parseFloat(targetId.split('_Legend_Shape_Index_')[1]) : parseFloat(targetId.split('_Legend_Index_')[1]);
6245
+ const valuePath = treemap.rangeColorValuePath;
6246
+ const index = this.treemap.legendSettings.mode === 'Default' ? (targetId.indexOf('Text') === -1 ? parseFloat(targetId.split('_Legend_Shape_Index_')[1]) : parseFloat(targetId.split('_Legend_Text_Index_')[1]))
6247
+ : parseFloat(targetId.split('_Legend_Index_')[1]);
5990
6248
  const dataLength = this.treemap.treeMapLegendModule.legendCollections[index]['legendData'].length;
5991
6249
  for (let k = 0; k < dataLength; k++) {
5992
6250
  for (let l = 0; l < this.treemap.layout.renderItems.length; l++) {
5993
- if (this.treemap.treeMapLegendModule.legendCollections[index]['legendData'][k]['levelOrderName'] === this.treemap.layout.renderItems[l]['levelOrderName']) {
6251
+ if ((!isNullOrUndefined(valuePath) && valuePath !== '' && treemap.leafItemSettings.colorMapping.length > 0) ?
6252
+ (treemap.treeMapLegendModule.legendCollections[index]['legendData'][k]['data'][valuePath] === treemap.layout.renderItems[l]['data'][valuePath])
6253
+ : (this.treemap.treeMapLegendModule.legendCollections[index]['legendData'][k]['levelOrderName'] === this.treemap.layout.renderItems[l]['levelOrderName'])) {
5994
6254
  itemIndex = l;
5995
6255
  groupIndex = this.treemap.layout.renderItems[l]['groupIndex'];
5996
6256
  const nodeEle = document.getElementById(this.treemap.element.id + '_Level_Index_' + groupIndex + '_Item_Index_' + itemIndex + '_RectPath');
5997
- if (k === 0) {
6257
+ this.treemap.selectionId = nodeEle.id;
6258
+ if (k === 0 || this.legendSelectionCollection.length === 0) {
5998
6259
  pushCollection(this.legendSelectionCollection, legendIndex, l, targetEle, nodeEle, this.treemap.layout.renderItems, collection);
5999
6260
  length = this.legendSelectionCollection.length;
6000
6261
  this.legendSelectionCollection[length - 1]['ShapeCollection'] = { Elements: [] };
6001
6262
  }
6263
+ this.treemap.selectionId = nodeEle.id;
6264
+ let legendItem;
6265
+ if (targetEle.id.indexOf('Text') > -1) {
6266
+ legendItem = this.treemap.legendSettings.mode === 'Interactive' ? document.getElementById(targetEle.id.replace('_Text', ''))
6267
+ : document.getElementById(this.treemap.element.id + '_Legend_Shape_Index_' + index);
6268
+ this.legendSelectId = legendItem.id;
6269
+ this.shapeElement = legendItem;
6270
+ }
6271
+ else {
6272
+ legendItem = this.treemap.legendSettings.mode === 'Interactive' ? document.getElementById(targetEle.id + '_Text')
6273
+ : document.getElementById(this.treemap.element.id + '_Legend_Text_Index_' + index);
6274
+ this.shapeElement = targetEle;
6275
+ }
6276
+ setColor(legendItem, selection.fill, selection.opacity, selection.border.color, selection.border.width.toString());
6002
6277
  setColor(targetEle, selection.fill, selection.opacity, selection.border.color, selection.border.width.toString());
6003
6278
  setColor(nodeEle, selection.fill, selection.opacity, selection.border.color, selection.border.width.toString());
6004
6279
  length = this.legendSelectionCollection.length;
6280
+ treemap.levelSelection.push(nodeEle.id);
6281
+ if (treemap.legendId.indexOf(targetEle.id) === -1) {
6282
+ treemap.legendId.push(targetEle.id);
6283
+ }
6284
+ if (treemap.legendId.indexOf(legendItem.id) === -1) {
6285
+ treemap.legendId.push(legendItem.id);
6286
+ }
6287
+ this.legendSelectionCollection[length - 1]['ShapeCollection']['Elements'].push(nodeEle);
6288
+ }
6289
+ }
6290
+ }
6291
+ if (dataLength === 0 && this.treemap.palette && this.treemap.palette.length > 0) {
6292
+ for (let j = 0; j < this.treemap.layout.renderItems.length; j++) {
6293
+ if ((this.treemap.treeMapLegendModule.legendCollections[index]['levelOrderName'] === this.treemap.layout.renderItems[j]['levelOrderName'] ||
6294
+ this.treemap.layout.renderItems[j]['levelOrderName'].indexOf(this.treemap.treeMapLegendModule.legendCollections[index]['levelOrderName']) > -1) &&
6295
+ ((!this.treemap.legendSettings.removeDuplicateLegend && treemap.palette && treemap.palette.length > 0) ?
6296
+ index === j : true)) {
6297
+ itemIndex = j;
6298
+ groupIndex = this.treemap.layout.renderItems[j]['groupIndex'];
6299
+ const nodeEle = document.getElementById(this.treemap.element.id + '_Level_Index_' + groupIndex + '_Item_Index_' + itemIndex + '_RectPath');
6300
+ pushCollection(this.legendSelectionCollection, index, j, targetEle, nodeEle, this.treemap.layout.renderItems, collection);
6301
+ this.treemap.selectionId = nodeEle.id;
6302
+ length = this.legendSelectionCollection.length;
6303
+ this.legendSelectionCollection[length - 1]['ShapeCollection'] = { Elements: [] };
6304
+ let legendItem;
6305
+ if (targetEle.id.indexOf('Text') > -1) {
6306
+ legendItem = this.treemap.legendSettings.mode === 'Interactive' ? document.getElementById(targetEle.id.replace('_Text', ''))
6307
+ : document.getElementById(this.treemap.element.id + '_Legend_Shape_Index_' + index);
6308
+ this.legendSelectId = legendItem.id;
6309
+ this.shapeElement = legendItem;
6310
+ }
6311
+ else {
6312
+ legendItem = this.treemap.legendSettings.mode === 'Interactive' ? document.getElementById(targetEle.id + '_Text')
6313
+ : document.getElementById(this.treemap.element.id + '_Legend_Text_Index_' + index);
6314
+ this.legendSelectId = targetId;
6315
+ this.shapeElement = targetEle;
6316
+ }
6317
+ setColor(legendItem, selection.fill, selection.opacity, selection.border.color, selection.border.width.toString());
6318
+ setColor(targetEle, selection.fill, selection.opacity, selection.border.color, selection.border.width.toString());
6319
+ setColor(nodeEle, selection.fill, selection.opacity, selection.border.color, selection.border.width.toString());
6320
+ treemap.levelSelection.push(nodeEle.id);
6321
+ if (treemap.legendId.indexOf(legendItem.id) === -1) {
6322
+ treemap.legendId.push(legendItem.id);
6323
+ }
6324
+ if (treemap.legendId.indexOf(targetEle.id) === -1) {
6325
+ treemap.legendId.push(targetEle.id);
6326
+ }
6327
+ length = this.legendSelectionCollection.length;
6005
6328
  this.legendSelectionCollection[length - 1]['ShapeCollection']['Elements'].push(nodeEle);
6006
6329
  }
6007
6330
  }
6008
6331
  }
6009
6332
  }
6010
6333
  else {
6011
- removeLegend(this.legendSelectionCollection);
6334
+ removeLegend(this.legendSelectionCollection, this.treemap);
6335
+ this.legendSelectionCollection = [];
6012
6336
  if (highlightModule) {
6013
6337
  highlightModule.shapeTarget = 'highlight';
6014
6338
  }
6015
6339
  this.legendSelect = true;
6016
6340
  this.legendSelectId = '';
6341
+ this.treemap.legendId = [];
6342
+ this.treemap.levelSelection = [];
6017
6343
  }
6018
6344
  }
6345
+ else if (isDrillItem) {
6346
+ removeLegend(this.legendSelectionCollection, this.treemap);
6347
+ this.legendSelectionCollection = [];
6348
+ this.legendSelect = true;
6349
+ this.legendSelectId = '';
6350
+ this.treemap.legendId = [];
6351
+ this.treemap.levelSelection = [];
6352
+ }
6019
6353
  }
6020
6354
  /**
6021
6355
  * @param {string} levelOrder - Specifies the level order of treemap item
@@ -6244,6 +6578,11 @@ class TreeMapTooltip {
6244
6578
  width: this.tooltipSettings.border.width || this.treemap.themeStyle.tooltipBorderWidth || 0,
6245
6579
  color: this.tooltipSettings.border.color || this.treemap.themeStyle.tooltipBorderColor || 'transparent'
6246
6580
  };
6581
+ if (this.treemap.enableHtmlSanitizer) {
6582
+ for (let a = 0; a < tooltipContent.length; a++) {
6583
+ tooltipContent[a] = SanitizeHtmlHelper.sanitize(tooltipContent[a]);
6584
+ }
6585
+ }
6247
6586
  tootipArgs = {
6248
6587
  cancel: false, name: tooltipRendering, item: item,
6249
6588
  options: {