squarified 0.1.2 → 0.2.1
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 +42 -8
- package/dist/index.d.mts +87 -67
- package/dist/index.d.ts +87 -67
- package/dist/index.js +502 -272
- package/dist/index.mjs +502 -272
- package/package.json +7 -13
package/README.md
CHANGED
|
@@ -4,19 +4,53 @@
|
|
|
4
4
|
|
|
5
5
|

|
|
6
6
|
|
|
7
|
-
##
|
|
7
|
+
## Install
|
|
8
8
|
|
|
9
|
-
```
|
|
10
|
-
|
|
9
|
+
```shell
|
|
10
|
+
$ yarn add squarified
|
|
11
|
+
```
|
|
11
12
|
|
|
12
|
-
|
|
13
|
+
## Usage
|
|
13
14
|
|
|
14
|
-
|
|
15
|
-
treemap.use('decorator', presetDecorator)
|
|
15
|
+
See the dev directory for a minimal example.
|
|
16
16
|
|
|
17
|
-
|
|
17
|
+
### API
|
|
18
18
|
|
|
19
|
-
|
|
19
|
+
```ts
|
|
20
|
+
// convert data into expected data
|
|
21
|
+
declare function c2m<
|
|
22
|
+
T extends AnyObject & {
|
|
23
|
+
groups: any[]
|
|
24
|
+
},
|
|
25
|
+
K extends keyof T
|
|
26
|
+
>(data: T, key: K, modifier?: (data: T) => T): T & {
|
|
27
|
+
weight: number
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
// preset theme layout (unstable)
|
|
31
|
+
declare function presetDecorator(app: TreemapLayout): void
|
|
32
|
+
|
|
33
|
+
declare function getNodeDepth(node: NativeModule): number
|
|
34
|
+
|
|
35
|
+
declare function visit<T extends AnyObject>(data: T[], fn: (data: T) => boolean | void): T | null
|
|
36
|
+
|
|
37
|
+
declare function findRelativeNode(p: {
|
|
38
|
+
x: number
|
|
39
|
+
y: number
|
|
40
|
+
}, layoutNodes: LayoutModule[]): LayoutModule | null
|
|
41
|
+
|
|
42
|
+
declare function findRelativeNodeById(id: string, layoutNodes: LayoutModule[]): LayoutModule | null
|
|
43
|
+
|
|
44
|
+
interface App {
|
|
45
|
+
init: (el: HTMLElement) => void
|
|
46
|
+
dispose: () => void
|
|
47
|
+
setOptions: (options: TreemapOptions) => void
|
|
48
|
+
resize: () => void
|
|
49
|
+
use: (using: Using, register: (app: TreemapLayout) => void) => void
|
|
50
|
+
zoom: (id: string) => void
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
declare function createTreemap(): App
|
|
20
54
|
```
|
|
21
55
|
|
|
22
56
|
### Auth
|
package/dist/index.d.mts
CHANGED
|
@@ -6,7 +6,7 @@ interface MatrixLoc {
|
|
|
6
6
|
e: number;
|
|
7
7
|
f: number;
|
|
8
8
|
}
|
|
9
|
-
declare class Matrix2D {
|
|
9
|
+
declare class Matrix2D implements MatrixLoc {
|
|
10
10
|
a: number;
|
|
11
11
|
b: number;
|
|
12
12
|
c: number;
|
|
@@ -26,7 +26,8 @@ declare const enum DisplayType {
|
|
|
26
26
|
Graph = "Graph",
|
|
27
27
|
Box = "Box",
|
|
28
28
|
Rect = "Rect",
|
|
29
|
-
Text = "Text"
|
|
29
|
+
Text = "Text",
|
|
30
|
+
Layer = "Layer"
|
|
30
31
|
}
|
|
31
32
|
declare abstract class Display {
|
|
32
33
|
parent: Display | null;
|
|
@@ -36,12 +37,6 @@ declare abstract class Display {
|
|
|
36
37
|
constructor();
|
|
37
38
|
destory(): void;
|
|
38
39
|
}
|
|
39
|
-
interface GraphStyleSheet {
|
|
40
|
-
stroke: string;
|
|
41
|
-
opacity: number;
|
|
42
|
-
font: string;
|
|
43
|
-
lineWidth: number;
|
|
44
|
-
}
|
|
45
40
|
interface LocOptions {
|
|
46
41
|
width: number;
|
|
47
42
|
height: number;
|
|
@@ -53,22 +48,6 @@ interface LocOptions {
|
|
|
53
48
|
skewX: number;
|
|
54
49
|
skewY: number;
|
|
55
50
|
}
|
|
56
|
-
interface GraphOptions extends LocOptions {
|
|
57
|
-
}
|
|
58
|
-
type Mod = [string, ...any[]];
|
|
59
|
-
interface Instruction {
|
|
60
|
-
mods: Mod[];
|
|
61
|
-
fillStyle(...args: any[]): void;
|
|
62
|
-
fillRect(...args: any[]): void;
|
|
63
|
-
strokeStyle(...args: any[]): void;
|
|
64
|
-
lineWidth(...args: any[]): void;
|
|
65
|
-
strokeRect(...args: any[]): void;
|
|
66
|
-
fillText(...args: any[]): void;
|
|
67
|
-
font(...args: any[]): void;
|
|
68
|
-
textBaseline(...args: any[]): void;
|
|
69
|
-
textAlign(...args: any[]): void;
|
|
70
|
-
}
|
|
71
|
-
declare function createInstruction(): Instruction;
|
|
72
51
|
declare abstract class S extends Display {
|
|
73
52
|
width: number;
|
|
74
53
|
height: number;
|
|
@@ -81,20 +60,16 @@ declare abstract class S extends Display {
|
|
|
81
60
|
skewY: number;
|
|
82
61
|
constructor(options?: Partial<LocOptions>);
|
|
83
62
|
}
|
|
84
|
-
declare abstract class Graph extends S {
|
|
85
|
-
instruction: ReturnType<typeof createInstruction>;
|
|
86
|
-
__refresh__: boolean;
|
|
87
|
-
__options__: Partial<LocOptions>;
|
|
88
|
-
abstract style: GraphStyleSheet;
|
|
89
|
-
constructor(options?: Partial<GraphOptions>);
|
|
90
|
-
abstract create(): void;
|
|
91
|
-
abstract clone(): Graph;
|
|
92
|
-
abstract get __shape__(): string;
|
|
93
|
-
render(ctx: CanvasRenderingContext2D): void;
|
|
94
|
-
get __instanceOf__(): DisplayType.Graph;
|
|
95
|
-
}
|
|
96
63
|
|
|
97
|
-
declare class
|
|
64
|
+
declare abstract class C extends Display {
|
|
65
|
+
elements: Display[];
|
|
66
|
+
constructor();
|
|
67
|
+
abstract get __instanceOf__(): string;
|
|
68
|
+
add(...elements: Display[]): void;
|
|
69
|
+
remove(...elements: Display[]): void;
|
|
70
|
+
destory(): void;
|
|
71
|
+
}
|
|
72
|
+
declare class Box extends C {
|
|
98
73
|
elements: Display[];
|
|
99
74
|
constructor();
|
|
100
75
|
add(...elements: Display[]): void;
|
|
@@ -104,6 +79,50 @@ declare class Box extends Display {
|
|
|
104
79
|
clone(): Box;
|
|
105
80
|
}
|
|
106
81
|
|
|
82
|
+
interface RenderViewportOptions {
|
|
83
|
+
width: number;
|
|
84
|
+
height: number;
|
|
85
|
+
devicePixelRatio: number;
|
|
86
|
+
shaow?: boolean;
|
|
87
|
+
}
|
|
88
|
+
declare class Render {
|
|
89
|
+
private c;
|
|
90
|
+
options: RenderViewportOptions;
|
|
91
|
+
constructor(to: Element, options: RenderViewportOptions);
|
|
92
|
+
clear(width: number, height: number): void;
|
|
93
|
+
get canvas(): HTMLCanvasElement;
|
|
94
|
+
get ctx(): CanvasRenderingContext2D;
|
|
95
|
+
initOptions(userOptions?: Partial<RenderViewportOptions>): void;
|
|
96
|
+
destory(): void;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
declare class Layer extends C implements S {
|
|
100
|
+
private c;
|
|
101
|
+
__refresh__: boolean;
|
|
102
|
+
options: RenderViewportOptions;
|
|
103
|
+
width: number;
|
|
104
|
+
height: number;
|
|
105
|
+
x: number;
|
|
106
|
+
y: number;
|
|
107
|
+
scaleX: number;
|
|
108
|
+
scaleY: number;
|
|
109
|
+
rotation: number;
|
|
110
|
+
skewX: number;
|
|
111
|
+
skewY: number;
|
|
112
|
+
constructor(options?: Partial<LocOptions>);
|
|
113
|
+
get __instanceOf__(): DisplayType.Layer;
|
|
114
|
+
setCanvasOptions(options?: Partial<RenderViewportOptions>): void;
|
|
115
|
+
cleanCacheSnapshot(): {
|
|
116
|
+
dpr: number;
|
|
117
|
+
matrix: Matrix2D;
|
|
118
|
+
};
|
|
119
|
+
setCacheSnapshot(c: HTMLCanvasElement): void;
|
|
120
|
+
initLoc(options?: Partial<LocOptions>): void;
|
|
121
|
+
draw(ctx: CanvasRenderingContext2D): void;
|
|
122
|
+
get canvas(): HTMLCanvasElement;
|
|
123
|
+
get ctx(): CanvasRenderingContext2D;
|
|
124
|
+
}
|
|
125
|
+
|
|
107
126
|
interface RGBColor {
|
|
108
127
|
r: number;
|
|
109
128
|
g: number;
|
|
@@ -144,36 +163,19 @@ declare class Event<EvtDefinition extends DefaultEventDefinition = DefaultEventD
|
|
|
144
163
|
bindWithContext<C>(c: C): (evt: keyof EvtDefinition, handler: BindThisParameter<EvtDefinition[keyof EvtDefinition], unknown extends C ? this : C>) => void;
|
|
145
164
|
}
|
|
146
165
|
|
|
147
|
-
interface RenderViewportOptions {
|
|
148
|
-
width: number;
|
|
149
|
-
height: number;
|
|
150
|
-
devicePixelRatio: number;
|
|
151
|
-
}
|
|
152
|
-
declare class Render {
|
|
153
|
-
canvas: HTMLCanvasElement;
|
|
154
|
-
ctx: CanvasRenderingContext2D;
|
|
155
|
-
options: RenderViewportOptions;
|
|
156
|
-
constructor(to: Element, options: RenderViewportOptions);
|
|
157
|
-
clear(width: number, height: number): void;
|
|
158
|
-
initOptions(userOptions?: Partial<RenderViewportOptions>): void;
|
|
159
|
-
update(schedule: Schedule$1): void;
|
|
160
|
-
destory(): void;
|
|
161
|
-
}
|
|
162
|
-
|
|
163
166
|
type ApplyTo = string | Element;
|
|
164
|
-
declare class Schedule
|
|
167
|
+
declare class Schedule<D extends DefaultEventDefinition = DefaultEventDefinition> extends Box {
|
|
165
168
|
render: Render;
|
|
166
169
|
to: Element;
|
|
167
|
-
event: Event
|
|
170
|
+
event: Event<D>;
|
|
168
171
|
constructor(to: ApplyTo, renderOptions?: Partial<RenderViewportOptions>);
|
|
169
|
-
applyTransform(matrix: Matrix2D): void;
|
|
170
172
|
update(): void;
|
|
171
173
|
execute(render: Render, graph?: Display): void;
|
|
172
174
|
}
|
|
173
175
|
|
|
174
|
-
declare function traverse(graphs: Display[], handler: (graph:
|
|
176
|
+
declare function traverse(graphs: Display[], handler: (graph: S) => void): void;
|
|
175
177
|
declare const etoile: {
|
|
176
|
-
Schedule: typeof Schedule
|
|
178
|
+
Schedule: typeof Schedule;
|
|
177
179
|
traverse: typeof traverse;
|
|
178
180
|
};
|
|
179
181
|
|
|
@@ -245,7 +247,7 @@ type NativeModule = ReturnType<typeof bindParentForModule>[number] & {
|
|
|
245
247
|
};
|
|
246
248
|
declare function getNodeDepth(node: NativeModule): number;
|
|
247
249
|
declare function visit<T extends AnyObject>(data: T[], fn: (data: T) => boolean | void): T | null;
|
|
248
|
-
declare function findRelativeNode(
|
|
250
|
+
declare function findRelativeNode(p: {
|
|
249
251
|
x: number;
|
|
250
252
|
y: number;
|
|
251
253
|
}, layoutNodes: LayoutModule[]): LayoutModule | null;
|
|
@@ -277,38 +279,56 @@ interface EventMethods<C = TreemapInstanceAPI, D = PrimitiveEventDefinition> {
|
|
|
277
279
|
on<Evt extends keyof D>(evt: Evt, handler: BindThisParameter<D[Evt], unknown extends C ? this : C>): void;
|
|
278
280
|
off<Evt extends keyof D>(evt: keyof D, handler?: BindThisParameter<D[Evt], unknown extends C ? this : C>): void;
|
|
279
281
|
}
|
|
282
|
+
declare const internalEventMappings: {
|
|
283
|
+
readonly CLEAN_UP: "self:cleanup";
|
|
284
|
+
readonly ON_LOAD: "self:onload";
|
|
285
|
+
readonly ON_ZOOM: "zoom";
|
|
286
|
+
};
|
|
287
|
+
type InternalEventType = typeof internalEventMappings[keyof typeof internalEventMappings];
|
|
288
|
+
interface InternalEventMappings {
|
|
289
|
+
[internalEventMappings.CLEAN_UP]: () => void;
|
|
290
|
+
[internalEventMappings.ON_LOAD]: (width: number, height: number, root: HTMLElement) => void;
|
|
291
|
+
[internalEventMappings.ON_ZOOM]: (node: LayoutModule) => void;
|
|
292
|
+
}
|
|
293
|
+
type InternalEventDefinition = {
|
|
294
|
+
[key in InternalEventType]: InternalEventMappings[key];
|
|
295
|
+
};
|
|
280
296
|
|
|
281
297
|
interface TreemapOptions {
|
|
282
298
|
data: Module[];
|
|
283
299
|
}
|
|
284
300
|
type Using = 'decorator';
|
|
285
301
|
interface App {
|
|
286
|
-
init: (el:
|
|
302
|
+
init: (el: HTMLElement) => void;
|
|
287
303
|
dispose: () => void;
|
|
288
304
|
setOptions: (options: TreemapOptions) => void;
|
|
289
305
|
resize: () => void;
|
|
290
306
|
use: (using: Using, register: (app: TreemapLayout) => void) => void;
|
|
291
307
|
zoom: (id: string) => void;
|
|
292
308
|
}
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
309
|
+
/**
|
|
310
|
+
* This interface isn't stable it might be remove at next few versions.
|
|
311
|
+
* If you want set custom decorator pls see 'presetDecorator' for details.
|
|
312
|
+
*/
|
|
313
|
+
type unstable_use = (app: TreemapLayout) => void;
|
|
314
|
+
declare class TreemapLayout extends etoile.Schedule<InternalEventDefinition> {
|
|
296
315
|
data: NativeModule[];
|
|
297
316
|
layoutNodes: LayoutModule[];
|
|
298
317
|
decorator: RenderDecorator;
|
|
299
|
-
private
|
|
318
|
+
private bgLayer;
|
|
300
319
|
private fgBox;
|
|
301
320
|
fontsCaches: Record<string, number>;
|
|
302
321
|
ellispsisWidthCache: Record<string, number>;
|
|
303
|
-
constructor(...args: ConstructorParameters<typeof Schedule>);
|
|
322
|
+
constructor(...args: ConstructorParameters<typeof etoile.Schedule>);
|
|
304
323
|
drawBackgroundNode(node: LayoutModule): void;
|
|
305
324
|
drawForegroundNode(node: LayoutModule): void;
|
|
306
|
-
reset(): void;
|
|
325
|
+
reset(refresh?: boolean): void;
|
|
307
326
|
get api(): {
|
|
308
327
|
zoom: (node: LayoutModule) => void;
|
|
309
328
|
};
|
|
329
|
+
get backgroundLayer(): Layer;
|
|
310
330
|
}
|
|
311
331
|
declare function createTreemap(): App & EventMethods;
|
|
312
332
|
type TreemapInstanceAPI = TreemapLayout['api'];
|
|
313
333
|
|
|
314
|
-
export { type App, type ColorMappings, type EventMethods, type LayoutModule, type Module, type NativeModule, type PrimitiveEvent, type PrimitiveEventCallback, type PrimitiveEventDefinition, type PrimitiveEventMetadata, type Rect, type RenderColor, type RenderDecorator, type RenderFont, type RenderLayout, type Series, type TreemapInstanceAPI, TreemapLayout, type TreemapOptions, c2m, createTreemap, defaultFontOptions, defaultLayoutOptions, findRelativeNode, findRelativeNodeById, flatten as flattenModule, getNodeDepth, presetDecorator, sortChildrenByKey, visit };
|
|
334
|
+
export { type App, type ColorMappings, type EventMethods, type LayoutModule, type Module, type NativeModule, type PrimitiveEvent, type PrimitiveEventCallback, type PrimitiveEventDefinition, type PrimitiveEventMetadata, type Rect, type RenderColor, type RenderDecorator, type RenderFont, type RenderLayout, type Series, type TreemapInstanceAPI, TreemapLayout, type TreemapOptions, c2m, createTreemap, defaultFontOptions, defaultLayoutOptions, findRelativeNode, findRelativeNodeById, flatten as flattenModule, getNodeDepth, presetDecorator, sortChildrenByKey, type unstable_use, visit };
|
package/dist/index.d.ts
CHANGED
|
@@ -6,7 +6,7 @@ interface MatrixLoc {
|
|
|
6
6
|
e: number;
|
|
7
7
|
f: number;
|
|
8
8
|
}
|
|
9
|
-
declare class Matrix2D {
|
|
9
|
+
declare class Matrix2D implements MatrixLoc {
|
|
10
10
|
a: number;
|
|
11
11
|
b: number;
|
|
12
12
|
c: number;
|
|
@@ -26,7 +26,8 @@ declare const enum DisplayType {
|
|
|
26
26
|
Graph = "Graph",
|
|
27
27
|
Box = "Box",
|
|
28
28
|
Rect = "Rect",
|
|
29
|
-
Text = "Text"
|
|
29
|
+
Text = "Text",
|
|
30
|
+
Layer = "Layer"
|
|
30
31
|
}
|
|
31
32
|
declare abstract class Display {
|
|
32
33
|
parent: Display | null;
|
|
@@ -36,12 +37,6 @@ declare abstract class Display {
|
|
|
36
37
|
constructor();
|
|
37
38
|
destory(): void;
|
|
38
39
|
}
|
|
39
|
-
interface GraphStyleSheet {
|
|
40
|
-
stroke: string;
|
|
41
|
-
opacity: number;
|
|
42
|
-
font: string;
|
|
43
|
-
lineWidth: number;
|
|
44
|
-
}
|
|
45
40
|
interface LocOptions {
|
|
46
41
|
width: number;
|
|
47
42
|
height: number;
|
|
@@ -53,22 +48,6 @@ interface LocOptions {
|
|
|
53
48
|
skewX: number;
|
|
54
49
|
skewY: number;
|
|
55
50
|
}
|
|
56
|
-
interface GraphOptions extends LocOptions {
|
|
57
|
-
}
|
|
58
|
-
type Mod = [string, ...any[]];
|
|
59
|
-
interface Instruction {
|
|
60
|
-
mods: Mod[];
|
|
61
|
-
fillStyle(...args: any[]): void;
|
|
62
|
-
fillRect(...args: any[]): void;
|
|
63
|
-
strokeStyle(...args: any[]): void;
|
|
64
|
-
lineWidth(...args: any[]): void;
|
|
65
|
-
strokeRect(...args: any[]): void;
|
|
66
|
-
fillText(...args: any[]): void;
|
|
67
|
-
font(...args: any[]): void;
|
|
68
|
-
textBaseline(...args: any[]): void;
|
|
69
|
-
textAlign(...args: any[]): void;
|
|
70
|
-
}
|
|
71
|
-
declare function createInstruction(): Instruction;
|
|
72
51
|
declare abstract class S extends Display {
|
|
73
52
|
width: number;
|
|
74
53
|
height: number;
|
|
@@ -81,20 +60,16 @@ declare abstract class S extends Display {
|
|
|
81
60
|
skewY: number;
|
|
82
61
|
constructor(options?: Partial<LocOptions>);
|
|
83
62
|
}
|
|
84
|
-
declare abstract class Graph extends S {
|
|
85
|
-
instruction: ReturnType<typeof createInstruction>;
|
|
86
|
-
__refresh__: boolean;
|
|
87
|
-
__options__: Partial<LocOptions>;
|
|
88
|
-
abstract style: GraphStyleSheet;
|
|
89
|
-
constructor(options?: Partial<GraphOptions>);
|
|
90
|
-
abstract create(): void;
|
|
91
|
-
abstract clone(): Graph;
|
|
92
|
-
abstract get __shape__(): string;
|
|
93
|
-
render(ctx: CanvasRenderingContext2D): void;
|
|
94
|
-
get __instanceOf__(): DisplayType.Graph;
|
|
95
|
-
}
|
|
96
63
|
|
|
97
|
-
declare class
|
|
64
|
+
declare abstract class C extends Display {
|
|
65
|
+
elements: Display[];
|
|
66
|
+
constructor();
|
|
67
|
+
abstract get __instanceOf__(): string;
|
|
68
|
+
add(...elements: Display[]): void;
|
|
69
|
+
remove(...elements: Display[]): void;
|
|
70
|
+
destory(): void;
|
|
71
|
+
}
|
|
72
|
+
declare class Box extends C {
|
|
98
73
|
elements: Display[];
|
|
99
74
|
constructor();
|
|
100
75
|
add(...elements: Display[]): void;
|
|
@@ -104,6 +79,50 @@ declare class Box extends Display {
|
|
|
104
79
|
clone(): Box;
|
|
105
80
|
}
|
|
106
81
|
|
|
82
|
+
interface RenderViewportOptions {
|
|
83
|
+
width: number;
|
|
84
|
+
height: number;
|
|
85
|
+
devicePixelRatio: number;
|
|
86
|
+
shaow?: boolean;
|
|
87
|
+
}
|
|
88
|
+
declare class Render {
|
|
89
|
+
private c;
|
|
90
|
+
options: RenderViewportOptions;
|
|
91
|
+
constructor(to: Element, options: RenderViewportOptions);
|
|
92
|
+
clear(width: number, height: number): void;
|
|
93
|
+
get canvas(): HTMLCanvasElement;
|
|
94
|
+
get ctx(): CanvasRenderingContext2D;
|
|
95
|
+
initOptions(userOptions?: Partial<RenderViewportOptions>): void;
|
|
96
|
+
destory(): void;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
declare class Layer extends C implements S {
|
|
100
|
+
private c;
|
|
101
|
+
__refresh__: boolean;
|
|
102
|
+
options: RenderViewportOptions;
|
|
103
|
+
width: number;
|
|
104
|
+
height: number;
|
|
105
|
+
x: number;
|
|
106
|
+
y: number;
|
|
107
|
+
scaleX: number;
|
|
108
|
+
scaleY: number;
|
|
109
|
+
rotation: number;
|
|
110
|
+
skewX: number;
|
|
111
|
+
skewY: number;
|
|
112
|
+
constructor(options?: Partial<LocOptions>);
|
|
113
|
+
get __instanceOf__(): DisplayType.Layer;
|
|
114
|
+
setCanvasOptions(options?: Partial<RenderViewportOptions>): void;
|
|
115
|
+
cleanCacheSnapshot(): {
|
|
116
|
+
dpr: number;
|
|
117
|
+
matrix: Matrix2D;
|
|
118
|
+
};
|
|
119
|
+
setCacheSnapshot(c: HTMLCanvasElement): void;
|
|
120
|
+
initLoc(options?: Partial<LocOptions>): void;
|
|
121
|
+
draw(ctx: CanvasRenderingContext2D): void;
|
|
122
|
+
get canvas(): HTMLCanvasElement;
|
|
123
|
+
get ctx(): CanvasRenderingContext2D;
|
|
124
|
+
}
|
|
125
|
+
|
|
107
126
|
interface RGBColor {
|
|
108
127
|
r: number;
|
|
109
128
|
g: number;
|
|
@@ -144,36 +163,19 @@ declare class Event<EvtDefinition extends DefaultEventDefinition = DefaultEventD
|
|
|
144
163
|
bindWithContext<C>(c: C): (evt: keyof EvtDefinition, handler: BindThisParameter<EvtDefinition[keyof EvtDefinition], unknown extends C ? this : C>) => void;
|
|
145
164
|
}
|
|
146
165
|
|
|
147
|
-
interface RenderViewportOptions {
|
|
148
|
-
width: number;
|
|
149
|
-
height: number;
|
|
150
|
-
devicePixelRatio: number;
|
|
151
|
-
}
|
|
152
|
-
declare class Render {
|
|
153
|
-
canvas: HTMLCanvasElement;
|
|
154
|
-
ctx: CanvasRenderingContext2D;
|
|
155
|
-
options: RenderViewportOptions;
|
|
156
|
-
constructor(to: Element, options: RenderViewportOptions);
|
|
157
|
-
clear(width: number, height: number): void;
|
|
158
|
-
initOptions(userOptions?: Partial<RenderViewportOptions>): void;
|
|
159
|
-
update(schedule: Schedule$1): void;
|
|
160
|
-
destory(): void;
|
|
161
|
-
}
|
|
162
|
-
|
|
163
166
|
type ApplyTo = string | Element;
|
|
164
|
-
declare class Schedule
|
|
167
|
+
declare class Schedule<D extends DefaultEventDefinition = DefaultEventDefinition> extends Box {
|
|
165
168
|
render: Render;
|
|
166
169
|
to: Element;
|
|
167
|
-
event: Event
|
|
170
|
+
event: Event<D>;
|
|
168
171
|
constructor(to: ApplyTo, renderOptions?: Partial<RenderViewportOptions>);
|
|
169
|
-
applyTransform(matrix: Matrix2D): void;
|
|
170
172
|
update(): void;
|
|
171
173
|
execute(render: Render, graph?: Display): void;
|
|
172
174
|
}
|
|
173
175
|
|
|
174
|
-
declare function traverse(graphs: Display[], handler: (graph:
|
|
176
|
+
declare function traverse(graphs: Display[], handler: (graph: S) => void): void;
|
|
175
177
|
declare const etoile: {
|
|
176
|
-
Schedule: typeof Schedule
|
|
178
|
+
Schedule: typeof Schedule;
|
|
177
179
|
traverse: typeof traverse;
|
|
178
180
|
};
|
|
179
181
|
|
|
@@ -245,7 +247,7 @@ type NativeModule = ReturnType<typeof bindParentForModule>[number] & {
|
|
|
245
247
|
};
|
|
246
248
|
declare function getNodeDepth(node: NativeModule): number;
|
|
247
249
|
declare function visit<T extends AnyObject>(data: T[], fn: (data: T) => boolean | void): T | null;
|
|
248
|
-
declare function findRelativeNode(
|
|
250
|
+
declare function findRelativeNode(p: {
|
|
249
251
|
x: number;
|
|
250
252
|
y: number;
|
|
251
253
|
}, layoutNodes: LayoutModule[]): LayoutModule | null;
|
|
@@ -277,38 +279,56 @@ interface EventMethods<C = TreemapInstanceAPI, D = PrimitiveEventDefinition> {
|
|
|
277
279
|
on<Evt extends keyof D>(evt: Evt, handler: BindThisParameter<D[Evt], unknown extends C ? this : C>): void;
|
|
278
280
|
off<Evt extends keyof D>(evt: keyof D, handler?: BindThisParameter<D[Evt], unknown extends C ? this : C>): void;
|
|
279
281
|
}
|
|
282
|
+
declare const internalEventMappings: {
|
|
283
|
+
readonly CLEAN_UP: "self:cleanup";
|
|
284
|
+
readonly ON_LOAD: "self:onload";
|
|
285
|
+
readonly ON_ZOOM: "zoom";
|
|
286
|
+
};
|
|
287
|
+
type InternalEventType = typeof internalEventMappings[keyof typeof internalEventMappings];
|
|
288
|
+
interface InternalEventMappings {
|
|
289
|
+
[internalEventMappings.CLEAN_UP]: () => void;
|
|
290
|
+
[internalEventMappings.ON_LOAD]: (width: number, height: number, root: HTMLElement) => void;
|
|
291
|
+
[internalEventMappings.ON_ZOOM]: (node: LayoutModule) => void;
|
|
292
|
+
}
|
|
293
|
+
type InternalEventDefinition = {
|
|
294
|
+
[key in InternalEventType]: InternalEventMappings[key];
|
|
295
|
+
};
|
|
280
296
|
|
|
281
297
|
interface TreemapOptions {
|
|
282
298
|
data: Module[];
|
|
283
299
|
}
|
|
284
300
|
type Using = 'decorator';
|
|
285
301
|
interface App {
|
|
286
|
-
init: (el:
|
|
302
|
+
init: (el: HTMLElement) => void;
|
|
287
303
|
dispose: () => void;
|
|
288
304
|
setOptions: (options: TreemapOptions) => void;
|
|
289
305
|
resize: () => void;
|
|
290
306
|
use: (using: Using, register: (app: TreemapLayout) => void) => void;
|
|
291
307
|
zoom: (id: string) => void;
|
|
292
308
|
}
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
309
|
+
/**
|
|
310
|
+
* This interface isn't stable it might be remove at next few versions.
|
|
311
|
+
* If you want set custom decorator pls see 'presetDecorator' for details.
|
|
312
|
+
*/
|
|
313
|
+
type unstable_use = (app: TreemapLayout) => void;
|
|
314
|
+
declare class TreemapLayout extends etoile.Schedule<InternalEventDefinition> {
|
|
296
315
|
data: NativeModule[];
|
|
297
316
|
layoutNodes: LayoutModule[];
|
|
298
317
|
decorator: RenderDecorator;
|
|
299
|
-
private
|
|
318
|
+
private bgLayer;
|
|
300
319
|
private fgBox;
|
|
301
320
|
fontsCaches: Record<string, number>;
|
|
302
321
|
ellispsisWidthCache: Record<string, number>;
|
|
303
|
-
constructor(...args: ConstructorParameters<typeof Schedule>);
|
|
322
|
+
constructor(...args: ConstructorParameters<typeof etoile.Schedule>);
|
|
304
323
|
drawBackgroundNode(node: LayoutModule): void;
|
|
305
324
|
drawForegroundNode(node: LayoutModule): void;
|
|
306
|
-
reset(): void;
|
|
325
|
+
reset(refresh?: boolean): void;
|
|
307
326
|
get api(): {
|
|
308
327
|
zoom: (node: LayoutModule) => void;
|
|
309
328
|
};
|
|
329
|
+
get backgroundLayer(): Layer;
|
|
310
330
|
}
|
|
311
331
|
declare function createTreemap(): App & EventMethods;
|
|
312
332
|
type TreemapInstanceAPI = TreemapLayout['api'];
|
|
313
333
|
|
|
314
|
-
export { type App, type ColorMappings, type EventMethods, type LayoutModule, type Module, type NativeModule, type PrimitiveEvent, type PrimitiveEventCallback, type PrimitiveEventDefinition, type PrimitiveEventMetadata, type Rect, type RenderColor, type RenderDecorator, type RenderFont, type RenderLayout, type Series, type TreemapInstanceAPI, TreemapLayout, type TreemapOptions, c2m, createTreemap, defaultFontOptions, defaultLayoutOptions, findRelativeNode, findRelativeNodeById, flatten as flattenModule, getNodeDepth, presetDecorator, sortChildrenByKey, visit };
|
|
334
|
+
export { type App, type ColorMappings, type EventMethods, type LayoutModule, type Module, type NativeModule, type PrimitiveEvent, type PrimitiveEventCallback, type PrimitiveEventDefinition, type PrimitiveEventMetadata, type Rect, type RenderColor, type RenderDecorator, type RenderFont, type RenderLayout, type Series, type TreemapInstanceAPI, TreemapLayout, type TreemapOptions, c2m, createTreemap, defaultFontOptions, defaultLayoutOptions, findRelativeNode, findRelativeNodeById, flatten as flattenModule, getNodeDepth, presetDecorator, sortChildrenByKey, type unstable_use, visit };
|