UNPKG

31.7 kBTypeScriptView Raw
1// Type definitions for vis.js 8.3.2
2// Project: https://github.com/almende/vis, http://visjs.org
3// Definitions by: Michaël Bitard <https://github.com/MichaelBitard>
4// MacLeod Broad <https://github.com/macleodbroad-wf>
5// Adrian Caballero <https://github.com/adripanico>
6// Severin <https://github.com/seveves>
7// kaktus40 <https://github.com/kaktus40>
8// Matthieu Maitre <https://github.com/mmaitre314>
9// Adam Lewis <https://github.com/supercargo>
10// Alex Soh <https://github.com/takato1314>
11// Oleksii Kachura <https://github.com/alex-kachura>
12// dcop <https://github.com/dcop>
13// Avraham Essoudry <https://github.com/avrahamcool>
14// Dmitriy Trifonov <https://github.com/divideby>
15// Sam Welek <https://github.com/tiberiushunter>
16// Slaven Tomac <https://github.com/slavede>
17// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
18
19import { DataInterface, DataSet, DataView } from 'vis-data';
20export type DataInterfaceEdges = DataInterface<Edge, 'id'>
21export type DataInterfaceNodes = DataInterface<Node, 'id'>
22export type DataSetEdges = DataSet<Edge, 'id'>
23export type DataSetNodes = DataSet<Node, 'id'>
24export type DataViewEdges = DataView<Edge, 'id'>
25export type DataViewNodes = DataView<Node, 'id'>
26
27export type IdType = string | number;
28export type DirectionType = 'from' | 'to';
29
30/**
31 * If true (default) or an Object, the range is animated smoothly to the new window.
32 * An object can be provided to specify duration and easing function.
33 * Default duration is 500 ms, and default easing function is 'easeInOutQuad'.
34 */
35export type TimelineAnimationType = boolean | AnimationOptions;
36
37export type NetworkEvents =
38 'click' |
39 'doubleClick' |
40 'oncontext' |
41 'hold' |
42 'release' |
43 'select' |
44 'selectNode' |
45 'selectEdge' |
46 'deselectNode' |
47 'deselectEdge' |
48 'dragStart' |
49 'dragging' |
50 'dragEnd' |
51 'controlNodeDragging' |
52 'controlNodeDragEnd' |
53 'hoverNode' |
54 'blurNode' |
55 'hoverEdge' |
56 'blurEdge' |
57 'zoom' |
58 'showPopup' |
59 'hidePopup' |
60 'startStabilizing' |
61 'stabilizationProgress' |
62 'stabilizationIterationsDone' |
63 'stabilized' |
64 'resize' |
65 'initRedraw' |
66 'beforeDrawing' |
67 'afterDrawing' |
68 'animationFinished' |
69 'configChange';
70
71/**
72 * Network is a visualization to display networks and networks consisting of nodes and edges.
73 * The visualization is easy to use and supports custom shapes, styles, colors, sizes, images, and more.
74 * The network visualization works smooth on any modern browser for up to a few thousand nodes and edges.
75 * To handle a larger amount of nodes, Network has clustering support. Network uses HTML canvas for rendering.
76 */
77export class Network {
78 /**
79 * Creates an instance of Network.
80 *
81 * @param container the HTML element representing the network container
82 * @param data network data
83 * @param [options] optional network options
84 */
85 constructor(container: HTMLElement, data: Data, options?: Options);
86
87 /**
88 * Remove the network from the DOM and remove all Hammer bindings and references.
89 */
90 destroy(): void;
91
92 /**
93 * Override all the data in the network.
94 * If stabilization is enabled in the physics module,
95 * the network will stabilize again.
96 * This method is also performed when first initializing the network.
97 *
98 * @param data network data
99 */
100 setData(data: Data): void;
101
102 /**
103 * Set the options.
104 * All available options can be found in the modules above.
105 * Each module requires it's own container with the module name to contain its options.
106 *
107 * @param options network options
108 */
109 setOptions(options: Options): void;
110
111 /**
112 * Set an event listener.
113 * Depending on the type of event you get different parameters for the callback function.
114 *
115 * @param eventName the name of the event, f.e. 'click'
116 * @param callback the callback function that will be raised
117 */
118 on(eventName: NetworkEvents, callback: (params?: any) => void): void;
119
120 /**
121 * Remove an event listener.
122 * The function you supply has to be the exact same as the one you used in the on function.
123 * If no function is supplied, all listeners will be removed.
124 *
125 * @param eventName the name of the event, f.e. 'click'
126 * @param [callback] the exact same callback function that was used when calling 'on'
127 */
128 off(eventName: NetworkEvents, callback?: (params?: any) => void): void;
129
130 /**
131 * Set an event listener only once.
132 * After it has taken place, the event listener will be removed.
133 * Depending on the type of event you get different parameters for the callback function.
134 *
135 * @param eventName the name of the event, f.e. 'click'
136 * @param callback the callback function that will be raised once
137 */
138 once(eventName: NetworkEvents, callback: (params?: any) => void): void;
139
140 /**
141 * This function converts canvas coordinates to coordinates on the DOM.
142 * Input and output are in the form of {x:Number, y:Number} (IPosition interface).
143 * The DOM values are relative to the network container.
144 *
145 * @param position the canvas coordinates
146 * @returns the DOM coordinates
147 */
148 canvasToDOM(position: Position): Position;
149
150 /**
151 * This function converts DOM coordinates to coordinates on the canvas.
152 * Input and output are in the form of {x:Number,y:Number} (IPosition interface).
153 * The DOM values are relative to the network container.
154 *
155 * @param position the DOM coordinates
156 * @returns the canvas coordinates
157 */
158 DOMtoCanvas(position: Position): Position;
159
160 /**
161 * Redraw the network.
162 */
163 redraw(): void;
164
165 /**
166 * Set the size of the canvas.
167 * This is automatically done on a window resize.
168 *
169 * @param width width in a common format, f.e. '100px'
170 * @param height height in a common format, f.e. '100px'
171 */
172 setSize(width: string, height: string): void;
173
174 /**
175 * The joinCondition function is presented with all nodes.
176 */
177 cluster(options?: ClusterOptions): void;
178
179 /**
180 * This method looks at the provided node and makes a cluster of it and all it's connected nodes.
181 * The behaviour can be customized by proving the options object.
182 * All options of this object are explained below.
183 * The joinCondition is only presented with the connected nodes.
184 *
185 * @param nodeId the id of the node
186 * @param [options] the cluster options
187 */
188 clusterByConnection(nodeId: string, options?: ClusterOptions): void;
189
190 /**
191 * This method checks all nodes in the network and those with a equal or higher
192 * amount of edges than specified with the hubsize qualify.
193 * If a hubsize is not defined, the hubsize will be determined as the average
194 * value plus two standard deviations.
195 * For all qualifying nodes, clusterByConnection is performed on each of them.
196 * The options object is described for clusterByConnection and does the same here.
197 *
198 * @param [hubsize] optional hubsize
199 * @param [options] optional cluster options
200 */
201 clusterByHubsize(hubsize?: number, options?: ClusterOptions): void;
202
203 /**
204 * This method will cluster all nodes with 1 edge with their respective connected node.
205 *
206 * @param [options] optional cluster options
207 */
208 clusterOutliers(options?: ClusterOptions): void;
209
210 /**
211 * Nodes can be in clusters.
212 * Clusters can also be in clusters.
213 * This function returns an array of nodeIds showing where the node is.
214 *
215 * Example:
216 * cluster 'A' contains cluster 'B', cluster 'B' contains cluster 'C',
217 * cluster 'C' contains node 'fred'.
218 *
219 * network.clustering.findNode('fred') will return ['A','B','C','fred'].
220 *
221 * @param nodeId the node id.
222 * @returns an array of nodeIds showing where the node is
223 */
224 findNode(nodeId: IdType): IdType[];
225
226 /**
227 * Similar to findNode in that it returns all the edge ids that were
228 * created from the provided edge during clustering.
229 *
230 * @param baseEdgeId the base edge id
231 * @returns an array of edgeIds
232 */
233 getClusteredEdges(baseEdgeId: IdType): IdType[];
234
235 /**
236 * When a clusteredEdgeId is available, this method will return the original
237 * baseEdgeId provided in data.edges ie.
238 * After clustering the 'SelectEdge' event is fired but provides only the clustered edge.
239 * This method can then be used to return the baseEdgeId.
240 */
241 getBaseEdge(clusteredEdgeId: IdType): IdType;
242
243 /**
244 * For the given clusteredEdgeId, this method will return all the original
245 * base edge id's provided in data.edges.
246 * For a non-clustered (i.e. 'base') edge, clusteredEdgeId is returned.
247 * Only the base edge id's are returned.
248 * All clustered edges id's under clusteredEdgeId are skipped,
249 * but scanned recursively to return their base id's.
250 */
251 getBaseEdges(clusteredEdgeId: IdType): IdType[];
252
253 /**
254 * Visible edges between clustered nodes are not the same edge as the ones provided
255 * in data.edges passed on network creation. With each layer of clustering, copies of
256 * the edges between clusters are created and the previous edges are hidden,
257 * until the cluster is opened. This method takes an edgeId (ie. a base edgeId from data.edges)
258 * and applys the options to it and any edges that were created from it while clustering.
259 */
260 updateEdge(startEdgeId: IdType, options?: EdgeOptions): void;
261
262 /**
263 * Clustered Nodes when created are not contained in the original data.nodes
264 * passed on network creation. This method updates the cluster node.
265 */
266 updateClusteredNode(clusteredNodeId: IdType, options?: NodeOptions): void;
267
268 /**
269 * Returns true if the node whose ID has been supplied is a cluster.
270 *
271 * @param nodeId the node id.
272 */
273 isCluster(nodeId: IdType): boolean;
274
275 /**
276 * Returns an array of all nodeIds of the nodes that
277 * would be released if you open the cluster.
278 *
279 * @param clusterNodeId the id of the cluster node
280 */
281 getNodesInCluster(clusterNodeId: IdType): IdType[];
282
283 /**
284 * Opens the cluster, releases the contained nodes and edges,
285 * removing the cluster node and cluster edges.
286 * The options object is optional and currently supports one option,
287 * releaseFunction, which is a function that can be used to manually
288 * position the nodes after the cluster is opened.
289 *
290 * @param nodeId the node id
291 * @param [options] optional open cluster options
292 */
293 openCluster(nodeId: IdType, options?: OpenClusterOptions): void;
294
295 /**
296 * If you like the layout of your network
297 * and would like it to start in the same way next time,
298 * ask for the seed using this method and put it in the layout.randomSeed option.
299 *
300 * @returns the current seed of the network.
301 */
302 getSeed(): number | string;
303
304 /**
305 * Programatically enable the edit mode.
306 * Similar effect to pressing the edit button.
307 */
308 enableEditMode(): void;
309
310 /**
311 * Programatically disable the edit mode.
312 * Similar effect to pressing the close icon (small cross in the corner of the toolbar).
313 */
314 disableEditMode(): void;
315
316 /**
317 * Go into addNode mode. Having edit mode or manipulation enabled is not required.
318 * To get out of this mode, call disableEditMode().
319 * The callback functions defined in handlerFunctions still apply.
320 * To use these methods without having the manipulation GUI, make sure you set enabled to false.
321 */
322 addNodeMode(): void;
323
324 /**
325 * Edit the selected node.
326 * The explaination from addNodeMode applies here as well.
327 */
328 editNode(): void;
329
330 /**
331 * Go into addEdge mode.
332 * The explaination from addNodeMode applies here as well.
333 */
334 addEdgeMode(): void;
335
336 /**
337 * Go into editEdge mode.
338 * The explaination from addNodeMode applies here as well.
339 */
340 editEdgeMode(): void;
341
342 /**
343 * Delete selected.
344 * Having edit mode or manipulation enabled is not required.
345 */
346 deleteSelected(): void;
347
348 /**
349 * Returns the x y positions in canvas space of a requested node or array of nodes.
350 *
351 * @remarks
352 * - If `nodeIds` is supplied as a single id that does not correspond
353 * to a node in the network, this function will return an empty object.
354 * - If `nodeIds` is supplied as an array of ids, but one or more do not correspond to a node in the network, the
355 * returned object will *not* include entries for the non-existent node positions.
356 *
357 * @param nodeIds - Either an array of node ids or a single node id. If not supplied, all node ids in the network will be used.
358 * @returns A an object containing the x y positions in canvas space of the nodes in the network, keyed by id.
359 */
360 getPositions(nodeIds?: IdType[] | IdType): { [nodeId: string]: Position };
361
362 /**
363 * Retrieves the x y position of a specific id.
364 *
365 * @param id - a node id
366 * @returns the x y position in canvas space of the requested node.
367 *
368 * @throws {@link TypeError}
369 * Thrown if an undefined or null id is provided as a parameter.
370 * @throws {@link ReferenceError}
371 * Thrown if the id provided as a parameter does not correspond to a node in the network.
372 */
373 getPosition(nodeId: IdType): Position;
374
375 /**
376 * When using the vis.DataSet to load your nodes into the network,
377 * this method will put the X and Y positions of all nodes into that dataset.
378 * If you're loading your nodes from a database and have this dynamically coupled with the DataSet,
379 * you can use this to stablize your network once, then save the positions in that database
380 * through the DataSet so the next time you load the nodes, stabilization will be near instantaneous.
381 *
382 * If the nodes are still moving and you're using dynamic smooth edges (which is on by default),
383 * you can use the option stabilization.onlyDynamicEdges in the physics module to improve initialization time.
384 *
385 * This method does not support clustering.
386 * At the moment it is not possible to cache positions when using clusters since
387 * they cannot be correctly initialized from just the positions.
388 */
389 storePositions(): void;
390
391 /**
392 * You can use this to programatically move a node.
393 * The supplied x and y positions have to be in canvas space!
394 *
395 * @param nodeId the node that will be moved
396 * @param x new canvas space x position
397 * @param y new canvas space y position
398 */
399 moveNode(nodeId: IdType, x: number, y: number): void;
400
401 /**
402 * Returns a bounding box for the node including label.
403 *
404 */
405 getBoundingBox(nodeId: IdType): BoundingBox;
406
407 /**
408 * Returns an array of nodeIds of the all the nodes that are directly connected to this node.
409 * If you supply an edgeId, vis will first match the id to nodes.
410 * If no match is found, it will search in the edgelist and return an array: [fromId, toId].
411 *
412 * @param nodeOrEdgeId a node or edge id
413 */
414 getConnectedNodes(nodeOrEdgeId: IdType, direction?: DirectionType): IdType[] | Array<{ fromId: IdType, toId: IdType }>;
415
416 /**
417 * Returns an array of edgeIds of the edges connected to this node.
418 *
419 * @param nodeId the node id
420 */
421 getConnectedEdges(nodeId: IdType): IdType[];
422
423 /**
424 * Start the physics simulation.
425 * This is normally done whenever needed and is only really useful
426 * if you stop the simulation yourself and wish to continue it afterwards.
427 */
428 startSimulation(): void;
429
430 /**
431 * This stops the physics simulation and triggers a stabilized event.
432 * Tt can be restarted by dragging a node,
433 * altering the dataset or calling startSimulation().
434 */
435 stopSimulation(): void;
436
437 /**
438 * You can manually call stabilize at any time.
439 * All the stabilization options above are used.
440 * You can optionally supply the number of iterations it should do.
441 *
442 * @param [iterations] the number of iterations it should do
443 */
444 stabilize(iterations?: number): void;
445
446 /**
447 * Returns an object with selected nodes and edges ids.
448 *
449 */
450 getSelection(): { nodes: IdType[], edges: IdType[] };
451
452 /**
453 * Returns an array of selected node ids like so:
454 * [nodeId1, nodeId2, ..].
455 *
456 */
457 getSelectedNodes(): IdType[];
458
459 /**
460 * Returns an array of selected edge ids like so:
461 * [edgeId1, edgeId2, ..].
462 *
463 */
464 getSelectedEdges(): IdType[];
465
466 /**
467 * Returns a nodeId or undefined.
468 * The DOM positions are expected to be in pixels from the top left corner of the canvas.
469 *
470 */
471 getNodeAt(position: Position): IdType;
472
473 /**
474 * Returns a edgeId or undefined.
475 * The DOM positions are expected to be in pixels from the top left corner of the canvas.
476 *
477 */
478 getEdgeAt(position: Position): IdType;
479
480 /**
481 * Selects the nodes corresponding to the id's in the input array.
482 * If highlightEdges is true or undefined, the neighbouring edges will also be selected.
483 * This method unselects all other objects before selecting its own objects. Does not fire events.
484 *
485 */
486 selectNodes(nodeIds: IdType[], highlightEdges?: boolean): void;
487
488 /**
489 * Selects the edges corresponding to the id's in the input array.
490 * This method unselects all other objects before selecting its own objects.
491 * Does not fire events.
492 *
493 */
494 selectEdges(edgeIds: IdType[]): void;
495
496 /**
497 * Sets the selection.
498 * You can also pass only nodes or edges in selection object.
499 *
500 */
501 setSelection(selection: { nodes?: IdType[], edges?: IdType[] }, options?: SelectionOptions): void;
502
503 /**
504 * Unselect all objects.
505 * Does not fire events.
506 */
507 unselectAll(): void;
508
509 /**
510 * Returns the current scale of the network.
511 * 1.0 is comparible to 100%, 0 is zoomed out infinitely.
512 *
513 * @returns the current scale of the network
514 */
515 getScale(): number;
516
517 /**
518 * Returns the current central focus point of the view in the form: { x: {Number}, y: {Number} }
519 *
520 * @returns the view position;
521 */
522 getViewPosition(): Position;
523
524 /**
525 * Zooms out so all nodes fit on the canvas.
526 *
527 * @param [options] All options are optional for the fit method
528 */
529 fit(options?: FitOptions): void;
530
531 /**
532 * You can focus on a node with this function.
533 * What that means is the view will lock onto that node, if it is moving, the view will also move accordingly.
534 * If the view is dragged by the user, the focus is broken. You can supply options to customize the effect.
535 *
536 */
537 focus(nodeId: IdType, options?: FocusOptions): void;
538
539 /**
540 * You can animate or move the camera using the moveTo method.
541 *
542 */
543 moveTo(options: MoveToOptions): void;
544
545 /**
546 * Programatically release the focussed node.
547 */
548 releaseNode(): void;
549
550 /**
551 * If you use the configurator, you can call this method to get an options object that contains
552 * all differences from the default options caused by users interacting with the configurator.
553 *
554 */
555 getOptionsFromConfigurator(): any;
556}
557
558/**
559 * Options interface for focus function.
560 */
561export interface FocusOptions extends ViewPortOptions {
562 /**
563 * Locked denotes whether or not the view remains locked to
564 * the node once the zoom-in animation is finished.
565 * Default value is true.
566 */
567 locked?: boolean;
568}
569
570/**
571 * Base options interface for some viewport functions.
572 */
573export interface ViewPortOptions {
574 /**
575 * The scale is the target zoomlevel.
576 * Default value is 1.0.
577 */
578 scale?: number;
579
580 /**
581 * The offset (in DOM units) is how many pixels from the center the view is focussed.
582 * Default value is {x:0,y:0}
583 */
584 offset?: Position;
585
586 /**
587 * For animation you can either use a Boolean to use it with the default options or
588 * disable it or you can define the duration (in milliseconds) and easing function manually.
589 */
590 animation?: AnimationOptions | boolean;
591}
592
593/**
594 * You will have to define at least a scale, position or offset.
595 * Otherwise, there is nothing to move to.
596 */
597export interface MoveToOptions extends ViewPortOptions {
598 /**
599 * The position (in canvas units!) is the position of the central focus point of the camera.
600 */
601 position?: Position;
602}
603
604/**
605 * Animation options interface.
606 */
607export interface AnimationOptions {
608 /**
609 * The duration (in milliseconds).
610 */
611 duration: number;
612 /**
613 * The easing function.
614 *
615 * Available are:
616 * linear, easeInQuad, easeOutQuad, easeInOutQuad, easeInCubic,
617 * easeOutCubic, easeInOutCubic, easeInQuart, easeOutQuart, easeInOutQuart,
618 * easeInQuint, easeOutQuint, easeInOutQuint.
619 */
620 easingFunction: EasingFunction;
621}
622
623export type EasingFunction =
624 'linear' |
625 'easeInQuad' |
626 'easeOutQuad' |
627 'easeInOutQuad' |
628 'easeInCubic' |
629 'easeOutCubic' |
630 'easeInOutCubic' |
631 'easeInQuart' |
632 'easeOutQuart' |
633 'easeInOutQuart' |
634 'easeInQuint' |
635 'easeOutQuint' |
636 'easeInOutQuint';
637
638/**
639 * Optional options for the fit method.
640 */
641export interface FitOptions {
642 /**
643 * The nodes can be used to zoom to fit only specific nodes in the view.
644 */
645 nodes?: IdType[];
646
647 /**
648 * How far away can be zoomed out, the default is just above 0.
649 *
650 * @remarks
651 * Values less than 1 mean zooming out, more than 1 means zooming in.
652 */
653 minZoomLevel?: number;
654
655 /**
656 * How close can be zoomed in, the default is 1.
657 *
658 * @remarks
659 * Values less than 1 mean zooming out, more than 1 means zooming in.
660 */
661 maxZoomLevel?: number;
662
663 /**
664 * For animation you can either use a Boolean to use it with the default options or
665 * disable it or you can define the duration (in milliseconds) and easing function manually.
666 */
667 animation?: TimelineAnimationType;
668}
669
670export interface SelectionOptions {
671 unselectAll?: boolean;
672 highlightEdges?: boolean;
673}
674
675/**
676 * These values are in canvas space.
677 */
678export interface BoundingBox {
679 top: number;
680 left: number;
681 right: number;
682 bottom: number;
683}
684
685/**
686 * Cluster methods options interface.
687 */
688export interface ClusterOptions {
689 /**
690 * Optional for all but the cluster method.
691 * The cluster module loops over all nodes that are selected to be in the cluster
692 * and calls this function with their data as argument. If this function returns true,
693 * this node will be added to the cluster. You have access to all options (including the default)
694 * as well as any custom fields you may have added to the node to determine whether or not to include it in the cluster.
695 */
696 joinCondition?(nodeOptions: any): boolean;
697
698 /**
699 * Optional.
700 * Before creating the new cluster node, this (optional) function will be called with the properties
701 * supplied by you (clusterNodeProperties), all contained nodes and all contained edges.
702 * You can use this to update the properties of the cluster based on which items it contains.
703 * The function should return the properties to create the cluster node.
704 */
705 processProperties?(clusterOptions: any, childNodesOptions: any[], childEdgesOptions: any[]): any;
706
707 /**
708 * Optional.
709 * This is an object containing the options for the cluster node.
710 * All options described in the nodes module are allowed.
711 * This allows you to style your cluster node any way you want.
712 * This is also the style object that is provided in the processProperties function for fine tuning.
713 * If undefined, default node options will be used.
714 */
715 clusterNodeProperties?: NodeOptions;
716
717 /**
718 * Optional.
719 * This is an object containing the options for the edges connected to the cluster.
720 * All options described in the edges module are allowed.
721 * Using this, you can style the edges connecting to the cluster any way you want.
722 * If none are provided, the options from the edges that are replaced are used.
723 * If undefined, default edge options will be used.
724 */
725 clusterEdgeProperties?: EdgeOptions;
726}
727
728/**
729 * Options for the openCluster function of Network.
730 */
731export interface OpenClusterOptions {
732 /**
733 * A function that can be used to manually position the nodes after the cluster is opened.
734 * The containedNodesPositions contain the positions of the nodes in the cluster at the
735 * moment they were clustered. This function is expected to return the newPositions,
736 * which can be the containedNodesPositions (altered) or a new object.
737 * This has to be an object with keys equal to the nodeIds that exist in the
738 * containedNodesPositions and an {x:x,y:y} position object.
739 *
740 * For all nodeIds not listed in this returned object,
741 * we will position them at the location of the cluster.
742 * This is also the default behaviour when no releaseFunction is defined.
743 */
744 releaseFunction(
745 clusterPosition: Position,
746 containedNodesPositions: { [nodeId: string]: Position }): { [nodeId: string]: Position };
747}
748
749export interface Position {
750 x: number;
751 y: number;
752}
753
754export interface Data {
755 nodes?: Node[] | DataInterfaceNodes;
756 edges?: Edge[] | DataInterfaceEdges;
757}
758
759export interface Node extends NodeOptions {
760 id?: IdType;
761}
762
763export interface Edge extends EdgeOptions {
764 from?: IdType;
765 to?: IdType;
766 id?: IdType;
767}
768
769export interface Locales {
770 [language: string]: LocaleMessages | undefined;
771 en?: LocaleMessages;
772 cn?: LocaleMessages;
773 de?: LocaleMessages;
774 es?: LocaleMessages;
775 it?: LocaleMessages;
776 nl?: LocaleMessages;
777 'pt-br'?: LocaleMessages;
778 ru?: LocaleMessages;
779}
780
781export interface LocaleMessages {
782 edit: string;
783 del: string;
784 back: string;
785 addNode: string;
786 addEdge: string;
787 editNode: string;
788 editEdge: string;
789 addDescription: string;
790 edgeDescription: string;
791 editEdgeDescription: string;
792 createEdgeError: string;
793 deleteClusterError: string;
794 editClusterError: string;
795}
796
797export interface Options {
798 autoResize?: boolean;
799
800 width?: string;
801
802 height?: string;
803
804 locale?: string;
805
806 locales?: Locales;
807
808 clickToUse?: boolean;
809
810 configure?: any; // https://visjs.github.io/vis-network/docs/network/configure.html
811
812 edges?: EdgeOptions;
813
814 nodes?: NodeOptions;
815
816 groups?: any;
817
818 layout?: any; // https://visjs.github.io/vis-network/docs/network/layout.html
819
820 interaction?: any; // https://visjs.github.io/vis-network/docs/network/interaction.html?keywords=edges
821
822 manipulation?: any; // https://visjs.github.io/vis-network/docs/network/manipulation.html
823
824 physics?: any; // https://visjs.github.io/vis-network/docs/network/physics.html
825}
826
827export interface Image {
828 unselected?: string;
829 selected?: string;
830}
831
832export interface ImagePadding {
833 top?: number;
834 right?: number;
835 bottom?: number;
836 left?: number;
837}
838
839export interface Color {
840 border?: string;
841
842 background?: string;
843
844 highlight?: string | {
845 border?: string;
846 background?: string;
847 };
848
849 hover?: string | {
850 border?: string;
851 background?: string;
852 };
853}
854
855export interface ChosenLabelValues {
856 color: string;
857 face: string;
858 mod: string;
859 size: number;
860 strokeColor: string;
861 strokeWidth: number;
862 vadjust: number;
863}
864export type NodeChosenLabelFunction = (
865 values: ChosenLabelValues,
866 id: IdType,
867 selected: boolean,
868 hovered: boolean
869) => void;
870
871export interface ChosenNodeValues {
872 borderColor: string;
873 borderDashes: boolean | number[];
874 borderRadius: number;
875 borderWidth: number;
876 color: string;
877 shadow: boolean;
878 shadowColor: string;
879 shadowSize: number;
880 shadowX: number;
881 shadowY: number;
882 size: number;
883}
884export type NodeChosenNodeFunction = (
885 values: ChosenNodeValues,
886 id: IdType,
887 selected: boolean,
888 hovered: boolean
889) => void;
890
891export interface NodeChosen {
892 node: boolean | NodeChosenNodeFunction;
893 label: boolean | NodeChosenLabelFunction;
894}
895
896export interface NodeOptions {
897 borderWidth?: number;
898
899 borderWidthSelected?: number;
900
901 brokenImage?: string;
902
903 color?: string | Color;
904
905 chosen?: boolean | NodeChosen;
906
907 opacity?: number;
908
909 fixed?: boolean | {
910 x?: boolean,
911 y?: boolean,
912 };
913
914 font?: string | Font;
915
916 group?: string;
917
918 hidden?: boolean;
919
920 icon?: {
921 face?: string,
922 code?: string,
923 size?: number, // 50,
924 color?: string,
925 weight?: number | string,
926 };
927
928 image?: string | Image;
929
930 imagePadding?: number | ImagePadding;
931
932 label?: string;
933
934 labelHighlightBold?: boolean;
935
936 level?: number;
937
938 margin?: {
939 top?: number;
940 right?: number;
941 bottom?: number;
942 left?: number;
943 };
944
945 mass?: number;
946
947 physics?: boolean;
948
949 scaling?: OptionsScaling;
950
951 shadow?: boolean | OptionsShadow;
952
953 shape?: string;
954
955 shapeProperties?: {
956 borderDashes?: boolean | number[], // only for borders
957 borderRadius?: number, // only for box shape
958 interpolation?: boolean, // only for image and circularImage shapes
959 useImageSize?: boolean, // only for image and circularImage shapes
960 useBorderWithImage?: boolean, // only for image shape
961 coordinateOrigin?: string // only for image and circularImage shapes
962 };
963
964 size?: number;
965
966 title?: string | HTMLElement;
967
968 value?: number;
969
970 /**
971 * If false, no widthConstraint is applied. If a number is specified, the minimum and maximum widths of the node are set to the value.
972 * The node's label's lines will be broken on spaces to stay below the maximum and the node's width
973 * will be set to the minimum if less than the value.
974 */
975 widthConstraint?: number | boolean | { minimum?: number, maximum?: number };
976
977 x?: number;
978
979 y?: number;
980}
981
982export interface EdgeOptions {
983 arrows?: string | {
984 to?: boolean | ArrowHead
985 middle?: boolean | ArrowHead
986 from?: boolean | ArrowHead
987 };
988
989 arrowStrikethrough?: boolean;
990
991 chosen?: boolean | {
992 edge?: boolean, // please note, chosen.edge could be also a function. This case is not represented here
993 label?: boolean, // please note, chosen.label could be also a function. This case is not represented here
994 };
995
996 color?: string | {
997 color?: string,
998 highlight?: string,
999 hover?: string,
1000 inherit?: boolean | string,
1001 opacity?: number,
1002 };
1003
1004 dashes?: boolean | number[];
1005
1006 font?: string | Font;
1007
1008 hidden?: boolean;
1009
1010 hoverWidth?: number; // please note, hoverWidth could be also a function. This case is not represented here
1011
1012 label?: string;
1013
1014 labelHighlightBold?: boolean;
1015
1016 length?: number;
1017
1018 physics?: boolean;
1019
1020 scaling?: OptionsScaling;
1021
1022 selectionWidth?: number; // please note, selectionWidth could be also a function. This case is not represented here
1023
1024 selfReferenceSize?: number;
1025
1026 selfReference?: {
1027 size?: number,
1028 angle?: number,
1029 renderBehindTheNode?: boolean
1030 };
1031
1032 shadow?: boolean | OptionsShadow;
1033
1034 smooth?: boolean | {
1035 enabled: boolean,
1036 type: string,
1037 forceDirection?: string | boolean,
1038 roundness: number,
1039 };
1040
1041 title?: string | HTMLElement;
1042
1043 value?: number;
1044
1045 width?: number;
1046
1047 widthConstraint?: number | boolean | {
1048 maximum?: number;
1049 };
1050}
1051
1052export interface ArrowHead {
1053 enabled?: boolean,
1054 imageHeight?: number,
1055 imageWidth?: number,
1056 scaleFactor?: number,
1057 src?: string,
1058 type?: string;
1059}
1060
1061export interface Font {
1062 color?: string,
1063 size?: number, // px
1064 face?: string,
1065 background?: string,
1066 strokeWidth?: number, // px
1067 strokeColor?: string,
1068 align?: string,
1069 vadjust?: number,
1070 multi?: boolean | string,
1071 bold?: string | FontStyles,
1072 ital?: string | FontStyles,
1073 boldital?: string | FontStyles,
1074 mono?: string | FontStyles,
1075}
1076
1077export interface FontStyles {
1078 color?: string;
1079 size?: number;
1080 face?: string;
1081 mod?: string;
1082 vadjust?: number;
1083}
1084
1085export interface OptionsScaling {
1086 min?: number;
1087 max?: number;
1088 label?: boolean | {
1089 enabled?: boolean,
1090 min?: number,
1091 max?: number,
1092 maxVisible?: number,
1093 drawThreshold?: number
1094 };
1095 customScalingFunction?(min?: number, max?: number, total?: number, value?: number): number;
1096}
1097
1098export interface OptionsShadow {
1099 enabled?: boolean;
1100 color?: string;
1101 size?: number;
1102 x?: number;
1103 y?: number;
1104}