@syncfusion/ej2-treemap 32.1.19 → 32.1.24

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.
@@ -957,24 +957,31 @@ function convertElement(element, labelId, data) {
957
957
  * @param {Size} labelSize - Specifies the label size.
958
958
  * @param {string} type - Specifies the type.
959
959
  * @param {TreeMap} treemap - Specifies the treemap instance.
960
+ * @param {number} textCount - Specifies the number of text.
960
961
  * @returns {Location} - Returns the text location.
961
962
  */
962
- function findLabelLocation(rect, position, labelSize, type, treemap) {
963
+ function findLabelLocation(rect, position, labelSize, type, treemap, textCount = 0) {
963
964
  const location = new Location(0, 0);
964
965
  const padding = 5;
965
966
  const paddings = 2;
966
967
  const x = (type === 'Template') ? treemap.areaRect.x : 0;
967
968
  const y = (type === 'Template') ? treemap.areaRect.y : 0;
969
+ const isTopLabel = (treemap.leafItemSettings.labelPosition === 'TopCenter' ||
970
+ treemap.leafItemSettings.labelPosition === 'TopLeft' ||
971
+ treemap.leafItemSettings.labelPosition === 'TopRight');
972
+ const textHeight = (textCount > 1 && !isTopLabel &&
973
+ (treemap.renderDirection === 'BottomLeftTopRight' ||
974
+ treemap.renderDirection === 'BottomRightTopLeft')) ? (labelSize.height * textCount) : labelSize.height;
968
975
  location.x = (Math.abs(x - ((position.indexOf('Left') > -1) ? rect.x + padding : !(position.indexOf('Right') > -1) ?
969
976
  rect.x + ((rect.width / 2) - (labelSize.width / 2)) : (rect.x + rect.width) - labelSize.width))) - paddings;
970
977
  if (treemap.enableDrillDown && (treemap.renderDirection === 'BottomLeftTopRight'
971
978
  || treemap.renderDirection === 'BottomRightTopLeft')) {
972
- location.y = Math.abs((rect.y + rect.height) - labelSize.height + padding);
979
+ location.y = Math.abs((rect.y + rect.height) - textHeight + padding);
973
980
  }
974
981
  else {
975
- location.y = Math.abs(y - ((position.indexOf('Top') > -1) ? (type === 'Template' ? rect.y : rect.y + labelSize.height) :
976
- !(position.indexOf('Bottom') > -1) ? type === 'Template' ? (rect.y + ((rect.height / 2) - (labelSize.height / 2))) :
977
- (rect.y + (rect.height / 2) + labelSize.height / 4) : (rect.y + rect.height) - labelSize.height));
982
+ location.y = Math.abs(y - ((position.indexOf('Top') > -1) ? (type === 'Template' ? rect.y : rect.y + textHeight) :
983
+ !(position.indexOf('Bottom') > -1) ? type === 'Template' ? (rect.y + ((rect.height / 2) - (textHeight / 2))) :
984
+ (rect.y + (rect.height / 2) + textHeight / 4) : (rect.y + rect.height) - textHeight));
978
985
  }
979
986
  return location;
980
987
  }
@@ -2473,7 +2480,18 @@ class LayoutPanel {
2473
2480
  let textName;
2474
2481
  textCollection = ((text.indexOf('<br>')) !== -1) ? text.split('<br>') : null;
2475
2482
  customText = this.labelInterSectAction(rect, text, textStyle, interSectAction);
2476
- textSize = measureText(textCollection && textCollection[0] || customText[0], textStyle);
2483
+ let largerText = '';
2484
+ let largerTextWidth = 0;
2485
+ if (!isNullOrUndefined(textCollection) && textCollection.length > 0) {
2486
+ for (let i = 0; i < textCollection.length; i++) {
2487
+ const currentTextWidth = measureText(textCollection[i], textStyle).width;
2488
+ if (currentTextWidth > largerTextWidth) {
2489
+ largerTextWidth = currentTextWidth;
2490
+ largerText = textCollection[i];
2491
+ }
2492
+ }
2493
+ }
2494
+ textSize = measureText(textCollection && largerText || customText[0], textStyle);
2477
2495
  if (this.treemap.enableRtl) {
2478
2496
  const labelSize = measureText(text, textStyle);
2479
2497
  const drillSymbolCount = text.search('[+]') || text.search('[-]');
@@ -2484,7 +2502,8 @@ class LayoutPanel {
2484
2502
  customText['0'] = textTrim(rect.width - drillSymbolSize.width - padding, customText[0], textStyle) + label;
2485
2503
  }
2486
2504
  }
2487
- const textLocation = findLabelLocation(rect, position, textSize, 'Text', this.treemap);
2505
+ const textCount = (!isNullOrUndefined(textCollection) && textCollection.length > 1) ? textCollection.length : 0;
2506
+ const textLocation = findLabelLocation(rect, position, textSize, 'Text', this.treemap, textCount);
2488
2507
  if (!isNullOrUndefined(textCollection)) {
2489
2508
  const collection = [];
2490
2509
  let texts = null;