@neo4j-nvl/base 0.3.1 → 0.3.2-e0e72a58
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 +6 -4
- package/dist/base.mjs +1 -1
- package/dist/types/index.d.ts +21 -15
- package/dist/types/layouts/animatedlayout/AnimatedLayout.test.d.ts +1 -0
- package/dist/types/layouts/animatedlayout/animationUtils.test.d.ts +1 -0
- package/dist/types/layouts/d3forcelayout/constants.d.ts +2 -1
- package/dist/types/layouts/d3forcelayout/d3ForceLayout.d.ts +4 -0
- package/dist/types/layouts/forcedirectedlayout/ForceCytoLayout.d.ts +12 -14
- package/dist/types/layouts/forcedirectedlayout/cosebilkentlayout/CoseBilkentLayout.d.ts +1 -1
- package/dist/types/layouts/forcedirectedlayout/physlayout/PhysLayout.d.ts +103 -113
- package/dist/types/layouts/forcedirectedlayout/physlayout/PhysLayout.test.d.ts +1 -0
- package/dist/types/layouts/forcedirectedlayout/physlayout/glwrapper.d.ts +2 -2
- package/dist/types/layouts/forcedirectedlayout/physlayout/shaders/multilevel-fragment-verlet.d.ts +2 -0
- package/dist/types/layouts/forcedirectedlayout/physlayout/shaders/multilevel-repulsive-fragment-verlet.d.ts +2 -0
- package/dist/types/layouts/forcedirectedlayout/physlayout/solarmerger/SolarMerger.test.d.ts +1 -0
- package/dist/types/layouts/forcedirectedlayout/physlayout/solarmerger/solar-placer.d.ts +2 -4
- package/dist/types/layouts/forcedirectedlayout/physlayout/solarmerger/solar-placer.test.d.ts +1 -0
- package/dist/types/layouts/hierarchicallayout/HierarchicalLayout.d.ts +2 -2
- package/dist/types/modules/CallbackHelper.d.ts +6 -6
- package/dist/types/modules/ExternalCallbackHandler.d.ts +2 -0
- package/dist/types/modules/NvlController.d.ts +89 -93
- package/dist/types/modules/Shader.d.ts +14 -14
- package/dist/types/modules/ZoomTransitionHandler.d.ts +1 -1
- package/dist/types/modules/ZoomTransitionHandler.test.d.ts +1 -0
- package/dist/types/modules/dataset.test.d.ts +1 -0
- package/dist/types/modules/logging.d.ts +7 -4
- package/dist/types/modules/state.d.ts +38 -11
- package/dist/types/modules/state.test.d.ts +1 -0
- package/dist/types/renderers/canvasrenderer/Animation.test.d.ts +1 -0
- package/dist/types/renderers/canvasrenderer/CanvasRenderer.test.d.ts +1 -0
- package/dist/types/renderers/canvasrenderer/ImageCache.d.ts +6 -6
- package/dist/types/renderers/canvasrenderer/ImageCache.test.d.ts +1 -0
- package/dist/types/renderers/canvasrenderer/arrows/ArrowBundle.test.d.ts +1 -0
- package/dist/types/renderers/canvasrenderer/arrows/ArrowBundler.test.d.ts +1 -0
- package/dist/types/renderers/canvasrenderer/arrows/arrows.d.ts +5 -3
- package/dist/types/renderers/canvasrenderer/arrows/arrows.test.d.ts +1 -0
- package/dist/types/renderers/canvasrenderer/arrows/constants.d.ts +0 -13
- package/dist/types/renderers/canvasrenderer/nodes/nodes.d.ts +4 -4
- package/dist/types/renderers/canvasrenderer/nodes/nodes.test.d.ts +1 -0
- package/dist/types/renderers/canvasrenderer/util.test.d.ts +1 -0
- package/dist/types/renderers/canvasrenderer/wordwrap.test.d.ts +1 -0
- package/dist/types/renderers/webglrenderer/Controller.d.ts +2 -2
- package/dist/types/renderers/webglrenderer/Controller.test.d.ts +1 -0
- package/dist/types/renderers/webglrenderer/Renderer.d.ts +3 -7
- package/dist/types/types/graph-element.d.ts +35 -3
- package/dist/types/types/nvl-window-functions.d.ts +16 -0
- package/dist/types/types/utils.d.ts +1 -0
- package/dist/types/utils/canvasManagement.d.ts +1 -1
- package/dist/types/utils/canvasManagement.test.d.ts +1 -0
- package/dist/types/utils/constants.d.ts +2 -0
- package/dist/types/utils/errors.test.d.ts +1 -0
- package/dist/types/utils/geometry.d.ts +3 -3
- package/dist/types/utils/geometry.test.d.ts +1 -0
- package/dist/types/utils/graphObjectUtils.d.ts +21 -7
- package/dist/types/utils/graphObjectUtils.test.d.ts +1 -0
- package/dist/types/utils/hittest.test.d.ts +1 -0
- package/dist/types/utils/mouseUtils.test.d.ts +1 -0
- package/dist/types/utils/segmentAnalytics.d.ts +51 -0
- package/dist/types/utils/zoomFunctions.d.ts +3 -3
- package/dist/types/utils/zoomFunctions.test.d.ts +1 -0
- package/package.json +25 -6
package/dist/types/index.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { ExternalCallbacks } from './modules/ExternalCallbackHandler';
|
|
2
|
-
import type { ForceDirectedOptions, HierarchicalOptions, Layout, LayoutOptions,
|
|
2
|
+
import type { ForceDirectedOptions, HierarchicalOptions, Layout, LayoutOptions, NvlOptions, NvlState, Renderer, ZoomOptions } from './modules/state';
|
|
3
3
|
import { ForceDirectedLayoutType, FreeLayoutType, GridLayoutType, HierarchicalLayoutType, d3ForceLayoutType } from './modules/state';
|
|
4
|
+
import type { StyledCaption } from './renderers/canvasrenderer/types';
|
|
4
5
|
import { drawCircleBand } from './renderers/canvasrenderer/util';
|
|
5
6
|
import type { Node, PartialNode, PartialRelationship, Relationship } from './types/graph-element';
|
|
6
7
|
import { CompatibilityError } from './utils/errors';
|
|
@@ -17,7 +18,9 @@ interface NvlMouseEvent extends MouseEvent {
|
|
|
17
18
|
* Class for a NVL instance.
|
|
18
19
|
* @example
|
|
19
20
|
* This is a basic setup for a NVL instance.
|
|
20
|
-
* ```
|
|
21
|
+
* ```ts
|
|
22
|
+
* import { NVL } from '@neo4j-nvl/base'
|
|
23
|
+
*
|
|
21
24
|
* const nodes = [
|
|
22
25
|
* { id: '1', label: 'Node 1', color: '#e04141' },
|
|
23
26
|
* { id: '2', label: 'Node 2', color: '#e09c41' }
|
|
@@ -26,7 +29,6 @@ interface NvlMouseEvent extends MouseEvent {
|
|
|
26
29
|
* { id: '12', from: '1', to: '2' }
|
|
27
30
|
* ]
|
|
28
31
|
* const options = {
|
|
29
|
-
* layout: 'hierarchical',
|
|
30
32
|
* initialZoom: 0.5
|
|
31
33
|
* }
|
|
32
34
|
* const callbacks = {
|
|
@@ -41,6 +43,7 @@ declare class NVL {
|
|
|
41
43
|
private visState;
|
|
42
44
|
private nvlController;
|
|
43
45
|
private options;
|
|
46
|
+
private segmentTrack;
|
|
44
47
|
/**
|
|
45
48
|
* Creates a new NVL instance.
|
|
46
49
|
* @constructor
|
|
@@ -68,7 +71,11 @@ declare class NVL {
|
|
|
68
71
|
* If an existing property is not provided, it will not be changed.
|
|
69
72
|
* @example
|
|
70
73
|
* Adding and updating nodes and relationships
|
|
71
|
-
* ```
|
|
74
|
+
* ```ts
|
|
75
|
+
* import { NVL } from '@neo4j-nvl/base'
|
|
76
|
+
*
|
|
77
|
+
* const nvl = new NVL(document.getElementById('frame'), [{ id: '0' }], [])
|
|
78
|
+
*
|
|
72
79
|
* const nodes = [
|
|
73
80
|
* { id: '1', label: 'Node 1', color: '#e04141' },
|
|
74
81
|
* { id: '2', label: 'Node 2', color: '#e09c41' }
|
|
@@ -104,15 +111,17 @@ declare class NVL {
|
|
|
104
111
|
* If an existing property is not provided, it will not be changed.
|
|
105
112
|
* @example
|
|
106
113
|
* Updating nodes and relationships
|
|
107
|
-
* ```
|
|
114
|
+
* ```ts
|
|
115
|
+
* import { NVL } from '@neo4j-nvl/base'
|
|
116
|
+
*
|
|
108
117
|
* const nodes = [
|
|
109
|
-
*
|
|
110
|
-
*
|
|
118
|
+
* { id: '1', label: 'Node 1', color: '#e04141' },
|
|
119
|
+
* { id: '2', label: 'Node 2', color: '#e09c41' }
|
|
111
120
|
* ]
|
|
112
121
|
* const relationships = [
|
|
113
|
-
*
|
|
122
|
+
* { id: '12', from: '1', to: '2' }
|
|
114
123
|
* ]
|
|
115
|
-
* const nvl = new NVL(
|
|
124
|
+
* const nvl = new NVL(document.getElementById('frame'), nodes, relationships)
|
|
116
125
|
* // Updates an existing node and relationship
|
|
117
126
|
* nvl.updateElementsInGraph([{ id: '1', selected: true }], [{ id: '12', color: '#e0df41' }])
|
|
118
127
|
* ```
|
|
@@ -277,9 +286,6 @@ declare class NVL {
|
|
|
277
286
|
* @param {string} options.backgroundColor - The background color of the png file.
|
|
278
287
|
* @note The size of the png file will be as large as the entire graph at the default zoom level.
|
|
279
288
|
* Can result in a very large file.
|
|
280
|
-
* @example
|
|
281
|
-
* // Save the entire graph visualization canvas as a png to the client.
|
|
282
|
-
* graphVisualization.saveFullGraphToFile({ filename: 'graph.png', backgroundColor: '#fff' })
|
|
283
289
|
*/
|
|
284
290
|
saveFullGraphToLargeFile(options: {
|
|
285
291
|
filename?: string;
|
|
@@ -341,10 +347,10 @@ declare class NVL {
|
|
|
341
347
|
* @example
|
|
342
348
|
* ```js
|
|
343
349
|
* const container = document.getElementById('frame')
|
|
344
|
-
* const nvl = new NVL(container,
|
|
350
|
+
* const nvl = new NVL(container, [{ id: '0' }], [])
|
|
345
351
|
*
|
|
346
352
|
* // Get the nodes and relationships that have been hit by a pointer event.
|
|
347
|
-
* container
|
|
353
|
+
* container?.addEventListener('click', (evt) => {
|
|
348
354
|
* const { nvlTargets } = nvl.getHits(evt)
|
|
349
355
|
* console.log('clicked elements:', nvlTargets)
|
|
350
356
|
* })
|
|
@@ -375,5 +381,5 @@ declare const colorMapperFunctions: {
|
|
|
375
381
|
textColorForBackground: (color: string) => string;
|
|
376
382
|
};
|
|
377
383
|
export default NVL;
|
|
378
|
-
export type { NvlOptions, Renderer, Node, Relationship, PartialNode, PartialRelationship, Layout, LayoutOptions, ForceDirectedOptions, HierarchicalOptions, ExternalCallbacks, HitTargets, HitTargetNode, HitTargetRelationship, Point, NvlMouseEvent,
|
|
384
|
+
export type { NvlOptions, Renderer, Node, Relationship, PartialNode, PartialRelationship, Layout, LayoutOptions, ForceDirectedOptions, HierarchicalOptions, ExternalCallbacks, HitTargets, HitTargetNode, HitTargetRelationship, Point, NvlMouseEvent, ZoomOptions, StyledCaption };
|
|
379
385
|
export { NVL, colorMapperFunctions, CompatibilityError, ForceDirectedLayoutType, HierarchicalLayoutType, GridLayoutType, FreeLayoutType, d3ForceLayoutType, drawCircleBand };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { SimulationLinkDatum } from 'd3-force';
|
|
1
|
+
import type { SimulationLinkDatum, SimulationNodeDatum } from 'd3-force';
|
|
2
2
|
import type { D3Node } from './types';
|
|
3
3
|
export declare const VELOCITY_DECAY = 0.4;
|
|
4
4
|
export declare const DEFAULT_ALPHA = 1;
|
|
@@ -10,6 +10,7 @@ export declare const MAX_STABILIZE_TICKS = 100;
|
|
|
10
10
|
export declare const LINK_DISTANCE = 45;
|
|
11
11
|
export declare const BARNES_HUT_THETA = 1.2;
|
|
12
12
|
export declare const FORCE_LINK_DISTANCE: (relationship: SimulationLinkDatum<D3Node>) => number;
|
|
13
|
+
export declare const FORCE_LINK_STRENGTH: (link: SimulationLinkDatum<SimulationNodeDatum>, count: number[]) => number;
|
|
13
14
|
export declare const FORCE_COLLIDE_RADIUS: (node: D3Node) => number;
|
|
14
15
|
export declare const LAYOUT_RADIUS: (numberOfNodes: number) => number;
|
|
15
16
|
export declare const FORCE_CHARGE: () => number;
|
|
@@ -8,9 +8,12 @@ export class d3ForceLayout {
|
|
|
8
8
|
x: number;
|
|
9
9
|
y: number;
|
|
10
10
|
};
|
|
11
|
+
nodeRelCount: any[];
|
|
11
12
|
simulation: import("d3-force").Simulation<import("d3-force").SimulationNodeDatum, undefined>;
|
|
12
13
|
simulationStopped: boolean;
|
|
13
14
|
shouldUpdate: boolean;
|
|
15
|
+
shouldReheatNodes: boolean;
|
|
16
|
+
shouldCountNodeRels: boolean;
|
|
14
17
|
stateDisposers: any[];
|
|
15
18
|
setOptions(options: any): void;
|
|
16
19
|
updateNodes(positionList: any): void;
|
|
@@ -26,4 +29,5 @@ export class d3ForceLayout {
|
|
|
26
29
|
terminateUpdate(): void;
|
|
27
30
|
destroy(): void;
|
|
28
31
|
setAlpha(alpha: any): void;
|
|
32
|
+
countNodeRels(): any[];
|
|
29
33
|
}
|
|
@@ -1,24 +1,22 @@
|
|
|
1
|
-
export const ForceDirectedLayoutType
|
|
2
|
-
export const CoseBilkentType
|
|
3
|
-
export class ForceCytoLayout {
|
|
1
|
+
export declare const ForceDirectedLayoutType = "forceDirected";
|
|
2
|
+
export declare const CoseBilkentType = "coseBilkent";
|
|
3
|
+
export declare class ForceCytoLayout {
|
|
4
|
+
private readonly physLayout;
|
|
5
|
+
private readonly coseBilkentLayout;
|
|
6
|
+
private readonly state;
|
|
7
|
+
private currentLayoutType;
|
|
8
|
+
private enableCytoscape;
|
|
9
|
+
private currentLayout;
|
|
4
10
|
constructor(config: any);
|
|
5
|
-
isCytoscapeEnabled: any;
|
|
6
|
-
_physLayout: PhysLayout;
|
|
7
|
-
_coseBilkentLayout: CoseBilkentLayout;
|
|
8
|
-
_currentLayout: PhysLayout;
|
|
9
|
-
_currentLayoutType: string;
|
|
10
|
-
_state: any;
|
|
11
11
|
setOptions(options: any): void;
|
|
12
|
-
|
|
13
|
-
|
|
12
|
+
private getLayout;
|
|
13
|
+
private setLayout;
|
|
14
14
|
copyLayoutPositions(nodeList: any, prevLayout: any, nextLayout: any): void;
|
|
15
15
|
update(refreshPositions?: boolean): void;
|
|
16
16
|
getShouldUpdate(): boolean;
|
|
17
17
|
getComputing(): boolean;
|
|
18
18
|
updateNodes(positionList: any): void;
|
|
19
|
-
getNodePositions(data: any):
|
|
19
|
+
getNodePositions(data: any): import("../..").Node[];
|
|
20
20
|
terminateUpdate(): void;
|
|
21
21
|
destroy(): void;
|
|
22
22
|
}
|
|
23
|
-
import { PhysLayout } from './physlayout/PhysLayout';
|
|
24
|
-
import { CoseBilkentLayout } from './cosebilkentlayout/CoseBilkentLayout';
|
|
@@ -21,7 +21,7 @@ export declare class CoseBilkentLayout extends AnimatedLayout {
|
|
|
21
21
|
cytoCompleteCallback?: () => void;
|
|
22
22
|
animationCompleteCallback?: () => void;
|
|
23
23
|
});
|
|
24
|
-
setOptions(
|
|
24
|
+
setOptions(): void;
|
|
25
25
|
update(refreshPositions?: boolean, updateMobXNodes?: Node[], updateMobXRelationships?: Relationship[]): void;
|
|
26
26
|
getShouldUpdate(): boolean;
|
|
27
27
|
getComputing(): boolean;
|
|
@@ -1,69 +1,86 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
1
|
+
import type { ForceDirectedOptions, NvlState } from '../../../modules/state';
|
|
2
|
+
import type { Node, Relationship } from '../../../types/graph-element';
|
|
3
|
+
import type { Point } from '../../../utils/geometry';
|
|
4
|
+
export declare class PhysLayout {
|
|
5
|
+
private physVbo;
|
|
6
|
+
private physSmallVbo;
|
|
7
|
+
private physProjection;
|
|
8
|
+
private physSmallProjection;
|
|
9
|
+
private gl;
|
|
10
|
+
private useReadpixelWorkaround;
|
|
11
|
+
private averageNodeSize;
|
|
12
|
+
private shouldUpdate;
|
|
13
|
+
private iterationCount;
|
|
14
|
+
private lastSpeedValues;
|
|
15
|
+
private rollingAvgGraphSpeed;
|
|
16
|
+
private nodeVariation;
|
|
17
|
+
private nodeCenterPoint;
|
|
18
|
+
private peakIterationMultiplier;
|
|
19
|
+
private stateDisposers;
|
|
20
|
+
private state;
|
|
21
|
+
private dpr;
|
|
22
|
+
private intelWorkaround;
|
|
23
|
+
private simulationStopVelocitySquared;
|
|
24
|
+
private gravity;
|
|
25
|
+
private force;
|
|
26
|
+
private nodeIdToIndex;
|
|
27
|
+
private nodeIndexToId;
|
|
28
|
+
private numNodes;
|
|
29
|
+
private solarMerger;
|
|
30
|
+
private subGraphs;
|
|
31
|
+
private nodeSortMap;
|
|
32
|
+
private firstUpdate;
|
|
33
|
+
private curPhysData;
|
|
34
|
+
private apprxRepForceShader;
|
|
35
|
+
private levelsClusterTexture;
|
|
36
|
+
private levelsFinestIndexTexture;
|
|
37
|
+
private initalLevelTexture;
|
|
38
|
+
private levelsData;
|
|
39
|
+
private collisionDetectionMultiplier;
|
|
40
|
+
private physShader;
|
|
41
|
+
private physData;
|
|
42
|
+
private workaroundData;
|
|
43
|
+
private pinData;
|
|
44
|
+
private updateData;
|
|
45
|
+
private updateShader;
|
|
46
|
+
private workaroundShader;
|
|
47
|
+
private physPositions;
|
|
48
|
+
private springTexture;
|
|
49
|
+
private sizeTexture;
|
|
50
|
+
private offsetTexture;
|
|
51
|
+
private pinTexture;
|
|
52
|
+
private addedNodes;
|
|
53
|
+
private updateTexture;
|
|
54
|
+
enableVerlet: boolean;
|
|
55
|
+
constructor(config: ForceDirectedOptions & {
|
|
56
|
+
webGLContext: WebGL2RenderingContext;
|
|
57
|
+
state: NvlState;
|
|
58
|
+
});
|
|
19
59
|
/**
|
|
20
60
|
* Sets the layout options
|
|
21
|
-
* @param {
|
|
22
|
-
* @param {boolean} options.intelWorkaround whether to use the layout implementation for Intel GPUs
|
|
23
|
-
* @param {Number} options.simulationStopVelocity the graph speed at which to stop the layout
|
|
24
|
-
* @param {Number} options.gravity the force layout's gravity strength
|
|
61
|
+
* @param {ForceDirectedOptions} options the object with the options
|
|
25
62
|
* @param {boolean} [initial=false] whether this is the first setting of options
|
|
26
63
|
*/
|
|
27
|
-
setOptions(options:
|
|
28
|
-
intelWorkaround: boolean;
|
|
29
|
-
simulationStopVelocity: number;
|
|
30
|
-
gravity: number;
|
|
31
|
-
}, initial?: boolean): void;
|
|
32
|
-
intelWorkaround: boolean;
|
|
33
|
-
simulationStopVelocitySquared: number;
|
|
34
|
-
gravity: number;
|
|
35
|
-
force: any;
|
|
64
|
+
setOptions(options?: ForceDirectedOptions, initial?: boolean): void;
|
|
36
65
|
/**
|
|
37
66
|
* Sets graph data to be used
|
|
38
|
-
* @param {
|
|
39
|
-
* @
|
|
40
|
-
* @param {Array<Object>} data.rels the relationships in the graph
|
|
41
|
-
* @returns {Object} the top level graph of the subgraphs created by the solar merger
|
|
67
|
+
* @param {{ nodes: Node[]; rels: Relationship[] }} data the graph object
|
|
68
|
+
* @returns the top level graph of the subgraphs created by the solar merger
|
|
42
69
|
*/
|
|
43
70
|
setData(data: {
|
|
44
|
-
nodes:
|
|
45
|
-
rels:
|
|
71
|
+
nodes: Node[];
|
|
72
|
+
rels: Relationship[];
|
|
46
73
|
}): any;
|
|
47
|
-
_nodeIdToIndex: {};
|
|
48
|
-
_nodeIndexToId: {};
|
|
49
|
-
_numNodes: any;
|
|
50
|
-
solarMerger: SolarMerger;
|
|
51
|
-
subGraphs: any[];
|
|
52
|
-
nodeSortMap: {};
|
|
53
|
-
_firstUpdate: boolean;
|
|
54
|
-
_curPhysData: any;
|
|
55
74
|
/**
|
|
56
75
|
* Updates the node's positions for the next step in the physics layout iterations if the layout needs to update
|
|
57
|
-
* @param
|
|
58
|
-
* @returns
|
|
76
|
+
* @param refreshPositions whether the entire layout should be reheated
|
|
77
|
+
* @returns whether the layout should update in the following step
|
|
59
78
|
*/
|
|
60
|
-
update(refreshPositions
|
|
61
|
-
collisionDetectionMultiplier: number;
|
|
79
|
+
update(refreshPositions?: boolean): boolean;
|
|
62
80
|
/**
|
|
63
81
|
* Stops the layout
|
|
64
82
|
*/
|
|
65
83
|
terminateUpdate(): void;
|
|
66
|
-
addedNodes: {};
|
|
67
84
|
/**
|
|
68
85
|
* Returns whether the current layout needs to be updated in the next iteration step.
|
|
69
86
|
* @returns {boolean} Whether the layout should update in the following step.
|
|
@@ -77,20 +94,23 @@ export class PhysLayout {
|
|
|
77
94
|
getComputing(): boolean;
|
|
78
95
|
/**
|
|
79
96
|
* Adds the current x,y coordinates for each node to a given list of nodes.
|
|
80
|
-
* @param {
|
|
81
|
-
* @returns {
|
|
97
|
+
* @param {Node[]} nodeList The list of nodes to get positions for.
|
|
98
|
+
* @returns {(Node & Point)[]} The list of nodes containing the x,y coordinates on each node object.
|
|
82
99
|
*/
|
|
83
|
-
getNodePositions(nodeList:
|
|
100
|
+
getNodePositions(nodeList: Node[]): (Node & Point)[];
|
|
84
101
|
/**
|
|
85
102
|
* Reheats the layout
|
|
86
103
|
* @param {Object} fullData The entire graph object.
|
|
87
104
|
*/
|
|
88
|
-
reheat(fullData:
|
|
105
|
+
reheat(fullData: {
|
|
106
|
+
nodes: Node[];
|
|
107
|
+
rels?: Relationship[];
|
|
108
|
+
}): void;
|
|
89
109
|
/**
|
|
90
110
|
* Updates the existing nodes of a graph with a given list of updates
|
|
91
|
-
* @param {
|
|
111
|
+
* @param {Node[]} nodeList The list of updates.
|
|
92
112
|
*/
|
|
93
|
-
updateNodes(nodeList:
|
|
113
|
+
updateNodes(nodeList: Node[]): void;
|
|
94
114
|
/**
|
|
95
115
|
* Adds and removes nodes from the graph based on given updates
|
|
96
116
|
* @param {Object} fullData The entire graph object.
|
|
@@ -101,67 +121,37 @@ export class PhysLayout {
|
|
|
101
121
|
* @param {Array<Object>} nodeChanges.removes A list of nodes to be removed.
|
|
102
122
|
*/
|
|
103
123
|
addRemoveData(fullData: {
|
|
104
|
-
nodes:
|
|
105
|
-
rels:
|
|
124
|
+
nodes: Node[];
|
|
125
|
+
rels: Relationship[];
|
|
106
126
|
}, nodeChanges: {
|
|
107
|
-
adds:
|
|
108
|
-
removes:
|
|
127
|
+
adds: Record<string, Node>;
|
|
128
|
+
removes: Record<string, Node>;
|
|
109
129
|
}): any;
|
|
110
|
-
_pinData: Uint8Array;
|
|
111
130
|
/**
|
|
112
131
|
* Destroys the class and all buffers and textures.
|
|
113
132
|
*/
|
|
114
133
|
destroy(): void;
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
_sizeTexture: any;
|
|
139
|
-
_setupSprings(data: any): void;
|
|
140
|
-
connections: any;
|
|
141
|
-
_offsetTexture: any;
|
|
142
|
-
_springTexture: any;
|
|
143
|
-
_setupPhysics(): void;
|
|
144
|
-
_setupPhysicsForNodes(): void;
|
|
145
|
-
_physData: any[];
|
|
146
|
-
_physShader: Shader;
|
|
147
|
-
_setupPhysicsForCoarse(): void;
|
|
148
|
-
levelsData: any[];
|
|
149
|
-
levelsClusterTexture: any[];
|
|
150
|
-
levelsFinestIndexTexture: any[];
|
|
151
|
-
initalLevelTexture: any;
|
|
152
|
-
_apprxRepForceShader: Shader;
|
|
153
|
-
_setupPinData(): void;
|
|
154
|
-
_pinTexture: any;
|
|
155
|
-
_setupUpdates(): void;
|
|
156
|
-
_updateData: Float32Array;
|
|
157
|
-
_updateTexture: any;
|
|
158
|
-
_updateShader: Shader;
|
|
159
|
-
_setupReadpixelWorkaround(): void;
|
|
160
|
-
_workaroundShader: Shader;
|
|
161
|
-
_workaroundData: any[];
|
|
162
|
-
_doReadpixelWorkaround(): void;
|
|
163
|
-
_definePhysicsArrays(): void;
|
|
134
|
+
private dumpTexture;
|
|
135
|
+
private getScaleNumber;
|
|
136
|
+
private getBaseLength;
|
|
137
|
+
private checkForUpdates;
|
|
138
|
+
private getNodePosition;
|
|
139
|
+
private getMaxSpeedSquared;
|
|
140
|
+
private getMedianSpeedSquared;
|
|
141
|
+
private getPhysData;
|
|
142
|
+
private newTexture;
|
|
143
|
+
private newFramebuffer;
|
|
144
|
+
private checkCompatibility;
|
|
145
|
+
private printGlStats;
|
|
146
|
+
private adjustToGlSize;
|
|
147
|
+
private setupSize;
|
|
148
|
+
private setupSprings;
|
|
149
|
+
private setupPhysics;
|
|
150
|
+
private setupPhysicsForNodes;
|
|
151
|
+
private setupPhysicsForCoarse;
|
|
152
|
+
private setupPinData;
|
|
153
|
+
private setupUpdates;
|
|
154
|
+
private setupReadpixelWorkaround;
|
|
155
|
+
private doReadpixelWorkaround;
|
|
156
|
+
private definePhysicsArrays;
|
|
164
157
|
}
|
|
165
|
-
import { mat4 } from 'gl-matrix';
|
|
166
|
-
import SolarMerger from './solarmerger/SolarMerger';
|
|
167
|
-
import Shader from '../../../modules/Shader';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/dist/types/layouts/forcedirectedlayout/physlayout/shaders/multilevel-fragment-verlet.d.ts
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
declare const _default: "precision mediump float;\n\nuniform sampler2D u_physData;\nuniform sampler2D u_connections;\nuniform sampler2D u_connectionOffsets;\nuniform sampler2D u_pinnedNodes;\nuniform sampler2D u_sizeTexture;\nuniform float u_baseLength;\nuniform float u_curIteration;\nuniform float u_iterationMultiplier;\nuniform vec2 u_gravityCenter;\nuniform float u_numNodes;\nuniform float u_gravity;\n\nuniform sampler2D u_clusterData;\nuniform sampler2D u_prevForce;\nuniform float u_collisionMultiplier;\n\n\nfloat DAMP = 0.6;\nfloat COOL = 0.99998;\nfloat TEMP = max(0.02, pow(COOL, u_curIteration));\nfloat TIMESTEP = 1.0 / 30.0;\nfloat VELOCITYDECAY = 0.6;\nfloat accLimitLow = 500000.0;\nfloat accLimitHigh = 750000.0;\nfloat accLimitPosHigh = 10000000.0;\n\nconst float denseNodeThreshold = 1000.0;\nconst float MIN_DISTANCE = 0.00000001;\nconst float MAX_DISTANCE = 1000000000.0;\nconst float MAX_ACCELERATION = 50000.0;\n\nvec4 getTextureData(sampler2D texture, float index, float base) {\n float x = mod(index, base);\n float y = (index - x) / base;\n return texture2D(texture, vec2(x + 0.5, y + 0.5) / base);\n}\n\nbool isNan(float val) {\n return (val < 0.0 || 0.0 < val || val == 0.0) ? false : true;\n}\n\nconst float BIG_NUMBER = 999999999999999999.0;\nbool isInf(float val) {\n return val > BIG_NUMBER || val < -BIG_NUMBER;\n}\n\nvec2 getDelta(vec2 v1, vec2 v2) {\n vec2 delta = v1 - v2;\n float dist = length(delta);\n if (dist < MIN_DISTANCE || isNan(dist)) {\n return vec2(MIN_DISTANCE, MIN_DISTANCE);\n }\n if (dist > MAX_DISTANCE) {\n vec2 normDelta = delta / dist;\n return normDelta * MAX_DISTANCE;\n }\n return delta;\n}\n\nvec4 getOtherNodePosition(float i) {\n return getTextureData(u_physData, i, 256.0);\n}\n\nfloat getCombinedNodeSize(float i, float nodeSize) {\n float otherNodeSize = getTextureData(u_sizeTexture, i, 256.0).a;\n return nodeSize + otherNodeSize;\n}\n\nvec2 getSpringForce(float curConnection, float numConnections, float springFScale, vec4 myPosition, float i) {\n float curSpring = getTextureData(u_connections, curConnection + i, 4096.0).a;\n\n vec4 otherPosition = getTextureData(u_physData, curSpring, 256.0);\n float otherDataPosition = getTextureData(u_connectionOffsets, curSpring, 256.0).a;\n float avgDegree;\n#if INTEL_WORKAROUND\n avgDegree = max(numConnections, 4.0);\n#else\n float otherNumConnections = getTextureData(u_connections, otherDataPosition, 4096.0).a;\n avgDegree = max((otherNumConnections + numConnections * 3.0) / 4.0, 4.0);\n#endif\n\n vec2 delta = getDelta(myPosition.xy, otherPosition.xy);\n float dist = length(delta);\n\n float F = (dist * dist * springFScale) / (u_baseLength * avgDegree);\n if (u_collisionMultiplier > 0.0) {\n F *= u_collisionMultiplier;\n }\n return (-delta / dist) * F;\n}\n\nvec2 getCollisionForce(float combinedNodeSize, float dist, float fScale, vec2 delta) {\n float collisionForce = (combinedNodeSize - dist) / (dist);\n if (u_collisionMultiplier > 0.0) {\n collisionForce *= u_collisionMultiplier;\n }\n return (delta * collisionForce * fScale * combinedNodeSize) / (combinedNodeSize + 1.0);\n}\n\nvec2 getRepulsionForce(float dist, float fScale, vec2 delta) {\n float F = (u_baseLength * u_baseLength * fScale) / (dist);\n return (delta / dist) * F * 0.05;\n}\n\nvoid main(void) {\n float textureSide = 256.0; //#TEXTURE_SIDE#;\n float index = (gl_FragCoord.x - 0.5) + (gl_FragCoord.y - 0.5) * textureSide;\n\n if (index >= u_numNodes) {\n discard;\n }\n\n vec4 clusterData = getTextureData(u_clusterData, index, 256.0);\n\n float clusterIndex = clusterData.x;\n float clusterStartIndex = clusterData.y;\n float clusterSize = clusterData.z;\n float clusterWeight = clusterData.w;\n\n vec4 myPosition = getTextureData(u_physData, index, 256.0);\n vec4 previousForce = getTextureData(u_prevForce, clusterIndex, 256.0);\n\n vec2 acceleration = previousForce.xy;\n\n float isPinned = getTextureData(u_pinnedNodes, index, 256.0).a;\n float nodeSize = getTextureData(u_sizeTexture, index, 256.0).a;\n\n if (isPinned > 0.5) {\n gl_FragColor = vec4(myPosition.xy, 0.0, 0.0);\n return;\n }\n\n float curConnection = getTextureData(u_connectionOffsets, index, 256.0).a;\n float numConnections = getTextureData(u_connections, curConnection, 4096.0).a;\n\n float fScale = 1.0 + sqrt(u_iterationMultiplier);\n float springFScale = fScale;\n\n if (numConnections > denseNodeThreshold) {\n springFScale = sqrt(fScale);\n }\n\n float numOfRels = 0.0;\n\n // Springs\n for (float i = 1.0; i <= 256.0 * 256.0; i++) {\n if (numOfRels >= numConnections) {\n break;\n }\n acceleration += getSpringForce(curConnection, numConnections, springFScale, myPosition, i);\n numOfRels += 1.0;\n }\n\n // Repulsion && collision detection\n if (u_collisionMultiplier > 0.0) {\n float number_of_collisions = 0.0;\n for (float i = 0.0; i < 256.0 * 256.0; i++) {\n if (i >= u_numNodes) {\n break;\n }\n\n if (i == index) {\n continue;\n }\n\n vec4 otherPosition = getOtherNodePosition(i);\n vec2 delta = getDelta(myPosition.xy, otherPosition.xy);\n float dist = length(delta);\n float combinedNodeSize = getCombinedNodeSize(i, nodeSize) * 2.0;\n\n if (dist < combinedNodeSize && number_of_collisions < 40.0) {\n number_of_collisions++;\n acceleration += getCollisionForce(combinedNodeSize, dist, fScale, delta);\n }\n\n if (i >= clusterStartIndex && i < clusterStartIndex + clusterSize) {\n acceleration += getRepulsionForce(dist, fScale, delta);\n }\n }\n } else {\n for (float i = 0.0; i < 256.0 * 256.0; i++) {\n if (i >= clusterStartIndex + clusterSize || i >= u_numNodes) {\n break;\n }\n\n if (i < clusterStartIndex || i == index) {\n continue;\n }\n\n vec4 otherPosition = getOtherNodePosition(i);\n vec2 delta = getDelta(myPosition.xy, otherPosition.xy);\n float dist = length(delta);\n float combinedNodeSize = getCombinedNodeSize(i, nodeSize);\n\n if (dist < combinedNodeSize) {\n acceleration += getCollisionForce(combinedNodeSize, dist, fScale, delta);\n }\n\n acceleration += getRepulsionForce(dist, fScale, delta);\n }\n }\n\n // Gravity\n vec2 delta = getDelta(u_gravityCenter, myPosition.xy);\n float dist = length(delta);\n\n vec2 grav = (delta / dist) * u_gravity * fScale;\n acceleration += grav * smoothstep(0.0, 500.0, dist);\n\n float accMagnitude = length(acceleration);\n acceleration *= min(MAX_ACCELERATION, accMagnitude) / accMagnitude;\n\n float iterationFrictionThreshold = 1000.0;\n\n if (u_curIteration > iterationFrictionThreshold) {\n float friction = 1.0 + pow((u_curIteration - iterationFrictionThreshold), 2.0) / 100.0;\n acceleration *= 1.0 / friction;\n }\n\n if (u_curIteration == 0.0) {\n gl_FragColor = vec4(myPosition.xy, myPosition.zw);\n } else {\n vec2 prevVelocity = myPosition.zw;\n vec2 currentPos = myPosition.xy;\n vec2 prevPos = currentPos - prevVelocity;\n\n vec2 newPos = currentPos + TEMP * ( DAMP * (prevVelocity) + acceleration * TIMESTEP * TIMESTEP);\n vec2 newVelocity = newPos - currentPos;\n gl_FragColor = vec4(newPos, newVelocity);\n }\n}";
|
|
2
|
+
export default _default;
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
declare const _default: "precision mediump float;\nuniform sampler2D u_physData;\nuniform sampler2D u_clusterData;\nuniform sampler2D u_finestIndexes;\nuniform sampler2D u_prevForce;\n\nuniform float u_baseLength;\nuniform float u_numNodes;\nuniform float u_iterationMultiplier;\nuniform float u_isTopLevel;\n\nfloat PI = 3.1415926535897932384626433832795;\nfloat TIMESTEP = 1.0 / 30.0;\nfloat VELOCITYDECAY = 0.6;\n\nvec4 getTextureData(sampler2D texture, float index, float base) {\n float x = mod(index, base);\n float y = (index - x) / base;\n return texture2D(texture, vec2(x + 0.5, y + 0.5) / base);\n}\n\nfloat getLogClusterWeight(float value) {\n return value / max(log(value), 1.0);\n}\n\nvoid main(void) {\n float index = (gl_FragCoord.x - 0.5) + (gl_FragCoord.y - 0.5) * 256.0;\n\n if (index >= u_numNodes) {\n discard;\n }\n\n vec4 clusterData = getTextureData(u_clusterData, index, 256.0);\n\n float clusterIndex = clusterData.x;\n float clusterStartIndex = clusterData.y;\n float clusterSize = clusterData.z;\n float clusterRadius = (clusterSize * 0.5) + u_baseLength;\n float clusterArea = PI * clusterRadius * clusterRadius;\n\n float finestIndex = getTextureData(u_finestIndexes, index, 256.0).a;\n vec4 myPosition = getTextureData(u_physData, finestIndex, 256.0);\n vec4 previousForce = getTextureData(u_prevForce, clusterIndex, 256.0);\n float fScale = 1.0 + sqrt(u_iterationMultiplier);\n\n vec2 acceleration = previousForce.xy;\n\n // Repulsion & Collision Detection\n for (float i = 0.0; i < 256.0 * 256.0; i++) {\n if (i >= clusterStartIndex + clusterSize || i >= u_numNodes) {\n break;\n }\n if (i < clusterStartIndex || i == index) {\n continue;\n }\n\n vec4 otherClusterData = getTextureData(u_clusterData, i, 256.0);\n float otherClusterWeight = getLogClusterWeight(otherClusterData.w);\n\n float otherFinestIndex = getTextureData(u_finestIndexes, i, 256.0).a;\n vec4 otherPosition = getTextureData(u_physData, otherFinestIndex, 256.0);\n\n vec2 delta = myPosition.xy - otherPosition.xy;\n float dist = max(length(delta), 0.0000001);\n float maxDist = 25.0;\n float repulsionForceScale = 0.1;\n\n float F = (clusterArea * fScale) / (dist * dist);\n\n if (u_isTopLevel == 1.0) {\n repulsionForceScale = 0.3;\n }\n\n acceleration += ((delta / sqrt(dist)) * F) * repulsionForceScale * otherClusterWeight;\n\n if (dist < maxDist) {\n float collide = (maxDist - dist) / (dist * dist);\n acceleration += delta * collide * fScale * maxDist / (maxDist + 1.0);\n }\n }\n\n gl_FragColor = vec4(acceleration, vec2(finestIndex, 0));\n}";
|
|
2
|
+
export default _default;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import { type HierarchicalOptions, type LayoutOptions, type NvlState } from '../../modules/state';
|
|
2
2
|
import AnimatedLayout from '../animatedlayout/AnimatedLayout';
|
|
3
3
|
type HierarchicalLayoutConfig = {
|
|
4
4
|
state: NvlState;
|
|
@@ -15,7 +15,7 @@ export declare class HierarchicalLayout extends AnimatedLayout {
|
|
|
15
15
|
private directionChanged;
|
|
16
16
|
private packingChanged;
|
|
17
17
|
constructor(config: HierarchicalLayoutConfig);
|
|
18
|
-
setOptions(options:
|
|
18
|
+
setOptions(options: LayoutOptions): void;
|
|
19
19
|
update(refreshPositions?: boolean): void;
|
|
20
20
|
getShouldUpdate(): boolean;
|
|
21
21
|
getComputing(): boolean;
|
|
@@ -1,18 +1,18 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import { type ExternalCallbacks } from './ExternalCallbackHandler';
|
|
2
2
|
type CallbackFunction = ExternalCallbacks['onError'] | ExternalCallbacks['onLayoutComputing'] | ExternalCallbacks['onLayoutDone'] | ExternalCallbacks['onLayoutStep'];
|
|
3
3
|
/**
|
|
4
4
|
* A class for registering and calling callbacks
|
|
5
5
|
* @example
|
|
6
6
|
* ```
|
|
7
|
+
* import { CallbackHelper } from './CallbackHelper'
|
|
8
|
+
*
|
|
7
9
|
* const callbackHelper = new CallbackHelper()
|
|
8
|
-
* callbackHelper.register('
|
|
9
|
-
* console.
|
|
10
|
+
* callbackHelper.register('onError', (e) => {
|
|
11
|
+
* console.error(e)
|
|
10
12
|
* })
|
|
11
|
-
* callbackHelper.callIfRegistered('myEvent', 'Hello World')
|
|
12
|
-
* // Logs 'Hello World'
|
|
13
13
|
* ```
|
|
14
14
|
*/
|
|
15
|
-
export
|
|
15
|
+
export declare class CallbackHelper {
|
|
16
16
|
private readonly callbacks;
|
|
17
17
|
constructor();
|
|
18
18
|
/**
|
|
@@ -12,7 +12,9 @@ export interface ExternalCallbacks {
|
|
|
12
12
|
/** Triggered when a asynchronous layout calculation starts/stops. */
|
|
13
13
|
onLayoutComputing?: (isComputing: boolean) => void;
|
|
14
14
|
onWebGLContextLost?: (webGLContextEvent: WebGLContextEvent) => void;
|
|
15
|
+
restart?: () => void;
|
|
15
16
|
}
|
|
17
|
+
export declare const isExternalCallback: (callback: unknown) => callback is keyof ExternalCallbacks;
|
|
16
18
|
export default class ExternalCallbackHandler {
|
|
17
19
|
callbacks: ExternalCallbacks;
|
|
18
20
|
constructor(externalCallbacks?: ExternalCallbacks);
|