@neo4j-nvl/base 0.3.1-dd1304e0 → 0.3.1-ebba99bf
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/dist/base.mjs +1 -1
- package/dist/types/index.d.ts +19 -14
- 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/physlayout/PhysLayout.d.ts +0 -1
- package/dist/types/modules/CallbackHelper.d.ts +5 -5
- package/dist/types/modules/state.d.ts +7 -1
- package/dist/types/renderers/canvasrenderer/ImageCache.d.ts +5 -5
- package/dist/types/types/graph-element.d.ts +4 -1
- package/dist/types/utils/graphObjectUtils.d.ts +1 -0
- package/package.json +2 -2
package/dist/types/index.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { ExternalCallbacks } from './modules/ExternalCallbackHandler';
|
|
2
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 = {
|
|
@@ -68,7 +70,11 @@ declare class NVL {
|
|
|
68
70
|
* If an existing property is not provided, it will not be changed.
|
|
69
71
|
* @example
|
|
70
72
|
* Adding and updating nodes and relationships
|
|
71
|
-
* ```
|
|
73
|
+
* ```ts
|
|
74
|
+
* import { NVL } from '@neo4j-nvl/base'
|
|
75
|
+
*
|
|
76
|
+
* const nvl = new NVL(document.getElementById('frame'), [{ id: '0' }], [])
|
|
77
|
+
*
|
|
72
78
|
* const nodes = [
|
|
73
79
|
* { id: '1', label: 'Node 1', color: '#e04141' },
|
|
74
80
|
* { id: '2', label: 'Node 2', color: '#e09c41' }
|
|
@@ -104,15 +110,17 @@ declare class NVL {
|
|
|
104
110
|
* If an existing property is not provided, it will not be changed.
|
|
105
111
|
* @example
|
|
106
112
|
* Updating nodes and relationships
|
|
107
|
-
* ```
|
|
113
|
+
* ```ts
|
|
114
|
+
* import { NVL } from '@neo4j-nvl/base'
|
|
115
|
+
*
|
|
108
116
|
* const nodes = [
|
|
109
|
-
*
|
|
110
|
-
*
|
|
117
|
+
* { id: '1', label: 'Node 1', color: '#e04141' },
|
|
118
|
+
* { id: '2', label: 'Node 2', color: '#e09c41' }
|
|
111
119
|
* ]
|
|
112
120
|
* const relationships = [
|
|
113
|
-
*
|
|
121
|
+
* { id: '12', from: '1', to: '2' }
|
|
114
122
|
* ]
|
|
115
|
-
* const nvl = new NVL(
|
|
123
|
+
* const nvl = new NVL(document.getElementById('frame'), nodes, relationships)
|
|
116
124
|
* // Updates an existing node and relationship
|
|
117
125
|
* nvl.updateElementsInGraph([{ id: '1', selected: true }], [{ id: '12', color: '#e0df41' }])
|
|
118
126
|
* ```
|
|
@@ -277,9 +285,6 @@ declare class NVL {
|
|
|
277
285
|
* @param {string} options.backgroundColor - The background color of the png file.
|
|
278
286
|
* @note The size of the png file will be as large as the entire graph at the default zoom level.
|
|
279
287
|
* 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
288
|
*/
|
|
284
289
|
saveFullGraphToLargeFile(options: {
|
|
285
290
|
filename?: string;
|
|
@@ -341,10 +346,10 @@ declare class NVL {
|
|
|
341
346
|
* @example
|
|
342
347
|
* ```js
|
|
343
348
|
* const container = document.getElementById('frame')
|
|
344
|
-
* const nvl = new NVL(container,
|
|
349
|
+
* const nvl = new NVL(container, [{ id: '0' }], [])
|
|
345
350
|
*
|
|
346
351
|
* // Get the nodes and relationships that have been hit by a pointer event.
|
|
347
|
-
* container
|
|
352
|
+
* container?.addEventListener('click', (evt) => {
|
|
348
353
|
* const { nvlTargets } = nvl.getHits(evt)
|
|
349
354
|
* console.log('clicked elements:', nvlTargets)
|
|
350
355
|
* })
|
|
@@ -375,5 +380,5 @@ declare const colorMapperFunctions: {
|
|
|
375
380
|
textColorForBackground: (color: string) => string;
|
|
376
381
|
};
|
|
377
382
|
export default NVL;
|
|
378
|
-
export type { NvlOptions, Renderer, Node, Relationship, PartialNode, PartialRelationship, Layout, LayoutOptions, ForceDirectedOptions, HierarchicalOptions, ExternalCallbacks, HitTargets, HitTargetNode, HitTargetRelationship, Point, NvlMouseEvent, ZoomOptions };
|
|
383
|
+
export type { NvlOptions, Renderer, Node, Relationship, PartialNode, PartialRelationship, Layout, LayoutOptions, ForceDirectedOptions, HierarchicalOptions, ExternalCallbacks, HitTargets, HitTargetNode, HitTargetRelationship, Point, NvlMouseEvent, ZoomOptions, StyledCaption };
|
|
379
384
|
export { NVL, colorMapperFunctions, CompatibilityError, ForceDirectedLayoutType, HierarchicalLayoutType, GridLayoutType, FreeLayoutType, d3ForceLayoutType, drawCircleBand };
|
|
@@ -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
|
}
|
|
@@ -116,7 +116,6 @@ export class PhysLayout {
|
|
|
116
116
|
_dumpTexture(framebuffer: any, numItems: any, msg: any): void;
|
|
117
117
|
_getScaleNumber(iterationNo: any, delayedDecayFormula?: (iterationNo: any, p: any, lowerBar: any) => any): any;
|
|
118
118
|
_getBaseLength(subGraphNodeCount: any): number;
|
|
119
|
-
_hasSizeChanged(updates?: any[]): boolean;
|
|
120
119
|
_checkForUpdates(fullRefresh?: boolean): void;
|
|
121
120
|
_getNodePosition(nodeIndex: any): {
|
|
122
121
|
x: any;
|
|
@@ -4,15 +4,15 @@ type CallbackFunction = ExternalCallbacks['onError'] | ExternalCallbacks['onLayo
|
|
|
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
|
/**
|
|
@@ -142,7 +142,13 @@ export interface NvlOptions {
|
|
|
142
142
|
* @note will be ignored when {@link renderer} is set
|
|
143
143
|
*/
|
|
144
144
|
useWebGL?: boolean;
|
|
145
|
-
/**
|
|
145
|
+
/**
|
|
146
|
+
* What renderer to use
|
|
147
|
+
* Possible values are 'webgl' or 'canvas'
|
|
148
|
+
* @defaultValue 'webgl'
|
|
149
|
+
* @note WebGL renderer uses GPU and has better performance.
|
|
150
|
+
* Captions and arrowheads are only displayed when using the canvas renderer.
|
|
151
|
+
*/
|
|
146
152
|
renderer?: Renderer;
|
|
147
153
|
/**
|
|
148
154
|
* @internal
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import type { Cache
|
|
1
|
+
import type { Cache } from './types';
|
|
2
2
|
declare class ImageCache {
|
|
3
3
|
cache: Cache;
|
|
4
4
|
constructor();
|
|
5
|
-
getOrCreateEntry(src: string): CacheItem;
|
|
6
|
-
invertCanvas(ctx: CanvasRenderingContext2D): void;
|
|
7
|
-
loadImage(src: string): CacheInfo;
|
|
8
|
-
drawIfNeeded(info: CacheInfo, inverted: boolean): void;
|
|
9
5
|
getImage(src: string, inverted?: boolean): HTMLCanvasElement;
|
|
6
|
+
private getOrCreateEntry;
|
|
7
|
+
private invertCanvas;
|
|
8
|
+
private loadImage;
|
|
9
|
+
private drawIfNeeded;
|
|
10
10
|
}
|
|
11
11
|
export default ImageCache;
|
|
@@ -29,7 +29,10 @@ interface GraphElement {
|
|
|
29
29
|
* @note Has no affect on self-referring relationships.
|
|
30
30
|
*/
|
|
31
31
|
captionAlign?: 'top' | 'bottom' | 'center';
|
|
32
|
-
/**
|
|
32
|
+
/**
|
|
33
|
+
* The caption text and font style.
|
|
34
|
+
* @note Captions are only visible when using the 'canvas' renderer.
|
|
35
|
+
*/
|
|
33
36
|
captions?: StyledCaption[];
|
|
34
37
|
/**
|
|
35
38
|
* An icon to be displayed anywhere on top of the graph element.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@neo4j-nvl/base",
|
|
3
|
-
"version": "0.3.1-
|
|
3
|
+
"version": "0.3.1-ebba99bf",
|
|
4
4
|
"license": "SEE LICENSE IN 'LICENSE.txt'",
|
|
5
5
|
"homepage": "https://neo4j.com/docs/nvl/current/",
|
|
6
6
|
"description": "Base library for the Neo4j Visualization Library",
|
|
@@ -33,7 +33,7 @@
|
|
|
33
33
|
"tsconfig": "./tsconfig.json"
|
|
34
34
|
},
|
|
35
35
|
"dependencies": {
|
|
36
|
-
"@neo4j-nvl/layout-workers": "^0.3.1-
|
|
36
|
+
"@neo4j-nvl/layout-workers": "^0.3.1-ebba99bf",
|
|
37
37
|
"color-string": "^1.9.1",
|
|
38
38
|
"contrast": "1.0.1",
|
|
39
39
|
"d3-force": "^3.0.0",
|