@syncfusion/ej2-treemap 27.2.2 → 28.1.39

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.
@@ -585,10 +585,12 @@ export function colorMap(colorMapping, equalValue, value) {
585
585
  for (var i = 0; i < colorMapping.length; i++) {
586
586
  var isEqualColor = false;
587
587
  var dataValue = value;
588
+ var colorMappingValue = colorMapping[i].value ? colorMapping[i].value.toString() :
589
+ colorMapping[i].value;
588
590
  if (!isNullOrUndefined(colorMapping[i].from) && !isNullOrUndefined(colorMapping[i].to)
589
591
  && !isNullOrUndefined(colorMapping[i].value)) {
590
592
  if ((value >= colorMapping[i].from && colorMapping[i].to >= value) &&
591
- (colorMapping[i].value === equalValue)) {
593
+ (colorMappingValue === equalValue)) {
592
594
  isEqualColor = true;
593
595
  if (Object.prototype.toString.call(colorMapping[i].color) === '[object Array]') {
594
596
  fill = !isEqualColor ? colorCollections(colorMapping[i], dataValue) : colorMapping[i].color[0];
@@ -601,8 +603,8 @@ export function colorMap(colorMapping, equalValue, value) {
601
603
  else if ((!isNullOrUndefined(colorMapping[i].from) && !isNullOrUndefined(colorMapping[i].to))
602
604
  || !isNullOrUndefined((colorMapping[i].value))) {
603
605
  if ((value >= colorMapping[i].from && colorMapping[i].to >= value)
604
- || (colorMapping[i].value === equalValue)) {
605
- if (colorMapping[i].value === equalValue) {
606
+ || (colorMappingValue === equalValue)) {
607
+ if (colorMappingValue === equalValue) {
606
608
  isEqualColor = true;
607
609
  }
608
610
  if (Object.prototype.toString.call(colorMapping[i].color) === '[object Array]') {
@@ -614,7 +616,7 @@ export function colorMap(colorMapping, equalValue, value) {
614
616
  }
615
617
  }
616
618
  if (((value >= colorMapping[i].from && value <= colorMapping[i].to)
617
- || (colorMapping[i].value === equalValue))
619
+ || (colorMappingValue === equalValue))
618
620
  && !isNullOrUndefined(colorMapping[i].minOpacity) && !isNullOrUndefined(colorMapping[i].maxOpacity)
619
621
  && fill) {
620
622
  opacity = deSaturationColor(colorMapping[i], value);
@@ -889,7 +891,8 @@ export function maintainSelection(treemap, element, className) {
889
891
  var elementId = treemap.levelSelection;
890
892
  if (elementId) {
891
893
  for (var index = 0; index < elementId.length; index++) {
892
- if (element.getAttribute('id') === elementId[index]) {
894
+ if (element.getAttribute('id') === elementId[index] ||
895
+ element.children[0].id === elementId[index]) {
893
896
  if (element.childElementCount > 0) {
894
897
  element.children[0].setAttribute('class', className);
895
898
  applyOptions(element.childNodes[0], {
@@ -914,13 +917,25 @@ export function legendMaintain(treemap, legendGroup) {
914
917
  var elementId = treemap.legendId;
915
918
  if (elementId) {
916
919
  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);
920
+ if (treemap.legendSettings.mode === 'Interactive') {
921
+ for (var j = 0; j < legendGroup.childElementCount; j++) {
922
+ if (legendGroup.childNodes[j]['id'] === elementId[i] ||
923
+ parseFloat(legendGroup.childNodes[j]['id'].split('Index_')[1]) === parseFloat(elementId[i].split('Index_')[1])) {
924
+ var treemapSVGRectElement = legendGroup.childNodes[j];
925
+ treemapSVGRectElement.setAttribute('fill', treemap.selectionSettings.fill);
926
+ treemapSVGRectElement.setAttribute('stroke', treemap.selectionSettings.border.color);
927
+ treemapSVGRectElement.setAttribute('stroke-width', (treemap.selectionSettings.border.width).toString());
928
+ treemapSVGRectElement.setAttribute('opacity', treemap.selectionSettings.opacity);
929
+ }
930
+ }
931
+ }
932
+ else {
933
+ var legendItem = document.getElementById(elementId[i]);
934
+ if (!isNullOrUndefined(legendItem)) {
935
+ legendItem.setAttribute('fill', treemap.selectionSettings.fill);
936
+ legendItem.setAttribute('stroke', treemap.selectionSettings.border.color);
937
+ legendItem.setAttribute('stroke-width', (treemap.selectionSettings.border.width).toString());
938
+ legendItem.setAttribute('opacity', treemap.selectionSettings.opacity);
924
939
  }
925
940
  }
926
941
  }
@@ -956,6 +971,9 @@ export function applyOptions(element, options) {
956
971
  if (!isNullOrUndefined(options['fill'])) {
957
972
  element.setAttribute('fill', options['fill']);
958
973
  }
974
+ else {
975
+ element.setAttribute('fill', 'black');
976
+ }
959
977
  element.setAttribute('stroke', options['border']['color']);
960
978
  element.setAttribute('stroke-width', options['border']['width']);
961
979
  }
@@ -1207,17 +1225,35 @@ export function removeShape(collection) {
1207
1225
  /**
1208
1226
  *
1209
1227
  * @param {any[]} collection - Specifies the legend collection.
1228
+ * @param {TreeMap} treeMap - Specifies the treemap instance.
1210
1229
  * @returns {void}
1211
1230
  * @private
1212
1231
  */
1213
- export function removeLegend(collection) {
1232
+ export function removeLegend(collection, treeMap) {
1214
1233
  if (collection.length > 0) {
1215
1234
  for (var j = 0; j < collection.length; j++) {
1216
1235
  var item = collection[j];
1217
- setColor(item['legendEle'], item['oldFill'], item['oldOpacity'], item['oldBorderColor'], item['oldBorderWidth']);
1218
- var dataCount = item['ShapeCollection']['Elements'].length;
1236
+ var legendIndex = parseFloat(item['legendEle'].id.split('_Index_')[1]);
1237
+ var isText = item['legendEle'].id.indexOf('Text') > -1;
1238
+ var shapeId = isText ? item['legendEle'].id.replace('_Text', '') : item['legendEle'].id;
1239
+ var legendShape = treeMap.legendSettings.mode === 'Interactive'
1240
+ ? document.getElementById(shapeId)
1241
+ : document.getElementById(treeMap.element.id + '_Legend_Shape_Index_' + legendIndex);
1242
+ var legendText = treeMap.legendSettings.mode === 'Interactive'
1243
+ ? document.getElementById(shapeId + '_Text')
1244
+ : document.getElementById(treeMap.element.id + '_Legend_Text_Index_' + legendIndex);
1245
+ if (!isNullOrUndefined(legendShape)) {
1246
+ setColor(legendShape, item['oldFill'], item['oldOpacity'], item['oldBorderColor'], item['oldBorderWidth']);
1247
+ }
1248
+ if (!isNullOrUndefined(legendText)) {
1249
+ setColor(legendText, treeMap.legendSettings.textStyle.color, item['oldOpacity'], item['oldBorderColor'], item['oldBorderWidth']);
1250
+ }
1251
+ var dataCount = !isNullOrUndefined(item['ShapeCollection']) ? item['ShapeCollection']['Elements'].length : 0;
1219
1252
  for (var k = 0; k < dataCount; k++) {
1220
- setColor(item['ShapeCollection']['Elements'][k], item['shapeOldFill'], item['shapeOldOpacity'], item['shapeOldBorderColor'], item['shapeOldBorderWidth']);
1253
+ var shapeElement = document.getElementById(item['ShapeCollection']['Elements'][k].id);
1254
+ if (!isNullOrUndefined(shapeElement)) {
1255
+ setColor(shapeElement, item['shapeOldFill'], item['shapeOldOpacity'], item['shapeOldBorderColor'], item['shapeOldBorderWidth']);
1256
+ }
1221
1257
  }
1222
1258
  }
1223
1259
  }
@@ -1245,7 +1281,7 @@ export function setColor(element, fill, opacity, borderColor, borderWidth) {
1245
1281
  * @returns {void}
1246
1282
  */
1247
1283
  export function removeSelectionWithHighlight(collection, element, treemap) {
1248
- removeShape(collection);
1284
+ removeLegend(collection, treemap);
1249
1285
  element = [];
1250
1286
  removeClassNames(document.getElementsByClassName('treeMapHighLight'), 'treeMapHighLight', treemap);
1251
1287
  }
@@ -1258,10 +1294,24 @@ export function removeSelectionWithHighlight(collection, element, treemap) {
1258
1294
  */
1259
1295
  export function getLegendIndex(length, item, treemap) {
1260
1296
  var index;
1297
+ var valuePath = treemap.rangeColorValuePath;
1261
1298
  for (var i = 0; i < length; i++) {
1262
1299
  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']) {
1300
+ if (dataLength > 0) {
1301
+ for (var j = 0; j < dataLength; j++) {
1302
+ if ((!isNullOrUndefined(valuePath) && valuePath !== '' && treemap.leafItemSettings.colorMapping.length > 0 ?
1303
+ (treemap.treeMapLegendModule.legendCollections[i]['legendData'][j]['data'][valuePath] === item['data'][valuePath])
1304
+ : treemap.treeMapLegendModule.legendCollections[i]['legendData'][j]['levelOrderName'] === item['levelOrderName']
1305
+ || item['levelOrderName'].indexOf(treemap.treeMapLegendModule.legendCollections[i]['legendName']) > -1)) {
1306
+ index = i;
1307
+ break;
1308
+ }
1309
+ }
1310
+ }
1311
+ else if (treemap.palette && treemap.palette.length > 0) {
1312
+ if ((treemap.treeMapLegendModule.legendCollections[i]['levelOrderName'] === item['levelOrderName'] ||
1313
+ (item['levelOrderName'].indexOf(treemap.treeMapLegendModule.legendCollections[i]['levelOrderName'])) > -1)
1314
+ && treemap.treeMapLegendModule.legendCollections[i]['legendName'] === item['name']) {
1265
1315
  index = i;
1266
1316
  break;
1267
1317
  }