@syncfusion/ej2-treemap 19.3.53 → 19.4.38

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,118 @@
1
+ /**
2
+ * TreeMap constants doc
3
+ */
4
+
5
+ /**
6
+ * Triggers when the treemap is on load.
7
+ *
8
+ * @private
9
+ */
10
+ export const load: string = 'load';
11
+ /**
12
+ * Triggers after treemap rendered.
13
+ *
14
+ * @private
15
+ */
16
+ export const loaded: string = 'loaded';
17
+ /**
18
+ * Trigger before call the print method.
19
+ *
20
+ * @private
21
+ */
22
+ export const beforePrint: string = 'beforePrint';
23
+ /**
24
+ * Trigger before each treemap item rendered.
25
+ *
26
+ * @private
27
+ */
28
+ export const itemRendering: string = 'itemRendering';
29
+ /**
30
+ * Trigger after click on treemap item.
31
+ *
32
+ * @private
33
+ */
34
+ export const drillStart: string = 'drillStart';
35
+ /**
36
+ * Trigger after drill start event completed.
37
+ *
38
+ * @private
39
+ */
40
+ export const drillEnd: string = 'drillEnd';
41
+ /**
42
+ * Trigger after select the treemap item.
43
+ *
44
+ * @private
45
+ */
46
+ export const itemSelected: string = 'itemSelected';
47
+ /**
48
+ * Trigger after hover on the treemap item.
49
+ *
50
+ * @private
51
+ */
52
+ export const itemHighlight: string = 'itemHighlight';
53
+ /**
54
+ * Trigger after mouse hover on the treemap item.
55
+ *
56
+ * @private
57
+ */
58
+ export const tooltipRendering: string = 'tooltipRendering';
59
+ /**
60
+ * Trigger after click on the treemap item.
61
+ *
62
+ * @private
63
+ */
64
+ export const itemClick: string = 'itemClick';
65
+ /**
66
+ * Trigger after mouse hover on the treemap item.
67
+ *
68
+ * @private
69
+ */
70
+ export const itemMove: string = 'itemMove';
71
+ /**
72
+ * Trigger after click on the treemap item.
73
+ *
74
+ * @private
75
+ */
76
+ export const click: string = 'click';
77
+ /**
78
+ * Trigger after double click on the treemap item.
79
+ *
80
+ * @private
81
+ */
82
+ export const doubleClick: string = 'doubleClick';
83
+ /**
84
+ * Trigger after right click on the treemap item.
85
+ *
86
+ * @private
87
+ */
88
+ export const rightClick: string = 'rightClick';
89
+ /**
90
+ * Trigger after mouse hover on the treemap item.
91
+ *
92
+ * @private
93
+ */
94
+ export const mouseMove: string = 'mouseMove';
95
+ /**
96
+ * Trigger before each treemap item.
97
+ *
98
+ * @private
99
+ */
100
+ export const legendItemRendering: string = 'legendItemRendering';
101
+ /**
102
+ * Trigger before legend items.
103
+ *
104
+ * @private
105
+ */
106
+ export const legendRendering: string = 'legendRendering';
107
+ /**
108
+ * Trigger after resize the treemap.
109
+ *
110
+ * @private
111
+ */
112
+ export const resize: string = 'resize';
113
+ /**
114
+ * Define the font family in treemap component.
115
+ *
116
+ * @private
117
+ */
118
+ export const defaultFont: string = 'Roboto, Segoe UI, Noto, Sans-serif';
@@ -0,0 +1,109 @@
1
+ import { createElement, Browser } from '@syncfusion/ej2-base';
2
+ import { TreeMap} from '../../index';
3
+ import { ExportType } from '../utils/enum';
4
+ import { triggerDownload } from '../utils/helper';
5
+
6
+ /**
7
+ * ImageExport module handles the export to image functionality for treemap.
8
+ *
9
+ * @hidden
10
+ */
11
+ export class ImageExport {
12
+ private control: TreeMap ;
13
+ /**
14
+ * Constructor for Maps
15
+ *
16
+ * @param {TreeMap} control - Specifies the treemap instance
17
+ */
18
+ // eslint-disable-next-line @typescript-eslint/explicit-member-accessibility
19
+ constructor(control: TreeMap) {
20
+ this.control = control;
21
+ }
22
+ /**
23
+ * This method is used to perform the export functionality for the rendered treemap.
24
+ *
25
+ * @param {ExportType} type - Specifies the type of the image file.
26
+ * @param {string} fileName - Specifies the file name of the image file.
27
+ * @param {boolean} allowDownload - Specifies whether to download the file or not.
28
+ * @returns {Promise} - Returns the promise string.
29
+ * @private
30
+ */
31
+ public export(type: ExportType, fileName: string, allowDownload ?: boolean): Promise<string> {
32
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
33
+ const promise: Promise<string> = new Promise((resolve: any, reject: any) => {
34
+ const element: HTMLCanvasElement = <HTMLCanvasElement>createElement('canvas', {
35
+ id: 'ej2-canvas',
36
+
37
+ attrs: {
38
+ 'height': this.control.availableSize.height.toString(),
39
+ 'width': this.control.availableSize.width.toString()
40
+ } });
41
+
42
+ const isDownload: boolean = !(Browser.userAgent.toString().indexOf('HeadlessChrome') > -1);
43
+ const svgData: string = '<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">' +
44
+ this.control.svgObject.outerHTML +
45
+ '</svg>';
46
+ const url: string = window.URL.createObjectURL(
47
+ new Blob(
48
+ type === 'SVG' ? [svgData] :
49
+ [(new XMLSerializer()).serializeToString(this.control.svgObject)],
50
+ { type: 'image/svg+xml' }
51
+ )
52
+ );
53
+ if (type === 'SVG' ) {
54
+ if (allowDownload) {
55
+ triggerDownload(
56
+ fileName, type,
57
+ url, isDownload
58
+ );
59
+ } else {
60
+ resolve(null);
61
+ }
62
+
63
+ } else {
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
+ if (allowDownload) {
71
+ triggerDownload(fileName, type,
72
+ element.toDataURL('image/png').replace('image/png', 'image/octet-stream'),
73
+ isDownload );
74
+ } else {
75
+
76
+ if (type === 'JPEG') {
77
+ resolve(element.toDataURL('image/jpeg'));
78
+ } else if (type === 'PNG') {
79
+ resolve(element.toDataURL('image/png'));
80
+ }
81
+
82
+ }
83
+
84
+ });
85
+ image.src = url;
86
+
87
+ }
88
+ });
89
+ return promise;
90
+ }
91
+
92
+ protected getModuleName(): string {
93
+ // Returns te module name
94
+ return 'ImageExport';
95
+ }
96
+
97
+ /**
98
+ * To destroy the ImageExport.
99
+ *
100
+ * @param {TreeMap} treemap - Specifies the instance of the treemap.
101
+ * @returns {void}
102
+ * @private
103
+ */
104
+ public destroy(treemap: TreeMap): void {
105
+ // Destroy method performed here
106
+ }
107
+
108
+
109
+ }