@syncfusion/ej2-treemap 20.2.45 → 20.3.56

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.
@@ -2118,6 +2118,7 @@ class LayoutPanel {
2118
2118
  }
2119
2119
  }
2120
2120
  itemGroup.setAttribute('aria-label', item['name']);
2121
+ itemGroup.setAttribute('role', '');
2121
2122
  itemGroup.setAttribute('tabindex', (this.treemap.tabIndex + i + 2).toString());
2122
2123
  maintainSelection(this.treemap, itemGroup, 'treeMapSelection');
2123
2124
  this.layoutGroup.appendChild(itemGroup);
@@ -2282,6 +2283,19 @@ class LayoutPanel {
2282
2283
  }
2283
2284
  return textValue;
2284
2285
  }
2286
+ /**
2287
+ *
2288
+ * @returns {void}
2289
+ * @private
2290
+ */
2291
+ destroy() {
2292
+ this.treemap = null;
2293
+ this.currentRect = null;
2294
+ this.layoutGroup = null;
2295
+ this.renderer = null;
2296
+ this.renderItems = [];
2297
+ this.parentData = [];
2298
+ }
2285
2299
  }
2286
2300
 
2287
2301
  /**
@@ -2513,7 +2527,6 @@ class Print {
2513
2527
  */
2514
2528
  // eslint-disable-next-line @typescript-eslint/explicit-member-accessibility
2515
2529
  constructor(control) {
2516
- this.control = control;
2517
2530
  }
2518
2531
  /**
2519
2532
  * This method is used to perform the print functionality in treemap.
@@ -2522,16 +2535,16 @@ class Print {
2522
2535
  * @returns {void}
2523
2536
  * @private
2524
2537
  */
2525
- print(elements) {
2526
- this.printWindow = window.open('', 'print', 'height=' + window.outerHeight + ',width=' + window.outerWidth + ',tabbar=no');
2527
- this.printWindow.moveTo(0, 0);
2528
- this.printWindow.resizeTo(screen.availWidth, screen.availHeight);
2538
+ print(treeMap, elements) {
2539
+ let printWindow = window.open('', 'print', 'height=' + window.outerHeight + ',width=' + window.outerWidth + ',tabbar=no');
2540
+ printWindow.moveTo(0, 0);
2541
+ printWindow.resizeTo(screen.availWidth, screen.availHeight);
2529
2542
  const argsData = {
2530
- cancel: false, htmlContent: this.getHTMLContent(elements), name: beforePrint
2543
+ cancel: false, htmlContent: this.getHTMLContent(treeMap, elements), name: beforePrint
2531
2544
  };
2532
- this.control.trigger(beforePrint, argsData, () => {
2545
+ treeMap.trigger(beforePrint, argsData, () => {
2533
2546
  if (!argsData.cancel) {
2534
- print(argsData.htmlContent, this.printWindow);
2547
+ print(argsData.htmlContent, printWindow);
2535
2548
  }
2536
2549
  });
2537
2550
  }
@@ -2542,7 +2555,7 @@ class Print {
2542
2555
  * @returns {Element} - Returns the element
2543
2556
  * @private
2544
2557
  */
2545
- getHTMLContent(elements) {
2558
+ getHTMLContent(treeMap, elements) {
2546
2559
  const div = createElement('div');
2547
2560
  if (elements) {
2548
2561
  if (elements instanceof Array) {
@@ -2558,7 +2571,7 @@ class Print {
2558
2571
  }
2559
2572
  }
2560
2573
  else {
2561
- div.appendChild(this.control.element.cloneNode(true));
2574
+ div.appendChild(treeMap.element.cloneNode(true));
2562
2575
  }
2563
2576
  return div;
2564
2577
  }
@@ -2572,17 +2585,12 @@ class Print {
2572
2585
  return 'Print';
2573
2586
  }
2574
2587
  /**
2575
- * To destroy the legend.
2588
+ * To destroy the Print module.
2576
2589
  *
2577
- * @param {TreeMap} treemap - Specifies the treemap instance
2578
2590
  * @returns {void}
2579
2591
  * @private
2580
2592
  */
2581
- destroy(treemap) {
2582
- /**
2583
- * Destroy method performed here
2584
- */
2585
- }
2593
+ destroy() { }
2586
2594
  }
2587
2595
 
2588
2596
  /**
@@ -2598,7 +2606,6 @@ class ImageExport {
2598
2606
  */
2599
2607
  // eslint-disable-next-line @typescript-eslint/explicit-member-accessibility
2600
2608
  constructor(control) {
2601
- this.control = control;
2602
2609
  }
2603
2610
  /**
2604
2611
  * This method is used to perform the export functionality for the rendered treemap.
@@ -2609,22 +2616,22 @@ class ImageExport {
2609
2616
  * @returns {Promise} - Returns the promise string.
2610
2617
  * @private
2611
2618
  */
2612
- export(type, fileName, allowDownload) {
2619
+ export(treeMap, type, fileName, allowDownload) {
2613
2620
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
2614
2621
  const promise = new Promise((resolve, reject) => {
2615
2622
  const element = createElement('canvas', {
2616
2623
  id: 'ej2-canvas',
2617
2624
  attrs: {
2618
- 'height': this.control.availableSize.height.toString(),
2619
- 'width': this.control.availableSize.width.toString()
2625
+ 'height': treeMap.availableSize.height.toString(),
2626
+ 'width': treeMap.availableSize.width.toString()
2620
2627
  }
2621
2628
  });
2622
2629
  const isDownload = !(Browser.userAgent.toString().indexOf('HeadlessChrome') > -1);
2623
2630
  const svgData = '<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">' +
2624
- this.control.svgObject.outerHTML +
2631
+ treeMap.svgObject.outerHTML +
2625
2632
  '</svg>';
2626
2633
  const url = window.URL.createObjectURL(new Blob(type === 'SVG' ? [svgData] :
2627
- [(new XMLSerializer()).serializeToString(this.control.svgObject)], { type: 'image/svg+xml' }));
2634
+ [(new XMLSerializer()).serializeToString(treeMap.svgObject)], { type: 'image/svg+xml' }));
2628
2635
  if (type === 'SVG') {
2629
2636
  if (allowDownload) {
2630
2637
  triggerDownload(fileName, type, url, isDownload);
@@ -2663,13 +2670,10 @@ class ImageExport {
2663
2670
  /**
2664
2671
  * To destroy the ImageExport.
2665
2672
  *
2666
- * @param {TreeMap} treemap - Specifies the instance of the treemap.
2667
2673
  * @returns {void}
2668
2674
  * @private
2669
2675
  */
2670
- destroy(treemap) {
2671
- // Destroy method performed here
2672
- }
2676
+ destroy() { }
2673
2677
  }
2674
2678
 
2675
2679
  /**
@@ -2685,7 +2689,6 @@ class PdfExport {
2685
2689
  */
2686
2690
  // eslint-disable-next-line @typescript-eslint/explicit-member-accessibility
2687
2691
  constructor(control) {
2688
- this.control = control;
2689
2692
  }
2690
2693
  /**
2691
2694
  * This method is used to perform the export functionality for the rendered treemap.
@@ -2697,24 +2700,24 @@ class PdfExport {
2697
2700
  * @returns {Promise} - Returns the string.
2698
2701
  * @private
2699
2702
  */
2700
- export(type, fileName, orientation, allowDownload) {
2703
+ export(treeMap, type, fileName, orientation, allowDownload) {
2701
2704
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
2702
2705
  const promise = new Promise((resolve, reject) => {
2703
2706
  const element = createElement('canvas', {
2704
2707
  id: 'ej2-canvas',
2705
2708
  attrs: {
2706
- 'width': this.control.availableSize.width.toString(),
2707
- 'height': this.control.availableSize.height.toString()
2709
+ 'width': treeMap.availableSize.width.toString(),
2710
+ 'height': treeMap.availableSize.height.toString()
2708
2711
  }
2709
2712
  });
2710
2713
  const isDownload = !(Browser.userAgent.toString().indexOf('HeadlessChrome') > -1);
2711
2714
  orientation = isNullOrUndefined(orientation) ? PdfPageOrientation.Landscape : orientation;
2712
- const exportElement = this.control.svgObject.cloneNode(true);
2715
+ const exportElement = treeMap.svgObject.cloneNode(true);
2713
2716
  const backgroundElement = exportElement.childNodes[0];
2714
2717
  if (!isNullOrUndefined(backgroundElement)) {
2715
2718
  const backgroundColor = backgroundElement.getAttribute('fill');
2716
- if ((this.control.theme === 'Tailwind' || this.control.theme === 'TailwindDark' || this.control.theme === 'Bootstrap5' || this.control.theme === 'Bootstrap5Dark'
2717
- || this.control.theme === 'Fluent' || this.control.theme === 'FluentDark') && (backgroundColor === 'rgba(255,255,255, 0.0)' || backgroundColor === 'transparent')) {
2719
+ if ((treeMap.theme === 'Tailwind' || treeMap.theme === 'TailwindDark' || treeMap.theme === 'Bootstrap5' || treeMap.theme === 'Bootstrap5Dark'
2720
+ || treeMap.theme === 'Fluent' || treeMap.theme === 'FluentDark') && (backgroundColor === 'rgba(255,255,255, 0.0)' || backgroundColor === 'transparent')) {
2718
2721
  exportElement.childNodes[0].setAttribute('fill', 'rgba(255,255,255, 1)');
2719
2722
  }
2720
2723
  }
@@ -2728,7 +2731,7 @@ class PdfExport {
2728
2731
  let imageString = element.toDataURL('image/jpeg').replace('image/jpeg', 'image/octet-stream');
2729
2732
  document.pageSettings.orientation = orientation;
2730
2733
  imageString = imageString.slice(imageString.indexOf(',') + 1);
2731
- document.pages.add().graphics.drawImage(new PdfBitmap(imageString), 0, 0, (this.control.availableSize.width - 60), this.control.availableSize.height);
2734
+ document.pages.add().graphics.drawImage(new PdfBitmap(imageString), 0, 0, (treeMap.availableSize.width - 60), treeMap.availableSize.height);
2732
2735
  if (allowDownload) {
2733
2736
  document.save(fileName + '.pdf');
2734
2737
  document.destroy();
@@ -2746,15 +2749,12 @@ class PdfExport {
2746
2749
  return 'PdfExport';
2747
2750
  }
2748
2751
  /**
2749
- * To destroy the ImageExport.
2752
+ * To destroy the PdfExport.
2750
2753
  *
2751
- * @param {TreeMap} treemap - Specifies the treemap instance.
2752
2754
  * @returns {void}
2753
2755
  * @private
2754
2756
  */
2755
- destroy(treemap) {
2756
- // Destroy method performed here
2757
- }
2757
+ destroy() { }
2758
2758
  }
2759
2759
 
2760
2760
  /* eslint-disable @typescript-eslint/ban-types */
@@ -2879,6 +2879,12 @@ let TreeMap = class TreeMap extends Component {
2879
2879
  remove(this.svgObject);
2880
2880
  }
2881
2881
  }
2882
+ if (isNullOrUndefined(this.renderer)) {
2883
+ this.renderer = new SvgRenderer(this.element.id);
2884
+ }
2885
+ if (isNullOrUndefined(this.layout)) {
2886
+ this.layout = new LayoutPanel(this);
2887
+ }
2882
2888
  this.clearTemplate();
2883
2889
  const containerWidth = this.element.clientWidth;
2884
2890
  const containerHeight = this.element.clientHeight;
@@ -2961,6 +2967,7 @@ let TreeMap = class TreeMap extends Component {
2961
2967
  const titleBounds = new Rect(location.x, location.y, elementSize.width, elementSize.height);
2962
2968
  const element = renderTextElement(options, style, style.color || (type === 'title' ? this.themeStyle.titleFontColor : this.themeStyle.subTitleFontColor), groupEle);
2963
2969
  element.setAttribute('aria-label', title.description || title.text);
2970
+ element.setAttribute('role', '');
2964
2971
  element.setAttribute('tabindex', (this.tabIndex + (type === 'title' ? 1 : 2)).toString());
2965
2972
  if ((type === 'title' && !title.subtitleSettings.text) || (type === 'subtitle')) {
2966
2973
  height = (this.availableSize.height - titleBounds.y - titlePadding - this.margin.bottom);
@@ -3133,7 +3140,7 @@ let TreeMap = class TreeMap extends Component {
3133
3140
  */
3134
3141
  print(id) {
3135
3142
  if (this.allowPrint && this.printModule) {
3136
- this.printModule.print(id);
3143
+ this.printModule.print(this, id);
3137
3144
  }
3138
3145
  }
3139
3146
  /**
@@ -3150,13 +3157,13 @@ let TreeMap = class TreeMap extends Component {
3150
3157
  if (type === 'PDF' && this.allowPdfExport && this.pdfExportModule) {
3151
3158
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
3152
3159
  return new Promise((resolve, reject) => {
3153
- resolve(this.pdfExportModule.export(type, fileName, orientation, allowDownload));
3160
+ resolve(this.pdfExportModule.export(this, type, fileName, orientation, allowDownload));
3154
3161
  });
3155
3162
  }
3156
3163
  else if (this.allowImageExport && (type !== 'PDF') && this.imageExportModule) {
3157
3164
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
3158
3165
  return new Promise((resolve, reject) => {
3159
- resolve(this.imageExportModule.export(type, fileName, allowDownload));
3166
+ resolve(this.imageExportModule.export(this, type, fileName, allowDownload));
3160
3167
  });
3161
3168
  }
3162
3169
  return null;
@@ -3322,6 +3329,7 @@ let TreeMap = class TreeMap extends Component {
3322
3329
  */
3323
3330
  addTabIndex() {
3324
3331
  this.element.setAttribute('aria-label', this.description || 'TreeMap Element');
3332
+ this.element.setAttribute('role', '');
3325
3333
  this.element.setAttribute('tabindex', this.tabIndex.toString());
3326
3334
  }
3327
3335
  /**
@@ -3330,28 +3338,30 @@ let TreeMap = class TreeMap extends Component {
3330
3338
  * @param e - Specifies the pointer event.
3331
3339
  */
3332
3340
  resizeOnTreeMap(e) {
3333
- this.isResize = true;
3334
- let args = {
3335
- name: resize,
3336
- cancel: false,
3337
- previousSize: this.availableSize,
3338
- currentSize: new Size(0, 0),
3339
- treemap: this
3340
- };
3341
- if (this.resizeTo) {
3342
- clearTimeout(this.resizeTo);
3343
- }
3344
- if (!isNullOrUndefined(this.element) && this.element.classList.contains('e-treemap')) {
3345
- this.resizeTo = setTimeout(() => {
3346
- this.unWireEVents();
3347
- this.createSvg();
3348
- this.refreshing = true;
3349
- this.wireEVents();
3350
- args.currentSize = this.availableSize;
3351
- this.trigger(resize, args, (observedArgs) => {
3352
- this.render();
3353
- });
3354
- }, 500);
3341
+ if (!this.isDestroyed) {
3342
+ this.isResize = true;
3343
+ let args = {
3344
+ name: resize,
3345
+ cancel: false,
3346
+ previousSize: this.availableSize,
3347
+ currentSize: new Size(0, 0),
3348
+ treemap: this
3349
+ };
3350
+ if (this.resizeTo) {
3351
+ clearTimeout(this.resizeTo);
3352
+ }
3353
+ if (!isNullOrUndefined(this.element) && this.element.classList.contains('e-treemap')) {
3354
+ this.resizeTo = setTimeout(() => {
3355
+ this.unWireEVents();
3356
+ this.createSvg();
3357
+ this.refreshing = true;
3358
+ this.wireEVents();
3359
+ args.currentSize = this.availableSize;
3360
+ this.trigger(resize, args, (observedArgs) => {
3361
+ this.render();
3362
+ });
3363
+ }, 500);
3364
+ }
3355
3365
  }
3356
3366
  }
3357
3367
  /**
@@ -3781,28 +3791,30 @@ let TreeMap = class TreeMap extends Component {
3781
3791
  * @private
3782
3792
  */
3783
3793
  onPropertyChanged(newProp, oldProp) {
3784
- let render = false;
3785
- for (const prop of Object.keys(newProp)) {
3786
- switch (prop) {
3787
- case 'background':
3788
- this.renderBorder();
3789
- break;
3790
- case 'height':
3791
- case 'width':
3792
- case 'layoutType':
3793
- case 'levels':
3794
- case 'drillDownView':
3795
- case 'renderDirection':
3796
- case 'leafItemSettings':
3797
- case 'legendSettings':
3798
- case 'dataSource':
3799
- render = true;
3800
- break;
3794
+ if (!this.isDestroyed) {
3795
+ let render = false;
3796
+ for (const prop of Object.keys(newProp)) {
3797
+ switch (prop) {
3798
+ case 'background':
3799
+ this.renderBorder();
3800
+ break;
3801
+ case 'height':
3802
+ case 'width':
3803
+ case 'layoutType':
3804
+ case 'levels':
3805
+ case 'drillDownView':
3806
+ case 'renderDirection':
3807
+ case 'leafItemSettings':
3808
+ case 'legendSettings':
3809
+ case 'dataSource':
3810
+ render = true;
3811
+ break;
3812
+ }
3813
+ }
3814
+ if (render) {
3815
+ this.createSvg();
3816
+ this.renderElements();
3801
3817
  }
3802
- }
3803
- if (render) {
3804
- this.createSvg();
3805
- this.renderElements();
3806
3818
  }
3807
3819
  }
3808
3820
  /**
@@ -3816,6 +3828,7 @@ let TreeMap = class TreeMap extends Component {
3816
3828
  */
3817
3829
  destroy() {
3818
3830
  this.unWireEVents();
3831
+ removeElement('treeMapMeasureText');
3819
3832
  this.drilledItems = [];
3820
3833
  this.levelSelection = [];
3821
3834
  this.legendId = [];
@@ -4949,15 +4962,25 @@ class TreeMapLegend {
4949
4962
  /**
4950
4963
  * To destroy the legend.
4951
4964
  *
4952
- * @param {TreeMap} treemap - Specifies treemap instance
4953
4965
  * @returns {void}
4954
4966
  * @private
4955
4967
  */
4956
- destroy(treemap) {
4957
- /**
4958
- * Destroy method performed here
4959
- */
4968
+ destroy() {
4969
+ this.legendRenderingCollections = [];
4970
+ this.legendCollections = [];
4971
+ this.outOfRangeLegend = null;
4972
+ this.totalPages = [];
4973
+ this.translate = null;
4974
+ this.legendBorderRect = null;
4975
+ this.legendGroup = null;
4976
+ this.legendNames = [];
4977
+ this.defsElement = null;
4978
+ this.legendLinearGradient = null;
4979
+ this.legendInteractiveGradient = [];
4980
+ this.legendItemRect = null;
4960
4981
  this.removeEventListener();
4982
+ //TODO: The removeInteractivePointer method (calling method) is called in a timer in the mouseUpHandler method. Because of this handling, adding the below code results in a spec failure.
4983
+ //this.treemap = null;
4961
4984
  }
4962
4985
  // eslint-disable-next-line valid-jsdoc
4963
4986
  /**
@@ -5192,12 +5215,16 @@ class TreeMapHighlight {
5192
5215
  /**
5193
5216
  * To destroy the hightlight.
5194
5217
  *
5195
- * @param {TreeMap} treeMap - Specifies the instance of the treemap.
5196
5218
  * @returns {void}
5197
5219
  * @private
5198
5220
  */
5199
- destroy(treeMap) {
5221
+ destroy() {
5222
+ this.shapeElement = null;
5223
+ this.shapeHighlightCollection = [];
5224
+ this.legendHighlightCollection = [];
5225
+ this.currentElement = [];
5200
5226
  this.removeEventListener();
5227
+ this.treemap = null;
5201
5228
  }
5202
5229
  }
5203
5230
  /**
@@ -5489,8 +5516,12 @@ class TreeMapSelection {
5489
5516
  * @returns {void}
5490
5517
  * @private
5491
5518
  */
5492
- destroy(treeMap) {
5519
+ destroy() {
5520
+ this.shapeElement = null;
5521
+ this.shapeSelectionCollection = [];
5522
+ this.legendSelectionCollection = [];
5493
5523
  this.removeEventListener();
5524
+ this.treemap = null;
5494
5525
  }
5495
5526
  }
5496
5527
 
@@ -5550,7 +5581,9 @@ class TreeMapTooltip {
5550
5581
  toolTipHeader = item['name'];
5551
5582
  value = item['weight'];
5552
5583
  toolTipData = item['data'];
5553
- markerFill = item['options']['fill'];
5584
+ if (!isNullOrUndefined(item['options'])) {
5585
+ markerFill = item['options']['fill'];
5586
+ }
5554
5587
  if (this.treemap.enableRtl) {
5555
5588
  tooltipContent = [textFormatter(this.tooltipSettings.format, toolTipData, this.treemap) ||
5556
5589
  formatValue(value, this.treemap) + ' : ' + this.treemap.weightValuePath.toString()];
@@ -5684,15 +5717,17 @@ class TreeMapTooltip {
5684
5717
  /**
5685
5718
  * To destroy the tooltip.
5686
5719
  *
5687
- * @param {TreeMap} treeMap - Specifies the instance of the treemap
5688
5720
  * @returns {void}
5689
5721
  * @private
5690
5722
  */
5691
- destroy(treeMap) {
5692
- /**
5693
- * Destroy method performed here
5694
- */
5723
+ destroy() {
5724
+ if (!isNullOrUndefined(this.svgTooltip)) {
5725
+ this.svgTooltip.destroy();
5726
+ }
5727
+ this.svgTooltip = null;
5728
+ this.tooltipSettings = null;
5695
5729
  this.removeEventListener();
5730
+ this.treemap = null;
5696
5731
  }
5697
5732
  }
5698
5733