@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.
- package/README.md +2 -2
- package/dist/ej2-treemap.min.js +3 -3
- package/dist/ej2-treemap.umd.min.js +3 -3
- package/dist/ej2-treemap.umd.min.js.map +1 -1
- package/dist/es6/ej2-treemap.es2015.js +427 -86
- package/dist/es6/ej2-treemap.es2015.js.map +1 -1
- package/dist/es6/ej2-treemap.es5.js +427 -86
- package/dist/es6/ej2-treemap.es5.js.map +1 -1
- package/dist/global/ej2-treemap.min.js +3 -3
- package/dist/global/ej2-treemap.min.js.map +1 -1
- package/dist/global/index.d.ts +2 -2
- package/package.json +12 -12
- package/src/treemap/layout/legend.js +53 -18
- package/src/treemap/layout/render-panel.js +12 -3
- package/src/treemap/model/image-export.js +2 -2
- package/src/treemap/model/pdf-export.js +2 -2
- package/src/treemap/model/print.js +2 -2
- package/src/treemap/model/theme.js +50 -2
- package/src/treemap/treemap-model.d.ts +8 -1
- package/src/treemap/treemap.d.ts +6 -0
- package/src/treemap/treemap.js +13 -6
- package/src/treemap/user-interaction/highlight-selection.js +225 -38
- package/src/treemap/user-interaction/tooltip.js +6 -1
- package/src/treemap/utils/enum.d.ts +4 -0
- package/src/treemap/utils/helper.d.ts +2 -1
- package/src/treemap/utils/helper.js +69 -19
|
@@ -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
|
-
|
|
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 =
|
|
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
|
-
|
|
72
|
+
var legendShapeElement = selectionModule ? selectionModule.shapeElement : null;
|
|
73
|
+
if (selectionModule ? this.shapeElement !== legendShapeElement : true) {
|
|
57
74
|
this.currentElement.push({ currentElement: this.shapeElement });
|
|
58
|
-
|
|
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 (
|
|
113
|
-
|
|
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
|
|
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 (
|
|
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,
|
|
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
|
-
|
|
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
|
-
|
|
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
|
|
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
|
-
|
|
351
|
+
removeLegend(this.shapeSelectionCollection, treemap);
|
|
270
352
|
if (highlightModule) {
|
|
271
353
|
highlightModule.shapeTarget = 'selection';
|
|
272
354
|
highlightModule.shapeHighlightCollection = [];
|
|
273
355
|
}
|
|
274
|
-
index =
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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.
|
|
329
|
-
|
|
330
|
-
|
|
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
|
-
|
|
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
|
|
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 (
|
|
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
|
-
|
|
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.
|