@syncfusion/ej2-treemap 31.1.17 → 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 +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 +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 +3 -3
- package/dist/global/ej2-treemap.min.js.map +1 -1
- package/dist/global/index.d.ts +2 -2
- 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,1817 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Tree Map Components
|
|
3
|
-
*/
|
|
4
|
-
|
|
5
|
-
import { Component, NotifyPropertyChanges, INotifyPropertyChanged, Property, extend, Fetch, SanitizeHtmlHelper } from '@syncfusion/ej2-base';
|
|
6
|
-
import { Complex, Collection, ModuleDeclaration } from '@syncfusion/ej2-base';
|
|
7
|
-
import { Event, EmitType, Internationalization } from '@syncfusion/ej2-base';
|
|
8
|
-
import { SvgRenderer } from '@syncfusion/ej2-svg-base';
|
|
9
|
-
import { isNullOrUndefined, createElement, EventHandler, Browser, remove } from '@syncfusion/ej2-base';
|
|
10
|
-
import { BorderModel, TitleSettingsModel, MarginModel, LevelSettingsModel, FontModel } from './model/base-model';
|
|
11
|
-
import { LeafItemSettingsModel, TooltipSettingsModel, LegendSettingsModel, InitialDrillSettingsModel } from './model/base-model';
|
|
12
|
-
import { HighlightSettingsModel, SelectionSettingsModel } from './model/base-model';
|
|
13
|
-
import { Border, Margin, TitleSettings, LegendSettings, InitialDrillSettings } from './model/base';
|
|
14
|
-
import { SelectionSettings, TooltipSettings, LevelSettings, LeafItemSettings, HighlightSettings } from './model/base';
|
|
15
|
-
import { TreeMapModel } from './treemap-model';
|
|
16
|
-
import { LayoutMode, TreeMapTheme, RenderingMode } from './utils/enum';
|
|
17
|
-
import { ILoadEventArgs, ILoadedEventArgs, IPrintEventArgs } from '../treemap/model/interface';
|
|
18
|
-
import { ILegendItemRenderingEventArgs, ILegendRenderingEventArgs } from '../treemap/model/interface';
|
|
19
|
-
import { IItemRenderingEventArgs, IResizeEventArgs, IDoubleClickEventArgs, IRightClickEventArgs } from '../treemap/model/interface';
|
|
20
|
-
import { IItemClickEventArgs, IItemMoveEventArgs, IClickEventArgs, IMouseMoveEventArgs } from '../treemap/model/interface';
|
|
21
|
-
import { IDrillStartEventArgs, IItemSelectedEventArgs, ITreeMapTooltipRenderEventArgs } from '../treemap/model/interface';
|
|
22
|
-
import { IItemHighlightEventArgs, IDrillEndEventArgs, IThemeStyle } from '../treemap/model/interface';
|
|
23
|
-
import { Size, stringToNumber, RectOption, Rect, textTrim, measureText, findChildren, removeElement, setItemTemplateContent, legendMaintain, removeLegend } from '../treemap/utils/helper';
|
|
24
|
-
import { removeClassNames, textFormatter } from '../treemap/utils/helper';
|
|
25
|
-
import { findPosition, Location, TextOption, renderTextElement, isContainsData, TreeMapAjax } from '../treemap/utils/helper';
|
|
26
|
-
import { load, loaded, drillStart, drillEnd } from '../treemap/model/constants';
|
|
27
|
-
import { itemClick, itemMove, click, mouseMove, resize, doubleClick, rightClick } from '../treemap/model/constants';
|
|
28
|
-
import { LayoutPanel } from './layout/render-panel';
|
|
29
|
-
import { TreeMapTooltip } from './user-interaction/tooltip';
|
|
30
|
-
import { ExportType } from '../treemap/utils/enum';
|
|
31
|
-
import { PdfPageOrientation } from '@syncfusion/ej2-pdf-export';
|
|
32
|
-
import { TreeMapHighlight, TreeMapSelection } from './user-interaction/highlight-selection';
|
|
33
|
-
import { TreeMapLegend } from './layout/legend';
|
|
34
|
-
import { DataManager, Query } from '@syncfusion/ej2-data';
|
|
35
|
-
import { getThemeStyle } from './model/theme';
|
|
36
|
-
import { Print } from './model/print';
|
|
37
|
-
import { ImageExport } from './model/image-export';
|
|
38
|
-
import { PdfExport } from './model/pdf-export';
|
|
39
|
-
/**
|
|
40
|
-
* Represents the treemap control. It is used to visualize both hierarchical and flat data.
|
|
41
|
-
* ```html
|
|
42
|
-
* <div id="container"/>
|
|
43
|
-
* <script>
|
|
44
|
-
* var treemap = new TreeMap();
|
|
45
|
-
* treemap.appendTo("#container");
|
|
46
|
-
* </script>
|
|
47
|
-
* ```
|
|
48
|
-
*/
|
|
49
|
-
|
|
50
|
-
@NotifyPropertyChanges
|
|
51
|
-
export class TreeMap extends Component<HTMLElement> implements INotifyPropertyChanged {
|
|
52
|
-
//Module Declaration for treemap.
|
|
53
|
-
/**
|
|
54
|
-
* Sets and gets the module that is used to add tooltip in the treemap.
|
|
55
|
-
*
|
|
56
|
-
* @private
|
|
57
|
-
*/
|
|
58
|
-
public treeMapTooltipModule: TreeMapTooltip;
|
|
59
|
-
/**
|
|
60
|
-
* Sets and gets the module that is used to add highlight functionality in the treemap.
|
|
61
|
-
*
|
|
62
|
-
* @private
|
|
63
|
-
*/
|
|
64
|
-
public treeMapHighlightModule: TreeMapHighlight;
|
|
65
|
-
/**
|
|
66
|
-
* Sets and gets the module that is used to add selection functionality in the treemap.
|
|
67
|
-
*
|
|
68
|
-
* @private
|
|
69
|
-
*/
|
|
70
|
-
public treeMapSelectionModule: TreeMapSelection;
|
|
71
|
-
/**
|
|
72
|
-
* Sets and gets the module that is used to add legend in the treemap.
|
|
73
|
-
*
|
|
74
|
-
* @private
|
|
75
|
-
*/
|
|
76
|
-
public treeMapLegendModule: TreeMapLegend;
|
|
77
|
-
/**
|
|
78
|
-
* Sets and gets the module that is used to add print functionality in the treemap.
|
|
79
|
-
*
|
|
80
|
-
* @private
|
|
81
|
-
*/
|
|
82
|
-
public printModule: Print;
|
|
83
|
-
/**
|
|
84
|
-
* Sets and gets the module that is used to add imageExport functionality in the treemap.
|
|
85
|
-
*
|
|
86
|
-
* @private
|
|
87
|
-
*/
|
|
88
|
-
public imageExportModule: ImageExport;
|
|
89
|
-
/**
|
|
90
|
-
* Sets and gets the module that is used to add pdf export functionality in the treemap.
|
|
91
|
-
*
|
|
92
|
-
* @private
|
|
93
|
-
*/
|
|
94
|
-
public pdfExportModule: PdfExport ;
|
|
95
|
-
/**
|
|
96
|
-
* Enables and disables the print functionality in treemap.
|
|
97
|
-
*
|
|
98
|
-
* @default false
|
|
99
|
-
*/
|
|
100
|
-
@Property(false)
|
|
101
|
-
public allowPrint: boolean;
|
|
102
|
-
/**
|
|
103
|
-
* Enables and disables the export to image functionality in treemap.
|
|
104
|
-
*
|
|
105
|
-
* @default false
|
|
106
|
-
*/
|
|
107
|
-
@Property(false)
|
|
108
|
-
public allowImageExport: boolean;
|
|
109
|
-
/**
|
|
110
|
-
* Enables and disables the export to pdf functionality in treemap.
|
|
111
|
-
*
|
|
112
|
-
* @default false
|
|
113
|
-
*/
|
|
114
|
-
@Property(false)
|
|
115
|
-
public allowPdfExport: boolean;
|
|
116
|
-
/**
|
|
117
|
-
* Sets and gets the width of the treemap.
|
|
118
|
-
*
|
|
119
|
-
* @default null
|
|
120
|
-
*/
|
|
121
|
-
@Property(null)
|
|
122
|
-
public width: string;
|
|
123
|
-
/**
|
|
124
|
-
* Sets and gets the height of the treemap.
|
|
125
|
-
*
|
|
126
|
-
* @default null
|
|
127
|
-
*/
|
|
128
|
-
@Property(null)
|
|
129
|
-
public height: string;
|
|
130
|
-
/**
|
|
131
|
-
* Sets and gets the options for customizing the color and width of the treemap border.
|
|
132
|
-
*/
|
|
133
|
-
@Complex<BorderModel>({}, Border)
|
|
134
|
-
public border: BorderModel;
|
|
135
|
-
/**
|
|
136
|
-
* Sets and gets the options for customizing the margin in the treemap.
|
|
137
|
-
*/
|
|
138
|
-
@Complex<MarginModel>({}, Margin)
|
|
139
|
-
public margin: MarginModel;
|
|
140
|
-
/**
|
|
141
|
-
* Sets and gets the background color of the treemap.
|
|
142
|
-
*
|
|
143
|
-
* @default null
|
|
144
|
-
*/
|
|
145
|
-
@Property(null)
|
|
146
|
-
public background: string;
|
|
147
|
-
/**
|
|
148
|
-
* Sets and gets the theme styles supported for treemap. When the theme is set, the styles associated with the theme will be set in the treemap.
|
|
149
|
-
*
|
|
150
|
-
* @default Material
|
|
151
|
-
*/
|
|
152
|
-
@Property('Material')
|
|
153
|
-
public theme: TreeMapTheme;
|
|
154
|
-
/**
|
|
155
|
-
* Sets and gets the options for customizing the title of the treemap.
|
|
156
|
-
*/
|
|
157
|
-
@Complex<TitleSettingsModel>({}, TitleSettings)
|
|
158
|
-
public titleSettings: TitleSettingsModel;
|
|
159
|
-
/**
|
|
160
|
-
* Specifies the rendering type for the layout of the treemap.
|
|
161
|
-
*
|
|
162
|
-
* @default 'Squarified'
|
|
163
|
-
*/
|
|
164
|
-
@Property('Squarified')
|
|
165
|
-
public layoutType: LayoutMode;
|
|
166
|
-
/**
|
|
167
|
-
* Sets and gets the data source for the treemap.
|
|
168
|
-
*
|
|
169
|
-
* @isGenericType true
|
|
170
|
-
* @isObservable true
|
|
171
|
-
* @default null
|
|
172
|
-
*/
|
|
173
|
-
@Property(null)
|
|
174
|
-
public dataSource: DataManager | TreeMapAjax | Object[];
|
|
175
|
-
/**
|
|
176
|
-
* Sets and gets the query to select particular data from the shape data.
|
|
177
|
-
* This property is applicable only when the data source is created by data manager.
|
|
178
|
-
*
|
|
179
|
-
* @default null
|
|
180
|
-
*/
|
|
181
|
-
@Property(null)
|
|
182
|
-
public query: Query;
|
|
183
|
-
/**
|
|
184
|
-
* Sets and gets the value path of the weight from the data source, based on which the treemap item is rendered.
|
|
185
|
-
*
|
|
186
|
-
* @default null
|
|
187
|
-
*/
|
|
188
|
-
@Property(null)
|
|
189
|
-
public weightValuePath: string;
|
|
190
|
-
/**
|
|
191
|
-
* Sets and gets the value path from the data source, based on it color is filled in treemap.
|
|
192
|
-
* This property is used when range color mapping is set in the treemap.
|
|
193
|
-
*
|
|
194
|
-
* @default ''
|
|
195
|
-
*/
|
|
196
|
-
@Property('')
|
|
197
|
-
public rangeColorValuePath: string;
|
|
198
|
-
/**
|
|
199
|
-
* Sets and gets the value path from the data source, based on it color is filled in treemap.
|
|
200
|
-
* This property is used when equal color mapping is set in the treemap.
|
|
201
|
-
*
|
|
202
|
-
* @default ''
|
|
203
|
-
*/
|
|
204
|
-
@Property('')
|
|
205
|
-
public equalColorValuePath: string;
|
|
206
|
-
/**
|
|
207
|
-
* Sets and gets the value path from the data source, based on it color is filled in treemap.
|
|
208
|
-
*
|
|
209
|
-
* @default null
|
|
210
|
-
*/
|
|
211
|
-
@Property(null)
|
|
212
|
-
public colorValuePath: string;
|
|
213
|
-
/**
|
|
214
|
-
* Sets and gets a set of colors to apply in the treemap items.
|
|
215
|
-
*
|
|
216
|
-
* @default []
|
|
217
|
-
*/
|
|
218
|
-
@Property([])
|
|
219
|
-
public palette: string[];
|
|
220
|
-
/**
|
|
221
|
-
* Specifies the rendering direction of layout of the treemap items.
|
|
222
|
-
*
|
|
223
|
-
* @default TopLeftBottomRight
|
|
224
|
-
*/
|
|
225
|
-
@Property('TopLeftBottomRight')
|
|
226
|
-
public renderDirection: RenderingMode;
|
|
227
|
-
/**
|
|
228
|
-
* Enables or disables the drill down functionality in treemap.
|
|
229
|
-
*
|
|
230
|
-
* @default false
|
|
231
|
-
*/
|
|
232
|
-
@Property(false)
|
|
233
|
-
public enableDrillDown: boolean;
|
|
234
|
-
/**
|
|
235
|
-
* Enables or disables the connection text in the header of the treemap when drill down is enabled.
|
|
236
|
-
*
|
|
237
|
-
* @default false
|
|
238
|
-
*/
|
|
239
|
-
@Property(false)
|
|
240
|
-
public enableBreadcrumb: boolean;
|
|
241
|
-
/**
|
|
242
|
-
* Specifies the symbol to show connection between the two words in the header of the treemap during drill down.
|
|
243
|
-
*
|
|
244
|
-
* @default ' - '
|
|
245
|
-
*/
|
|
246
|
-
@Property(' - ')
|
|
247
|
-
public breadcrumbConnector: string;
|
|
248
|
-
/**
|
|
249
|
-
* Enables or disables the initial drill in the treemap.
|
|
250
|
-
*
|
|
251
|
-
* @default false
|
|
252
|
-
*/
|
|
253
|
-
@Property(false)
|
|
254
|
-
public drillDownView: boolean;
|
|
255
|
-
/**
|
|
256
|
-
* Specifies whether to enable the rendering of untrusted HTML values in the TreeMap. If `enableHtmlSanitizer` set to **true**, the component will sanitize any suspected untrusted strings and scripts before rendering them.
|
|
257
|
-
*
|
|
258
|
-
* @default false
|
|
259
|
-
*/
|
|
260
|
-
@Property(false)
|
|
261
|
-
public enableHtmlSanitizer: boolean;
|
|
262
|
-
/**
|
|
263
|
-
* Specifies the options for customizing the initial drill down in treemap.
|
|
264
|
-
*/
|
|
265
|
-
@Complex<InitialDrillSettingsModel>({}, InitialDrillSettings)
|
|
266
|
-
public initialDrillDown: InitialDrillSettingsModel;
|
|
267
|
-
/**
|
|
268
|
-
* Sets and gets the options for customizing the leaf item of the treemap.
|
|
269
|
-
*/
|
|
270
|
-
@Complex<LeafItemSettingsModel>({}, LeafItemSettings)
|
|
271
|
-
public leafItemSettings: LeafItemSettingsModel;
|
|
272
|
-
/**
|
|
273
|
-
* Sets and gets the options to configure and customize the levels of treemap items.
|
|
274
|
-
*/
|
|
275
|
-
@Collection<LevelSettingsModel>([], LevelSettings)
|
|
276
|
-
public levels: LevelSettingsModel[];
|
|
277
|
-
/**
|
|
278
|
-
* Sets and gets the options to customize the highlight functionality of the treemap.
|
|
279
|
-
*/
|
|
280
|
-
@Complex<HighlightSettingsModel>({}, HighlightSettings)
|
|
281
|
-
public highlightSettings: HighlightSettingsModel;
|
|
282
|
-
/**
|
|
283
|
-
* Sets and gets the options for customizing the selection functionality of the treemap.
|
|
284
|
-
*/
|
|
285
|
-
@Complex<SelectionSettingsModel>({}, SelectionSettings)
|
|
286
|
-
public selectionSettings: SelectionSettingsModel;
|
|
287
|
-
/**
|
|
288
|
-
* Sets and gets the options for customizing the tooltip of the treemap.
|
|
289
|
-
*/
|
|
290
|
-
@Complex<TooltipSettingsModel>({}, TooltipSettings)
|
|
291
|
-
public tooltipSettings: TooltipSettingsModel;
|
|
292
|
-
/**
|
|
293
|
-
* Sets and gets the options for customizing the legend of the treemap.
|
|
294
|
-
*/
|
|
295
|
-
@Complex<LegendSettingsModel>({}, LegendSettings)
|
|
296
|
-
public legendSettings: LegendSettingsModel;
|
|
297
|
-
/**
|
|
298
|
-
* Enables or disables the visibility state of the separator for grouping.
|
|
299
|
-
*
|
|
300
|
-
* @default false
|
|
301
|
-
*/
|
|
302
|
-
@Property(false)
|
|
303
|
-
public useGroupingSeparator: boolean;
|
|
304
|
-
/**
|
|
305
|
-
* Sets and gets the description for treemap.
|
|
306
|
-
*
|
|
307
|
-
* @default null
|
|
308
|
-
*/
|
|
309
|
-
@Property(null)
|
|
310
|
-
public description: string;
|
|
311
|
-
|
|
312
|
-
/**
|
|
313
|
-
* Sets and gets the tab index value for treemap.
|
|
314
|
-
*
|
|
315
|
-
* @default 0
|
|
316
|
-
*/
|
|
317
|
-
@Property(0)
|
|
318
|
-
public tabIndex: number;
|
|
319
|
-
/**
|
|
320
|
-
* Sets and gets format for the texts in the treemap. This property accepts any global string format like 'C', 'N1', 'P' etc.
|
|
321
|
-
*
|
|
322
|
-
* @default null
|
|
323
|
-
*/
|
|
324
|
-
@Property(null)
|
|
325
|
-
public format: string;
|
|
326
|
-
/**
|
|
327
|
-
* Triggers before the treemap is rendered.
|
|
328
|
-
*
|
|
329
|
-
* @event load
|
|
330
|
-
*/
|
|
331
|
-
@Event()
|
|
332
|
-
public load: EmitType<ILoadEventArgs>;
|
|
333
|
-
/**
|
|
334
|
-
* Triggers before the print gets started.
|
|
335
|
-
*
|
|
336
|
-
* @event beforePrint
|
|
337
|
-
*/
|
|
338
|
-
@Event()
|
|
339
|
-
public beforePrint: EmitType<IPrintEventArgs>;
|
|
340
|
-
/**
|
|
341
|
-
* Triggers after treemap is rendered.
|
|
342
|
-
*
|
|
343
|
-
* @event loaded
|
|
344
|
-
*/
|
|
345
|
-
@Event()
|
|
346
|
-
public loaded: EmitType<ILoadedEventArgs>;
|
|
347
|
-
/**
|
|
348
|
-
* Triggers before item rendering in the treemap.
|
|
349
|
-
*
|
|
350
|
-
* @event itemRendering
|
|
351
|
-
*/
|
|
352
|
-
@Event()
|
|
353
|
-
public itemRendering: EmitType<IItemRenderingEventArgs>;
|
|
354
|
-
/**
|
|
355
|
-
* Triggers on performing drill down functionality in the treemap.
|
|
356
|
-
*
|
|
357
|
-
* @event drillStart
|
|
358
|
-
*/
|
|
359
|
-
@Event()
|
|
360
|
-
public drillStart: EmitType<IDrillStartEventArgs>;
|
|
361
|
-
/**
|
|
362
|
-
* Triggers after drill down functionality gets completed in the treemap.
|
|
363
|
-
*
|
|
364
|
-
* @event drillEnd
|
|
365
|
-
*/
|
|
366
|
-
@Event()
|
|
367
|
-
public drillEnd: EmitType<IDrillEndEventArgs>;
|
|
368
|
-
/**
|
|
369
|
-
* Triggers after selecting a treemap item.
|
|
370
|
-
*
|
|
371
|
-
* @event itemSelected
|
|
372
|
-
*/
|
|
373
|
-
@Event()
|
|
374
|
-
public itemSelected: EmitType<IItemSelectedEventArgs>;
|
|
375
|
-
/**
|
|
376
|
-
* Triggers after highlighting on the treemap item.
|
|
377
|
-
*
|
|
378
|
-
* @event itemHighlight
|
|
379
|
-
*/
|
|
380
|
-
@Event()
|
|
381
|
-
public itemHighlight: EmitType<IItemHighlightEventArgs>;
|
|
382
|
-
/**
|
|
383
|
-
* Triggers on rendering of the tooltip in the treemap.
|
|
384
|
-
*
|
|
385
|
-
* @event tooltipRendering
|
|
386
|
-
*/
|
|
387
|
-
@Event()
|
|
388
|
-
public tooltipRendering: EmitType<ITreeMapTooltipRenderEventArgs>;
|
|
389
|
-
/**
|
|
390
|
-
* Triggers after clicking an item in the treemap.
|
|
391
|
-
*
|
|
392
|
-
* @event itemClick
|
|
393
|
-
*/
|
|
394
|
-
@Event()
|
|
395
|
-
public itemClick: EmitType<IItemClickEventArgs>;
|
|
396
|
-
/**
|
|
397
|
-
* Triggers after mouse hover on the treemap item.
|
|
398
|
-
*
|
|
399
|
-
* @event itemMove
|
|
400
|
-
*/
|
|
401
|
-
@Event()
|
|
402
|
-
public itemMove: EmitType<IItemMoveEventArgs>;
|
|
403
|
-
/**
|
|
404
|
-
* Triggers after clicking on the treemap.
|
|
405
|
-
*
|
|
406
|
-
* @event click
|
|
407
|
-
*/
|
|
408
|
-
@Event()
|
|
409
|
-
public click: EmitType<IItemClickEventArgs>;
|
|
410
|
-
/**
|
|
411
|
-
* Triggers after double clicking on the treemap.
|
|
412
|
-
*
|
|
413
|
-
* @event doubleClick
|
|
414
|
-
*/
|
|
415
|
-
@Event()
|
|
416
|
-
public doubleClick: EmitType<IDoubleClickEventArgs>;
|
|
417
|
-
/**
|
|
418
|
-
* Triggers after right clicking on the treemap.
|
|
419
|
-
*
|
|
420
|
-
* @event rightClick
|
|
421
|
-
*/
|
|
422
|
-
@Event()
|
|
423
|
-
public rightClick: EmitType<IMouseMoveEventArgs>;
|
|
424
|
-
/**
|
|
425
|
-
* Triggers after mouse hover on the treemap.
|
|
426
|
-
*
|
|
427
|
-
* @event mouseMove
|
|
428
|
-
*/
|
|
429
|
-
@Event()
|
|
430
|
-
public mouseMove: EmitType<IMouseMoveEventArgs>;
|
|
431
|
-
/**
|
|
432
|
-
* Triggers to notify the resize of the treemap when the window is resized.
|
|
433
|
-
*
|
|
434
|
-
* @event resize
|
|
435
|
-
*/
|
|
436
|
-
@Event()
|
|
437
|
-
public resize: EmitType<IResizeEventArgs>;
|
|
438
|
-
/**
|
|
439
|
-
* Triggers before rendering each legend item in the treemap.
|
|
440
|
-
*
|
|
441
|
-
* @event legendItemRendering
|
|
442
|
-
*/
|
|
443
|
-
@Event()
|
|
444
|
-
public legendItemRendering: EmitType<ILegendItemRenderingEventArgs>;
|
|
445
|
-
/**
|
|
446
|
-
* Triggers before rendering the legend items in the treemap.
|
|
447
|
-
*
|
|
448
|
-
* @event legendRendering
|
|
449
|
-
* @deprecated
|
|
450
|
-
*/
|
|
451
|
-
@Event()
|
|
452
|
-
public legendRendering: EmitType<ILegendRenderingEventArgs>;
|
|
453
|
-
|
|
454
|
-
/**
|
|
455
|
-
* resize the treemap
|
|
456
|
-
*/
|
|
457
|
-
private isResize: boolean = false;
|
|
458
|
-
/**
|
|
459
|
-
* svg renderer object.
|
|
460
|
-
*
|
|
461
|
-
* @private
|
|
462
|
-
*/
|
|
463
|
-
public renderer: SvgRenderer;
|
|
464
|
-
/**
|
|
465
|
-
* treemap svg element object
|
|
466
|
-
*
|
|
467
|
-
* @private
|
|
468
|
-
*/
|
|
469
|
-
public svgObject: Element;
|
|
470
|
-
/**
|
|
471
|
-
* Stores the exact size of treemap.
|
|
472
|
-
*
|
|
473
|
-
* @private
|
|
474
|
-
*/
|
|
475
|
-
public availableSize: Size;
|
|
476
|
-
/**
|
|
477
|
-
* Internal use of internationalization instance.
|
|
478
|
-
*
|
|
479
|
-
* @private
|
|
480
|
-
*/
|
|
481
|
-
public intl: Internationalization;
|
|
482
|
-
/**
|
|
483
|
-
* Stores the area bounds.
|
|
484
|
-
*
|
|
485
|
-
* @private
|
|
486
|
-
*/
|
|
487
|
-
public areaRect: Rect;
|
|
488
|
-
/**
|
|
489
|
-
* Define the theme style for treemap.
|
|
490
|
-
*
|
|
491
|
-
* @private
|
|
492
|
-
*/
|
|
493
|
-
public themeStyle: IThemeStyle;
|
|
494
|
-
/**
|
|
495
|
-
* Stores the legend bounds.
|
|
496
|
-
*
|
|
497
|
-
* @private
|
|
498
|
-
*/
|
|
499
|
-
public totalRect: Rect;
|
|
500
|
-
/** @private */
|
|
501
|
-
public layout: LayoutPanel;
|
|
502
|
-
/** @private */
|
|
503
|
-
public orientation: string = 'Horizontal';
|
|
504
|
-
/** @private */
|
|
505
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
506
|
-
public drilledItems: any[] = [];
|
|
507
|
-
/** @private */
|
|
508
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
509
|
-
public drilledLegendItems: any;
|
|
510
|
-
/** @private */
|
|
511
|
-
public currentLevel: number;
|
|
512
|
-
/** @private */
|
|
513
|
-
public isHierarchicalData: boolean = false;
|
|
514
|
-
/** @private */
|
|
515
|
-
private resizeTo: number;
|
|
516
|
-
/** @private */
|
|
517
|
-
private mouseDown: boolean;
|
|
518
|
-
/** @private */
|
|
519
|
-
private drillMouseMove: boolean;
|
|
520
|
-
/** @private */
|
|
521
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
522
|
-
public doubleTapTimer: any;
|
|
523
|
-
/** @private */
|
|
524
|
-
public levelSelection: string[] = [];
|
|
525
|
-
/** @private */
|
|
526
|
-
public legendId: string[] = [];
|
|
527
|
-
/** @private */
|
|
528
|
-
public selectionId: string;
|
|
529
|
-
/** @private */
|
|
530
|
-
public treemapLevelData: LevelsData;
|
|
531
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
532
|
-
private resizeEvent: any;
|
|
533
|
-
|
|
534
|
-
/**
|
|
535
|
-
* Constructor for TreeMap.
|
|
536
|
-
*
|
|
537
|
-
* @param {TreeMapModel} options - Specifies the treemap instance.
|
|
538
|
-
* @param {string | HTMLElement} element - Specifies the treemap element.
|
|
539
|
-
*/
|
|
540
|
-
constructor(options?: TreeMapModel, element?: string | HTMLElement) {
|
|
541
|
-
super(options, element);
|
|
542
|
-
}
|
|
543
|
-
|
|
544
|
-
protected preRender(): void {
|
|
545
|
-
this.trigger(load, { treemap: this }, () => {
|
|
546
|
-
this.initPrivateVariable();
|
|
547
|
-
this.unWireEVents();
|
|
548
|
-
this.createSvg();
|
|
549
|
-
this.wireEVents();
|
|
550
|
-
this.setCulture();
|
|
551
|
-
});
|
|
552
|
-
|
|
553
|
-
}
|
|
554
|
-
|
|
555
|
-
protected render(): void {
|
|
556
|
-
this.renderElements();
|
|
557
|
-
}
|
|
558
|
-
|
|
559
|
-
private renderElements(): void {
|
|
560
|
-
this.treemapLevelData = new LevelsData();
|
|
561
|
-
this.treemapLevelData.levelsData = null;
|
|
562
|
-
this.treemapLevelData.defaultLevelsData = null;
|
|
563
|
-
this.treemapLevelData.hierarchyData = null;
|
|
564
|
-
this.createSecondaryElement();
|
|
565
|
-
this.addTabIndex();
|
|
566
|
-
this.themeStyle = getThemeStyle(this.theme);
|
|
567
|
-
this.renderBorder();
|
|
568
|
-
this.renderTitle(this.titleSettings, 'title', null, null);
|
|
569
|
-
if (!isNullOrUndefined(this.treemapLevelData.levelsData)) {
|
|
570
|
-
this.treemapLevelData.defaultLevelsData = this.treemapLevelData.levelsData;
|
|
571
|
-
}
|
|
572
|
-
this.processDataManager();
|
|
573
|
-
}
|
|
574
|
-
|
|
575
|
-
private processDataManager(): void {
|
|
576
|
-
let dataModule: DataManager; let queryModule: Query; let fetchApiModule: Fetch;
|
|
577
|
-
let localAjax: TreeMapAjax;
|
|
578
|
-
if (this.dataSource instanceof DataManager) {
|
|
579
|
-
dataModule = this.dataSource;
|
|
580
|
-
queryModule = this.query instanceof Query ? this.query : new Query();
|
|
581
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
582
|
-
const dataManager: Promise<any> = dataModule.executeQuery(queryModule);
|
|
583
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
584
|
-
dataManager.then((e: any) => {
|
|
585
|
-
this.dataSource = e['result'];
|
|
586
|
-
this.renderTreeMapElements();
|
|
587
|
-
});
|
|
588
|
-
} else if (this.dataSource instanceof TreeMapAjax) {
|
|
589
|
-
localAjax = this.dataSource as TreeMapAjax;
|
|
590
|
-
fetchApiModule = new Fetch(localAjax.dataOptions, localAjax.type, localAjax.contentType);
|
|
591
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
592
|
-
fetchApiModule.onSuccess = (args: any) => {
|
|
593
|
-
if (!isNullOrUndefined(args.type) && args.type === 'application/octet-stream') {
|
|
594
|
-
const reader: FileReader = new FileReader();
|
|
595
|
-
// eslint-disable-next-line @typescript-eslint/no-this-alias
|
|
596
|
-
const treemap: TreeMap = this;
|
|
597
|
-
reader.onload = function (): void {
|
|
598
|
-
args = JSON.parse(reader.result.toString());
|
|
599
|
-
treemap.dataSource = args;
|
|
600
|
-
treemap.renderTreeMapElements();
|
|
601
|
-
};
|
|
602
|
-
reader.readAsText(args);
|
|
603
|
-
} else {
|
|
604
|
-
this.dataSource = args;
|
|
605
|
-
this.renderTreeMapElements();
|
|
606
|
-
}
|
|
607
|
-
};
|
|
608
|
-
fetchApiModule.send(localAjax.sendData);
|
|
609
|
-
} else {
|
|
610
|
-
this.renderTreeMapElements();
|
|
611
|
-
}
|
|
612
|
-
}
|
|
613
|
-
|
|
614
|
-
private renderTreeMapElements(): void {
|
|
615
|
-
|
|
616
|
-
this.processingData();
|
|
617
|
-
|
|
618
|
-
if (this.treeMapLegendModule && this.legendSettings.visible) {
|
|
619
|
-
|
|
620
|
-
this.treeMapLegendModule.renderLegend();
|
|
621
|
-
|
|
622
|
-
}
|
|
623
|
-
|
|
624
|
-
this.layout.processLayoutPanel();
|
|
625
|
-
|
|
626
|
-
this.element.appendChild(this.svgObject);
|
|
627
|
-
if (!isNullOrUndefined(this.treeMapLegendModule) && this.legendSettings.visible) {
|
|
628
|
-
legendMaintain(this, this.treeMapLegendModule.legendGroup);
|
|
629
|
-
}
|
|
630
|
-
this.elementChange();
|
|
631
|
-
|
|
632
|
-
this.trigger(loaded, {treemap: this, isResized: this.isResize});
|
|
633
|
-
this.isResize = false;
|
|
634
|
-
|
|
635
|
-
this.renderComplete();
|
|
636
|
-
}
|
|
637
|
-
|
|
638
|
-
protected createSvg(): void {
|
|
639
|
-
if (this.svgObject) {
|
|
640
|
-
while (this.svgObject.childNodes.length > 0) {
|
|
641
|
-
this.svgObject.removeChild(this.svgObject.firstChild);
|
|
642
|
-
}
|
|
643
|
-
if (!this.svgObject.hasChildNodes() && this.svgObject.parentNode) {
|
|
644
|
-
remove(this.svgObject);
|
|
645
|
-
}
|
|
646
|
-
}
|
|
647
|
-
if (isNullOrUndefined(this.renderer)) {
|
|
648
|
-
this.renderer = new SvgRenderer(this.element.id);
|
|
649
|
-
}
|
|
650
|
-
if (isNullOrUndefined(this.layout)) {
|
|
651
|
-
this.layout = new LayoutPanel(this);
|
|
652
|
-
}
|
|
653
|
-
this.clearTemplate();
|
|
654
|
-
const containerWidth: number = this.element.clientWidth;
|
|
655
|
-
const containerHeight: number = this.element.clientHeight;
|
|
656
|
-
this.availableSize = new Size(
|
|
657
|
-
stringToNumber(this.width, containerWidth) || containerWidth || 600,
|
|
658
|
-
stringToNumber(this.height, containerHeight) || containerHeight || 450
|
|
659
|
-
);
|
|
660
|
-
this.svgObject = this.renderer.createSvg({
|
|
661
|
-
id: this.element.id + '_svg',
|
|
662
|
-
width: this.availableSize.width,
|
|
663
|
-
height: this.availableSize.height
|
|
664
|
-
});
|
|
665
|
-
}
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
/**
|
|
669
|
-
* To initilize the private varibales of treemap.
|
|
670
|
-
*
|
|
671
|
-
* @returns {void}
|
|
672
|
-
*/
|
|
673
|
-
private initPrivateVariable(): void {
|
|
674
|
-
if (this.element.id === '') {
|
|
675
|
-
const collection: number = document.getElementsByClassName('e-treemap').length;
|
|
676
|
-
this.element.id = 'treemap_control_' + collection;
|
|
677
|
-
}
|
|
678
|
-
this.renderer = new SvgRenderer(this.element.id);
|
|
679
|
-
|
|
680
|
-
this.layout = new LayoutPanel(this);
|
|
681
|
-
|
|
682
|
-
}
|
|
683
|
-
|
|
684
|
-
private createSecondaryElement(): void {
|
|
685
|
-
const secondaryEle: Element = document.getElementById(this.element.id + '_Secondary_Element');
|
|
686
|
-
if (secondaryEle && secondaryEle.childElementCount > 0) {
|
|
687
|
-
secondaryEle.parentNode.removeChild(secondaryEle);
|
|
688
|
-
}
|
|
689
|
-
if (isNullOrUndefined(document.getElementById(this.element.id + '_Secondary_Element'))) {
|
|
690
|
-
const secondaryElement: Element = createElement('div', {
|
|
691
|
-
id: this.element.id + '_Secondary_Element'
|
|
692
|
-
});
|
|
693
|
-
(secondaryElement as HTMLElement).style.cssText = 'position: absolute;z-index:1;';
|
|
694
|
-
this.element.appendChild(secondaryElement);
|
|
695
|
-
}
|
|
696
|
-
}
|
|
697
|
-
|
|
698
|
-
private elementChange(): void {
|
|
699
|
-
if (this.treeMapLegendModule && this.legendSettings.visible && this.treeMapLegendModule.legendGroup && this.layout.layoutGroup
|
|
700
|
-
&& !isNullOrUndefined(this.svgObject) && !isNullOrUndefined(document.getElementById(this.layout.layoutGroup.id))
|
|
701
|
-
&& !isNullOrUndefined(document.getElementById(this.treeMapLegendModule.legendGroup.id))) {
|
|
702
|
-
this.svgObject.insertBefore(this.layout.layoutGroup, this.treeMapLegendModule.legendGroup);
|
|
703
|
-
}
|
|
704
|
-
}
|
|
705
|
-
|
|
706
|
-
/**
|
|
707
|
-
* Render the treemap border
|
|
708
|
-
*
|
|
709
|
-
* @private
|
|
710
|
-
* @returns {void}
|
|
711
|
-
*/
|
|
712
|
-
private renderBorder(): void {
|
|
713
|
-
const width: number = this.border.width;
|
|
714
|
-
const borderElement: Element = this.svgObject.querySelector('#' + this.element.id + '_TreeMap_Border');
|
|
715
|
-
if ((this.border.width > 0 || (this.background || this.themeStyle.backgroundColor)) && isNullOrUndefined(borderElement)) {
|
|
716
|
-
const borderRect: RectOption = new RectOption(
|
|
717
|
-
this.element.id + '_TreeMap_Border', this.background || this.themeStyle.backgroundColor, this.border, 1,
|
|
718
|
-
new Rect(width / 2, width / 2, this.availableSize.width - width, this.availableSize.height - width));
|
|
719
|
-
this.svgObject.appendChild(this.renderer.drawRectangle(borderRect) as SVGRectElement);
|
|
720
|
-
} else if (borderElement) {
|
|
721
|
-
borderElement.setAttribute('fill', this.background || this.themeStyle.backgroundColor);
|
|
722
|
-
}
|
|
723
|
-
}
|
|
724
|
-
|
|
725
|
-
private renderTitle(title: TitleSettingsModel, type: string, bounds: Rect, groupEle: Element): void {
|
|
726
|
-
const style: FontModel = {
|
|
727
|
-
color: title.textStyle.color, size: title.textStyle.size, fontFamily: title.textStyle.fontFamily,
|
|
728
|
-
fontStyle: title.textStyle.fontStyle, fontWeight: title.textStyle.fontWeight, opacity: title.textStyle.opacity
|
|
729
|
-
};
|
|
730
|
-
let height: number; const titlePadding: number = 10;
|
|
731
|
-
const width: number = (this.availableSize.width - this.margin.right - this.margin.left);
|
|
732
|
-
style.fontFamily = style.fontFamily || this.themeStyle.fontFamily;
|
|
733
|
-
style.fontWeight = style.fontWeight || this.themeStyle.titleFontWeight;
|
|
734
|
-
style.size = style.size || (type === 'title' ? this.themeStyle.fontSize : this.themeStyle.subtitleFontSize);
|
|
735
|
-
if (title.text) {
|
|
736
|
-
if (isNullOrUndefined(groupEle)) {
|
|
737
|
-
groupEle = this.renderer.createGroup({ id: this.element.id + '_Title_Group' });
|
|
738
|
-
}
|
|
739
|
-
const titleText: string = this.enableHtmlSanitizer ? (SanitizeHtmlHelper.sanitize(title.text)) : title.text;
|
|
740
|
-
const trimmedTitle: string = textTrim(width, titleText, style);
|
|
741
|
-
const elementSize: Size = measureText(trimmedTitle, style);
|
|
742
|
-
const rect: Rect = (isNullOrUndefined(bounds)) ? new Rect(
|
|
743
|
-
this.margin.left, this.margin.top, this.availableSize.width, this.availableSize.height) : bounds;
|
|
744
|
-
const location: Location = findPosition(rect, title.alignment, elementSize, type);
|
|
745
|
-
const options: TextOption = new TextOption(
|
|
746
|
-
this.element.id + '_TreeMap_' + type, location.x, location.y, 'start', trimmedTitle
|
|
747
|
-
);
|
|
748
|
-
const titleBounds: Rect = new Rect(location.x, location.y, elementSize.width, elementSize.height);
|
|
749
|
-
const element: Element = renderTextElement(
|
|
750
|
-
options, style, style.color || (type === 'title' ? this.themeStyle.titleFontColor : this.themeStyle.subTitleFontColor),
|
|
751
|
-
groupEle
|
|
752
|
-
);
|
|
753
|
-
element.setAttribute('aria-label', title.description || titleText);
|
|
754
|
-
element.setAttribute('role', 'region');
|
|
755
|
-
element.setAttribute('tabindex', this.tabIndex.toString());
|
|
756
|
-
if ((type === 'title' && !title.subtitleSettings.text) || (type === 'subtitle')) {
|
|
757
|
-
height = (this.availableSize.height - titleBounds.y - titlePadding - this.margin.bottom);
|
|
758
|
-
this.areaRect = new Rect(this.margin.left, titleBounds.y + titlePadding, width, height);
|
|
759
|
-
}
|
|
760
|
-
if (type !== 'subtitle' && title.subtitleSettings.text) {
|
|
761
|
-
this.renderTitle(title.subtitleSettings, 'subtitle', titleBounds, groupEle);
|
|
762
|
-
} else {
|
|
763
|
-
this.svgObject.appendChild(groupEle);
|
|
764
|
-
}
|
|
765
|
-
} else {
|
|
766
|
-
height = (this.availableSize.height - this.margin.top - this.margin.bottom);
|
|
767
|
-
this.areaRect = new Rect(this.margin.left, this.margin.top, width, height);
|
|
768
|
-
}
|
|
769
|
-
}
|
|
770
|
-
|
|
771
|
-
protected processingData(): void {
|
|
772
|
-
let path: string;
|
|
773
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
774
|
-
this.dataSource = this.dataSource as any[];
|
|
775
|
-
if (!isNullOrUndefined(this.dataSource) && this.dataSource.length > 0 && this.weightValuePath) {
|
|
776
|
-
this.treemapLevelData.levelsData = [];
|
|
777
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
778
|
-
this.dataSource.map((data: any) => {
|
|
779
|
-
data[this.weightValuePath] = (data[this.weightValuePath]) ? (data[this.weightValuePath] as string).toString() :
|
|
780
|
-
data[this.weightValuePath];
|
|
781
|
-
});
|
|
782
|
-
this.leafItemSettings.labelPath = this.leafItemSettings.labelPath || this.weightValuePath;
|
|
783
|
-
this.checkIsHierarchicalData();
|
|
784
|
-
if (this.levels.length === 0) {
|
|
785
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
786
|
-
const data: any = {};
|
|
787
|
-
data['level'] = 0;
|
|
788
|
-
path = this.leafItemSettings.labelPath;
|
|
789
|
-
data[path as string] = [];
|
|
790
|
-
for (let i: number = 0; i < this.dataSource.length; i++) {
|
|
791
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
792
|
-
const child: any[] = findChildren(this.dataSource[i as number] as any)['values'];
|
|
793
|
-
if (this.isHierarchicalData && child && child.length > 0) {
|
|
794
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
795
|
-
child.forEach((currentData: any) => {
|
|
796
|
-
if (currentData[path as string]) {
|
|
797
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
798
|
-
(<any[]>data[path as string]).push({
|
|
799
|
-
groupIndex: 0, name: currentData[path as string],
|
|
800
|
-
levelOrderName: (currentData[path as string] as string).toString(),
|
|
801
|
-
data: currentData, weight: currentData[this.weightValuePath]
|
|
802
|
-
});
|
|
803
|
-
}
|
|
804
|
-
});
|
|
805
|
-
} else {
|
|
806
|
-
if (this.dataSource[i as number][path as string]) {
|
|
807
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
808
|
-
(<any[]>data[path as string]).push({
|
|
809
|
-
groupIndex: 0, name: this.dataSource[i as number][path as string], levelOrderName: (
|
|
810
|
-
this.dataSource[i as number][path as string] as string).toString(), data: this.dataSource[i as number],
|
|
811
|
-
weight: this.dataSource[i as number][this.weightValuePath]
|
|
812
|
-
});
|
|
813
|
-
}
|
|
814
|
-
}
|
|
815
|
-
}
|
|
816
|
-
this.treemapLevelData.levelsData.push(data);
|
|
817
|
-
} else {
|
|
818
|
-
if (this.isHierarchicalData) {
|
|
819
|
-
this.treemapLevelData.hierarchyData = [];
|
|
820
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
821
|
-
this.treemapLevelData.hierarchyData = extend([], this.dataSource, this.treemapLevelData.hierarchyData, true) as any[];
|
|
822
|
-
for (let i: number = 0; i < this.treemapLevelData.hierarchyData.length; i++) {
|
|
823
|
-
this.processHierarchicalData(this.treemapLevelData.hierarchyData[i as number], i);
|
|
824
|
-
}
|
|
825
|
-
this.treemapLevelData.levelsData = this.treemapLevelData.hierarchyData;
|
|
826
|
-
} else {
|
|
827
|
-
this.processFlatJsonData();
|
|
828
|
-
if (this.treemapLevelData.levelsData.length > 1) {
|
|
829
|
-
this.reOrderLevelData(this.treemapLevelData.levelsData.length - 1);
|
|
830
|
-
}
|
|
831
|
-
}
|
|
832
|
-
path = this.levels[0].groupPath;
|
|
833
|
-
}
|
|
834
|
-
if (!this.isHierarchicalData) {
|
|
835
|
-
this.findTotalWeight(this.treemapLevelData.levelsData[0][path as string], 'Parent');
|
|
836
|
-
}
|
|
837
|
-
}
|
|
838
|
-
}
|
|
839
|
-
|
|
840
|
-
private checkIsHierarchicalData(): void {
|
|
841
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
842
|
-
let child: any[]; this.dataSource = this.dataSource as any[];
|
|
843
|
-
for (let i: number = 0; i < this.dataSource.length; i++) {
|
|
844
|
-
child = findChildren(this.dataSource[i as number])['values'];
|
|
845
|
-
if (child && child.length) {
|
|
846
|
-
this.isHierarchicalData = true;
|
|
847
|
-
break;
|
|
848
|
-
} else if (i === this.dataSource.length - 1) {
|
|
849
|
-
this.isHierarchicalData = false;
|
|
850
|
-
}
|
|
851
|
-
}
|
|
852
|
-
}
|
|
853
|
-
|
|
854
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
855
|
-
private processHierarchicalData(data: any, dataCount: number): void {
|
|
856
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
857
|
-
let childData: any[];
|
|
858
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
859
|
-
let newData: any = {};
|
|
860
|
-
let levelIndex: number;
|
|
861
|
-
const path: string = this.leafItemSettings.labelPath ? this.leafItemSettings.labelPath : this.weightValuePath;
|
|
862
|
-
let key: string;
|
|
863
|
-
newData = findChildren(data);
|
|
864
|
-
childData = newData ? newData['values'] : null;
|
|
865
|
-
if (childData && childData.length > 0) {
|
|
866
|
-
key = newData['key'];
|
|
867
|
-
for (let i: number = 0; i < this.levels.length; i++) {
|
|
868
|
-
if (key === this.levels[i as number].groupPath) {
|
|
869
|
-
levelIndex = i;
|
|
870
|
-
}
|
|
871
|
-
}
|
|
872
|
-
for (let j: number = 0; j < childData.length; j++) {
|
|
873
|
-
childData[j as number]['name'] = childData[j as number][path as string];
|
|
874
|
-
childData[j as number]['levelOrderName'] = (levelIndex === 0 ? childData[j as number]['name'] :
|
|
875
|
-
data['levelOrderName'] + '#' + childData[j as number]['name']) + '';
|
|
876
|
-
const childItemLevel: string = childData[j as number]['levelOrderName']; let childLevel: number;
|
|
877
|
-
if (childItemLevel.search('#') > 0) {
|
|
878
|
-
childLevel = childItemLevel.split('#').length - 1;
|
|
879
|
-
}
|
|
880
|
-
childData[j as number]['groupIndex'] = isNullOrUndefined(levelIndex) ? childLevel === this.levels.length
|
|
881
|
-
? this.levels.length : childLevel : levelIndex;
|
|
882
|
-
if (levelIndex !== 0) {
|
|
883
|
-
childData[j as number]['parent'] = data;
|
|
884
|
-
}
|
|
885
|
-
childData[j as number]['groupName'] = key;
|
|
886
|
-
childData[j as number]['data'] = childData[j as number];
|
|
887
|
-
childData[j as number]['isDrilled'] = false;
|
|
888
|
-
childData[j as number]['weight'] = childData[j as number][this.weightValuePath];
|
|
889
|
-
}
|
|
890
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
891
|
-
childData.forEach((currentData: any) => {
|
|
892
|
-
this.processHierarchicalData(currentData, dataCount);
|
|
893
|
-
});
|
|
894
|
-
}
|
|
895
|
-
if (dataCount === this.treemapLevelData.hierarchyData.length - 1) {
|
|
896
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
897
|
-
let mainData: any[] = this.treemapLevelData.hierarchyData[0][this.levels[0].groupPath];
|
|
898
|
-
if (!isNullOrUndefined(mainData)) {
|
|
899
|
-
for (let k: number = 0; k < this.treemapLevelData.hierarchyData.length; k++) {
|
|
900
|
-
childData = findChildren(this.treemapLevelData.hierarchyData[k as number])['values'];
|
|
901
|
-
if (k !== 0 && childData) {
|
|
902
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
903
|
-
childData.forEach((currentData: any) => { mainData.push(currentData); });
|
|
904
|
-
this.treemapLevelData.hierarchyData.splice(k, 1);
|
|
905
|
-
k -= 1;
|
|
906
|
-
}
|
|
907
|
-
}
|
|
908
|
-
mainData = this.treemapLevelData.hierarchyData[0][this.levels[0].groupPath];
|
|
909
|
-
for (let l: number = 0; l < mainData.length; l++) {
|
|
910
|
-
newData[this.levels[0].groupPath] = mainData;
|
|
911
|
-
mainData[l as number]['parent'] = newData;
|
|
912
|
-
}
|
|
913
|
-
}
|
|
914
|
-
}
|
|
915
|
-
}
|
|
916
|
-
/* eslint-disable valid-jsdoc */
|
|
917
|
-
/**
|
|
918
|
-
* This method is used to perform the print functionality in treemap.
|
|
919
|
-
*
|
|
920
|
-
* @param {string[] | string | Element} id - Specifies the element to print the treemap.
|
|
921
|
-
* @returns {void}
|
|
922
|
-
*/
|
|
923
|
-
public print(id?: string[] | string | Element): void {
|
|
924
|
-
if (this.allowPrint && this.printModule) {
|
|
925
|
-
this.printModule.print(this, id);
|
|
926
|
-
}
|
|
927
|
-
}
|
|
928
|
-
/**
|
|
929
|
-
* This method is used to perform the export functionality for the rendered treemap.
|
|
930
|
-
*
|
|
931
|
-
* @param {ExportType} type - Specifies the extension type of the exported document.
|
|
932
|
-
* @param {string} fileName - Specifies file name for exporting the rendered TreeMap.
|
|
933
|
-
* @param {PdfPageOrientation} orientation - Specifies the orientation of the PDF document.
|
|
934
|
-
* @param {boolean} allowDownload - Specifies whether the exported file should be downloaded or not.
|
|
935
|
-
* @returns {string} - Specifies the base64 string of the exported image which is returned when the allowDownload is set to false.
|
|
936
|
-
*/
|
|
937
|
-
public export(type: ExportType, fileName: string, orientation?: PdfPageOrientation, allowDownload?: boolean): Promise<string> {
|
|
938
|
-
if (isNullOrUndefined(allowDownload)) {
|
|
939
|
-
allowDownload = true;
|
|
940
|
-
}
|
|
941
|
-
if (type === 'PDF' && this.allowPdfExport && this.pdfExportModule) {
|
|
942
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/no-unused-vars
|
|
943
|
-
return new Promise((resolve: any, reject: any) => {
|
|
944
|
-
resolve(this.pdfExportModule.export(this, type, fileName, orientation, allowDownload));
|
|
945
|
-
});
|
|
946
|
-
|
|
947
|
-
} else if (this.allowImageExport && (type !== 'PDF') && this.imageExportModule) {
|
|
948
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/no-unused-vars
|
|
949
|
-
return new Promise((resolve: any, reject: any) => {
|
|
950
|
-
resolve(this.imageExportModule.export(this, type, fileName, allowDownload));
|
|
951
|
-
});
|
|
952
|
-
}
|
|
953
|
-
return null;
|
|
954
|
-
}
|
|
955
|
-
private processFlatJsonData(): void {
|
|
956
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
957
|
-
this.dataSource = this.dataSource as any[];
|
|
958
|
-
let groupPath: string;
|
|
959
|
-
const orderNames: string[] = [];
|
|
960
|
-
for (let i: number = 0; i < this.levels.length + 1; i++) {
|
|
961
|
-
groupPath = this.levels[i as number] ? this.levels[i as number].groupPath : this.leafItemSettings.labelPath;
|
|
962
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
963
|
-
const level: any = {};
|
|
964
|
-
level['level'] = i;
|
|
965
|
-
level[groupPath as string] = [];
|
|
966
|
-
this.treemapLevelData.levelsData.push(level);
|
|
967
|
-
for (let j: number = 0; j < this.dataSource.length; j++) {
|
|
968
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
969
|
-
const currentData: any = {}; let childName: string = '';
|
|
970
|
-
if (!isNullOrUndefined(groupPath)) {
|
|
971
|
-
const name: string = this.dataSource[j as number][groupPath as string];
|
|
972
|
-
if (i !== 0) {
|
|
973
|
-
for (let k: number = 0; k <= i; k++) {
|
|
974
|
-
const childGroupPath: string = this.levels[k as number] ? this.levels[k as number].groupPath : groupPath;
|
|
975
|
-
childName += (this.dataSource[j as number][childGroupPath as string]) + ((k === i) ? '' : '#');
|
|
976
|
-
}
|
|
977
|
-
}
|
|
978
|
-
if (!(orderNames.length > 0 ? orderNames.indexOf(childName ?
|
|
979
|
-
childName : name) !== -1 : false)) {
|
|
980
|
-
currentData['name'] = name;
|
|
981
|
-
currentData['levelOrderName'] = ((childName) ? childName : name) + '';
|
|
982
|
-
currentData['groupIndex'] = i;
|
|
983
|
-
currentData['isDrilled'] = false;
|
|
984
|
-
currentData['groupName'] = groupPath;
|
|
985
|
-
currentData['data'] = this.dataSource[j as number];
|
|
986
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any, max-len
|
|
987
|
-
(<any[]>this.treemapLevelData.levelsData[(this.treemapLevelData.levelsData.length - 1) as number][groupPath as string]).push(currentData);
|
|
988
|
-
orderNames.push((childName) ? childName : name);
|
|
989
|
-
}
|
|
990
|
-
}
|
|
991
|
-
}
|
|
992
|
-
}
|
|
993
|
-
}
|
|
994
|
-
|
|
995
|
-
/**
|
|
996
|
-
* This method orders the treemap level data.
|
|
997
|
-
*
|
|
998
|
-
* @param {number} start - Specifies the start value of the treemap level.
|
|
999
|
-
* @returns {void}
|
|
1000
|
-
* @private
|
|
1001
|
-
*/
|
|
1002
|
-
public reOrderLevelData(start: number): void {
|
|
1003
|
-
let currentName: string;
|
|
1004
|
-
const currentPath: string = this.levels[start as number] ? this.levels[start as number].groupPath : this.leafItemSettings.labelPath;
|
|
1005
|
-
const prevPath: string = this.levels[start - 1].groupPath;
|
|
1006
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
1007
|
-
const currentData: any[] = this.treemapLevelData.levelsData[start as number][currentPath as string] as any[];
|
|
1008
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
1009
|
-
const previousData: any[] = this.treemapLevelData.levelsData[start - 1][prevPath as string] as any[];
|
|
1010
|
-
for (let i: number = 0; i < currentData.length; i++) {
|
|
1011
|
-
currentName = currentData[i as number]['levelOrderName'] as string;
|
|
1012
|
-
for (let j: number = 0; j < previousData.length; j++) {
|
|
1013
|
-
previousData[j as number][currentPath as string] = isNullOrUndefined(previousData[j as number][currentPath as string]) ?
|
|
1014
|
-
[] : previousData[j as number][currentPath as string];
|
|
1015
|
-
if (this.IsChildHierarchy(currentName.split('#'), (previousData[j as number]['levelOrderName'] as string).split('#'))) {
|
|
1016
|
-
if (isNullOrUndefined(currentData[i as number]['parent'])) {
|
|
1017
|
-
currentData[i as number]['parent'] = previousData[j as number];
|
|
1018
|
-
}
|
|
1019
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
1020
|
-
(<any[]>previousData[j as number][currentPath as string]).push(currentData[i as number]);
|
|
1021
|
-
break;
|
|
1022
|
-
}
|
|
1023
|
-
}
|
|
1024
|
-
}
|
|
1025
|
-
this.findTotalWeight(this.treemapLevelData.levelsData[this.treemapLevelData.levelsData.length - 1][currentPath as string], 'Child');
|
|
1026
|
-
this.treemapLevelData.levelsData.splice(start, 1);
|
|
1027
|
-
if ((start - 1) > 0) {
|
|
1028
|
-
this.reOrderLevelData(start - 1);
|
|
1029
|
-
}
|
|
1030
|
-
}
|
|
1031
|
-
|
|
1032
|
-
private IsChildHierarchy (current: string[], previous: string[]): boolean {
|
|
1033
|
-
let isChild: boolean = false;
|
|
1034
|
-
for (let i: number = 0; i < previous.length; i++)
|
|
1035
|
-
{
|
|
1036
|
-
if (current.length < i || previous[i as number] !== current[i as number])
|
|
1037
|
-
{
|
|
1038
|
-
return false;
|
|
1039
|
-
}
|
|
1040
|
-
else
|
|
1041
|
-
{
|
|
1042
|
-
isChild = true;
|
|
1043
|
-
}
|
|
1044
|
-
}
|
|
1045
|
-
return isChild;
|
|
1046
|
-
}
|
|
1047
|
-
|
|
1048
|
-
/**
|
|
1049
|
-
* This method finds the weight value of the treemap level.
|
|
1050
|
-
*
|
|
1051
|
-
* @param {any[]} processData - Specifies the treemap data.
|
|
1052
|
-
* @param {string} type - Specifies the type of the data.
|
|
1053
|
-
* @returns {void}
|
|
1054
|
-
* @private
|
|
1055
|
-
*/
|
|
1056
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
1057
|
-
public findTotalWeight(processData: any[], type: string): void {
|
|
1058
|
-
let totalWeight: number;
|
|
1059
|
-
let split: string[];
|
|
1060
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
1061
|
-
let groupName: string; const groupObj: any = {};
|
|
1062
|
-
for (let i: number = 0; i < processData.length; i++) {
|
|
1063
|
-
totalWeight = 0;
|
|
1064
|
-
groupName = processData[i as number]['groupName'];
|
|
1065
|
-
split = (processData[i as number]['levelOrderName'] as string).split('#');
|
|
1066
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
1067
|
-
(<any[]>this.dataSource).forEach((data: any) => {
|
|
1068
|
-
if (isContainsData(split, processData[i as number]['levelOrderName'], data, this)) {
|
|
1069
|
-
totalWeight += parseFloat(data[this.weightValuePath]);
|
|
1070
|
-
}
|
|
1071
|
-
});
|
|
1072
|
-
if (type === 'Parent') {
|
|
1073
|
-
groupObj[groupName as string] = processData;
|
|
1074
|
-
processData[i as number]['parent'] = groupObj;
|
|
1075
|
-
}
|
|
1076
|
-
processData[i as number]['weight'] = totalWeight;
|
|
1077
|
-
}
|
|
1078
|
-
}
|
|
1079
|
-
|
|
1080
|
-
/**
|
|
1081
|
-
* To unbind event handlers for treemap.
|
|
1082
|
-
*
|
|
1083
|
-
* @returns {void}
|
|
1084
|
-
* @private
|
|
1085
|
-
*/
|
|
1086
|
-
private unWireEVents(): void {
|
|
1087
|
-
EventHandler.remove(this.element, 'click', this.clickOnTreeMap);
|
|
1088
|
-
EventHandler.remove(this.element, 'dblclick', this.doubleClickOnTreeMap);
|
|
1089
|
-
EventHandler.remove(this.element, 'contextmenu', this.rightClickOnTreeMap);
|
|
1090
|
-
EventHandler.remove(this.element, Browser.touchStartEvent, this.mouseDownOnTreeMap);
|
|
1091
|
-
EventHandler.remove(this.element, Browser.touchMoveEvent, this.mouseMoveOnTreeMap);
|
|
1092
|
-
EventHandler.remove(this.element, Browser.touchEndEvent, this.mouseEndOnTreeMap);
|
|
1093
|
-
EventHandler.remove(this.element, 'pointerleave mouseleave', this.mouseLeaveOnTreeMap);
|
|
1094
|
-
EventHandler.remove(this.element, 'keydown', this.keyDownHandler);
|
|
1095
|
-
EventHandler.remove(this.element, 'keyup', this.keyUpHandler);
|
|
1096
|
-
EventHandler.remove(this.element, 'focusout', this.focusHandler);
|
|
1097
|
-
window.removeEventListener('resize', this.resizeEvent);
|
|
1098
|
-
}
|
|
1099
|
-
|
|
1100
|
-
/**
|
|
1101
|
-
* To bind event handlers for treemap.
|
|
1102
|
-
*
|
|
1103
|
-
* @returns {void}
|
|
1104
|
-
*/
|
|
1105
|
-
private wireEVents(): void {
|
|
1106
|
-
EventHandler.add(this.element, 'click', this.clickOnTreeMap, this);
|
|
1107
|
-
EventHandler.add(this.element, 'dblclick', this.doubleClickOnTreeMap, this);
|
|
1108
|
-
EventHandler.add(this.element, 'contextmenu', this.rightClickOnTreeMap, this);
|
|
1109
|
-
EventHandler.add(this.element, Browser.touchStartEvent, this.mouseDownOnTreeMap, this);
|
|
1110
|
-
EventHandler.add(this.element, Browser.touchMoveEvent, this.mouseMoveOnTreeMap, this);
|
|
1111
|
-
EventHandler.add(this.element, Browser.touchEndEvent, this.mouseEndOnTreeMap, this);
|
|
1112
|
-
EventHandler.add(this.element, 'pointerleave mouseleave', this.mouseLeaveOnTreeMap, this);
|
|
1113
|
-
EventHandler.add(this.element, 'keydown', this.keyDownHandler, this);
|
|
1114
|
-
EventHandler.add(this.element, 'keyup', this.keyUpHandler, this);
|
|
1115
|
-
EventHandler.add(this.element, 'focusout', this.focusHandler, this);
|
|
1116
|
-
this.resizeEvent = this.resizeOnTreeMap.bind(this);
|
|
1117
|
-
window.addEventListener('resize', this.resizeEvent);
|
|
1118
|
-
}
|
|
1119
|
-
|
|
1120
|
-
/**
|
|
1121
|
-
* Method to set culture for maps
|
|
1122
|
-
*
|
|
1123
|
-
* @returns {void}
|
|
1124
|
-
*/
|
|
1125
|
-
private setCulture(): void {
|
|
1126
|
-
this.intl = new Internationalization();
|
|
1127
|
-
}
|
|
1128
|
-
|
|
1129
|
-
/**
|
|
1130
|
-
* To add tab index for treemap element
|
|
1131
|
-
*
|
|
1132
|
-
* @returns {void}
|
|
1133
|
-
*/
|
|
1134
|
-
private addTabIndex(): void {
|
|
1135
|
-
this.element.setAttribute('aria-label', this.description || 'TreeMap Element');
|
|
1136
|
-
this.element.setAttribute('role', 'region');
|
|
1137
|
-
this.element.setAttribute('tabindex', this.tabIndex.toString());
|
|
1138
|
-
}
|
|
1139
|
-
|
|
1140
|
-
/**
|
|
1141
|
-
* This method handles the window resize event on treemap.
|
|
1142
|
-
*
|
|
1143
|
-
* @param {Event} e - Specifies the pointer event.
|
|
1144
|
-
* @returns {void}
|
|
1145
|
-
* @private
|
|
1146
|
-
*/
|
|
1147
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
1148
|
-
public resizeOnTreeMap(e: Event): void {
|
|
1149
|
-
if (!this.isDestroyed) {
|
|
1150
|
-
this.isResize = true;
|
|
1151
|
-
const args: IResizeEventArgs = {
|
|
1152
|
-
name: resize,
|
|
1153
|
-
cancel: false,
|
|
1154
|
-
previousSize: this.availableSize,
|
|
1155
|
-
currentSize: new Size(0, 0),
|
|
1156
|
-
treemap: this
|
|
1157
|
-
};
|
|
1158
|
-
if (this.resizeTo) {
|
|
1159
|
-
clearTimeout(this.resizeTo);
|
|
1160
|
-
}
|
|
1161
|
-
if (!isNullOrUndefined(this.element) && this.element.classList.contains('e-treemap')) {
|
|
1162
|
-
this.resizeTo = setTimeout(
|
|
1163
|
-
(): void => {
|
|
1164
|
-
this.unWireEVents();
|
|
1165
|
-
this.createSvg();
|
|
1166
|
-
this.refreshing = true;
|
|
1167
|
-
this.wireEVents();
|
|
1168
|
-
args.currentSize = this.availableSize;
|
|
1169
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
1170
|
-
this.trigger(resize, args, (observedArgs: IResizeEventArgs) => {
|
|
1171
|
-
this.render();
|
|
1172
|
-
this.refreshing = false;
|
|
1173
|
-
});
|
|
1174
|
-
},
|
|
1175
|
-
500);
|
|
1176
|
-
}
|
|
1177
|
-
}
|
|
1178
|
-
}
|
|
1179
|
-
|
|
1180
|
-
/**
|
|
1181
|
-
* This method handles the click event on the treemap.
|
|
1182
|
-
*
|
|
1183
|
-
* @param {PointerEvent} e - Specifies the mouse click event in the treemap.
|
|
1184
|
-
* @returns {void}
|
|
1185
|
-
* @private
|
|
1186
|
-
*/
|
|
1187
|
-
public clickOnTreeMap(e: PointerEvent): void {
|
|
1188
|
-
const targetEle: Element = <Element>e.target;
|
|
1189
|
-
const targetId: string = targetEle.id;
|
|
1190
|
-
let eventArgs: IItemClickEventArgs;
|
|
1191
|
-
let itemIndex: number;
|
|
1192
|
-
const labelText : string = (targetEle as HTMLElement).innerHTML;
|
|
1193
|
-
const clickArgs: IClickEventArgs = { cancel: false, name: click, treemap: this, mouseEvent: e };
|
|
1194
|
-
this.trigger(click, clickArgs);
|
|
1195
|
-
if (targetId.indexOf('_Item_Index') > -1) {
|
|
1196
|
-
e.preventDefault();
|
|
1197
|
-
itemIndex = parseFloat(targetId.split('_Item_Index_')[1]);
|
|
1198
|
-
eventArgs = {
|
|
1199
|
-
cancel: false, name: itemClick, treemap: this, item: this.layout.renderItems[itemIndex as number], mouseEvent: e,
|
|
1200
|
-
groupIndex: this.layout.renderItems[itemIndex as number]['groupIndex'], groupName: this.layout.renderItems[itemIndex as number]['name'],
|
|
1201
|
-
text: labelText, contentItemTemplate : labelText
|
|
1202
|
-
};
|
|
1203
|
-
this.trigger(itemClick, eventArgs, (observedArgs: IItemClickEventArgs) => {
|
|
1204
|
-
if (observedArgs.text !== labelText || observedArgs.contentItemTemplate !== labelText) {
|
|
1205
|
-
if (isNullOrUndefined(this.leafItemSettings.labelTemplate)) {
|
|
1206
|
-
observedArgs.text = textFormatter(observedArgs.text, observedArgs['item']['data'], observedArgs.treemap);
|
|
1207
|
-
(targetEle as HTMLElement).textContent = observedArgs.text;
|
|
1208
|
-
} else {
|
|
1209
|
-
setItemTemplateContent(targetId, targetEle, observedArgs.contentItemTemplate);
|
|
1210
|
-
}
|
|
1211
|
-
}
|
|
1212
|
-
});
|
|
1213
|
-
}
|
|
1214
|
-
const end: number = new Date().getMilliseconds();
|
|
1215
|
-
let doubleTapTimer1: number;
|
|
1216
|
-
if (!isNullOrUndefined(this.doubleClick)) {
|
|
1217
|
-
if (!isNullOrUndefined(doubleTapTimer1) && end - doubleTapTimer1 < 500) {
|
|
1218
|
-
this.doubleClickOnTreeMap(e);
|
|
1219
|
-
}
|
|
1220
|
-
doubleTapTimer1 = end;
|
|
1221
|
-
}
|
|
1222
|
-
|
|
1223
|
-
}
|
|
1224
|
-
|
|
1225
|
-
/**
|
|
1226
|
-
* This method handles the double click event in the treemap.
|
|
1227
|
-
*
|
|
1228
|
-
* @param {PointerEvent} e - Specifies the pointer event of mouse click.
|
|
1229
|
-
* @returns {void}
|
|
1230
|
-
*/
|
|
1231
|
-
public doubleClickOnTreeMap(e: PointerEvent): void {
|
|
1232
|
-
const doubleClickArgs: IDoubleClickEventArgs = { cancel: false, name: doubleClick, treemap: this, mouseEvent: e };
|
|
1233
|
-
this.trigger(doubleClick, doubleClickArgs);
|
|
1234
|
-
//this.notify('dblclick', e);
|
|
1235
|
-
}
|
|
1236
|
-
|
|
1237
|
-
/**
|
|
1238
|
-
* This method handles the right click event in the treemap.
|
|
1239
|
-
*
|
|
1240
|
-
* @param {PointerEvent} e - Specifies the pointer event of mouse click.
|
|
1241
|
-
* @returns {void}
|
|
1242
|
-
* @private
|
|
1243
|
-
*/
|
|
1244
|
-
public rightClickOnTreeMap(e: PointerEvent): void {
|
|
1245
|
-
const rightClickArgs: IRightClickEventArgs = { cancel: false, name: rightClick, treemap: this, mouseEvent: e };
|
|
1246
|
-
this.trigger(rightClick, rightClickArgs);
|
|
1247
|
-
}
|
|
1248
|
-
|
|
1249
|
-
|
|
1250
|
-
/**
|
|
1251
|
-
* This method handles the mouse down event in the treemap.
|
|
1252
|
-
*
|
|
1253
|
-
* @param {PointerEvent} e - Specifies the pointer event of mouse click.
|
|
1254
|
-
* @returns {void}
|
|
1255
|
-
* @private
|
|
1256
|
-
*/
|
|
1257
|
-
public mouseDownOnTreeMap(e: PointerEvent): void {
|
|
1258
|
-
if ((<Element>e.target).id.indexOf('_Item_Index') > -1) {
|
|
1259
|
-
this.mouseDown = true;
|
|
1260
|
-
}
|
|
1261
|
-
if (e.type === 'touchstart' || e.type === 'mousedown') {
|
|
1262
|
-
this.removeFocus('none');
|
|
1263
|
-
e.preventDefault();
|
|
1264
|
-
}
|
|
1265
|
-
this.notify(Browser.touchStartEvent, e);
|
|
1266
|
-
}
|
|
1267
|
-
|
|
1268
|
-
/**
|
|
1269
|
-
* This method handles the mouse move event in the treemap.
|
|
1270
|
-
*
|
|
1271
|
-
* @param {PointerEvent} e - Specifies the pointer event of mouse click.
|
|
1272
|
-
* @returns {void}
|
|
1273
|
-
* @private
|
|
1274
|
-
*/
|
|
1275
|
-
public mouseMoveOnTreeMap(e: PointerEvent): void {
|
|
1276
|
-
const targetEle: Element = <Element>e.target;
|
|
1277
|
-
const targetId: string = targetEle.id;
|
|
1278
|
-
let eventArgs: IItemMoveEventArgs;
|
|
1279
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
1280
|
-
let item: any;
|
|
1281
|
-
const moveArgs: IMouseMoveEventArgs = { cancel: false, name: mouseMove, treemap: this, mouseEvent: e };
|
|
1282
|
-
this.trigger(mouseMove, moveArgs);
|
|
1283
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
1284
|
-
let childItems: any[];
|
|
1285
|
-
this.removeFocus('none');
|
|
1286
|
-
if (targetId.indexOf('_Item_Index') > -1) {
|
|
1287
|
-
item = this.layout.renderItems[parseFloat(targetId.split('_Item_Index_')[1])];
|
|
1288
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
1289
|
-
childItems = findChildren(item)['values'] as any[];
|
|
1290
|
-
this.element.style.cursor = (!item['isLeafItem'] && childItems && childItems.length > 0 && this.enableDrillDown) ?
|
|
1291
|
-
'pointer' : 'auto';
|
|
1292
|
-
eventArgs = { cancel: false, name: itemMove, treemap: this, item: item, mouseEvent: e };
|
|
1293
|
-
this.trigger(itemMove, eventArgs);
|
|
1294
|
-
} else {
|
|
1295
|
-
this.element.style.cursor = 'default';
|
|
1296
|
-
}
|
|
1297
|
-
this.notify(Browser.touchMoveEvent, e);
|
|
1298
|
-
}
|
|
1299
|
-
|
|
1300
|
-
/**
|
|
1301
|
-
* This method calculates the selected treemap levels.
|
|
1302
|
-
*
|
|
1303
|
-
* @param {string} labelText - Specifies the label text.
|
|
1304
|
-
* @param {any} item - Specifies the treemap item.
|
|
1305
|
-
* @returns {any} - Returns label of the drilled level.
|
|
1306
|
-
* @private
|
|
1307
|
-
*/
|
|
1308
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
1309
|
-
public calculateSelectedTextLevels(labelText: string, item: any): any {
|
|
1310
|
-
//to find the levels by clicking the particular text both for drillDownView as true / false.
|
|
1311
|
-
let drillLevel: number; let k: string; let text: string;
|
|
1312
|
-
const levelLabels: string = item['levelOrderName'];
|
|
1313
|
-
const levelText: string[] = levelLabels.split('#');
|
|
1314
|
-
for (k of Object.keys(levelText)) {
|
|
1315
|
-
if (levelText[k as string] === labelText) {
|
|
1316
|
-
drillLevel = parseInt(k, 10);
|
|
1317
|
-
text = labelText;
|
|
1318
|
-
}
|
|
1319
|
-
}
|
|
1320
|
-
return { drillLevel: drillLevel, currentLevelLabel: text, levelText: levelText };
|
|
1321
|
-
}
|
|
1322
|
-
|
|
1323
|
-
/**
|
|
1324
|
-
* This method calculates the previous level of child items in treemap.
|
|
1325
|
-
*
|
|
1326
|
-
* @param {any} drillLevelValues - Specifies the values of drill level.
|
|
1327
|
-
* @param {any} item - Specifies the treemap item.
|
|
1328
|
-
* @param {boolean} directLevel - Specifies the current level.
|
|
1329
|
-
* @returns {boolean} - check whether it is previous level or not.
|
|
1330
|
-
* @private
|
|
1331
|
-
*/
|
|
1332
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
1333
|
-
public calculatePreviousLevelChildItems(drillLevelValues: any, item: any, directLevel: boolean): boolean {
|
|
1334
|
-
//By clicking any child items drilldown to the particular level.
|
|
1335
|
-
//At the time store all the previous drilled level items in drilledItems
|
|
1336
|
-
// This condition satisfies while drilldown View is set as false and the text contains '[+]'
|
|
1337
|
-
let text: string; let p: number = 0; let levelItems: string; let text1: string;
|
|
1338
|
-
const drillTextLevel: number = this.layout.renderItems[0]['levelOrderName'].split('#').length;
|
|
1339
|
-
for (let h: number = 0; h < drillTextLevel; h++) {
|
|
1340
|
-
text1 = h === 0 ? drillLevelValues['levelText'][h as number] : text1 + '#' + drillLevelValues['levelText'][h as number];
|
|
1341
|
-
}
|
|
1342
|
-
p = drillTextLevel > 1 ? drillTextLevel : p;
|
|
1343
|
-
for (levelItems of Object['values'](this.layout.renderItems)) {
|
|
1344
|
-
const drillLevelText: string = levelItems['levelOrderName'].split('#');
|
|
1345
|
-
if (drillLevelText[0] === drillLevelValues['levelText'][0]) {
|
|
1346
|
-
text = p === 0 ? isNullOrUndefined(text1 as string) ? text1 : drillLevelValues['levelText'][p as number] :
|
|
1347
|
-
directLevel ? text1 : text1 + '#' + drillLevelValues['levelText'][p as number];
|
|
1348
|
-
if (text === levelItems['levelOrderName']) {
|
|
1349
|
-
this.drilledItems.push({ name: levelItems['levelOrderName'], data: levelItems });
|
|
1350
|
-
p++;
|
|
1351
|
-
directLevel = true;
|
|
1352
|
-
if (p <= item['groupIndex']) {
|
|
1353
|
-
text = text + '#' + drillLevelValues['levelText'][p as number];
|
|
1354
|
-
text1 = text;
|
|
1355
|
-
}
|
|
1356
|
-
}
|
|
1357
|
-
}
|
|
1358
|
-
}
|
|
1359
|
-
return directLevel;
|
|
1360
|
-
}
|
|
1361
|
-
|
|
1362
|
-
/**
|
|
1363
|
-
* This method compares the selected labels with the drill down items.
|
|
1364
|
-
*
|
|
1365
|
-
* @param {any} drillLevelValues - Specifies the values of drill level.
|
|
1366
|
-
* @param {any} item - Specifies the treemap item.
|
|
1367
|
-
* @param {number} i - Specifies the treemap item.
|
|
1368
|
-
* @returns {any} - return the new drill down object.
|
|
1369
|
-
* @private
|
|
1370
|
-
*/
|
|
1371
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
1372
|
-
public compareSelectedLabelWithDrillDownItems(drillLevelValues: any, item: any, i: number): any {
|
|
1373
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
1374
|
-
let drillLevelChild: any; const newDrillItem: any = {};
|
|
1375
|
-
const b: number = drillLevelValues['drillLevel'] + 1;
|
|
1376
|
-
if (b === this.drilledItems[i as number]['data']['groupIndex']) {
|
|
1377
|
-
drillLevelChild = this.drilledItems[i as number]['data']['parent'];
|
|
1378
|
-
drillLevelChild['isDrilled'] = true;
|
|
1379
|
-
newDrillItem[drillLevelChild[this.drilledItems[i as number]['data']['groupName']]]
|
|
1380
|
-
= [drillLevelChild];
|
|
1381
|
-
// to remove all the items after matched drilled items
|
|
1382
|
-
this.drilledItems.splice(i, this.drilledItems.length);
|
|
1383
|
-
} else if (drillLevelValues['drillLevel'] === (this.drilledItems.length - 1)
|
|
1384
|
-
|| drillLevelValues['drillLevel'] === item['groupIndex']) {
|
|
1385
|
-
newDrillItem[item['groupName']] = [item];
|
|
1386
|
-
}
|
|
1387
|
-
return newDrillItem;
|
|
1388
|
-
}
|
|
1389
|
-
|
|
1390
|
-
/**
|
|
1391
|
-
* This method handles mouse end event in treemap.
|
|
1392
|
-
*
|
|
1393
|
-
* @param {PointerEvent} e - Specifies the pointer event of mouse.
|
|
1394
|
-
* @returns {void}
|
|
1395
|
-
* @private
|
|
1396
|
-
*/
|
|
1397
|
-
public mouseEndOnTreeMap(e: PointerEvent | KeyboardEvent): void {
|
|
1398
|
-
const targetEle: Element = <Element>e.target; const targetId: string = targetEle.id; let totalRect: Rect;
|
|
1399
|
-
let startEvent: IDrillStartEventArgs; let endEvent: IDrillEndEventArgs; let directLevel: boolean = false;
|
|
1400
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
1401
|
-
let index: number; let newDrillItem: any = {}; let item: any; const process: boolean = true;
|
|
1402
|
-
const layoutID: string = this.element.id + '_TreeMap_' + this.layoutType + '_Layout'; let drillLevel: number;
|
|
1403
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
1404
|
-
const templateID: string = this.element.id + '_Label_Template_Group'; let drillLevelValues: any;
|
|
1405
|
-
if (targetId.indexOf('_Item_Index') > -1 && this.enableDrillDown && !this.drillMouseMove) {
|
|
1406
|
-
if (e.cancelable) {
|
|
1407
|
-
e.preventDefault();
|
|
1408
|
-
}
|
|
1409
|
-
index = parseFloat(targetId.split('_Item_Index_')[1]);
|
|
1410
|
-
item = this.layout.renderItems[index as number];
|
|
1411
|
-
const labelText: string = (targetEle as HTMLElement).textContent;
|
|
1412
|
-
if (this.enableBreadcrumb) {
|
|
1413
|
-
drillLevelValues = this.calculateSelectedTextLevels(labelText, item);
|
|
1414
|
-
drillLevel = drillLevelValues['drillLevel'];
|
|
1415
|
-
if (!this.drillDownView && labelText.search('[+]') !== -1) {
|
|
1416
|
-
directLevel = this.calculatePreviousLevelChildItems(drillLevelValues, item, directLevel);
|
|
1417
|
-
}
|
|
1418
|
-
}
|
|
1419
|
-
if (this.levels.length !== 0 && !item['isLeafItem'] && findChildren(item)['values'] &&
|
|
1420
|
-
findChildren(item)['values'].length > 0) {
|
|
1421
|
-
if (this.drilledItems.length > 0) {
|
|
1422
|
-
item = directLevel ? this.drilledItems[this.drilledItems.length - 1]['data'] : item;
|
|
1423
|
-
for (let i: number = 0; i < this.drilledItems.length; i++) {
|
|
1424
|
-
if (!isNullOrUndefined(drillLevel)) { //Compare the selected text level with drilled items
|
|
1425
|
-
const drillLength: number = this.drilledItems.length;
|
|
1426
|
-
newDrillItem = this.compareSelectedLabelWithDrillDownItems(drillLevelValues, item, i);
|
|
1427
|
-
if (drillLength !== this.drilledItems.length) {
|
|
1428
|
-
i -= 1; break;
|
|
1429
|
-
}
|
|
1430
|
-
} //when clicking the levels drill back to the previous level process takes place
|
|
1431
|
-
if (item['levelOrderName'] === this.drilledItems[i as number]['name'] && !directLevel && isNullOrUndefined(drillLevel)) {
|
|
1432
|
-
if (item['groupIndex'] === 0 && item['parent'][item['groupName']] instanceof Array) {
|
|
1433
|
-
item['isDrilled'] = !(item['isDrilled']);
|
|
1434
|
-
if (!item['isDrilled']) {
|
|
1435
|
-
newDrillItem = item['parent'];
|
|
1436
|
-
} else {
|
|
1437
|
-
newDrillItem[item['groupName']] = [item];
|
|
1438
|
-
}
|
|
1439
|
-
} else {
|
|
1440
|
-
item['isDrilled'] = false; item['parent']['isDrilled'] = true; item = item['parent'];
|
|
1441
|
-
newDrillItem[item['groupName']] = [item];
|
|
1442
|
-
}
|
|
1443
|
-
this.drilledItems.splice(i, 1);
|
|
1444
|
-
i -= 1; break;
|
|
1445
|
-
} else if (i === this.drilledItems.length - 1 && isNullOrUndefined(drillLevel)) {
|
|
1446
|
-
item['isDrilled'] = true; // click the items move to next level.
|
|
1447
|
-
newDrillItem[item['groupName']] = [item];
|
|
1448
|
-
}
|
|
1449
|
-
}
|
|
1450
|
-
} else {
|
|
1451
|
-
item['isDrilled'] = true;
|
|
1452
|
-
newDrillItem[item['groupName']] = [item];
|
|
1453
|
-
}
|
|
1454
|
-
startEvent = {
|
|
1455
|
-
cancel: false, name: drillStart, treemap: this,
|
|
1456
|
-
element: targetEle, groupIndex: this.enableBreadcrumb &&
|
|
1457
|
-
this.drilledItems.length !== 0 && !isNullOrUndefined(drillLevel) ?
|
|
1458
|
-
this.drilledItems[this.drilledItems.length - 1]['data']['groupIndex'] : item['groupIndex'],
|
|
1459
|
-
groupName: this.enableBreadcrumb && this.drilledItems.length !== 0 && !isNullOrUndefined(drillLevel) ?
|
|
1460
|
-
this.drilledItems[this.drilledItems.length - 1]['data']['name'] : item['name'],
|
|
1461
|
-
rightClick: e.which === 3 ? true : false, childItems: null, item: newDrillItem
|
|
1462
|
-
};
|
|
1463
|
-
this.trigger(drillStart, startEvent, (observedArgs: IDrillStartEventArgs) => {
|
|
1464
|
-
this.currentLevel = item['isDrilled'] && isNullOrUndefined(drillLevel) ? item['groupIndex'] :
|
|
1465
|
-
(!isNullOrUndefined(drillLevel) && this.enableBreadcrumb && item['isDrilled']) ? drillLevel : null;
|
|
1466
|
-
if (!observedArgs.cancel) {
|
|
1467
|
-
if (document.getElementById(layoutID)) {
|
|
1468
|
-
const layerElementId: HTMLElement = document.getElementById(layoutID);
|
|
1469
|
-
layerElementId.parentNode.removeChild(layerElementId);
|
|
1470
|
-
}
|
|
1471
|
-
totalRect = extend({}, this.areaRect, totalRect, true) as Rect;
|
|
1472
|
-
if (this.legendSettings.visible && !isNullOrUndefined(this.treeMapLegendModule)) {
|
|
1473
|
-
if (!isNullOrUndefined(newDrillItem)) {
|
|
1474
|
-
this.treeMapLegendModule.legendGroup.textContent = ''; this.treeMapLegendModule.legendGroup = null;
|
|
1475
|
-
this.treeMapLegendModule.widthIncrement = 0; this.treeMapLegendModule.heightIncrement = 0;
|
|
1476
|
-
if (this.enableBreadcrumb && !isNullOrUndefined(drillLevel)) {
|
|
1477
|
-
this.drilledLegendItems = {
|
|
1478
|
-
name: this.drilledItems[this.drilledItems.length - 1]['data']['levelOrderName'],
|
|
1479
|
-
data: this.drilledItems[this.drilledItems.length - 1]['data']
|
|
1480
|
-
};
|
|
1481
|
-
} else {
|
|
1482
|
-
this.drilledLegendItems = { name: item['levelOrderName'], data: item };
|
|
1483
|
-
}
|
|
1484
|
-
this.treeMapLegendModule.renderLegend();
|
|
1485
|
-
}
|
|
1486
|
-
totalRect = !isNullOrUndefined(this.totalRect) ? this.totalRect : totalRect;
|
|
1487
|
-
}
|
|
1488
|
-
if (document.getElementById(templateID)) {
|
|
1489
|
-
const drillElementId: HTMLElement = document.getElementById(templateID);
|
|
1490
|
-
drillElementId.parentNode.removeChild(drillElementId);
|
|
1491
|
-
}
|
|
1492
|
-
if (!isNullOrUndefined(observedArgs.childItems) && !observedArgs.cancel) {
|
|
1493
|
-
this.layout.onDemandProcess(observedArgs.childItems);
|
|
1494
|
-
} else {
|
|
1495
|
-
this.layout.calculateLayoutItems(newDrillItem, totalRect);
|
|
1496
|
-
this.layout.renderLayoutItems();
|
|
1497
|
-
}
|
|
1498
|
-
}
|
|
1499
|
-
});
|
|
1500
|
-
endEvent = { cancel: false, name: drillEnd, treemap: this, renderItems: this.layout.renderItems };
|
|
1501
|
-
this.trigger(drillEnd, endEvent);
|
|
1502
|
-
if (process) {
|
|
1503
|
-
if (!directLevel && isNullOrUndefined(drillLevel)) {
|
|
1504
|
-
this.drilledItems.push({ name: item['levelOrderName'], data: item });
|
|
1505
|
-
}
|
|
1506
|
-
}
|
|
1507
|
-
}
|
|
1508
|
-
}
|
|
1509
|
-
this.mouseDown = false;
|
|
1510
|
-
this.notify(Browser.touchEndEvent, e);
|
|
1511
|
-
}
|
|
1512
|
-
|
|
1513
|
-
/**
|
|
1514
|
-
* This method handles mouse leave event in treemap.
|
|
1515
|
-
*
|
|
1516
|
-
* @param {PointerEvent} e - Specifies the pointer event of mouse.
|
|
1517
|
-
* @return {void}
|
|
1518
|
-
* @private
|
|
1519
|
-
*/
|
|
1520
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
1521
|
-
public mouseLeaveOnTreeMap(e: PointerEvent): void {
|
|
1522
|
-
if (this.treeMapTooltipModule) {
|
|
1523
|
-
this.treeMapTooltipModule.removeTooltip();
|
|
1524
|
-
}
|
|
1525
|
-
if (this.treeMapLegendModule) {
|
|
1526
|
-
this.treeMapLegendModule.removeInteractivePointer();
|
|
1527
|
-
}
|
|
1528
|
-
removeClassNames(document.getElementsByClassName('treeMapHighLight'), 'treeMapHighLight', this);
|
|
1529
|
-
if (this.treeMapHighlightModule) {
|
|
1530
|
-
removeLegend(this.treeMapHighlightModule.shapeHighlightCollection, this);
|
|
1531
|
-
this.treeMapHighlightModule.highLightId = '';
|
|
1532
|
-
}
|
|
1533
|
-
this.removeFocus('');
|
|
1534
|
-
}
|
|
1535
|
-
|
|
1536
|
-
/**
|
|
1537
|
-
* This method is used to perform operations when keyboard up on TreeMap.
|
|
1538
|
-
*
|
|
1539
|
-
* @param {KeyboardEvent} event - Specifies the keyboard event on TreeMap.
|
|
1540
|
-
* @returns {void}
|
|
1541
|
-
* @private
|
|
1542
|
-
*/
|
|
1543
|
-
public keyUpHandler(event: KeyboardEvent): void {
|
|
1544
|
-
if (event.code !== 'Tab') {
|
|
1545
|
-
return;
|
|
1546
|
-
}
|
|
1547
|
-
const id: string = event.target['id'];
|
|
1548
|
-
const targetEle: Element = document.getElementById(id);
|
|
1549
|
-
if ((id.indexOf('Item_Index') > -1 || id.indexOf('Legend') > -1)) {
|
|
1550
|
-
if (this.treeMapTooltipModule) {
|
|
1551
|
-
this.treeMapTooltipModule.removeTooltip();
|
|
1552
|
-
}
|
|
1553
|
-
if (this.treeMapHighlightModule && this.highlightSettings.enable) {
|
|
1554
|
-
(targetEle as HTMLElement).style.setProperty('outline', 'none');
|
|
1555
|
-
(targetEle as HTMLElement).classList.add('keyboard-focused');
|
|
1556
|
-
const highlightElement: Element = id.indexOf('_Legend_') > -1 && this.legendSettings.mode === 'Default' ?
|
|
1557
|
-
targetEle.children[0] : targetEle;
|
|
1558
|
-
this.treeMapHighlightModule.highlightOnMouseMove(highlightElement);
|
|
1559
|
-
} else {
|
|
1560
|
-
this.removeFocus('');
|
|
1561
|
-
(targetEle as HTMLElement).style.outline = '2px solid black';
|
|
1562
|
-
(targetEle as HTMLElement).classList.add('keyboard-focused');
|
|
1563
|
-
}
|
|
1564
|
-
} else {
|
|
1565
|
-
removeClassNames(document.getElementsByClassName('treeMapHighLight'), 'treeMapHighLight', this);
|
|
1566
|
-
if (this.treeMapHighlightModule) {
|
|
1567
|
-
removeLegend(this.treeMapHighlightModule.shapeHighlightCollection, this);
|
|
1568
|
-
}
|
|
1569
|
-
this.removeFocus('none');
|
|
1570
|
-
}
|
|
1571
|
-
}
|
|
1572
|
-
|
|
1573
|
-
/**
|
|
1574
|
-
* This method is used to perform operations when keyboard down on treemap.
|
|
1575
|
-
*
|
|
1576
|
-
* @param {KeyboardEvent} event - Specifies the keyboard event on treemap.
|
|
1577
|
-
* @returns {void}
|
|
1578
|
-
* @private
|
|
1579
|
-
*/
|
|
1580
|
-
public keyDownHandler(event: KeyboardEvent): void {
|
|
1581
|
-
const id: string = event.target['id'];
|
|
1582
|
-
const targetEle: Element = document.getElementById(id);
|
|
1583
|
-
if (event.code === 'Enter') {
|
|
1584
|
-
if (this.selectionSettings.enable && (id.indexOf('Item_Index') > -1 || id.indexOf('Legend') > -1)) {
|
|
1585
|
-
const selectionElement: Element = id.indexOf('_Legend_') > -1 && this.legendSettings.mode === 'Default' ?
|
|
1586
|
-
targetEle.children[0] : targetEle;
|
|
1587
|
-
this.treeMapSelectionModule.selectionOnMouseDown(selectionElement);
|
|
1588
|
-
}
|
|
1589
|
-
if (this.enableDrillDown && targetEle.childElementCount > 0) {
|
|
1590
|
-
this.mouseEndOnTreeMap(event);
|
|
1591
|
-
}
|
|
1592
|
-
}
|
|
1593
|
-
}
|
|
1594
|
-
|
|
1595
|
-
/**
|
|
1596
|
-
* This method is used to perform operations when focus out on treemap.
|
|
1597
|
-
*
|
|
1598
|
-
* @param {KeyboardEvent} event - Specifies the keyboard event on treemap.
|
|
1599
|
-
* @returns {void}
|
|
1600
|
-
* @private
|
|
1601
|
-
*/
|
|
1602
|
-
public focusHandler(event: FocusEvent): void {
|
|
1603
|
-
const id: string = event.target['id'];
|
|
1604
|
-
if (!this.element.contains(event.relatedTarget as Node) ||
|
|
1605
|
-
(id.indexOf('Item_Index') > -1 && (event.relatedTarget as HTMLElement).id.indexOf('Legend') > -1) ||
|
|
1606
|
-
(id.indexOf('Legend') > -1 && (event.relatedTarget as HTMLElement).id.indexOf('Item_Index') > -1)) {
|
|
1607
|
-
if (this.treeMapHighlightModule && this.highlightSettings.enable) {
|
|
1608
|
-
removeClassNames(document.getElementsByClassName('treeMapHighLight'), 'treeMapHighLight', this);
|
|
1609
|
-
removeLegend(this.treeMapHighlightModule.legendHighlightCollection, this);
|
|
1610
|
-
this.treeMapHighlightModule.highLightId = '';
|
|
1611
|
-
} else {
|
|
1612
|
-
this.removeFocus('none');
|
|
1613
|
-
}
|
|
1614
|
-
}
|
|
1615
|
-
}
|
|
1616
|
-
|
|
1617
|
-
private removeFocus(outline: string): void {
|
|
1618
|
-
const highlightedElement: Element = document.querySelector('.keyboard-focused');
|
|
1619
|
-
if (highlightedElement) {
|
|
1620
|
-
(highlightedElement as HTMLElement).style.outline = outline;
|
|
1621
|
-
highlightedElement.classList.remove('keyboard-focused');
|
|
1622
|
-
}
|
|
1623
|
-
}
|
|
1624
|
-
|
|
1625
|
-
/**
|
|
1626
|
-
* This method is used to select or remove the selection of treemap item based on the provided selection settings.
|
|
1627
|
-
*
|
|
1628
|
-
* @param {string[]} levelOrder - Specifies the order of the level.
|
|
1629
|
-
* @param {boolean} isSelected - Specifies whether the treemap item should be selected or the selection should be removed.
|
|
1630
|
-
* @return {void}
|
|
1631
|
-
*/
|
|
1632
|
-
public selectItem(levelOrder: string[], isSelected ?: boolean): void {
|
|
1633
|
-
if (isNullOrUndefined(isSelected)) {
|
|
1634
|
-
isSelected = true;
|
|
1635
|
-
}
|
|
1636
|
-
let levelOrderName: string = '';
|
|
1637
|
-
for (let i: number = 0; i < levelOrder.length; i++) {
|
|
1638
|
-
if (i !== levelOrder.length - 1) {
|
|
1639
|
-
levelOrderName += levelOrder[i as number] + '#';
|
|
1640
|
-
} else {
|
|
1641
|
-
levelOrderName += levelOrder[i as number];
|
|
1642
|
-
}
|
|
1643
|
-
}
|
|
1644
|
-
if (this.treeMapSelectionModule && this.selectionSettings.enable) {
|
|
1645
|
-
this.treeMapSelectionModule.selectTreemapItem(levelOrderName, isSelected);
|
|
1646
|
-
}
|
|
1647
|
-
}
|
|
1648
|
-
|
|
1649
|
-
|
|
1650
|
-
/**
|
|
1651
|
-
* To provide the array of modules needed for maps rendering
|
|
1652
|
-
*
|
|
1653
|
-
* @returns {ModuleDeclaration[]} Returns the modules
|
|
1654
|
-
* @private
|
|
1655
|
-
*/
|
|
1656
|
-
public requiredModules(): ModuleDeclaration[] {
|
|
1657
|
-
const modules: ModuleDeclaration[] = [];
|
|
1658
|
-
if (this.tooltipSettings.visible) {
|
|
1659
|
-
modules.push({
|
|
1660
|
-
member: 'treeMapTooltip',
|
|
1661
|
-
args: [this],
|
|
1662
|
-
name: 'TreeMapTooltip'
|
|
1663
|
-
});
|
|
1664
|
-
}
|
|
1665
|
-
if (this.highlightSettings.enable) {
|
|
1666
|
-
modules.push({
|
|
1667
|
-
member: 'treeMapHighlight',
|
|
1668
|
-
args: [this],
|
|
1669
|
-
name: 'TreeMapHighlight'
|
|
1670
|
-
});
|
|
1671
|
-
}
|
|
1672
|
-
if (this.selectionSettings.enable) {
|
|
1673
|
-
modules.push({
|
|
1674
|
-
member: 'treeMapSelection',
|
|
1675
|
-
args: [this],
|
|
1676
|
-
name: 'TreeMapSelection'
|
|
1677
|
-
});
|
|
1678
|
-
}
|
|
1679
|
-
if (this.legendSettings.visible) {
|
|
1680
|
-
modules.push({
|
|
1681
|
-
member: 'treeMapLegend',
|
|
1682
|
-
args: [this],
|
|
1683
|
-
name: 'TreeMapLegend'
|
|
1684
|
-
});
|
|
1685
|
-
}
|
|
1686
|
-
if (this.allowPrint) {
|
|
1687
|
-
modules.push({
|
|
1688
|
-
member: 'Print',
|
|
1689
|
-
args: [this, Print],
|
|
1690
|
-
name: 'Print'
|
|
1691
|
-
});
|
|
1692
|
-
}
|
|
1693
|
-
if (this.allowImageExport) {
|
|
1694
|
-
modules.push({
|
|
1695
|
-
member: 'ImageExport',
|
|
1696
|
-
args: [this, ImageExport],
|
|
1697
|
-
name: 'ImageExport'
|
|
1698
|
-
});
|
|
1699
|
-
}
|
|
1700
|
-
if (this.allowPdfExport) {
|
|
1701
|
-
modules.push({
|
|
1702
|
-
member: 'PdfExport',
|
|
1703
|
-
args: [this, PdfExport],
|
|
1704
|
-
name: 'PdfExport'
|
|
1705
|
-
});
|
|
1706
|
-
}
|
|
1707
|
-
return modules;
|
|
1708
|
-
}
|
|
1709
|
-
|
|
1710
|
-
/**
|
|
1711
|
-
* Called internally if any of the property value changed.
|
|
1712
|
-
*
|
|
1713
|
-
* @param {TreeMapModel} newProp - Specifies the new property
|
|
1714
|
-
* @param {TreeMapModel} oldProp - Specifies the old property
|
|
1715
|
-
* @returns {void}
|
|
1716
|
-
* @private
|
|
1717
|
-
*/
|
|
1718
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
1719
|
-
public onPropertyChanged(newProp: TreeMapModel, oldProp: TreeMapModel): void {
|
|
1720
|
-
if (!this.isDestroyed) {
|
|
1721
|
-
let render: boolean = false;
|
|
1722
|
-
for (const prop of Object.keys(newProp)) {
|
|
1723
|
-
switch (prop) {
|
|
1724
|
-
case 'background':
|
|
1725
|
-
this.renderBorder();
|
|
1726
|
-
break;
|
|
1727
|
-
case 'height':
|
|
1728
|
-
case 'width':
|
|
1729
|
-
case 'layoutType':
|
|
1730
|
-
case 'levels':
|
|
1731
|
-
case 'drillDownView':
|
|
1732
|
-
case 'renderDirection':
|
|
1733
|
-
case 'leafItemSettings':
|
|
1734
|
-
case 'legendSettings':
|
|
1735
|
-
case 'dataSource':
|
|
1736
|
-
render = true;
|
|
1737
|
-
break;
|
|
1738
|
-
}
|
|
1739
|
-
}
|
|
1740
|
-
if (render) {
|
|
1741
|
-
this.createSvg();
|
|
1742
|
-
this.renderElements();
|
|
1743
|
-
}
|
|
1744
|
-
}
|
|
1745
|
-
}
|
|
1746
|
-
|
|
1747
|
-
/**
|
|
1748
|
-
* Gets component name.
|
|
1749
|
-
*
|
|
1750
|
-
* @returns {string} - return the treemap instance.
|
|
1751
|
-
* @private
|
|
1752
|
-
*/
|
|
1753
|
-
public getModuleName(): string {
|
|
1754
|
-
return 'treemap';
|
|
1755
|
-
}
|
|
1756
|
-
|
|
1757
|
-
/**
|
|
1758
|
-
* This method destroys the treemap. This method removes the events associated with the treemap and disposes the objects created for rendering and updating the treemap.
|
|
1759
|
-
*/
|
|
1760
|
-
public destroy(): void {
|
|
1761
|
-
this.unWireEVents();
|
|
1762
|
-
removeElement('treeMapMeasureText');
|
|
1763
|
-
this.drilledItems = [];
|
|
1764
|
-
this.levelSelection = [];
|
|
1765
|
-
this.legendId = [];
|
|
1766
|
-
this.removeSvg();
|
|
1767
|
-
super.destroy();
|
|
1768
|
-
this.areaRect = null;
|
|
1769
|
-
this.themeStyle = null;
|
|
1770
|
-
this.totalRect = null;
|
|
1771
|
-
this.drilledLegendItems = null;
|
|
1772
|
-
this.doubleTapTimer = null;
|
|
1773
|
-
this.treemapLevelData = null;
|
|
1774
|
-
this.resizeEvent = null;
|
|
1775
|
-
this.availableSize = null;
|
|
1776
|
-
this.intl = null;
|
|
1777
|
-
if (!isNullOrUndefined(this.layout)) {
|
|
1778
|
-
this.layout.destroy();
|
|
1779
|
-
}
|
|
1780
|
-
this.layout = null;
|
|
1781
|
-
this.renderer = null;
|
|
1782
|
-
}
|
|
1783
|
-
|
|
1784
|
-
private removeSvg(): void {
|
|
1785
|
-
removeElement(this.element.id + '_Secondary_Element');
|
|
1786
|
-
if (this.svgObject) {
|
|
1787
|
-
while (this.svgObject.childNodes.length > 0) {
|
|
1788
|
-
this.svgObject.removeChild(this.svgObject.firstChild);
|
|
1789
|
-
}
|
|
1790
|
-
if (!this.svgObject.hasChildNodes() && this.svgObject.parentNode) {
|
|
1791
|
-
remove(this.svgObject);
|
|
1792
|
-
}
|
|
1793
|
-
}
|
|
1794
|
-
}
|
|
1795
|
-
|
|
1796
|
-
/**
|
|
1797
|
-
* Get the properties to be maintained in the persisted state.
|
|
1798
|
-
*
|
|
1799
|
-
* @returns {string} - Returns the string value.
|
|
1800
|
-
* @private
|
|
1801
|
-
*/
|
|
1802
|
-
public getPersistData(): string {
|
|
1803
|
-
return '';
|
|
1804
|
-
}
|
|
1805
|
-
}
|
|
1806
|
-
|
|
1807
|
-
/**
|
|
1808
|
-
* @private
|
|
1809
|
-
*/
|
|
1810
|
-
export class LevelsData {
|
|
1811
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
1812
|
-
levelsData : any[];
|
|
1813
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
1814
|
-
defaultLevelsData : any[];
|
|
1815
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
1816
|
-
hierarchyData : any[];
|
|
1817
|
-
}
|