forked from DefinitelyTyped/DefinitelyTyped
-
Notifications
You must be signed in to change notification settings - Fork 0
/
sigmajs.d.ts
303 lines (264 loc) · 8.19 KB
/
sigmajs.d.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
// Type definitions for sigma.js v1.0.3
// Project: https://github.com/jacomyal/sigma.js
// Definitions by: Qinfeng Chen <https://github.com/qinfchen>
// Definitions: https://github.com/borisyankov/DefinitelyTyped
declare module SigmaJs{
interface Animation {
camera(camera: Camera, target: { [index: string]: any }, options: { [index: string]: any }): number;
}
interface Camera {
angle: number;
cameraPosition(x: number, y:number): {x: number; y: number};
goTo(settings: { [index: string]: any }): void;
graphPosition(x: number, y:number): {x: number; y: number};
ratio: number;
readPrefix: string;
settings(setting: string) : any;
x: number;
y: number;
}
interface Canvas {
edges: {[renderType: string]: (edge: Edge, source: Node, target: Node, ...a:any[]) => void};
labels: {[renderType: string]: (node: Node, ...a:any[]) => void};
nodes: {[renderType: string]: (node: Node, ...a:any[]) => void};
}
interface Classes {
configurable: Configurable;
graph: Graph;
}
interface Configurable {
new(setting: Settings): Configurable;
new(settings: Settings[]): Configurable;
(key: string): string;
}
interface CustomShapes {
init(sigma: Sigma): void;
}
interface DragNodes {
(sigma: Sigma, renderer: Renderer): DragNodes;
}
interface Edge {
[key : string] : any;
color?: string;
id: string;
size?: number;
source: string;
target: string;
}
interface JsonParser {
(target: string, sigma: Sigma, callback: (graph: Sigma) => void): void;
}
interface GexfParser {
(target: string, sigma: Sigma, callback: (graph: Sigma) => void): void;
}
interface Graph {
addEdge(edge: Edge): Graph;
addNode(node: Node): Graph;
addMethod(name: string, method: (input: any) => any): void;
clear(): Graph;
degree(id: string): number;
degree(id: string, type: string): number;
degree(ids: string[]): number[];
degree(ids: string[], type: string): number[];
dropEdge(id: string): Graph;
dropNode(id: string): Graph;
edges(): Edge[];
edges(id: string): Edge;
edges(ids: string[]): Edge[];
kill(): Graph;
nodes(): Node[];
nodes(id: string): Node;
nodes(ids: string[]): Node[];
}
interface GraphData {
edges: Edge[];
nodes: Node[];
}
interface Image {
clip?: number;
scale?: number;
url?: string;
x?: number;
y?: number;
}
interface Miscellaneous {
animation: Animation;
}
interface Node {
[key : string] : any;
color?: string;
id: string;
image?: any;
label?: string;
size?: number;
type?: string;
x?: number;
y?: number;
}
interface Parsers {
json: JsonParser;
gexf: GexfParser;
}
interface Plugins {
dragNodes: DragNodes;
}
interface Renderer {
container: HTMLElement;
refresh(): Sigma;
render(): Sigma;
resize(): Sigma;
settings(settings: Settings): void;
}
interface RendererConfigs{
container?: Element;
id?: string;
type?: string;
}
interface ShapeLibrary {
enumerate(): any;
}
interface Sigma {
addRenderer(): Renderer;
addRenderer(configs: RendererConfigs): Renderer;
bind(event: string, callback: (e: any) => void): void;
cameras: Camera[];
graph: Graph;
killRenderer(renderer: string): Sigma;
killRenderer(renderer: Renderer): Sigma;
kill(): void;
refresh(): void;
renderers: Renderer[];
settings(key: string): any;
settings(settings: Settings): void;
// forceAtlas2 layout
configForceAtlas2(configs: { [key: string]: any }): void;
isForceAtlas2Running(): boolean;
killForceAtlas2(): void;
startForceAtlas2(): void;
startForceAtlas2(configs: { [key: string]: any }): void;
stopForceAtlas2(): void;
}
interface SigmaConfigs {
container?: Element;
graph?: GraphData;
id?: string;
renderers?: Renderer[];
settings?: { [index: string]: any };
}
interface SigmaFactory {
new(): Sigma;
new(container: string): Sigma;
new(container: Element): Sigma;
new(configuration: SigmaConfigs): Sigma;
canvas: Canvas;
classes:Classes;
misc: Miscellaneous;
parsers: Parsers;
plugins: Plugins;
svg: SVG;
}
interface Settings {
// Graph settings
clone?: boolean;
immutable?: boolean;
verbose?: boolean;
// Renderers settings
defaultNodeType?: string;
defaultEdgeType?: string;
defaultLabelColor?: string;
defaultEdgeColor?: string;
defaultNodeColor?: string;
defaultLabelSize?: string;
edgeColor?: string;
minArrowSize?: number;
font?: string;
fontStyle?: string;
labelAlignment?: string;
labelColor?: string;
labelSize?: string;
labelSizeRatio?: string;
labelThreshold?: number;
webglOversamplingRatio?: number;
// hovered node customizations
borderSize?: number;
defaultNodeBorderColor?: string;
hoverFont?: number;
hoverFontStyle?: string;
labelHoverShadow?: string;
labelHoverShadowColor?: string;
nodeHoverColor?: string;
defaultNodeHoverColor?: string;
labelHoverBGColor?: string;
defaultHoverLabelBGColor?: string;
labelHoverColor?: string;
defaultLabelHoverColor?: string;
singleHover?: boolean;
// hovered edge customizations
edgeHoverColor?: string;
edgeHoverSizeRatio?: number;
defaultEdgeHoverColor?: string;
edgeHoverExtremities?: boolean;
// Draw settings for labels, edges, and nodes
drawLabels?: boolean;
drawEdges?: boolean;
drawNodes?: boolean;
// Batch edge drawing
batchEdgesDrawing?: boolean;
hideEdgesOnMove?: boolean;
canvasEdgesBatchSize?: number;
webglEdgesBatchSize?: number;
// Rescale settings
scalingMode?: string;
sideMargin?: number;
// max/min node and edge size
minEdgeSize?: number;
maxEdgeSize?: number;
minNodeSize?: number;
maxNodeSize?: number;
// Captor settings
touchEnabled?: boolean;
mouseEnabled?: boolean;
mouseWheelEnabled?: boolean;
doubleClickEnabled?: boolean;
eventsEnabled?: boolean;
zoomingRatio?: number;
doubleClickZoomingRatio?: number;
zoomMin?: number;
zoomMax?: number;
mouseZoomDuration?: number;
doubleClickZoomDuration?: number;
mouseInertiaDuration?: number;
mouseInertiaRatio?: number;
touchInertiaDuration?: number;
touchInertiaRatio?: number;
doubleClickTimeout?: number;
doubleTapTimeout?: number;
dragTimeout?: number;
// Global settings
autoResize?: boolean;
autoRescale?: any;
enableCamera?: boolean;
enableHovering?: boolean;
enableEdgeHovering?: boolean;
edgeHoverPrecision?: number;
rescaleIgnoreSize?: boolean;
skipErrors?: boolean;
// Camera settings
nodesPowRatio?: number;
edgesPowRatio?: number;
// Animation settings
animationsTime?: number;
}
interface SVG {
edges: {[renderType: string]: SVGObject<SigmaJs.Edge>};
labels: {[renderType: string]: SVGObject<SigmaJs.Node>};
nodes: {[renderType: string]: SVGObject<SigmaJs.Node>};
}
interface SVGObject<T> {
create: (object: T, ...a:any[]) => Element;
update: (object: T, ...a:any[]) => void;
}
}
declare var sigma: SigmaJs.SigmaFactory;
declare var CustomShapes: SigmaJs.CustomShapes;
declare var ShapeLibrary: SigmaJs.CustomShapes;