@syncfusion/ej2-treemap 31.2.2 → 31.2.12
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 +11 -2
- package/dist/ej2-treemap.min.js +2 -2
- 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 +4 -0
- package/dist/es6/ej2-treemap.es2015.js.map +1 -1
- package/dist/es6/ej2-treemap.es5.js +4 -0
- 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/package.json +17 -52
- package/src/treemap/treemap.d.ts +1 -0
- package/src/treemap/treemap.js +4 -0
- package/dist/ts/index.d.ts +0 -4
- package/dist/ts/index.ts +0 -4
- package/dist/ts/treemap/index.d.ts +0 -19
- package/dist/ts/treemap/index.ts +0 -19
- package/dist/ts/treemap/layout/legend.d.ts +0 -137
- package/dist/ts/treemap/layout/legend.ts +0 -1095
- package/dist/ts/treemap/layout/render-panel.d.ts +0 -47
- package/dist/ts/treemap/layout/render-panel.ts +0 -758
- package/dist/ts/treemap/model/base-model.d.ts +0 -795
- package/dist/ts/treemap/model/base.d.ts +0 -671
- package/dist/ts/treemap/model/base.ts +0 -798
- package/dist/ts/treemap/model/constants.d.ts +0 -117
- package/dist/ts/treemap/model/constants.ts +0 -118
- package/dist/ts/treemap/model/image-export.d.ts +0 -34
- package/dist/ts/treemap/model/image-export.ts +0 -117
- package/dist/ts/treemap/model/interface.d.ts +0 -555
- package/dist/ts/treemap/model/interface.ts +0 -583
- package/dist/ts/treemap/model/pdf-export.d.ts +0 -36
- package/dist/ts/treemap/model/pdf-export.ts +0 -105
- package/dist/ts/treemap/model/print.d.ts +0 -45
- package/dist/ts/treemap/model/print.ts +0 -106
- package/dist/ts/treemap/model/theme.d.ts +0 -19
- package/dist/ts/treemap/model/theme.ts +0 -450
- package/dist/ts/treemap/treemap-model.d.ts +0 -374
- package/dist/ts/treemap/treemap.d.ts +0 -724
- package/dist/ts/treemap/treemap.ts +0 -1817
- package/dist/ts/treemap/user-interaction/highlight-selection.d.ts +0 -118
- package/dist/ts/treemap/user-interaction/highlight-selection.ts +0 -799
- package/dist/ts/treemap/user-interaction/tooltip.d.ts +0 -42
- package/dist/ts/treemap/user-interaction/tooltip.ts +0 -228
- package/dist/ts/treemap/utils/enum.d.ts +0 -256
- package/dist/ts/treemap/utils/enum.ts +0 -263
- package/dist/ts/treemap/utils/helper.d.ts +0 -543
- package/dist/ts/treemap/utils/helper.ts +0 -1453
|
@@ -1,799 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
import { TreeMap } from '../treemap';
|
|
3
|
-
import { Browser, isNullOrUndefined } from '@syncfusion/ej2-base';
|
|
4
|
-
import { IItemHighlightEventArgs, IItemSelectedEventArgs } from '../model/interface';
|
|
5
|
-
import { itemHighlight, itemSelected } from '../model/constants';
|
|
6
|
-
import { HighlightSettingsModel, SelectionSettingsModel } from '../model/base-model';
|
|
7
|
-
import { findHightLightItems, removeClassNames, applyOptions, removeShape, removeLegend,
|
|
8
|
-
removeSelectionWithHighlight, setColor, getLegendIndex, pushCollection, setItemTemplateContent } from '../utils/helper';
|
|
9
|
-
|
|
10
|
-
/**
|
|
11
|
-
* Performing treemap highlight
|
|
12
|
-
*/
|
|
13
|
-
export class TreeMapHighlight {
|
|
14
|
-
private treemap: TreeMap;
|
|
15
|
-
public highLightId: string;
|
|
16
|
-
private target: string = 'highlight';
|
|
17
|
-
public shapeTarget: string = 'highlight';
|
|
18
|
-
private shapeElement: Element;
|
|
19
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
20
|
-
public shapeHighlightCollection: any[] = [];
|
|
21
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
22
|
-
public legendHighlightCollection: any[] = [];
|
|
23
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
24
|
-
public currentElement: any[] = [];
|
|
25
|
-
constructor(treeMap: TreeMap) {
|
|
26
|
-
this.treemap = treeMap;
|
|
27
|
-
this.addEventListener();
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
/**
|
|
31
|
-
* Mouse Move event in highlight
|
|
32
|
-
*
|
|
33
|
-
* @param {PointerEvent} e - Specifies the pointer argument.
|
|
34
|
-
* @returns {boolean} - return the highlight process is true or false.
|
|
35
|
-
* @private
|
|
36
|
-
*/
|
|
37
|
-
public mouseMove(e: PointerEvent | KeyboardEvent): boolean {
|
|
38
|
-
const targetEle: Element = <Element>e.target;
|
|
39
|
-
return this.highlightOnMouseMove(targetEle);
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
/**
|
|
43
|
-
* This method highlights the target element for mouse move event.
|
|
44
|
-
*
|
|
45
|
-
* @param {Element} targetElement - Specifies the target element to highlight.
|
|
46
|
-
* @returns {boolean} - return the highlight process is true or false.
|
|
47
|
-
* @private
|
|
48
|
-
*/
|
|
49
|
-
public highlightOnMouseMove(targetElement: Element): boolean {
|
|
50
|
-
const treemap: TreeMap = this.treemap;
|
|
51
|
-
let processHighlight: boolean;
|
|
52
|
-
const targetId: string = targetElement.id;
|
|
53
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
54
|
-
let eventArgs: IItemHighlightEventArgs; const items: any[] = [];
|
|
55
|
-
const highlight: HighlightSettingsModel = this.treemap.highlightSettings;
|
|
56
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
57
|
-
let item: any; const highLightElements: Element[] = []; let process: boolean;
|
|
58
|
-
let treeMapElement: Element; let element: Element; let orders: string[];
|
|
59
|
-
const selectionModule: TreeMapSelection = this.treemap.treeMapSelectionModule;
|
|
60
|
-
let shapeSelected: boolean = false;
|
|
61
|
-
if (selectionModule && selectionModule.legendSelectionCollection.length > 0) {
|
|
62
|
-
for (let i: number = 0; i < selectionModule.legendSelectionCollection.length; i++) {
|
|
63
|
-
for (let j: number = 0; j < selectionModule.legendSelectionCollection[i as number]['ShapeCollection']['Elements'].length; j++) {
|
|
64
|
-
const selectedElementIndex: number = parseFloat(selectionModule.legendSelectionCollection[i as number]['ShapeCollection']['Elements'][j as number].id.split('Item_Index_')[1].split('_')[0]);
|
|
65
|
-
const targetElementIndex: number = targetId.indexOf('_Item_Index_') > -1 ? parseFloat(targetId.split('Item_Index_')[1].split('_')[0]) : null;
|
|
66
|
-
if (selectionModule.legendSelectionCollection[i as number]['ShapeCollection']['Elements'][j as number].id === targetId ||
|
|
67
|
-
selectedElementIndex === targetElementIndex) {
|
|
68
|
-
shapeSelected = true;
|
|
69
|
-
break;
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
if (targetId.indexOf('_Item_Index') > -1 && !shapeSelected) {
|
|
75
|
-
if (this.highLightId !== targetId ||
|
|
76
|
-
(this.legendHighlightCollection[0] ? this.legendHighlightCollection[0]['ShapeCollection']['Elements'].length > 1 : false)) {
|
|
77
|
-
treeMapElement = document.getElementById(treemap.element.id + '_TreeMap_' + treemap.layoutType + '_Layout');
|
|
78
|
-
const selectionElements: HTMLCollection = document.getElementsByClassName('treeMapSelection');
|
|
79
|
-
item = this.treemap.layout.renderItems[parseFloat(targetId.split('_Item_Index_')[1])];
|
|
80
|
-
let index: number;
|
|
81
|
-
if (this.treemap.legendSettings.visible) {
|
|
82
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
83
|
-
const collection: any[] = this.treemap.treeMapLegendModule.legendCollections;
|
|
84
|
-
const length: number = this.treemap.treeMapLegendModule.legendCollections.length;
|
|
85
|
-
index = (!treemap.legendSettings.removeDuplicateLegend && treemap.palette && treemap.palette.length > 0 &&
|
|
86
|
-
treemap.leafItemSettings.colorMapping.length === 0 && treemap.levels.length === 0) ?
|
|
87
|
-
parseFloat(targetId.split('_Item_Index_')[1]) : getLegendIndex(length, item, treemap);
|
|
88
|
-
if (isNullOrUndefined(index)) {
|
|
89
|
-
removeLegend(this.legendHighlightCollection, treemap);
|
|
90
|
-
removeLegend(this.shapeHighlightCollection, treemap);
|
|
91
|
-
this.legendHighlightCollection = [];
|
|
92
|
-
treemap.treeMapLegendModule.removeInteractivePointer();
|
|
93
|
-
}
|
|
94
|
-
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);
|
|
95
|
-
if (this.shapeElement !== null) {
|
|
96
|
-
if (selectionModule ? this.shapeElement.id !== ((selectionModule && selectionModule.shapeElement)
|
|
97
|
-
? selectionModule.shapeElement.id : null) : true) {
|
|
98
|
-
this.currentElement.push({currentElement: this.shapeElement});
|
|
99
|
-
removeLegend(this.shapeHighlightCollection, treemap);
|
|
100
|
-
this.shapeHighlightCollection.push({ legendEle: this.shapeElement, oldFill: collection[index as number]['legendFill'],
|
|
101
|
-
oldOpacity: collection[index as number]['opacity'], oldBorderColor: collection[index as number]['borderColor'],
|
|
102
|
-
oldBorderWidth: collection[index as number]['borderWidth']
|
|
103
|
-
});
|
|
104
|
-
const legendText: Element = this.treemap.legendSettings.mode === 'Default' ? document.getElementById(this.treemap.element.id + '_Legend_Text_Index_' + index)
|
|
105
|
-
: document.getElementById(this.treemap.element.id + '_Legend_Index_' + index + '_Text');
|
|
106
|
-
setColor(
|
|
107
|
-
legendText, highlight.fill, highlight.opacity, null,
|
|
108
|
-
null);
|
|
109
|
-
setColor(
|
|
110
|
-
this.shapeElement, highlight.fill, highlight.opacity, highlight.border.color,
|
|
111
|
-
highlight.border.width.toString());
|
|
112
|
-
this.target = 'highlight';
|
|
113
|
-
} else if (this.currentElement.length > 0 && this.currentElement[this.currentElement.length - 1]['currentElement'] !== this.shapeElement) {
|
|
114
|
-
removeSelectionWithHighlight(this.shapeHighlightCollection, this.currentElement, treemap);
|
|
115
|
-
this.highLightId = '';
|
|
116
|
-
}
|
|
117
|
-
}
|
|
118
|
-
}
|
|
119
|
-
orders = findHightLightItems(item, [], highlight.mode, treemap);
|
|
120
|
-
for (let i: number = 0; i < treeMapElement.childElementCount; i++) {
|
|
121
|
-
element = treeMapElement.childNodes[i as number] as Element;
|
|
122
|
-
process = true;
|
|
123
|
-
const valuePath: string = (treemap.rangeColorValuePath !== '') ? treemap.rangeColorValuePath : null;
|
|
124
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
125
|
-
const targetItem: any = treemap.layout.renderItems[parseFloat(targetId.split('_Item_Index_')[1])];
|
|
126
|
-
item = treemap.layout.renderItems[parseFloat(element.id.split('_Item_Index_')[1])];
|
|
127
|
-
for (let j: number = 0; j < selectionElements.length; j++) {
|
|
128
|
-
if (element.id === selectionElements[j as number].id ||
|
|
129
|
-
element.id === selectionElements[j as number].parentElement.id) {
|
|
130
|
-
process = false;
|
|
131
|
-
break;
|
|
132
|
-
}
|
|
133
|
-
}
|
|
134
|
-
if (orders.indexOf(item['levelOrderName']) > -1 && process &&
|
|
135
|
-
(!isNullOrUndefined(valuePath) ?
|
|
136
|
-
(item['data'][valuePath as string] === targetItem['data'][valuePath as string] ||
|
|
137
|
-
(highlight.mode !== 'Item' && treemap.levels.length > 0)
|
|
138
|
-
) : true)) {
|
|
139
|
-
highLightElements.push(element);
|
|
140
|
-
items.push(item);
|
|
141
|
-
}
|
|
142
|
-
}
|
|
143
|
-
removeClassNames(document.getElementsByClassName('treeMapHighLight'), 'treeMapHighLight', treemap);
|
|
144
|
-
for (let k: number = 0; k < highLightElements.length; k++) {
|
|
145
|
-
element = highLightElements[k as number];
|
|
146
|
-
applyOptions(
|
|
147
|
-
element.childNodes[0] as SVGPathElement,
|
|
148
|
-
{ border: highlight.border, fill: highlight.fill, opacity: highlight.opacity }
|
|
149
|
-
);
|
|
150
|
-
element.classList.add('treeMapHighLight');
|
|
151
|
-
this.highLightId = targetId;
|
|
152
|
-
}
|
|
153
|
-
eventArgs = { cancel: false, name: itemHighlight, treemap: treemap, items: items, elements: highLightElements };
|
|
154
|
-
treemap.trigger(itemHighlight, eventArgs);
|
|
155
|
-
}
|
|
156
|
-
} else if (targetId.indexOf('_Legend_Shape') > -1 || targetId.indexOf('_Legend_Index') > -1 || targetId.indexOf('_Legend_Text_Index') > -1) {
|
|
157
|
-
if (!isNullOrUndefined(selectionModule)) {
|
|
158
|
-
selectionModule.legendSelectId = !isNullOrUndefined(treemap.legendId[0]) ? treemap.legendId[0] : null;
|
|
159
|
-
}
|
|
160
|
-
const selectedLegendIndex: number = selectionModule && selectionModule.legendSelectId ?
|
|
161
|
-
parseFloat(selectionModule.legendSelectId.split('Index_')[1]) :
|
|
162
|
-
(selectionModule && selectionModule.shapeSelectId ? parseFloat(selectionModule.shapeSelectId.split('Index_')[1]) : null);
|
|
163
|
-
const targetIndex: number = this.treemap.legendSettings.mode === 'Default' ? (targetId.indexOf('Text') === -1 ? parseFloat(targetId.split('_Legend_Shape_Index_')[1]) : parseFloat(targetId.split('_Legend_Text_Index_')[1]))
|
|
164
|
-
: parseFloat(targetId.split('_Legend_Index_')[1]);
|
|
165
|
-
if (this.treemap.legendSettings.visible && targetIndex !== selectedLegendIndex) {
|
|
166
|
-
let itemIndex: number;
|
|
167
|
-
let groupIndex: number;
|
|
168
|
-
let length: number;
|
|
169
|
-
const valuePath: string = (treemap.rangeColorValuePath !== '') ? treemap.rangeColorValuePath : null;
|
|
170
|
-
const targetEle: Element = document.getElementById(targetId);
|
|
171
|
-
if (this.shapeTarget === 'highlight') {
|
|
172
|
-
removeLegend(this.legendHighlightCollection, this.treemap);
|
|
173
|
-
this.legendHighlightCollection = [];
|
|
174
|
-
}
|
|
175
|
-
this.shapeTarget = 'highlight';
|
|
176
|
-
const dataLength: number = this.treemap.treeMapLegendModule.legendCollections[targetIndex as number]['legendData'].length;
|
|
177
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
178
|
-
const collection: any[] = this.treemap.treeMapLegendModule.legendCollections;
|
|
179
|
-
for (let i: number = 0; i < dataLength; i++) {
|
|
180
|
-
for (let j: number = 0; j < this.treemap.layout.renderItems.length; j++) {
|
|
181
|
-
if ((!isNullOrUndefined(valuePath) && treemap.leafItemSettings.colorMapping.length > 0 &&
|
|
182
|
-
treemap.levels.length === 0)
|
|
183
|
-
? treemap.treeMapLegendModule.legendCollections[targetIndex as number]['legendData'][i as number]['data'][valuePath as string] === treemap.layout.renderItems[j as number]['data'][valuePath as string]
|
|
184
|
-
: (treemap.treeMapLegendModule.legendCollections[targetIndex as number]['legendData'][i as number]['levelOrderName'] === treemap.layout.renderItems[j as number]['levelOrderName'])) {
|
|
185
|
-
itemIndex = j;
|
|
186
|
-
groupIndex = this.treemap.layout.renderItems[j as number]['groupIndex'];
|
|
187
|
-
const nodeEle: Element = document.getElementById(this.treemap.element.id + '_Level_Index_' + groupIndex + '_Item_Index_' + itemIndex + '_RectPath');
|
|
188
|
-
if (i === 0 || this.legendHighlightCollection.length === 0) {
|
|
189
|
-
this.legendHighlightCollection = [];
|
|
190
|
-
pushCollection(
|
|
191
|
-
this.legendHighlightCollection, targetIndex, j, targetEle, nodeEle,
|
|
192
|
-
this.treemap.layout.renderItems, collection);
|
|
193
|
-
length = this.legendHighlightCollection.length;
|
|
194
|
-
this.legendHighlightCollection[length - 1]['ShapeCollection'] = { Elements: [] };
|
|
195
|
-
}
|
|
196
|
-
let legendShape: Element; let legendText: Element;
|
|
197
|
-
if (targetEle.id.indexOf('Text') > -1) {
|
|
198
|
-
legendShape = this.treemap.legendSettings.mode === 'Interactive' ? document.getElementById(targetEle.id.replace('_Text', ''))
|
|
199
|
-
: document.getElementById(this.treemap.element.id + '_Legend_Shape_Index_' + targetIndex);
|
|
200
|
-
setColor(targetEle, highlight.fill, highlight.opacity, null, null);
|
|
201
|
-
setColor(legendShape, highlight.fill, highlight.opacity, highlight.border.color,
|
|
202
|
-
highlight.border.width.toString());
|
|
203
|
-
} else {
|
|
204
|
-
legendText = this.treemap.legendSettings.mode === 'Interactive' ? document.getElementById(targetEle.id + '_Text')
|
|
205
|
-
: document.getElementById(this.treemap.element.id + '_Legend_Text_Index_' + targetIndex);
|
|
206
|
-
setColor(legendText, highlight.fill, highlight.opacity, null, null);
|
|
207
|
-
setColor(targetEle, highlight.fill, highlight.opacity, highlight.border.color,
|
|
208
|
-
highlight.border.width.toString());
|
|
209
|
-
}
|
|
210
|
-
setColor(
|
|
211
|
-
nodeEle, highlight.fill, highlight.opacity, highlight.border.color,
|
|
212
|
-
highlight.border.width.toString());
|
|
213
|
-
length = this.legendHighlightCollection.length;
|
|
214
|
-
this.legendHighlightCollection[length - 1]['ShapeCollection']['Elements'].push(nodeEle);
|
|
215
|
-
}
|
|
216
|
-
}
|
|
217
|
-
}
|
|
218
|
-
if (dataLength === 0 && this.treemap.palette && this.treemap.palette.length > 0) {
|
|
219
|
-
for (let j: number = 0; j < this.treemap.layout.renderItems.length; j++) {
|
|
220
|
-
if ((this.treemap.treeMapLegendModule.legendCollections[targetIndex as number]['levelOrderName'] === this.treemap.layout.renderItems[j as number]['levelOrderName'] ||
|
|
221
|
-
this.treemap.layout.renderItems[j as number]['levelOrderName'].indexOf(this.treemap.treeMapLegendModule.legendCollections[targetIndex as number]['levelOrderName']) > -1) &&
|
|
222
|
-
((!this.treemap.legendSettings.removeDuplicateLegend && treemap.palette && treemap.palette.length > 0 &&
|
|
223
|
-
!this.treemap.layout.renderItems[j as number].parent.isDrilled) ?
|
|
224
|
-
targetIndex === j : true)) {
|
|
225
|
-
itemIndex = j;
|
|
226
|
-
groupIndex = this.treemap.layout.renderItems[j as number]['groupIndex'];
|
|
227
|
-
const nodeEle: Element = document.getElementById(this.treemap.element.id + '_Level_Index_' + groupIndex + '_Item_Index_' + itemIndex + '_RectPath');
|
|
228
|
-
pushCollection(
|
|
229
|
-
this.legendHighlightCollection, targetIndex, j, targetEle, nodeEle,
|
|
230
|
-
this.treemap.layout.renderItems, collection);
|
|
231
|
-
length = this.legendHighlightCollection.length;
|
|
232
|
-
this.legendHighlightCollection[length - 1]['ShapeCollection'] = { Elements: [] };
|
|
233
|
-
let legendItem: Element;
|
|
234
|
-
if (targetEle.id.indexOf('Text') > -1) {
|
|
235
|
-
legendItem = this.treemap.legendSettings.mode === 'Interactive' ? document.getElementById(targetEle.id.replace('_Text', ''))
|
|
236
|
-
: document.getElementById(this.treemap.element.id + '_Legend_Shape_Index_' + targetIndex);
|
|
237
|
-
setColor(targetEle, highlight.fill, highlight.opacity, null, null);
|
|
238
|
-
setColor(
|
|
239
|
-
legendItem, highlight.fill, highlight.opacity, highlight.border.color,
|
|
240
|
-
highlight.border.width.toString());
|
|
241
|
-
} else {
|
|
242
|
-
legendItem = this.treemap.legendSettings.mode === 'Interactive' ? document.getElementById(targetEle.id + '_Text')
|
|
243
|
-
: document.getElementById(this.treemap.element.id + '_Legend_Text_Index_' + targetIndex);
|
|
244
|
-
setColor(legendItem, highlight.fill, highlight.opacity, null, null);
|
|
245
|
-
setColor(
|
|
246
|
-
targetEle, highlight.fill, highlight.opacity, highlight.border.color,
|
|
247
|
-
highlight.border.width.toString());
|
|
248
|
-
}
|
|
249
|
-
setColor(
|
|
250
|
-
nodeEle, highlight.fill, highlight.opacity, highlight.border.color,
|
|
251
|
-
highlight.border.width.toString());
|
|
252
|
-
length = this.legendHighlightCollection.length;
|
|
253
|
-
this.legendHighlightCollection[length - 1]['ShapeCollection']['Elements'].push(nodeEle);
|
|
254
|
-
}
|
|
255
|
-
}
|
|
256
|
-
}
|
|
257
|
-
} else {
|
|
258
|
-
removeClassNames(document.getElementsByClassName('treeMapHighLight'), 'treeMapHighLight', treemap);
|
|
259
|
-
removeLegend(this.legendHighlightCollection, treemap);
|
|
260
|
-
this.legendHighlightCollection = [];
|
|
261
|
-
}
|
|
262
|
-
} else {
|
|
263
|
-
if (selectionModule ? this.shapeElement ? this.shapeElement.getAttribute('id') !== selectionModule.legendSelectId : true : true) {
|
|
264
|
-
if (selectionModule ? this.shapeElement !== selectionModule.shapeElement : true && this.treemap.legendSettings.visible) {
|
|
265
|
-
removeClassNames(document.getElementsByClassName('treeMapHighLight'), 'treeMapHighLight', treemap);
|
|
266
|
-
}
|
|
267
|
-
}
|
|
268
|
-
if ((this.shapeTarget === 'highlight' || this.target === 'highlight') && this.treemap.legendSettings.visible) {
|
|
269
|
-
if (selectionModule ? this.shapeElement ? this.shapeElement.getAttribute('id') !== selectionModule.legendSelectId : true : true) {
|
|
270
|
-
if (selectionModule ? this.shapeElement !== selectionModule.shapeElement : true && selectionModule ?
|
|
271
|
-
selectionModule.legendSelect : true) {
|
|
272
|
-
removeLegend(this.shapeHighlightCollection, treemap);
|
|
273
|
-
this.shapeHighlightCollection = [];
|
|
274
|
-
}
|
|
275
|
-
}
|
|
276
|
-
}
|
|
277
|
-
if (this.shapeTarget === 'highlight' && this.treemap.legendSettings.visible) {
|
|
278
|
-
removeLegend(this.legendHighlightCollection, this.treemap);
|
|
279
|
-
}
|
|
280
|
-
this.highLightId = '';
|
|
281
|
-
processHighlight = false;
|
|
282
|
-
}
|
|
283
|
-
return processHighlight;
|
|
284
|
-
}
|
|
285
|
-
|
|
286
|
-
/**
|
|
287
|
-
* To bind events for highlight
|
|
288
|
-
*
|
|
289
|
-
* @returns {void}
|
|
290
|
-
*/
|
|
291
|
-
private addEventListener(): void {
|
|
292
|
-
if (this.treemap.isDestroyed) {
|
|
293
|
-
return;
|
|
294
|
-
}
|
|
295
|
-
this.treemap.on(Browser.touchMoveEvent, this.mouseMove, this);
|
|
296
|
-
}
|
|
297
|
-
/**
|
|
298
|
-
* To unbind events for highlight
|
|
299
|
-
*
|
|
300
|
-
* @returns {void}
|
|
301
|
-
*/
|
|
302
|
-
private removeEventListener(): void {
|
|
303
|
-
if (this.treemap.isDestroyed) {
|
|
304
|
-
return;
|
|
305
|
-
}
|
|
306
|
-
this.treemap.off(Browser.touchMoveEvent, this.mouseMove);
|
|
307
|
-
}
|
|
308
|
-
|
|
309
|
-
/**
|
|
310
|
-
* Get module name.
|
|
311
|
-
*
|
|
312
|
-
* @returns {string} - Returns the module name
|
|
313
|
-
*/
|
|
314
|
-
protected getModuleName(): string {
|
|
315
|
-
return 'treeMapHighlight';
|
|
316
|
-
}
|
|
317
|
-
/**
|
|
318
|
-
* To destroy the hightlight.
|
|
319
|
-
*
|
|
320
|
-
* @returns {void}
|
|
321
|
-
* @private
|
|
322
|
-
*/
|
|
323
|
-
public destroy(): void {
|
|
324
|
-
this.shapeElement = null;
|
|
325
|
-
this.shapeHighlightCollection = [];
|
|
326
|
-
this.legendHighlightCollection = [];
|
|
327
|
-
this.currentElement = [];
|
|
328
|
-
this.removeEventListener();
|
|
329
|
-
this.treemap = null;
|
|
330
|
-
}
|
|
331
|
-
}
|
|
332
|
-
/**
|
|
333
|
-
* Performing treemap selection
|
|
334
|
-
*/
|
|
335
|
-
export class TreeMapSelection {
|
|
336
|
-
private treemap: TreeMap;
|
|
337
|
-
public legendSelectId: string;
|
|
338
|
-
public shapeSelectId: string;
|
|
339
|
-
public shapeElement: Element;
|
|
340
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
341
|
-
public shapeSelectionCollection: any[] = [];
|
|
342
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
343
|
-
public legendSelectionCollection: any[] = [];
|
|
344
|
-
public shapeSelect: boolean = true;
|
|
345
|
-
public legendSelect: boolean = true;
|
|
346
|
-
constructor(treeMap: TreeMap) {
|
|
347
|
-
this.treemap = treeMap;
|
|
348
|
-
this.addEventListener();
|
|
349
|
-
}
|
|
350
|
-
|
|
351
|
-
/**
|
|
352
|
-
* Mouse down event in selection
|
|
353
|
-
*
|
|
354
|
-
* @param {PointerEvent} e - Specifies the pointer argument.
|
|
355
|
-
* @returns {void}
|
|
356
|
-
* @private
|
|
357
|
-
*/
|
|
358
|
-
public mouseDown(e: PointerEvent | KeyboardEvent): void {
|
|
359
|
-
const targetEle: Element = <Element>e.target;
|
|
360
|
-
e.preventDefault();
|
|
361
|
-
this.selectionOnMouseDown(targetEle);
|
|
362
|
-
}
|
|
363
|
-
|
|
364
|
-
/**
|
|
365
|
-
* This method selects the target element for mouse down event.
|
|
366
|
-
*
|
|
367
|
-
* @param {Element} targetEle - Specifies the target element that was clicked.
|
|
368
|
-
* @returns {void}
|
|
369
|
-
* @private
|
|
370
|
-
*/
|
|
371
|
-
public selectionOnMouseDown(targetEle: Element): void {
|
|
372
|
-
let eventArgs: IItemSelectedEventArgs;
|
|
373
|
-
const treemap: TreeMap = this.treemap;
|
|
374
|
-
(targetEle as HTMLElement).setAttribute('tabindex', '-1');
|
|
375
|
-
(targetEle as HTMLElement).style.outline = 'none';
|
|
376
|
-
if (!targetEle.id.includes('Legend_Shape_Index')) {
|
|
377
|
-
(targetEle as HTMLElement).focus();
|
|
378
|
-
}
|
|
379
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
380
|
-
const items: any[] = []; const targetId: string = targetEle.id; const labelText : string = (targetEle as HTMLElement).innerHTML;
|
|
381
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
382
|
-
let item: any; const selectionElements: Element[] = [];
|
|
383
|
-
let treeMapElement: Element; let element: Element; let orders: string[];
|
|
384
|
-
const selection: SelectionSettingsModel = treemap.selectionSettings;
|
|
385
|
-
const highlightModule: TreeMapHighlight = this.treemap.treeMapHighlightModule;
|
|
386
|
-
const layoutID: string = treemap.element.id + '_TreeMap_' + treemap.layoutType + '_Layout';
|
|
387
|
-
item = treemap.layout.renderItems[parseFloat(targetId.split('_Item_Index_')[1])];
|
|
388
|
-
const isDrillItem: boolean = (item && !item.isLeafItem && treemap.enableDrillDown) &&
|
|
389
|
-
(targetEle.textContent.indexOf('[+]') > -1 || targetEle.textContent.indexOf('[-]') > -1 ||
|
|
390
|
-
(!isNullOrUndefined(targetEle.nextElementSibling) &&
|
|
391
|
-
(targetEle.nextSibling.textContent.indexOf('[+]') > -1 || targetEle.nextSibling.textContent.indexOf('[-]') > -1)));
|
|
392
|
-
if (targetId.indexOf('_Item_Index') > -1 && !isDrillItem) {
|
|
393
|
-
if ((this.treemap.selectionId !== targetId &&
|
|
394
|
-
(treemap.selectionId ? parseFloat(treemap.selectionId.split('_Item_Index_')[1]) !== parseFloat(targetId.split('_Item_Index_')[1]) : true)) ||
|
|
395
|
-
(this.legendSelectionCollection[0] ? this.legendSelectionCollection[0]['ShapeCollection']['Elements'].length > 1 : false)) {
|
|
396
|
-
treemap.levelSelection = [];
|
|
397
|
-
treemap.legendId = [];
|
|
398
|
-
this.shapeSelectId = '';
|
|
399
|
-
removeLegend(this.legendSelectionCollection, treemap);
|
|
400
|
-
this.legendSelectionCollection = [];
|
|
401
|
-
treeMapElement = document.getElementById(layoutID);
|
|
402
|
-
let index: number;
|
|
403
|
-
if (this.treemap.legendSettings.visible) {
|
|
404
|
-
this.shapeSelect = false;
|
|
405
|
-
const length: number = this.treemap.treeMapLegendModule.legendCollections.length;
|
|
406
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
407
|
-
const collection: any[] = this.treemap.treeMapLegendModule.legendCollections;
|
|
408
|
-
this.shapeElement = undefined;
|
|
409
|
-
removeLegend(this.shapeSelectionCollection, treemap);
|
|
410
|
-
if (highlightModule) {
|
|
411
|
-
highlightModule.shapeTarget = 'selection';
|
|
412
|
-
highlightModule.shapeHighlightCollection = [];
|
|
413
|
-
}
|
|
414
|
-
index = (!treemap.legendSettings.removeDuplicateLegend && treemap.palette && treemap.palette.length > 0 &&
|
|
415
|
-
treemap.leafItemSettings.colorMapping.length === 0
|
|
416
|
-
&& treemap.levels.length === 0) ?
|
|
417
|
-
parseFloat(targetId.split('_Item_Index_')[1]) : getLegendIndex(length, item, treemap);
|
|
418
|
-
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);
|
|
419
|
-
if (this.shapeElement !== null) {
|
|
420
|
-
this.shapeSelectId = this.shapeElement.getAttribute('id');
|
|
421
|
-
this.shapeSelectionCollection.push({ legendEle: this.shapeElement, oldFill: collection[index as number]['legendFill'],
|
|
422
|
-
oldOpacity: collection[index as number]['opacity'], oldBorderColor: collection[index as number]['borderColor'],
|
|
423
|
-
oldBorderWidth: collection[index as number]['borderWidth']
|
|
424
|
-
});
|
|
425
|
-
const legendText: Element = this.treemap.legendSettings.mode === 'Default' ? document.getElementById(this.treemap.element.id + '_Legend_Text_Index_' + index)
|
|
426
|
-
: document.getElementById(this.treemap.element.id + '_Legend_Index_' + index + '_Text');
|
|
427
|
-
setColor(
|
|
428
|
-
legendText, selection.fill, selection.opacity, null,
|
|
429
|
-
null);
|
|
430
|
-
setColor(
|
|
431
|
-
this.shapeElement, selection.fill, selection.opacity, selection.border.color,
|
|
432
|
-
selection.border.width.toString());
|
|
433
|
-
treemap.legendId.push(this.shapeElement.id);
|
|
434
|
-
treemap.legendId.push(legendText.id);
|
|
435
|
-
}
|
|
436
|
-
}
|
|
437
|
-
orders = findHightLightItems(item, [], selection.mode, treemap);
|
|
438
|
-
for (let i: number = 0; i < treeMapElement.childElementCount; i++) {
|
|
439
|
-
element = treeMapElement.childNodes[i as number] as Element;
|
|
440
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
441
|
-
const targetItem: any = treemap.layout.renderItems[parseFloat(targetId.split('_Item_Index_')[1])];
|
|
442
|
-
item = treemap.layout.renderItems[parseFloat(element.id.split('_Item_Index_')[1])];
|
|
443
|
-
const valuePath: string = (treemap.rangeColorValuePath !== '') ? treemap.rangeColorValuePath : null;
|
|
444
|
-
if (orders.indexOf(item['levelOrderName']) > -1 &&
|
|
445
|
-
(!isNullOrUndefined(valuePath) ?
|
|
446
|
-
(item['data'][valuePath as string] === targetItem['data'][valuePath as string] ||
|
|
447
|
-
(selection.mode !== 'Item' && treemap.levels.length > 0)
|
|
448
|
-
) : true)) {
|
|
449
|
-
selectionElements.push(element);
|
|
450
|
-
if (targetId.indexOf('_RectPath') > -1) {
|
|
451
|
-
treemap.levelSelection.push(element.id);
|
|
452
|
-
}
|
|
453
|
-
items.push(item);
|
|
454
|
-
}
|
|
455
|
-
}
|
|
456
|
-
removeClassNames(document.getElementsByClassName('treeMapSelection'), 'treeMapSelection', treemap);
|
|
457
|
-
this.treemap.selectionId = targetId;
|
|
458
|
-
const highLightElements: HTMLCollection = document.getElementsByClassName('treeMapHighLight');
|
|
459
|
-
for (let k: number = 0; k < selectionElements.length; k++) {
|
|
460
|
-
element = selectionElements[k as number];
|
|
461
|
-
if (highLightElements.length > 0) {
|
|
462
|
-
for (let j: number = 0; j < highLightElements.length; j++) {
|
|
463
|
-
if (highLightElements[j as number].id === element.id) {
|
|
464
|
-
highLightElements[j as number].classList.remove('treeMapHighLight');
|
|
465
|
-
}
|
|
466
|
-
applyOptions(
|
|
467
|
-
element.childNodes[0] as SVGPathElement,
|
|
468
|
-
{ border: selection.border, fill: selection.fill, opacity: selection.opacity }
|
|
469
|
-
);
|
|
470
|
-
element.classList.add('treeMapSelection');
|
|
471
|
-
}
|
|
472
|
-
} else {
|
|
473
|
-
applyOptions(
|
|
474
|
-
element.childNodes[0] as SVGPathElement,
|
|
475
|
-
{ border: selection.border, fill: selection.fill, opacity: selection.opacity }
|
|
476
|
-
);
|
|
477
|
-
element.classList.add('treeMapSelection');
|
|
478
|
-
}
|
|
479
|
-
eventArgs = { cancel: false, name: itemSelected, treemap: treemap, items: items, elements: selectionElements,
|
|
480
|
-
text : labelText, contentItemTemplate : labelText };
|
|
481
|
-
treemap.trigger(itemSelected, eventArgs, (observedArgs: IItemSelectedEventArgs) => {
|
|
482
|
-
if (observedArgs.contentItemTemplate !== labelText) {
|
|
483
|
-
setItemTemplateContent(targetId, targetEle, observedArgs.contentItemTemplate);
|
|
484
|
-
}
|
|
485
|
-
});
|
|
486
|
-
}
|
|
487
|
-
} else {
|
|
488
|
-
removeLegend(this.legendSelectionCollection, treemap);
|
|
489
|
-
removeLegend(this.shapeSelectionCollection, treemap);
|
|
490
|
-
this.treemap.legendId = [];
|
|
491
|
-
this.shapeSelectionCollection = [];
|
|
492
|
-
this.legendSelectionCollection = [];
|
|
493
|
-
this.shapeElement = undefined;
|
|
494
|
-
this.shapeSelect = true;
|
|
495
|
-
this.shapeSelectId = '';
|
|
496
|
-
this.treemap.levelSelection = [];
|
|
497
|
-
this.legendSelectId = '';
|
|
498
|
-
if (this.legendSelect || this.shapeSelect) {
|
|
499
|
-
removeClassNames(document.getElementsByClassName('treeMapSelection'), 'treeMapSelection', treemap);
|
|
500
|
-
this.treemap.selectionId = '';
|
|
501
|
-
}
|
|
502
|
-
}
|
|
503
|
-
} else if (targetId.indexOf('_Legend_Shape') > -1 || targetId.indexOf('_Legend_Index') > -1 || targetId.indexOf('_Legend_Text_') > -1) {
|
|
504
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
505
|
-
const collection: any[] = this.treemap.treeMapLegendModule.legendCollections;
|
|
506
|
-
const legendSelectIdIndex: number = !isNullOrUndefined(this.legendSelectId) ? parseFloat(this.legendSelectId.split('_Index_')[1]) : null;
|
|
507
|
-
if (this.treemap.legendSettings.visible && (legendSelectIdIndex !== parseFloat(targetId.split('_Index_')[1]))) {
|
|
508
|
-
let itemIndex: number;
|
|
509
|
-
let groupIndex: number;
|
|
510
|
-
let length: number;
|
|
511
|
-
treemap.legendId = [];
|
|
512
|
-
treemap.levelSelection = [];
|
|
513
|
-
this.legendSelectId = targetId;
|
|
514
|
-
this.legendSelect = false;
|
|
515
|
-
const legendIndex: number = !isNaN(parseInt(targetId[targetId.length - 1], 10)) ?
|
|
516
|
-
parseInt(targetId[targetId.length - 1], 10) :
|
|
517
|
-
parseInt(targetId[targetId.length - 6], 10);
|
|
518
|
-
const targetEle: Element = document.getElementById(targetId);
|
|
519
|
-
removeLegend(this.legendSelectionCollection, treemap);
|
|
520
|
-
removeClassNames(document.getElementsByClassName('treeMapSelection'), 'treeMapSelection', treemap);
|
|
521
|
-
removeLegend(this.shapeSelectionCollection, treemap);
|
|
522
|
-
this.legendSelectionCollection = [];
|
|
523
|
-
if (highlightModule) {
|
|
524
|
-
highlightModule.shapeTarget = 'selection';
|
|
525
|
-
highlightModule.legendHighlightCollection = [];
|
|
526
|
-
}
|
|
527
|
-
const valuePath: string = (treemap.rangeColorValuePath !== '') ? treemap.rangeColorValuePath : null;
|
|
528
|
-
const index: number = this.treemap.legendSettings.mode === 'Default' ? (targetId.indexOf('Text') === -1 ? parseFloat(targetId.split('_Legend_Shape_Index_')[1]) : parseFloat(targetId.split('_Legend_Text_Index_')[1]))
|
|
529
|
-
: parseFloat(targetId.split('_Legend_Index_')[1]);
|
|
530
|
-
const dataLength: number = this.treemap.treeMapLegendModule.legendCollections[index as number]['legendData'].length;
|
|
531
|
-
for (let k: number = 0; k < dataLength; k++) {
|
|
532
|
-
for (let l: number = 0; l < this.treemap.layout.renderItems.length; l++) {
|
|
533
|
-
if ((!isNullOrUndefined(valuePath) && treemap.leafItemSettings.colorMapping.length > 0 &&
|
|
534
|
-
treemap.levels.length === 0) ?
|
|
535
|
-
(treemap.treeMapLegendModule.legendCollections[index as number]['legendData'][k as number]['data'][valuePath as string] === treemap.layout.renderItems[l as number]['data'][valuePath as string])
|
|
536
|
-
: (this.treemap.treeMapLegendModule.legendCollections[index as number]['legendData'][k as number]['levelOrderName'] === this.treemap.layout.renderItems[l as number]['levelOrderName'])) {
|
|
537
|
-
itemIndex = l;
|
|
538
|
-
groupIndex = this.treemap.layout.renderItems[l as number]['groupIndex'];
|
|
539
|
-
const nodeEle: Element = document.getElementById(this.treemap.element.id + '_Level_Index_' + groupIndex + '_Item_Index_' + itemIndex + '_RectPath');
|
|
540
|
-
this.treemap.selectionId = nodeEle.id;
|
|
541
|
-
if (k === 0 || this.legendSelectionCollection.length === 0) {
|
|
542
|
-
pushCollection(
|
|
543
|
-
this.legendSelectionCollection, legendIndex, l, targetEle, nodeEle,
|
|
544
|
-
this.treemap.layout.renderItems, collection);
|
|
545
|
-
length = this.legendSelectionCollection.length;
|
|
546
|
-
this.legendSelectionCollection[length - 1]['ShapeCollection'] = { Elements: [] };
|
|
547
|
-
}
|
|
548
|
-
this.treemap.selectionId = nodeEle.id;
|
|
549
|
-
let legendShape: Element; let legendText: Element;
|
|
550
|
-
if (targetEle.id.indexOf('Text') > -1) {
|
|
551
|
-
legendShape = this.treemap.legendSettings.mode === 'Interactive' ? document.getElementById(targetEle.id.replace('_Text', ''))
|
|
552
|
-
: document.getElementById(this.treemap.element.id + '_Legend_Shape_Index_' + index);
|
|
553
|
-
setColor(legendShape, selection.fill, selection.opacity, selection.border.color,
|
|
554
|
-
selection.border.width.toString());
|
|
555
|
-
setColor(targetEle, selection.fill, selection.opacity, null, null);
|
|
556
|
-
this.legendSelectId = legendShape.id;
|
|
557
|
-
this.shapeElement = legendShape;
|
|
558
|
-
treemap.legendId.push(targetEle.id);
|
|
559
|
-
treemap.legendId.push(legendShape.id);
|
|
560
|
-
} else {
|
|
561
|
-
legendText = this.treemap.legendSettings.mode === 'Interactive' ? document.getElementById(targetEle.id + '_Text')
|
|
562
|
-
: document.getElementById(this.treemap.element.id + '_Legend_Text_Index_' + index);
|
|
563
|
-
setColor(legendText, selection.fill, selection.opacity, null, null);
|
|
564
|
-
setColor(targetEle, selection.fill, selection.opacity, selection.border.color,
|
|
565
|
-
selection.border.width.toString());
|
|
566
|
-
this.shapeElement = targetEle;
|
|
567
|
-
treemap.legendId.push(targetEle.id);
|
|
568
|
-
treemap.legendId.push(legendText.id);
|
|
569
|
-
}
|
|
570
|
-
setColor(
|
|
571
|
-
nodeEle, selection.fill, selection.opacity, selection.border.color,
|
|
572
|
-
selection.border.width.toString());
|
|
573
|
-
length = this.legendSelectionCollection.length;
|
|
574
|
-
treemap.levelSelection.push(nodeEle.id);
|
|
575
|
-
this.legendSelectionCollection[length - 1]['ShapeCollection']['Elements'].push(nodeEle);
|
|
576
|
-
}
|
|
577
|
-
}
|
|
578
|
-
}
|
|
579
|
-
if (dataLength === 0 && this.treemap.palette && this.treemap.palette.length > 0) {
|
|
580
|
-
for (let j: number = 0; j < this.treemap.layout.renderItems.length; j++) {
|
|
581
|
-
if ( (this.treemap.treeMapLegendModule.legendCollections[index as number]['levelOrderName'] === this.treemap.layout.renderItems[j as number]['levelOrderName'] ||
|
|
582
|
-
this.treemap.layout.renderItems[j as number]['levelOrderName'].indexOf(this.treemap.treeMapLegendModule.legendCollections[index as number]['levelOrderName']) > -1) &&
|
|
583
|
-
((!this.treemap.legendSettings.removeDuplicateLegend && treemap.palette && treemap.palette.length > 0 &&
|
|
584
|
-
!this.treemap.layout.renderItems[j as number].parent.isDrilled) ?
|
|
585
|
-
index === j : true)) {
|
|
586
|
-
itemIndex = j;
|
|
587
|
-
groupIndex = this.treemap.layout.renderItems[j as number]['groupIndex'];
|
|
588
|
-
const nodeEle: Element = document.getElementById(this.treemap.element.id + '_Level_Index_' + groupIndex + '_Item_Index_' + itemIndex + '_RectPath');
|
|
589
|
-
pushCollection(
|
|
590
|
-
this.legendSelectionCollection, index, j, targetEle, nodeEle,
|
|
591
|
-
this.treemap.layout.renderItems, collection);
|
|
592
|
-
this.treemap.selectionId = nodeEle.id;
|
|
593
|
-
length = this.legendSelectionCollection.length;
|
|
594
|
-
this.legendSelectionCollection[length - 1]['ShapeCollection'] = { Elements: [] };
|
|
595
|
-
let legendItem: Element;
|
|
596
|
-
if (targetEle.id.indexOf('Text') > -1) {
|
|
597
|
-
legendItem = this.treemap.legendSettings.mode === 'Interactive' ? document.getElementById(targetEle.id.replace('_Text', ''))
|
|
598
|
-
: document.getElementById(this.treemap.element.id + '_Legend_Shape_Index_' + index);
|
|
599
|
-
setColor(targetEle, selection.fill, selection.opacity, null, null);
|
|
600
|
-
setColor(legendItem, selection.fill, selection.opacity, selection.border.color,
|
|
601
|
-
selection.border.width.toString());
|
|
602
|
-
this.legendSelectId = legendItem.id;
|
|
603
|
-
this.shapeElement = legendItem;
|
|
604
|
-
} else {
|
|
605
|
-
legendItem = this.treemap.legendSettings.mode === 'Interactive' ? document.getElementById(targetEle.id + '_Text')
|
|
606
|
-
: document.getElementById(this.treemap.element.id + '_Legend_Text_Index_' + index);
|
|
607
|
-
setColor(legendItem, selection.fill, selection.opacity, null, null);
|
|
608
|
-
setColor(targetEle, selection.fill, selection.opacity, selection.border.color,
|
|
609
|
-
selection.border.width.toString());
|
|
610
|
-
this.legendSelectId = targetId;
|
|
611
|
-
this.shapeElement = targetEle;
|
|
612
|
-
}
|
|
613
|
-
setColor(
|
|
614
|
-
nodeEle, selection.fill, selection.opacity, selection.border.color,
|
|
615
|
-
selection.border.width.toString());
|
|
616
|
-
treemap.levelSelection.push(nodeEle.id);
|
|
617
|
-
if (treemap.legendId.indexOf(legendItem.id) === -1) {
|
|
618
|
-
treemap.legendId.push(legendItem.id);
|
|
619
|
-
}
|
|
620
|
-
if (treemap.legendId.indexOf(targetEle.id) === -1) {
|
|
621
|
-
treemap.legendId.push(targetEle.id);
|
|
622
|
-
}
|
|
623
|
-
length = this.legendSelectionCollection.length;
|
|
624
|
-
this.legendSelectionCollection[length - 1]['ShapeCollection']['Elements'].push(nodeEle);
|
|
625
|
-
}
|
|
626
|
-
}
|
|
627
|
-
}
|
|
628
|
-
} else {
|
|
629
|
-
removeLegend(this.legendSelectionCollection, this.treemap);
|
|
630
|
-
removeLegend(this.shapeSelectionCollection, this.treemap);
|
|
631
|
-
this.legendSelectionCollection = [];
|
|
632
|
-
if (highlightModule) { highlightModule.shapeTarget = 'highlight'; }
|
|
633
|
-
this.legendSelect = true;
|
|
634
|
-
this.legendSelectId = '';
|
|
635
|
-
this.treemap.legendId = [];
|
|
636
|
-
this.treemap.levelSelection = [];
|
|
637
|
-
this.shapeElement = null;
|
|
638
|
-
this.shapeSelectId = '';
|
|
639
|
-
if (this.legendSelect || this.shapeSelect) {
|
|
640
|
-
removeClassNames(document.getElementsByClassName('treeMapSelection'), 'treeMapSelection', treemap);
|
|
641
|
-
this.treemap.selectionId = '';
|
|
642
|
-
}
|
|
643
|
-
}
|
|
644
|
-
} else if (isDrillItem) {
|
|
645
|
-
removeLegend(this.legendSelectionCollection, this.treemap);
|
|
646
|
-
this.legendSelectionCollection = [];
|
|
647
|
-
this.legendSelect = true;
|
|
648
|
-
this.legendSelectId = '';
|
|
649
|
-
this.treemap.legendId = [];
|
|
650
|
-
this.treemap.levelSelection = [];
|
|
651
|
-
this.treemap.selectionId = '';
|
|
652
|
-
this.shapeElement = null;
|
|
653
|
-
}
|
|
654
|
-
}
|
|
655
|
-
|
|
656
|
-
/**
|
|
657
|
-
* @param {string} levelOrder - Specifies the level order of treemap item
|
|
658
|
-
* @param {boolean} enable - Specifies the boolean value
|
|
659
|
-
* @returns {void}
|
|
660
|
-
* @private
|
|
661
|
-
*/
|
|
662
|
-
public selectTreemapItem(levelOrder: string, enable: boolean): void {
|
|
663
|
-
if (enable) {
|
|
664
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
665
|
-
let item: any;
|
|
666
|
-
for (let s: number = 0; s < this.treemap.layout.renderItems.length; s++) {
|
|
667
|
-
if (levelOrder === this.treemap.layout.renderItems[s as number]['levelOrderName']) {
|
|
668
|
-
item = this.treemap.layout.renderItems[s as number];
|
|
669
|
-
break;
|
|
670
|
-
}
|
|
671
|
-
}
|
|
672
|
-
const selection: SelectionSettingsModel = this.treemap.selectionSettings;
|
|
673
|
-
const selectionElements: Element[] = [];
|
|
674
|
-
let element: Element;
|
|
675
|
-
let index: number;
|
|
676
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
677
|
-
const items: any[] = [];
|
|
678
|
-
this.treemap.levelSelection = [];
|
|
679
|
-
const layoutID: string = this.treemap.element.id + '_TreeMap_' + this.treemap.layoutType + '_Layout';
|
|
680
|
-
const treeMapElement: Element = document.getElementById(layoutID);
|
|
681
|
-
const orders: string[] = findHightLightItems(item, [], selection.mode, this.treemap);
|
|
682
|
-
for (let i: number = 0; i < treeMapElement.childElementCount; i++) {
|
|
683
|
-
element = treeMapElement.childNodes[i as number] as Element;
|
|
684
|
-
item = this.treemap.layout.renderItems[parseFloat(element.id.split('_Item_Index_')[1])];
|
|
685
|
-
if (orders.indexOf(item['levelOrderName']) > -1) {
|
|
686
|
-
selectionElements.push(element);
|
|
687
|
-
this.treemap.levelSelection.push(element.id);
|
|
688
|
-
items.push(item);
|
|
689
|
-
}
|
|
690
|
-
}
|
|
691
|
-
if (this.treemap.legendSettings.visible) {
|
|
692
|
-
for (let m: number = 0; m < items.length; m++) {
|
|
693
|
-
this.shapeSelect = false;
|
|
694
|
-
const length: number = this.treemap.treeMapLegendModule.legendCollections.length;
|
|
695
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
696
|
-
const collection: any[] = this.treemap.treeMapLegendModule.legendCollections;
|
|
697
|
-
this.shapeElement = undefined;
|
|
698
|
-
removeShape(this.shapeSelectionCollection);
|
|
699
|
-
index = getLegendIndex(length, items[m as number], this.treemap);
|
|
700
|
-
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);
|
|
701
|
-
if (this.shapeElement !== null) {
|
|
702
|
-
this.shapeSelectId = this.shapeElement.getAttribute('id');
|
|
703
|
-
this.treemap.legendId.push(this.shapeSelectId);
|
|
704
|
-
this.shapeSelectionCollection.push({
|
|
705
|
-
legendEle: this.shapeElement, oldFill: collection[index as number]['legendFill'],
|
|
706
|
-
oldOpacity: collection[index as number]['opacity'], oldBorderColor: collection[index as number]['borderColor'],
|
|
707
|
-
oldBorderWidth: collection[index as number]['borderWidth']
|
|
708
|
-
});
|
|
709
|
-
setColor(
|
|
710
|
-
this.shapeElement, selection.fill, selection.opacity, selection.border.color,
|
|
711
|
-
selection.border.width.toString());
|
|
712
|
-
}
|
|
713
|
-
}
|
|
714
|
-
}
|
|
715
|
-
removeClassNames(document.getElementsByClassName('treeMapSelection'), 'treeMapSelection', this.treemap);
|
|
716
|
-
const selectionElement: Element = document.getElementById(this.treemap.levelSelection[0]);
|
|
717
|
-
this.treemap.selectionId = selectionElement.childNodes[0]['id'];
|
|
718
|
-
const highLightElements: HTMLCollection = document.getElementsByClassName('treeMapHighLight');
|
|
719
|
-
for (let k: number = 0; k < selectionElements.length; k++) {
|
|
720
|
-
element = selectionElements[k as number];
|
|
721
|
-
if (highLightElements.length > 0) {
|
|
722
|
-
for (let j: number = 0; j < highLightElements.length; j++) {
|
|
723
|
-
if (highLightElements[j as number].id === element.id) {
|
|
724
|
-
highLightElements[j as number].classList.remove('treeMapHighLight');
|
|
725
|
-
}
|
|
726
|
-
applyOptions(
|
|
727
|
-
element.childNodes[0] as SVGPathElement,
|
|
728
|
-
{ border: selection.border, fill: selection.fill, opacity: selection.opacity }
|
|
729
|
-
);
|
|
730
|
-
element.classList.add('treeMapSelection');
|
|
731
|
-
}
|
|
732
|
-
} else {
|
|
733
|
-
selection.fill = selection.fill === 'null' ?
|
|
734
|
-
this.treemap.layout.renderItems[parseInt(element.id.split('Item_Index_')[1], 10)]['options']['fill']
|
|
735
|
-
: selection.fill;
|
|
736
|
-
applyOptions(
|
|
737
|
-
element.childNodes[0] as SVGPathElement,
|
|
738
|
-
{ border: selection.border, fill: selection.fill, opacity: selection.opacity }
|
|
739
|
-
);
|
|
740
|
-
element.classList.add('treeMapSelection');
|
|
741
|
-
}
|
|
742
|
-
}
|
|
743
|
-
} else {
|
|
744
|
-
removeShape(this.shapeSelectionCollection);
|
|
745
|
-
this.shapeElement = undefined;
|
|
746
|
-
this.treemap.levelSelection = [];
|
|
747
|
-
this.shapeSelect = true;
|
|
748
|
-
this.shapeSelectId = '';
|
|
749
|
-
this.treemap.legendId = [];
|
|
750
|
-
removeClassNames(document.getElementsByClassName('treeMapSelection'), 'treeMapSelection', this.treemap);
|
|
751
|
-
this.treemap.selectionId = '';
|
|
752
|
-
}
|
|
753
|
-
}
|
|
754
|
-
|
|
755
|
-
/**
|
|
756
|
-
* To bind events for selection
|
|
757
|
-
*
|
|
758
|
-
* @returns {void}
|
|
759
|
-
*/
|
|
760
|
-
private addEventListener(): void {
|
|
761
|
-
if (this.treemap.isDestroyed) {
|
|
762
|
-
return;
|
|
763
|
-
}
|
|
764
|
-
this.treemap.on(Browser.touchStartEvent, this.mouseDown, this);
|
|
765
|
-
}
|
|
766
|
-
/**
|
|
767
|
-
* To unbind events for selection
|
|
768
|
-
*
|
|
769
|
-
* @returns {void}
|
|
770
|
-
*/
|
|
771
|
-
private removeEventListener(): void {
|
|
772
|
-
if (this.treemap.isDestroyed) {
|
|
773
|
-
return;
|
|
774
|
-
}
|
|
775
|
-
this.treemap.off(Browser.touchStartEvent, this.mouseDown);
|
|
776
|
-
}
|
|
777
|
-
|
|
778
|
-
/**
|
|
779
|
-
* Get module name.
|
|
780
|
-
*
|
|
781
|
-
* @returns {string} - Returns the module name.
|
|
782
|
-
*/
|
|
783
|
-
protected getModuleName(): string {
|
|
784
|
-
return 'treeMapSelection';
|
|
785
|
-
}
|
|
786
|
-
/**
|
|
787
|
-
* To destroy the selection.
|
|
788
|
-
*
|
|
789
|
-
* @returns {void}
|
|
790
|
-
* @private
|
|
791
|
-
*/
|
|
792
|
-
public destroy(): void {
|
|
793
|
-
this.shapeElement = null;
|
|
794
|
-
this.shapeSelectionCollection = [];
|
|
795
|
-
this.legendSelectionCollection = [];
|
|
796
|
-
this.removeEventListener();
|
|
797
|
-
this.treemap = null;
|
|
798
|
-
}
|
|
799
|
-
}
|