@syncfusion/ej2-treemap 19.3.53 → 19.4.38
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/.github/PULL_REQUEST_TEMPLATE/Bug.md +72 -0
- package/.github/PULL_REQUEST_TEMPLATE/Feature.md +49 -0
- package/dist/ej2-treemap.umd.min.js +2 -2
- package/dist/ej2-treemap.umd.min.js.map +1 -1
- package/dist/es6/ej2-treemap.es2015.js +40 -8
- package/dist/es6/ej2-treemap.es2015.js.map +1 -1
- package/dist/es6/ej2-treemap.es5.js +40 -8
- package/dist/es6/ej2-treemap.es5.js.map +1 -1
- package/dist/global/ej2-treemap.min.js +2 -2
- package/dist/global/ej2-treemap.min.js.map +1 -1
- package/dist/global/index.d.ts +1 -1
- package/dist/ts/treemap/layout/legend.ts +991 -0
- package/dist/ts/treemap/layout/render-panel.ts +717 -0
- package/dist/ts/treemap/model/base.ts +800 -0
- package/dist/ts/treemap/model/constants.ts +118 -0
- package/dist/ts/treemap/model/image-export.ts +109 -0
- package/dist/ts/treemap/model/interface.ts +554 -0
- package/dist/ts/treemap/model/pdf-export.ts +103 -0
- package/dist/ts/treemap/model/print.ts +93 -0
- package/dist/ts/treemap/model/theme.ts +202 -0
- package/dist/ts/treemap/treemap.ts +1571 -0
- package/dist/ts/treemap/user-interaction/highlight-selection.ts +530 -0
- package/dist/ts/treemap/user-interaction/tooltip.ts +199 -0
- package/dist/ts/treemap/utils/enum.ts +218 -0
- package/dist/ts/treemap/utils/helper.ts +1181 -0
- package/package.json +11 -11
- package/src/treemap/layout/render-panel.js +1 -1
- package/src/treemap/model/theme.js +34 -0
- package/src/treemap/utils/helper.js +5 -7
|
@@ -0,0 +1,530 @@
|
|
|
1
|
+
/* eslint-disable @typescript-eslint/dot-notation */
|
|
2
|
+
/* eslint-disable @typescript-eslint/naming-convention */
|
|
3
|
+
/* eslint-disable brace-style */
|
|
4
|
+
import { TreeMap } from '../treemap';
|
|
5
|
+
import { Browser, isNullOrUndefined, createElement } from '@syncfusion/ej2-base';
|
|
6
|
+
import { IItemHighlightEventArgs, IItemSelectedEventArgs } from '../model/interface';
|
|
7
|
+
import { itemHighlight, itemSelected } from '../model/constants';
|
|
8
|
+
import { HighlightSettingsModel, SelectionSettingsModel } from '../model/base-model';
|
|
9
|
+
import { findHightLightItems, removeClassNames, applyOptions, removeShape, removeLegend,
|
|
10
|
+
removeSelectionWithHighlight, setColor, getLegendIndex, pushCollection, setItemTemplateContent } from '../utils/helper';
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Performing treemap highlight
|
|
14
|
+
*/
|
|
15
|
+
export class TreeMapHighlight {
|
|
16
|
+
private treemap: TreeMap;
|
|
17
|
+
public highLightId: string;
|
|
18
|
+
private target: string = 'highlight';
|
|
19
|
+
public shapeTarget: string = 'highlight';
|
|
20
|
+
private shapeElement: Element;
|
|
21
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
22
|
+
public shapeHighlightCollection: any[] = [];
|
|
23
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
24
|
+
public legendHighlightCollection: any[] = [];
|
|
25
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
26
|
+
public currentElement: any[] = [];
|
|
27
|
+
// eslint-disable-next-line @typescript-eslint/explicit-member-accessibility
|
|
28
|
+
constructor(treeMap: TreeMap) {
|
|
29
|
+
this.treemap = treeMap;
|
|
30
|
+
this.addEventListener();
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/* eslint-disable max-len */
|
|
34
|
+
// eslint-disable-next-line valid-jsdoc
|
|
35
|
+
/**
|
|
36
|
+
* Mouse down event in highlight
|
|
37
|
+
*/
|
|
38
|
+
public mouseMove(e: PointerEvent): boolean {
|
|
39
|
+
const treemap: TreeMap = this.treemap;
|
|
40
|
+
let processHighlight: boolean;
|
|
41
|
+
const targetId: string = (<Element>e.target).id;
|
|
42
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
43
|
+
let eventArgs: IItemHighlightEventArgs; const items: any[] = [];
|
|
44
|
+
const highlight: HighlightSettingsModel = this.treemap.highlightSettings;
|
|
45
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
46
|
+
let item: any; const highLightElements: Element[] = []; let process: boolean;
|
|
47
|
+
let treeMapElement: Element; let element: Element; let orders: string[];
|
|
48
|
+
const selectionModule: TreeMapSelection = this.treemap.treeMapSelectionModule;
|
|
49
|
+
if (targetId.indexOf('_Item_Index') > -1 && (selectionModule ? this.treemap.selectionId !== targetId : true)) {
|
|
50
|
+
if (this.highLightId !== targetId) {
|
|
51
|
+
treeMapElement = document.getElementById(treemap.element.id + '_TreeMap_' + treemap.layoutType + '_Layout');
|
|
52
|
+
const selectionElements: HTMLCollection = document.getElementsByClassName('treeMapSelection');
|
|
53
|
+
item = this.treemap.layout.renderItems[parseFloat(targetId.split('_')[6])];
|
|
54
|
+
let index: number;
|
|
55
|
+
if (this.treemap.legendSettings.visible) {
|
|
56
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
57
|
+
const collection: any[] = this.treemap.treeMapLegendModule.legendCollections;
|
|
58
|
+
const length: number = this.treemap.treeMapLegendModule.legendCollections.length;
|
|
59
|
+
index = getLegendIndex(length, item, treemap);
|
|
60
|
+
this.shapeElement = this.treemap.legendSettings.mode === 'Default' ? document.getElementById('container_Legend_Shape_Index_' + index) : document.getElementById('container_Legend_Index_' + index);
|
|
61
|
+
if (this.shapeElement !== null && (selectionModule ? this.shapeElement.getAttribute('id') !== selectionModule.legendSelectId : true)) {
|
|
62
|
+
if (selectionModule ? this.shapeElement !== selectionModule.shapeElement : true) {
|
|
63
|
+
this.currentElement.push({currentElement: this.shapeElement});
|
|
64
|
+
removeShape(this.shapeHighlightCollection, 'highlight');
|
|
65
|
+
this.shapeHighlightCollection.push({ legendEle: this.shapeElement, oldFill: collection[index]['legendFill'],
|
|
66
|
+
oldOpacity: collection[index]['opacity'], oldBorderColor: collection[index]['borderColor'],
|
|
67
|
+
oldBorderWidth: collection[index]['borderWidth']
|
|
68
|
+
});
|
|
69
|
+
setColor(
|
|
70
|
+
this.shapeElement, highlight.fill, highlight.opacity, highlight.border.color,
|
|
71
|
+
highlight.border.width.toString());
|
|
72
|
+
this.target = 'highlight';
|
|
73
|
+
} else if (this.currentElement.length > 0 && this.currentElement[this.currentElement.length - 1]['currentElement'] !== this.shapeElement) {
|
|
74
|
+
removeSelectionWithHighlight(this.shapeHighlightCollection, this.currentElement, treemap);
|
|
75
|
+
this.highLightId = '';
|
|
76
|
+
}
|
|
77
|
+
} else if (this.currentElement.length > 0 && this.currentElement[this.currentElement.length - 1]['currentElement'] !== this.shapeElement) {
|
|
78
|
+
removeSelectionWithHighlight(this.shapeHighlightCollection, this.currentElement, treemap);
|
|
79
|
+
this.highLightId = '';
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
orders = findHightLightItems(item, [], highlight.mode, treemap);
|
|
83
|
+
if (this.treemap.legendSettings.visible ? selectionModule ? this.shapeElement ? this.shapeElement.getAttribute('id') !== selectionModule.legendSelectId : true : true : true) {
|
|
84
|
+
if (this.treemap.legendSettings.visible ? selectionModule ? this.shapeElement !== selectionModule.shapeElement : true : true) {
|
|
85
|
+
for (let i: number = 0; i < treeMapElement.childElementCount; i++) {
|
|
86
|
+
element = treeMapElement.childNodes[i] as Element;
|
|
87
|
+
process = true;
|
|
88
|
+
item = treemap.layout.renderItems[element.id.split('_')[6]];
|
|
89
|
+
for (let j: number = 0; j < selectionElements.length; j++) {
|
|
90
|
+
if (element.id === selectionElements[j].id) {
|
|
91
|
+
process = false;
|
|
92
|
+
break;
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
if (orders.indexOf(item['levelOrderName']) > -1 && process) {
|
|
96
|
+
highLightElements.push(element);
|
|
97
|
+
items.push(item);
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
removeClassNames(document.getElementsByClassName('treeMapHighLight'), 'treeMapHighLight', treemap);
|
|
101
|
+
for (let k: number = 0; k < highLightElements.length; k++) {
|
|
102
|
+
element = highLightElements[k];
|
|
103
|
+
applyOptions(
|
|
104
|
+
element.childNodes[0] as SVGPathElement,
|
|
105
|
+
{ border: highlight.border, fill: highlight.fill, opacity: highlight.opacity }
|
|
106
|
+
);
|
|
107
|
+
element.classList.add('treeMapHighLight');
|
|
108
|
+
this.highLightId = targetId;
|
|
109
|
+
}
|
|
110
|
+
eventArgs = { cancel: false, name: itemHighlight, treemap: treemap, items: items, elements: highLightElements };
|
|
111
|
+
treemap.trigger(itemHighlight, eventArgs);
|
|
112
|
+
} else {
|
|
113
|
+
processHighlight = false;
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
} else if (targetId.indexOf('_Legend_Shape') > -1 || targetId.indexOf('_Legend_Index') > -1) {
|
|
118
|
+
if (this.treemap.legendSettings.visible && (selectionModule ? selectionModule.legendSelectId !== targetId : true) && (selectionModule ? selectionModule.shapeSelectId !== targetId : true)) {
|
|
119
|
+
let itemIndex: number;
|
|
120
|
+
let groupIndex: number;
|
|
121
|
+
let length: number;
|
|
122
|
+
const targetEle: Element = document.getElementById(targetId);
|
|
123
|
+
if (this.shapeTarget === 'highlight') {
|
|
124
|
+
removeLegend(this.legendHighlightCollection, 'highlight');
|
|
125
|
+
}
|
|
126
|
+
this.shapeTarget = 'highlight';
|
|
127
|
+
const index: number = this.treemap.legendSettings.mode === 'Default' ? parseFloat(targetId.split('_')[4]) : parseFloat(targetId.split('_')[3]);
|
|
128
|
+
const dataLength: number = this.treemap.treeMapLegendModule.legendCollections[index]['legendData'].length;
|
|
129
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
130
|
+
const collection: any[] = this.treemap.treeMapLegendModule.legendCollections;
|
|
131
|
+
const legendIndex: number = parseInt(targetId[targetId.length - 1], 10);
|
|
132
|
+
for (let i: number = 0; i < dataLength; i++) {
|
|
133
|
+
for (let j: number = 0; j < this.treemap.layout.renderItems.length; j++) {
|
|
134
|
+
if (this.treemap.treeMapLegendModule.legendCollections[index]['legendData'][i]['levelOrderName'] === this.treemap.layout.renderItems[j]['levelOrderName']) {
|
|
135
|
+
itemIndex = j;
|
|
136
|
+
groupIndex = this.treemap.layout.renderItems[j]['groupIndex'];
|
|
137
|
+
const nodeEle: Element = document.getElementById('container_Level_Index_' + groupIndex + '_Item_Index_' + itemIndex + '_RectPath');
|
|
138
|
+
if (i === 0) {
|
|
139
|
+
this.legendHighlightCollection = [];
|
|
140
|
+
pushCollection(
|
|
141
|
+
this.legendHighlightCollection, legendIndex, j, targetEle, nodeEle,
|
|
142
|
+
this.treemap.layout.renderItems, collection);
|
|
143
|
+
length = this.legendHighlightCollection.length;
|
|
144
|
+
this.legendHighlightCollection[length - 1]['ShapeCollection'] = { Elements: [] };
|
|
145
|
+
}
|
|
146
|
+
setColor(
|
|
147
|
+
targetEle, highlight.fill, highlight.opacity, highlight.border.color,
|
|
148
|
+
highlight.border.width.toString());
|
|
149
|
+
setColor(
|
|
150
|
+
nodeEle, highlight.fill, highlight.opacity, highlight.border.color,
|
|
151
|
+
highlight.border.width.toString());
|
|
152
|
+
length = this.legendHighlightCollection.length;
|
|
153
|
+
this.legendHighlightCollection[length - 1]['ShapeCollection']['Elements'].push(nodeEle);
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
} else {
|
|
159
|
+
if (selectionModule ? this.shapeElement ? this.shapeElement.getAttribute('id') !== selectionModule.legendSelectId : true : true) {
|
|
160
|
+
if (selectionModule ? this.shapeElement !== selectionModule.shapeElement : true && this.treemap.legendSettings.visible) {
|
|
161
|
+
removeClassNames(document.getElementsByClassName('treeMapHighLight'), 'treeMapHighLight', treemap);
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
if ((this.shapeTarget === 'highlight' || this.target === 'highlight') && this.treemap.legendSettings.visible) {
|
|
165
|
+
if (selectionModule ? this.shapeElement ? this.shapeElement.getAttribute('id') !== selectionModule.legendSelectId : true : true) {
|
|
166
|
+
if (selectionModule ? this.shapeElement !== selectionModule.shapeElement : true && selectionModule ? selectionModule.legendSelect : true) {
|
|
167
|
+
removeShape(this.shapeHighlightCollection, 'highlight');
|
|
168
|
+
this.shapeHighlightCollection = [];
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
if (this.shapeTarget === 'highlight' && this.treemap.legendSettings.visible) {
|
|
173
|
+
removeLegend(this.legendHighlightCollection, 'highlight');
|
|
174
|
+
}
|
|
175
|
+
this.highLightId = '';
|
|
176
|
+
processHighlight = false;
|
|
177
|
+
}
|
|
178
|
+
return processHighlight;
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
/**
|
|
182
|
+
* To bind events for highlight
|
|
183
|
+
*
|
|
184
|
+
* @returns {void}
|
|
185
|
+
*/
|
|
186
|
+
private addEventListener(): void {
|
|
187
|
+
if (this.treemap.isDestroyed) {
|
|
188
|
+
return;
|
|
189
|
+
}
|
|
190
|
+
this.treemap.on(Browser.touchMoveEvent, this.mouseMove, this);
|
|
191
|
+
}
|
|
192
|
+
/**
|
|
193
|
+
* To unbind events for highlight
|
|
194
|
+
*
|
|
195
|
+
* @returns {void}
|
|
196
|
+
*/
|
|
197
|
+
private removeEventListener(): void {
|
|
198
|
+
if (this.treemap.isDestroyed) {
|
|
199
|
+
return;
|
|
200
|
+
}
|
|
201
|
+
this.treemap.off(Browser.touchMoveEvent, this.mouseMove);
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
/**
|
|
205
|
+
* Get module name.
|
|
206
|
+
*
|
|
207
|
+
* @returns {string} - Returns the module name
|
|
208
|
+
*/
|
|
209
|
+
protected getModuleName(): string {
|
|
210
|
+
return 'treeMapHighlight';
|
|
211
|
+
}
|
|
212
|
+
/**
|
|
213
|
+
* To destroy the hightlight.
|
|
214
|
+
*
|
|
215
|
+
* @param {TreeMap} treeMap - Specifies the instance of the treemap.
|
|
216
|
+
* @returns {void}
|
|
217
|
+
* @private
|
|
218
|
+
*/
|
|
219
|
+
public destroy(treeMap: TreeMap): void {
|
|
220
|
+
this.removeEventListener();
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
/**
|
|
224
|
+
* Performing treemap selection
|
|
225
|
+
*/
|
|
226
|
+
export class TreeMapSelection {
|
|
227
|
+
private treemap: TreeMap;
|
|
228
|
+
public legendSelectId: string;
|
|
229
|
+
public shapeSelectId: string;
|
|
230
|
+
public shapeElement: Element;
|
|
231
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
232
|
+
public shapeSelectionCollection: any[] = [];
|
|
233
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
234
|
+
public legendSelectionCollection: any[] = [];
|
|
235
|
+
public shapeSelect: boolean = true;
|
|
236
|
+
public legendSelect: boolean = true;
|
|
237
|
+
// eslint-disable-next-line @typescript-eslint/explicit-member-accessibility
|
|
238
|
+
constructor(treeMap: TreeMap) {
|
|
239
|
+
this.treemap = treeMap;
|
|
240
|
+
this.addEventListener();
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
// eslint-disable-next-line valid-jsdoc
|
|
244
|
+
/**
|
|
245
|
+
* Mouse down event in selection
|
|
246
|
+
*/
|
|
247
|
+
public mouseDown(e: PointerEvent): void {
|
|
248
|
+
const targetEle: Element = <Element>e.target;
|
|
249
|
+
let eventArgs: IItemSelectedEventArgs;
|
|
250
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
251
|
+
const treemap: TreeMap = this.treemap;
|
|
252
|
+
treemap.levelSelection = [];
|
|
253
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
254
|
+
const items: any[] = []; const targetId: string = targetEle.id; const labelText : string = targetEle.innerHTML;
|
|
255
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
256
|
+
let item: any; const selectionElements: Element[] = []; let opacity: string;
|
|
257
|
+
let treeMapElement: Element; let element: Element; let orders: string[];
|
|
258
|
+
const selection: SelectionSettingsModel = treemap.selectionSettings;
|
|
259
|
+
const highlightModule: TreeMapHighlight = this.treemap.treeMapHighlightModule;
|
|
260
|
+
const layoutID: string = treemap.element.id + '_TreeMap_' + treemap.layoutType + '_Layout';
|
|
261
|
+
if (targetId.indexOf('_Item_Index') > -1) {
|
|
262
|
+
e.preventDefault();
|
|
263
|
+
if (this.treemap.selectionId !== targetId && this.legendSelect) {
|
|
264
|
+
treeMapElement = document.getElementById(layoutID);
|
|
265
|
+
item = treemap.layout.renderItems[parseFloat(targetId.split('_')[6])];
|
|
266
|
+
let index: number;
|
|
267
|
+
if (this.treemap.legendSettings.visible) {
|
|
268
|
+
this.shapeSelect = false;
|
|
269
|
+
const length: number = this.treemap.treeMapLegendModule.legendCollections.length;
|
|
270
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
271
|
+
const collection: any[] = this.treemap.treeMapLegendModule.legendCollections;
|
|
272
|
+
this.shapeElement = undefined;
|
|
273
|
+
removeShape(this.shapeSelectionCollection, 'selection');
|
|
274
|
+
if (highlightModule) {
|
|
275
|
+
highlightModule.shapeTarget = 'selection';
|
|
276
|
+
highlightModule.shapeHighlightCollection = [];
|
|
277
|
+
}
|
|
278
|
+
index = getLegendIndex(length, item, treemap);
|
|
279
|
+
this.shapeElement = this.treemap.legendSettings.mode === 'Default' ? document.getElementById('container_Legend_Shape_Index_' + index) : document.getElementById('container_Legend_Index_' + index);
|
|
280
|
+
if (this.shapeElement !== null) {
|
|
281
|
+
this.shapeSelectId = this.shapeElement.getAttribute('id');
|
|
282
|
+
this.shapeSelectionCollection.push({ legendEle: this.shapeElement, oldFill: collection[index]['legendFill'],
|
|
283
|
+
oldOpacity: collection[index]['opacity'], oldBorderColor: collection[index]['borderColor'],
|
|
284
|
+
oldBorderWidth: collection[index]['borderWidth']
|
|
285
|
+
});
|
|
286
|
+
setColor(
|
|
287
|
+
this.shapeElement, selection.fill, selection.opacity, selection.border.color,
|
|
288
|
+
selection.border.width.toString());
|
|
289
|
+
}
|
|
290
|
+
}
|
|
291
|
+
orders = findHightLightItems(item, [], selection.mode, treemap);
|
|
292
|
+
for (let i: number = 0; i < treeMapElement.childElementCount; i++) {
|
|
293
|
+
element = treeMapElement.childNodes[i] as Element;
|
|
294
|
+
item = treemap.layout.renderItems[element.id.split('_')[6]];
|
|
295
|
+
if (orders.indexOf(item['levelOrderName']) > -1) {
|
|
296
|
+
selectionElements.push(element);
|
|
297
|
+
treemap.levelSelection.push(element.id);
|
|
298
|
+
items.push(item);
|
|
299
|
+
}
|
|
300
|
+
}
|
|
301
|
+
removeClassNames(document.getElementsByClassName('treeMapSelection'), 'treeMapSelection', treemap);
|
|
302
|
+
this.treemap.selectionId = targetId;
|
|
303
|
+
const highLightElements: HTMLCollection = document.getElementsByClassName('treeMapHighLight');
|
|
304
|
+
for (let k: number = 0; k < selectionElements.length; k++) {
|
|
305
|
+
element = selectionElements[k];
|
|
306
|
+
if (highLightElements.length > 0) {
|
|
307
|
+
for (let j: number = 0; j < highLightElements.length; j++) {
|
|
308
|
+
if (highLightElements[j].id === element.id) {
|
|
309
|
+
highLightElements[j].classList.remove('treeMapHighLight');
|
|
310
|
+
}
|
|
311
|
+
applyOptions(
|
|
312
|
+
element.childNodes[0] as SVGPathElement,
|
|
313
|
+
{ border: selection.border, fill: selection.fill, opacity: selection.opacity }
|
|
314
|
+
);
|
|
315
|
+
element.classList.add('treeMapSelection');
|
|
316
|
+
}
|
|
317
|
+
} else {
|
|
318
|
+
applyOptions(
|
|
319
|
+
element.childNodes[0] as SVGPathElement,
|
|
320
|
+
{ border: selection.border, fill: selection.fill, opacity: selection.opacity }
|
|
321
|
+
);
|
|
322
|
+
element.classList.add('treeMapSelection');
|
|
323
|
+
}
|
|
324
|
+
eventArgs = { cancel: false, name: itemSelected, treemap: treemap, items: items, elements: selectionElements,
|
|
325
|
+
text : labelText, contentItemTemplate : labelText };
|
|
326
|
+
treemap.trigger(itemSelected, eventArgs, (observedArgs: IItemSelectedEventArgs) => {
|
|
327
|
+
if (observedArgs.contentItemTemplate !== labelText) {
|
|
328
|
+
setItemTemplateContent(targetId, targetEle, observedArgs.contentItemTemplate);
|
|
329
|
+
}
|
|
330
|
+
});
|
|
331
|
+
}
|
|
332
|
+
} else {
|
|
333
|
+
removeShape(this.shapeSelectionCollection, 'selection');
|
|
334
|
+
this.shapeSelectionCollection = [];
|
|
335
|
+
this.shapeElement = undefined;
|
|
336
|
+
this.shapeSelect = true;
|
|
337
|
+
this.shapeSelectId = '';
|
|
338
|
+
this.treemap.legendId = [];
|
|
339
|
+
removeClassNames(document.getElementsByClassName('treeMapSelection'), 'treeMapSelection', treemap);
|
|
340
|
+
this.treemap.selectionId = '';
|
|
341
|
+
}
|
|
342
|
+
} else if (targetId.indexOf('_Legend_Shape') > -1 || targetId.indexOf('_Legend_Index') > -1) {
|
|
343
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
344
|
+
const collection: any[] = this.treemap.treeMapLegendModule.legendCollections;
|
|
345
|
+
if (this.treemap.legendSettings.visible && this.legendSelectId !== targetId && this.shapeSelect) {
|
|
346
|
+
let itemIndex: number;
|
|
347
|
+
let groupIndex: number;
|
|
348
|
+
let length: number;
|
|
349
|
+
this.legendSelectId = targetId;
|
|
350
|
+
this.legendSelect = false;
|
|
351
|
+
const legendIndex: number = parseInt(targetId[targetId.length - 1], 10);
|
|
352
|
+
const targetEle: Element = document.getElementById(targetId);
|
|
353
|
+
removeLegend(this.legendSelectionCollection, 'selection');
|
|
354
|
+
if (highlightModule) { highlightModule.shapeTarget = 'selection'; }
|
|
355
|
+
const index: number = this.treemap.legendSettings.mode === 'Default' ? parseFloat(targetId.split('_')[4]) : parseFloat(targetId.split('_')[3]);
|
|
356
|
+
const dataLength: number = this.treemap.treeMapLegendModule.legendCollections[index]['legendData'].length;
|
|
357
|
+
for (let k: number = 0; k < dataLength; k++) {
|
|
358
|
+
for (let l: number = 0; l < this.treemap.layout.renderItems.length; l++) {
|
|
359
|
+
if (this.treemap.treeMapLegendModule.legendCollections[index]['legendData'][k]['levelOrderName'] === this.treemap.layout.renderItems[l]['levelOrderName']) {
|
|
360
|
+
itemIndex = l;
|
|
361
|
+
groupIndex = this.treemap.layout.renderItems[l]['groupIndex'];
|
|
362
|
+
const nodeEle: Element = document.getElementById('container_Level_Index_' + groupIndex + '_Item_Index_' + itemIndex + '_RectPath');
|
|
363
|
+
if (k === 0) {
|
|
364
|
+
pushCollection(
|
|
365
|
+
this.legendSelectionCollection, legendIndex, l, targetEle, nodeEle,
|
|
366
|
+
this.treemap.layout.renderItems, collection);
|
|
367
|
+
length = this.legendSelectionCollection.length;
|
|
368
|
+
this.legendSelectionCollection[length - 1]['ShapeCollection'] = { Elements: [] };
|
|
369
|
+
}
|
|
370
|
+
setColor(
|
|
371
|
+
targetEle, selection.fill, selection.opacity, selection.border.color,
|
|
372
|
+
selection.border.width.toString());
|
|
373
|
+
setColor(
|
|
374
|
+
nodeEle, selection.fill, selection.opacity, selection.border.color,
|
|
375
|
+
selection.border.width.toString());
|
|
376
|
+
length = this.legendSelectionCollection.length;
|
|
377
|
+
this.legendSelectionCollection[length - 1]['ShapeCollection']['Elements'].push(nodeEle);
|
|
378
|
+
}
|
|
379
|
+
}
|
|
380
|
+
}
|
|
381
|
+
} else {
|
|
382
|
+
removeLegend(this.legendSelectionCollection, 'Selection');
|
|
383
|
+
if (highlightModule) { highlightModule.shapeTarget = 'highlight'; }
|
|
384
|
+
this.legendSelect = true;
|
|
385
|
+
this.legendSelectId = '';
|
|
386
|
+
}
|
|
387
|
+
}
|
|
388
|
+
}
|
|
389
|
+
|
|
390
|
+
/**
|
|
391
|
+
* @param {string} levelOrder - Specifies the level order of treemap item
|
|
392
|
+
* @param {boolean} enable - Specifies the boolean value
|
|
393
|
+
* @returns {void}
|
|
394
|
+
* @private
|
|
395
|
+
*/
|
|
396
|
+
public selectTreemapItem(levelOrder: string, enable: boolean): void {
|
|
397
|
+
if (enable) {
|
|
398
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
399
|
+
let item: any;
|
|
400
|
+
for (let s: number = 0; s < this.treemap.layout.renderItems.length; s++) {
|
|
401
|
+
if (levelOrder === this.treemap.layout.renderItems[s]['levelOrderName']) {
|
|
402
|
+
item = this.treemap.layout.renderItems[s];
|
|
403
|
+
break;
|
|
404
|
+
}
|
|
405
|
+
}
|
|
406
|
+
const selection: SelectionSettingsModel = this.treemap.selectionSettings;
|
|
407
|
+
const selectionElements: Element[] = [];
|
|
408
|
+
let element: Element;
|
|
409
|
+
let index: number;
|
|
410
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
411
|
+
const items: any[] = [];
|
|
412
|
+
this.treemap.levelSelection = [];
|
|
413
|
+
const layoutID: string = this.treemap.element.id + '_TreeMap_' + this.treemap.layoutType + '_Layout';
|
|
414
|
+
const treeMapElement: Element = document.getElementById(layoutID);
|
|
415
|
+
const orders: string[] = findHightLightItems(item, [], selection.mode, this.treemap);
|
|
416
|
+
for (let i: number = 0; i < treeMapElement.childElementCount; i++) {
|
|
417
|
+
element = treeMapElement.childNodes[i] as Element;
|
|
418
|
+
item = this.treemap.layout.renderItems[element.id.split('_')[6]];
|
|
419
|
+
if (orders.indexOf(item['levelOrderName']) > -1) {
|
|
420
|
+
selectionElements.push(element);
|
|
421
|
+
this.treemap.levelSelection.push(element.id);
|
|
422
|
+
items.push(item);
|
|
423
|
+
}
|
|
424
|
+
}
|
|
425
|
+
if (this.treemap.legendSettings.visible) {
|
|
426
|
+
for (let m: number = 0; m < items.length; m++) {
|
|
427
|
+
this.shapeSelect = false;
|
|
428
|
+
const length: number = this.treemap.treeMapLegendModule.legendCollections.length;
|
|
429
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
430
|
+
const collection: any[] = this.treemap.treeMapLegendModule.legendCollections;
|
|
431
|
+
this.shapeElement = undefined;
|
|
432
|
+
removeShape(this.shapeSelectionCollection, 'selection');
|
|
433
|
+
index = getLegendIndex(length, items[m], this.treemap);
|
|
434
|
+
this.shapeElement = this.treemap.legendSettings.mode === 'Default' ? document.getElementById('container_Legend_Shape_Index_' + index) : document.getElementById('container_Legend_Index_' + index);
|
|
435
|
+
if (this.shapeElement !== null) {
|
|
436
|
+
this.shapeSelectId = this.shapeElement.getAttribute('id');
|
|
437
|
+
this.treemap.legendId.push(this.shapeSelectId);
|
|
438
|
+
this.shapeSelectionCollection.push({
|
|
439
|
+
legendEle: this.shapeElement, oldFill: collection[index]['legendFill'],
|
|
440
|
+
oldOpacity: collection[index]['opacity'], oldBorderColor: collection[index]['borderColor'],
|
|
441
|
+
oldBorderWidth: collection[index]['borderWidth']
|
|
442
|
+
});
|
|
443
|
+
setColor(
|
|
444
|
+
this.shapeElement, selection.fill, selection.opacity, selection.border.color,
|
|
445
|
+
selection.border.width.toString());
|
|
446
|
+
}
|
|
447
|
+
}
|
|
448
|
+
}
|
|
449
|
+
removeClassNames(document.getElementsByClassName('treeMapSelection'), 'treeMapSelection', this.treemap);
|
|
450
|
+
const selectionElement: Element = document.getElementById(this.treemap.levelSelection[0]);
|
|
451
|
+
this.treemap.selectionId = selectionElement.childNodes[0]['id'];
|
|
452
|
+
const highLightElements: HTMLCollection = document.getElementsByClassName('treeMapHighLight');
|
|
453
|
+
for (let k: number = 0; k < selectionElements.length; k++) {
|
|
454
|
+
element = selectionElements[k];
|
|
455
|
+
if (highLightElements.length > 0) {
|
|
456
|
+
for (let j: number = 0; j < highLightElements.length; j++) {
|
|
457
|
+
if (highLightElements[j].id === element.id) {
|
|
458
|
+
highLightElements[j].classList.remove('treeMapHighLight');
|
|
459
|
+
}
|
|
460
|
+
applyOptions(
|
|
461
|
+
element.childNodes[0] as SVGPathElement,
|
|
462
|
+
{ border: selection.border, fill: selection.fill, opacity: selection.opacity }
|
|
463
|
+
);
|
|
464
|
+
element.classList.add('treeMapSelection');
|
|
465
|
+
}
|
|
466
|
+
} else {
|
|
467
|
+
selection.fill = selection.fill === 'null' ?
|
|
468
|
+
this.treemap.layout.renderItems[parseInt(element.id.split('Item_Index_')[1], 10)]['options']['fill']
|
|
469
|
+
: selection.fill;
|
|
470
|
+
applyOptions(
|
|
471
|
+
element.childNodes[0] as SVGPathElement,
|
|
472
|
+
{ border: selection.border, fill: selection.fill, opacity: selection.opacity }
|
|
473
|
+
);
|
|
474
|
+
element.classList.add('treeMapSelection');
|
|
475
|
+
}
|
|
476
|
+
}
|
|
477
|
+
} else {
|
|
478
|
+
removeShape(this.shapeSelectionCollection, 'selection');
|
|
479
|
+
this.shapeElement = undefined;
|
|
480
|
+
this.treemap.levelSelection = [];
|
|
481
|
+
this.shapeSelect = true;
|
|
482
|
+
this.shapeSelectId = '';
|
|
483
|
+
this.treemap.legendId = [];
|
|
484
|
+
removeClassNames(document.getElementsByClassName('treeMapSelection'), 'treeMapSelection', this.treemap);
|
|
485
|
+
this.treemap.selectionId = '';
|
|
486
|
+
}
|
|
487
|
+
}
|
|
488
|
+
|
|
489
|
+
/**
|
|
490
|
+
* To bind events for selection
|
|
491
|
+
*
|
|
492
|
+
* @returns {void}
|
|
493
|
+
*/
|
|
494
|
+
private addEventListener(): void {
|
|
495
|
+
if (this.treemap.isDestroyed) {
|
|
496
|
+
return;
|
|
497
|
+
}
|
|
498
|
+
this.treemap.on(Browser.touchStartEvent, this.mouseDown, this);
|
|
499
|
+
}
|
|
500
|
+
/**
|
|
501
|
+
* To unbind events for selection
|
|
502
|
+
*
|
|
503
|
+
* @returns {void}
|
|
504
|
+
*/
|
|
505
|
+
private removeEventListener(): void {
|
|
506
|
+
if (this.treemap.isDestroyed) {
|
|
507
|
+
return;
|
|
508
|
+
}
|
|
509
|
+
this.treemap.off(Browser.touchStartEvent, this.mouseDown);
|
|
510
|
+
}
|
|
511
|
+
|
|
512
|
+
/**
|
|
513
|
+
* Get module name.
|
|
514
|
+
*
|
|
515
|
+
* @returns {string} - Returns the module name.
|
|
516
|
+
*/
|
|
517
|
+
protected getModuleName(): string {
|
|
518
|
+
return 'treeMapSelection';
|
|
519
|
+
}
|
|
520
|
+
/**
|
|
521
|
+
* To destroy the selection.
|
|
522
|
+
*
|
|
523
|
+
* @param {TreeMap} treeMap - Specifies the treemap instance.
|
|
524
|
+
* @returns {void}
|
|
525
|
+
* @private
|
|
526
|
+
*/
|
|
527
|
+
public destroy(treeMap: TreeMap): void {
|
|
528
|
+
this.removeEventListener();
|
|
529
|
+
}
|
|
530
|
+
}
|