@syncfusion/ej2-treemap 20.1.59 → 20.2.36

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.
@@ -0,0 +1,554 @@
1
+ /* eslint-disable @typescript-eslint/member-delimiter-style */
2
+ /* eslint-disable @typescript-eslint/naming-convention */
3
+ import { TreeMap } from '../../treemap/treemap';
4
+ import { BorderModel, FontModel } from '../model/base-model';
5
+ import { LegendShape, LegendPosition } from '../utils/enum';
6
+ import { Size } from '../utils/helper';
7
+
8
+
9
+ /**
10
+ * Specifies the event argument for the treemap component.
11
+ *
12
+ * @private
13
+ */
14
+ export interface ITreeMapEventArgs {
15
+ /** Defines the name of the event. */
16
+ name: string;
17
+ /**
18
+ * Specifies the cancel state for the event. The default value is false.
19
+ * If set as true, the event progress will be stopped.
20
+ */
21
+ cancel: boolean;
22
+ }
23
+ /**
24
+ * Specifies the event arguments for print event in treemap.
25
+ */
26
+ export interface IPrintEventArgs extends ITreeMapEventArgs {
27
+ /**
28
+ * Specifies the html content that is printed. The html content returned is usually the id string of the treemap.
29
+ */
30
+ htmlContent: Element;
31
+ }
32
+ /**
33
+ * Specifies the event arguments for on load event in treemap.
34
+ */
35
+ export interface ILoadEventArgs extends ITreeMapEventArgs {
36
+ /** Defines the current treemap instance.
37
+ *
38
+ * @deprecated
39
+ */
40
+ treemap?: TreeMap;
41
+ }
42
+
43
+ /**
44
+ * Specifies the event arguments for loaded event in treemap.
45
+ */
46
+ export interface ILoadedEventArgs extends ITreeMapEventArgs {
47
+ /** Defines the current treemap instance.
48
+ *
49
+ * @deprecated
50
+ */
51
+ treemap?: TreeMap;
52
+
53
+ /** Defines isResized argument.
54
+ */
55
+ isResized: boolean;
56
+ }
57
+
58
+ /**
59
+ * Specifies the event arguments in item rendering event in treemap.
60
+ */
61
+ export interface IItemRenderingEventArgs extends ITreeMapEventArgs {
62
+ /** Defines the current treemap instance
63
+ *
64
+ * @deprecated
65
+ */
66
+ treemap?: TreeMap;
67
+ /**
68
+ * Defines the current rendering item.
69
+ */
70
+ // eslint-disable-next-line @typescript-eslint/ban-types
71
+ currentItem: Object;
72
+ /**
73
+ * Defines all the items for rendering.
74
+ */
75
+ // eslint-disable-next-line @typescript-eslint/ban-types
76
+ RenderItems?: Object[];
77
+ /**
78
+ * Defines the options for the treemap item rendering.
79
+ */
80
+ // eslint-disable-next-line @typescript-eslint/ban-types
81
+ options: Object;
82
+ /**
83
+ * Defines the header text of the treemap item.
84
+ */
85
+ text: string;
86
+ }
87
+
88
+ /**
89
+ * Specifies the event arguments for the drill down start event of treemap.
90
+ */
91
+ export interface IDrillStartEventArgs extends ITreeMapEventArgs {
92
+ /** Defines the current treemap instance.
93
+ *
94
+ * @deprecated
95
+ */
96
+ treemap?: TreeMap;
97
+ /**
98
+ * Defines the current drill-down.
99
+ */
100
+ // eslint-disable-next-line @typescript-eslint/ban-types
101
+ item: Object;
102
+ /**
103
+ * Defines the current element of drill-down.
104
+ */
105
+ element: Element;
106
+ /**
107
+ * Defines the level of the treemap item.
108
+ */
109
+ groupIndex: number;
110
+ /**
111
+ * Defines the parent name of the treemap item.
112
+ */
113
+ groupName: string;
114
+ /**
115
+ * Returns a boolean value whether it is right click or not.
116
+ */
117
+ rightClick: boolean;
118
+ /**
119
+ * Defines the child values of the item in the drill start event.
120
+ */
121
+ // eslint-disable-next-line @typescript-eslint/ban-types
122
+ childItems: Object;
123
+ }
124
+
125
+ /**
126
+ * Specifies the event arguments for the drill down end event of the treemap.
127
+ */
128
+ export interface IDrillEndEventArgs extends ITreeMapEventArgs {
129
+ /** Defines the current treemap instance.
130
+ *
131
+ * @deprecated
132
+ */
133
+ treemap?: TreeMap;
134
+ /**
135
+ * Defines all the items for rendering.
136
+ */
137
+ // eslint-disable-next-line @typescript-eslint/ban-types
138
+ renderItems: Object[];
139
+ }
140
+
141
+ /**
142
+ * Defines the event arguments for treemap item click event.
143
+ */
144
+ export interface IItemClickEventArgs extends ITreeMapEventArgs {
145
+ /** Defines the current treemap instance.
146
+ *
147
+ * @deprecated
148
+ */
149
+ treemap?: TreeMap;
150
+ /**
151
+ * Defines the current item in the click event.
152
+ *
153
+ * @isGenericType true
154
+ */
155
+ // eslint-disable-next-line @typescript-eslint/ban-types
156
+ item: Object;
157
+ /**
158
+ * Defines the original mouse event arguments.
159
+ */
160
+ mouseEvent: PointerEvent;
161
+ /**
162
+ * Defines the level of the current treemap item.
163
+ */
164
+ groupIndex: number;
165
+ /**
166
+ * Defines the parent name of the current treemap item.
167
+ */
168
+ groupName: string;
169
+ /**
170
+ * Defines the header name of the current treemap item.
171
+ */
172
+ text: string;
173
+ /**
174
+ * Defines the template of the treemap item which is used to add it in the treemap control.
175
+ */
176
+ contentItemTemplate : string;
177
+ }
178
+
179
+ /**
180
+ * Defines the event argument of the treemap item data.
181
+ */
182
+ export interface IItemDataEventArgs {
183
+ /**
184
+ * Defines the name of the treemap item.
185
+ */
186
+ name: string;
187
+ /**
188
+ * Defines the level of the current treemap item.
189
+ */
190
+ groupIndex: number;
191
+ /**
192
+ * Defines the parent name of the current treemap item.
193
+ */
194
+ groupName: string;
195
+ /**
196
+ * Specifies whether the drill down is performed or not.
197
+ */
198
+ isDrilled: boolean;
199
+ /**
200
+ * Specifies whether the item is leaf item or not.
201
+ */
202
+ isLeafItem: boolean;
203
+ /**
204
+ * Defines the item area in the treemap.
205
+ */
206
+ itemArea: number;
207
+ /**
208
+ * Defines the name of the parent level of the treemap item.
209
+ */
210
+ levelOrderName: string;
211
+ /**
212
+ * Defines the options provided in the event arguments
213
+ */
214
+ // eslint-disable-next-line @typescript-eslint/ban-types
215
+ options?: Object;
216
+ /**
217
+ * Specifies the rect element in the event.
218
+ */
219
+ // eslint-disable-next-line @typescript-eslint/ban-types
220
+ rect?: Object;
221
+ }
222
+
223
+ /**
224
+ * Specifies the event arguments available on performing mouse move on the treemap items.
225
+ */
226
+ export interface IItemMoveEventArgs extends ITreeMapEventArgs {
227
+ /** Defines the current treemap instance.
228
+ *
229
+ * @deprecated
230
+ */
231
+ treemap?: TreeMap;
232
+ /**
233
+ * Defines the current item move.
234
+ *
235
+ * @isGenericType true
236
+ */
237
+ // eslint-disable-next-line @typescript-eslint/ban-types
238
+ item: Object;
239
+ /**
240
+ * Defines the original mouse event arguments.
241
+ */
242
+ mouseEvent: PointerEvent;
243
+ }
244
+
245
+ /**
246
+ * Specifies the event arguments available on performing click event on the treemap items.
247
+ */
248
+ export interface IClickEventArgs extends ITreeMapEventArgs {
249
+ /** Defines the current treemap instance.
250
+ *
251
+ * @deprecated
252
+ */
253
+ treemap?: TreeMap;
254
+ /**
255
+ * Defines the original mouse event arguments.
256
+ */
257
+ mouseEvent: PointerEvent;
258
+ }
259
+
260
+ /**
261
+ * Specifies the event arguments available on performing double click event on the treemap items.
262
+ */
263
+ export interface IDoubleClickEventArgs extends ITreeMapEventArgs {
264
+ /** Defines the current treemap instance.
265
+ *
266
+ * @deprecated
267
+ */
268
+ treemap?: TreeMap;
269
+ /**
270
+ * Defines the original mouse event arguments.
271
+ */
272
+ mouseEvent: PointerEvent;
273
+ }
274
+
275
+ /**
276
+ * Specifies the event arguments available on performing right click event on the treemap items.
277
+ */
278
+ export interface IRightClickEventArgs extends ITreeMapEventArgs {
279
+ /** Defines the current treemap instance.
280
+ *
281
+ * @deprecated
282
+ */
283
+ treemap?: TreeMap;
284
+ /**
285
+ * Defines the original mouse event arguments.
286
+ */
287
+ mouseEvent: PointerEvent;
288
+ }
289
+
290
+ /**
291
+ * Specifies the event arguments available on performing mouse over on the treemap items.
292
+ */
293
+ export interface IMouseMoveEventArgs extends ITreeMapEventArgs {
294
+ /** Defines the current treemap instance.
295
+ *
296
+ * @deprecated
297
+ */
298
+ treemap?: TreeMap;
299
+ /**
300
+ * Defines the original mouse event arguments.
301
+ */
302
+ mouseEvent: PointerEvent;
303
+ }
304
+
305
+ /**
306
+ * Specifies the event arguments available when the item is selected in the treemap component.
307
+ */
308
+ export interface IItemSelectedEventArgs extends ITreeMapEventArgs {
309
+ /** Defines the current treemap instance.
310
+ *
311
+ * @deprecated
312
+ */
313
+ treemap?: TreeMap;
314
+ /**
315
+ * Specifies the current selected item.
316
+ */
317
+ // eslint-disable-next-line @typescript-eslint/ban-types
318
+ items: Object[];
319
+ /**
320
+ * Specifies the current selected elements.
321
+ */
322
+ elements: Element[];
323
+ /**
324
+ * Defines the text used in the label contents.
325
+ */
326
+ text: string;
327
+ /**
328
+ * Defines the template of the treemap item which is used to add it in the treemap control.
329
+ */
330
+ contentItemTemplate : string;
331
+ }
332
+
333
+ /**
334
+ * Specifies the event arguments available when the item is highlighted in the treemap component.
335
+ */
336
+ export interface IItemHighlightEventArgs extends ITreeMapEventArgs {
337
+ /**
338
+ * Defines the current treemap instance.
339
+ *
340
+ * @deprecated
341
+ */
342
+ treemap?: TreeMap;
343
+ /**
344
+ * Defines the current item which is highlighted.
345
+ */
346
+ // eslint-disable-next-line @typescript-eslint/ban-types
347
+ items: Object[];
348
+ /**
349
+ * Defines the current highlighted elements.
350
+ */
351
+ elements: Element[];
352
+ }
353
+
354
+ /**
355
+ * Specifies the event arguments available when the tooltip is rendered in the treemap component.
356
+ */
357
+ export interface ITreeMapTooltipRenderEventArgs extends ITreeMapEventArgs {
358
+ /** Defines the current treemap instance.
359
+ *
360
+ * @deprecated
361
+ */
362
+ treemap?: TreeMap;
363
+ /**
364
+ * Defines the current treemap item in which the tooltip appears.
365
+ */
366
+ // eslint-disable-next-line @typescript-eslint/ban-types
367
+ item: Object;
368
+ /**
369
+ * Defines the options for customizing the tooltip.
370
+ */
371
+ // eslint-disable-next-line @typescript-eslint/ban-types
372
+ options: Object;
373
+ /**
374
+ * Defines the current tooltip element.
375
+ */
376
+ element?: Element;
377
+ /**
378
+ * Defines the original mouse event arguments.
379
+ */
380
+ eventArgs: PointerEvent;
381
+ }
382
+
383
+ /**
384
+ * Specifies the event arguments available for the tooltip events in the treemap component.
385
+ */
386
+ export interface ITreeMapTooltipArgs extends ITreeMapEventArgs {
387
+ /**
388
+ * Defines the location of the tooltip rendering event.
389
+ */
390
+ // eslint-disable-next-line @typescript-eslint/ban-types
391
+ location: Object;
392
+ /**
393
+ * Defines the text rendered in the tooltip.
394
+ */
395
+ text: string[];
396
+ /**
397
+ * Defines the data for rendering the tooltip.
398
+ */
399
+ // eslint-disable-next-line @typescript-eslint/ban-types
400
+ data: Object;
401
+ /**
402
+ * Defines the text style for customizing the tooltip text.
403
+ */
404
+ textStyle: FontModel;
405
+ /**
406
+ * Defines the template for rendering the tooltip.
407
+ */
408
+ template: string;
409
+ }
410
+
411
+ /**
412
+ * Specifies the event arguments available when rendering each legend item in the treemap component.
413
+ */
414
+ export interface ILegendItemRenderingEventArgs extends ITreeMapEventArgs {
415
+ /**
416
+ * Defines the current treemap instance.
417
+ *
418
+ * @deprecated
419
+ */
420
+ treemap?: TreeMap;
421
+ /**
422
+ * Specifies the shape color of the legend.
423
+ */
424
+ fill?: string;
425
+ /**
426
+ * Specifies the options for customizing the color and width of the shape border.
427
+ */
428
+ shapeBorder?: BorderModel;
429
+ /**
430
+ * Defines the legend shape of the treemap.
431
+ */
432
+ shape?: LegendShape;
433
+ /**
434
+ * Defines the URL of the legend if the shape is rendered as image.
435
+ */
436
+ imageUrl?: string;
437
+ }
438
+
439
+ /**
440
+ * Specifies the event arguments available when rendering the legend in the treemap component.
441
+ */
442
+ export interface ILegendRenderingEventArgs extends ITreeMapEventArgs {
443
+ /**
444
+ * Defines the current treemap instance.
445
+ *
446
+ * @deprecated
447
+ */
448
+ treemap?: TreeMap;
449
+ /**
450
+ * Specifies the position of the legend in the treemap component.
451
+ */
452
+ position?: LegendPosition;
453
+ /**
454
+ * Specifies the position of the legend in the treemap component.
455
+ */
456
+ _changePosition?: LegendPosition;
457
+ }
458
+
459
+
460
+ /**
461
+ * Specifies the event arguments available for resize event of the treemap component.
462
+ */
463
+ export interface IResizeEventArgs extends ITreeMapEventArgs {
464
+ /** Defines the size of the treemap before resizing. */
465
+ previousSize: Size;
466
+ /** Defines the size of the treemap after resizing. */
467
+ currentSize: Size;
468
+ /** Defines the treemap instance.
469
+ *
470
+ * @deprecated
471
+ */
472
+ treemap?: TreeMap;
473
+ }
474
+
475
+
476
+ /**
477
+ * @private
478
+ */
479
+ export interface IFontMapping {
480
+ size?: string;
481
+ color?: string;
482
+ fontWeight?: string;
483
+ fontStyle?: string;
484
+ fontFamily?: string;
485
+ }
486
+
487
+
488
+ /**
489
+ * @private
490
+ */
491
+ export interface IShapes {
492
+ // eslint-disable-next-line @typescript-eslint/ban-types
493
+ renderOption?: Object;
494
+ functionName?: string;
495
+ }
496
+
497
+
498
+ /**
499
+ * Defines the theme supported for treemap component.
500
+ */
501
+ export interface IThemeStyle {
502
+ /**
503
+ * Defines the background color of the treemap, supporting the theme.
504
+ */
505
+ backgroundColor: string;
506
+ /**
507
+ * Defines the title text color of the treemap, supporting the theme.
508
+ */
509
+ titleFontColor: string;
510
+ /**
511
+ * Defines the subtitle text color of the treemap, supporting the theme.
512
+ */
513
+ subTitleFontColor: string;
514
+ /**
515
+ * Defines the tooltip fill color of the treemap, supporting the theme.
516
+ */
517
+ tooltipFillColor: string;
518
+ /**
519
+ * Defines the tooltip text color of the treemap supporting the theme.
520
+ */
521
+ tooltipFontColor: string;
522
+ /**
523
+ * Defines the opacity of tooltip in the treemap, supporting the theme.
524
+ */
525
+ tooltipFillOpacity?: number;
526
+ /**
527
+ * Defines the opacity of tooltip text in the treemap, supporting the theme.
528
+ */
529
+ tooltipTextOpacity?: number;
530
+ /**
531
+ * Defines the color of the legend title in the treemap, supporting the theme.
532
+ */
533
+ legendTitleColor: string;
534
+ /**
535
+ * Defines the color of the legend text in the treemap, supporting the theme.
536
+ */
537
+ legendTextColor: string;
538
+ /**
539
+ * Defines the font family of texts in the treemap, supporting the theme.
540
+ */
541
+ fontFamily?: string;
542
+ /**
543
+ * Defines the font size of the texts in the treemap, supporting the theme.
544
+ */
545
+ fontSize?: string;
546
+ /**
547
+ * Defines the font size of the legend texts in the treemap, supporting the theme.
548
+ */
549
+ legendFontSize?: string;
550
+ /**
551
+ * Defines the font family of the label contents in the treemap, supporting the theme.
552
+ */
553
+ labelFontFamily?: string;
554
+ }
@@ -0,0 +1,103 @@
1
+ import { createElement, isNullOrUndefined, Browser } from '@syncfusion/ej2-base';
2
+ import { TreeMap} from '../../index';
3
+ import { ExportType } from '../utils/enum';
4
+ import { PdfPageOrientation, PdfDocument, PdfBitmap } from '@syncfusion/ej2-pdf-export';
5
+
6
+ /**
7
+ * PdfExport module handles the export to pdf functionality for treemap.
8
+ *
9
+ * @hidden
10
+ */
11
+ export class PdfExport {
12
+ private control: TreeMap ;
13
+
14
+ /**
15
+ * Constructor for Maps
16
+ *
17
+ * @param {TreeMap} control - Specifies the treemap instance
18
+ */
19
+ // eslint-disable-next-line @typescript-eslint/explicit-member-accessibility
20
+ constructor(control: TreeMap) {
21
+ this.control = control;
22
+ }
23
+
24
+ /**
25
+ * This method is used to perform the export functionality for the rendered treemap.
26
+ *
27
+ * @param {ExportType} type - Specifies the type of the document.
28
+ * @param {string} fileName - Specifies the name of the document.
29
+ * @param {PdfPageOrientation} orientation - Specifies the orientation of the PDF document to export the component.
30
+ * @param {boolean} allowDownload - Specifies whether to download the document or not.
31
+ * @returns {Promise} - Returns the string.
32
+ * @private
33
+ */
34
+ public export(type: ExportType, fileName: string, orientation?: PdfPageOrientation, allowDownload ?: boolean): Promise<string> {
35
+
36
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
37
+ const promise: Promise<string> = new Promise((resolve: any, reject: any) => {
38
+ const element: HTMLCanvasElement = <HTMLCanvasElement>createElement('canvas', {
39
+ id: 'ej2-canvas',
40
+ attrs: {
41
+ 'width': this.control.availableSize.width.toString(),
42
+ 'height': this.control.availableSize.height.toString()
43
+ }
44
+ });
45
+ const isDownload: boolean = !(Browser.userAgent.toString().indexOf('HeadlessChrome') > -1);
46
+ orientation = isNullOrUndefined(orientation) ? PdfPageOrientation.Landscape : orientation;
47
+ const exportElement: HTMLElement = this.control.svgObject.cloneNode(true) as HTMLElement;
48
+ const backgroundElement: HTMLElement = exportElement.childNodes[0] as HTMLElement;
49
+ if (!isNullOrUndefined(backgroundElement)) {
50
+ const backgroundColor: string = backgroundElement.getAttribute('fill');
51
+ if ((this.control.theme === 'Tailwind' || this.control.theme === 'TailwindDark' || this.control.theme === 'Bootstrap5' || this.control.theme === 'Bootstrap5Dark'
52
+ || this.control.theme === 'Fluent' || this.control.theme === 'FluentDark') && (backgroundColor === 'rgba(255,255,255, 0.0)' || backgroundColor === 'transparent')) {
53
+ (exportElement.childNodes[0] as HTMLElement).setAttribute('fill', 'rgba(255,255,255, 1)');
54
+ }
55
+ }
56
+
57
+ const url: string = window.URL.createObjectURL(
58
+ new Blob(
59
+ [(new XMLSerializer()).serializeToString(exportElement)],
60
+ { type: 'image/svg+xml' }
61
+ )
62
+ );
63
+
64
+ const image: HTMLImageElement = new Image();
65
+ const context: CanvasRenderingContext2D = element.getContext('2d');
66
+ image.onload = (() => {
67
+ context.drawImage(image, 0, 0);
68
+ window.URL.revokeObjectURL(url);
69
+
70
+ const document: PdfDocument = new PdfDocument();
71
+ let imageString: string = element.toDataURL('image/jpeg').replace('image/jpeg', 'image/octet-stream');
72
+ document.pageSettings.orientation = orientation;
73
+ imageString = imageString.slice(imageString.indexOf(',') + 1);
74
+ document.pages.add().graphics.drawImage(
75
+ new PdfBitmap(imageString), 0, 0, (this.control.availableSize.width - 60), this.control.availableSize.height
76
+ );
77
+ if (allowDownload) {
78
+ document.save(fileName + '.pdf');
79
+ document.destroy();
80
+ } else {
81
+ resolve(null);
82
+ }
83
+ });
84
+ image.src = url;
85
+ });
86
+ return promise;
87
+ }
88
+ protected getModuleName(): string {
89
+ // Returns te module name
90
+ return 'PdfExport';
91
+ }
92
+
93
+ /**
94
+ * To destroy the ImageExport.
95
+ *
96
+ * @param {TreeMap} treemap - Specifies the treemap instance.
97
+ * @returns {void}
98
+ * @private
99
+ */
100
+ public destroy(treemap: TreeMap): void {
101
+ // Destroy method performed here
102
+ }
103
+ }