@neo4j-nvl/base 0.3.9 → 1.0.0-08b14670
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/CHANGELOG.md +20 -0
- package/dist/base.mjs +1 -1
- package/dist/types/index.d.ts +101 -78
- package/dist/types/layouts/animatedlayout/animationUtils.d.ts +3 -3
- package/dist/types/layouts/circularLayout/CircularLayout.d.ts +18 -0
- package/dist/types/layouts/forcedirectedlayout/ForceCytoLayout.d.ts +1 -1
- package/dist/types/layouts/forcedirectedlayout/physlayout/PhysLayout.d.ts +27 -22
- package/dist/types/layouts/forcedirectedlayout/physlayout/shaders/multilevel-fragment-verlet.d.ts +1 -1
- package/dist/types/layouts/forcedirectedlayout/physlayout/solarmerger/SolarMerger.d.ts +17 -39
- package/dist/types/layouts/forcedirectedlayout/physlayout/solarmerger/types.d.ts +49 -0
- package/dist/types/modules/CallbackHelper.d.ts +5 -5
- package/dist/types/modules/ExternalCallbackHandler.d.ts +7 -0
- package/dist/types/modules/NvlController.d.ts +11 -7
- package/dist/types/modules/dataset.d.ts +1 -1
- package/dist/types/modules/state/state.d.ts +2 -2
- package/dist/types/modules/state/types.d.ts +73 -61
- package/dist/types/modules/state/utils.d.ts +8 -6
- package/dist/types/renderers/domrenderer/BaseRenderer.d.ts +66 -0
- package/dist/types/renderers/{canvasrenderer → domrenderer/canvasrenderer}/Animation.d.ts +8 -11
- package/dist/types/renderers/{canvasrenderer → domrenderer/canvasrenderer}/AnimationHandler.d.ts +15 -16
- package/dist/types/renderers/domrenderer/canvasrenderer/CanvasRenderer.d.ts +153 -0
- package/dist/types/renderers/domrenderer/canvasrenderer/canvasUtils.d.ts +56 -0
- package/dist/types/renderers/{canvasrenderer → domrenderer/shared}/ImageCache.d.ts +1 -1
- package/dist/types/renderers/{canvasrenderer → domrenderer/shared}/arrows/ArrowBundle.d.ts +17 -17
- package/dist/types/renderers/{canvasrenderer → domrenderer/shared}/arrows/ArrowBundler.d.ts +9 -9
- package/dist/types/renderers/domrenderer/shared/arrows/arrows.d.ts +148 -0
- package/dist/types/renderers/domrenderer/shared/nodes/nodeUtils.d.ts +28 -0
- package/dist/types/renderers/domrenderer/shared/nodes/nodes.d.ts +58 -0
- package/dist/types/renderers/{canvasrenderer → domrenderer/shared}/types.d.ts +8 -6
- package/dist/types/renderers/domrenderer/shared/util.d.ts +11 -0
- package/dist/types/renderers/{canvasrenderer → domrenderer/shared}/vectorUtils.d.ts +1 -1
- package/dist/types/renderers/{canvasrenderer → domrenderer/shared}/wordwrap.d.ts +13 -13
- package/dist/types/renderers/domrenderer/shared/wordwrap.test.d.ts +1 -0
- package/dist/types/renderers/domrenderer/svgrenderer/SvgRenderer.d.ts +27 -0
- package/dist/types/renderers/domrenderer/svgrenderer/SvgRenderer.test.d.ts +1 -0
- package/dist/types/renderers/domrenderer/svgrenderer/svgUtils.d.ts +191 -0
- package/dist/types/renderers/webglrenderer/Renderer.d.ts +5 -1
- package/dist/types/renderers/webglrenderer/Renderer.test.d.ts +1 -0
- package/dist/types/types/graph-element.d.ts +16 -7
- package/dist/types/utils/canvasManagement.d.ts +18 -2
- package/dist/types/utils/circularUtils.d.ts +3 -0
- package/dist/types/utils/circularUtils.test.d.ts +1 -0
- package/dist/types/utils/colorUtils.d.ts +3 -3
- package/dist/types/utils/constants.d.ts +6 -4
- package/dist/types/utils/errors.d.ts +2 -1
- package/dist/types/utils/geometry.d.ts +31 -30
- package/dist/types/utils/graphObjectUtils.d.ts +5 -5
- package/dist/types/utils/hittest.d.ts +2 -0
- package/dist/types/utils/jsDriverResultTransformer.d.ts +14 -7
- package/dist/types/utils/segmentAnalytics.d.ts +8 -8
- package/dist/types/utils/zoomFunctions.d.ts +30 -23
- package/package.json +25 -24
- package/dist/types/modules/performance.d.ts +0 -93
- package/dist/types/renderers/canvasrenderer/CanvasRenderer.d.ts +0 -93
- package/dist/types/renderers/canvasrenderer/arrows/arrows.d.ts +0 -55
- package/dist/types/renderers/canvasrenderer/nodes/nodes.d.ts +0 -59
- package/dist/types/renderers/canvasrenderer/util.d.ts +0 -69
- /package/dist/types/{renderers/canvasrenderer/Animation.test.d.ts → layouts/d3forcelayout/circularLayout.test.d.ts} +0 -0
- /package/dist/types/renderers/{canvasrenderer/CanvasRenderer.test.d.ts → domrenderer/canvasrenderer/Animation.test.d.ts} +0 -0
- /package/dist/types/renderers/{canvasrenderer/ImageCache.test.d.ts → domrenderer/canvasrenderer/CanvasRenderer.test.d.ts} +0 -0
- /package/dist/types/renderers/{canvasrenderer/arrows/ArrowBundle.test.d.ts → domrenderer/shared/ImageCache.test.d.ts} +0 -0
- /package/dist/types/renderers/{canvasrenderer/arrows/ArrowBundler.test.d.ts → domrenderer/shared/arrows/ArrowBundle.test.d.ts} +0 -0
- /package/dist/types/renderers/{canvasrenderer/arrows/arrows.test.d.ts → domrenderer/shared/arrows/ArrowBundler.test.d.ts} +0 -0
- /package/dist/types/renderers/{canvasrenderer/nodes/nodes.test.d.ts → domrenderer/shared/arrows/arrows.test.d.ts} +0 -0
- /package/dist/types/renderers/{canvasrenderer → domrenderer/shared}/arrows/constants.d.ts +0 -0
- /package/dist/types/renderers/{canvasrenderer/util.test.d.ts → domrenderer/shared/nodes/nodes.test.d.ts} +0 -0
- /package/dist/types/renderers/{canvasrenderer/wordwrap.test.d.ts → domrenderer/shared/util.test.d.ts} +0 -0
|
@@ -1,11 +1,15 @@
|
|
|
1
1
|
import type { Node as DriverNode, Relationship as DriverRelationship, Path, Record } from 'neo4j-driver';
|
|
2
|
+
import type { Node as NvlNode, Relationship as NvlRelationship } from '../types/graph-element';
|
|
2
3
|
export declare const recordMapper: (record: Record) => any[];
|
|
3
4
|
type GraphElement = DriverNode | DriverRelationship | Path;
|
|
4
5
|
type NestedGraphElements = GraphElement | NestedGraphElements[];
|
|
5
6
|
export declare const recordCollector: (graphElements: NestedGraphElements[]) => {
|
|
6
|
-
|
|
7
|
-
nodes:
|
|
8
|
-
relationships
|
|
7
|
+
/** The nodes of the graph. */
|
|
8
|
+
nodes: NvlNode[];
|
|
9
|
+
/** The relationships of the graph. */
|
|
10
|
+
relationships: NvlRelationship[];
|
|
11
|
+
/** A map from element id to the driver graph element. */
|
|
12
|
+
recordObjectMap: Map<string, DriverNode | DriverRelationship | Path>;
|
|
9
13
|
};
|
|
10
14
|
/**
|
|
11
15
|
* Result transformer for the Neo4j JavaScript driver results to NVL graph elements.
|
|
@@ -27,9 +31,12 @@ export declare const recordCollector: (graphElements: NestedGraphElements[]) =>
|
|
|
27
31
|
*
|
|
28
32
|
* @see {@link https://neo4j.com/docs/api/javascript-driver/current/class/lib6/result-transformers.js~ResultTransformers.html|ResultTransformers on Neo4j JS Driver API Docs}
|
|
29
33
|
*/
|
|
30
|
-
export declare const nvlResultTransformer: import("neo4j-driver-core
|
|
31
|
-
|
|
32
|
-
nodes:
|
|
33
|
-
relationships
|
|
34
|
+
export declare const nvlResultTransformer: import("neo4j-driver-core").ResultTransformer<{
|
|
35
|
+
/** The nodes of the graph. */
|
|
36
|
+
nodes: NvlNode[];
|
|
37
|
+
/** The relationships of the graph. */
|
|
38
|
+
relationships: NvlRelationship[];
|
|
39
|
+
/** A map from element id to the driver graph element. */
|
|
40
|
+
recordObjectMap: Map<string, DriverNode | DriverRelationship | Path>;
|
|
34
41
|
}>;
|
|
35
42
|
export {};
|
|
@@ -6,32 +6,32 @@ type AnalyticsTrackPayload = {
|
|
|
6
6
|
};
|
|
7
7
|
export declare abstract class AnalyticsFunction {
|
|
8
8
|
/**
|
|
9
|
-
* Perform asynchronous bootstrapping
|
|
9
|
+
* Perform asynchronous bootstrapping.
|
|
10
10
|
*/
|
|
11
11
|
abstract init(apiKey: string): void;
|
|
12
12
|
/**
|
|
13
|
-
* Associate session with known user identifier
|
|
13
|
+
* Associate session with known user identifier.
|
|
14
14
|
*/
|
|
15
15
|
abstract identify(): void;
|
|
16
16
|
/**
|
|
17
|
-
* Load unique segment Id in the localstorage
|
|
17
|
+
* Load unique segment Id in the localstorage.
|
|
18
18
|
*/
|
|
19
19
|
abstract loadSavedSegmentId(): string;
|
|
20
20
|
/**
|
|
21
|
-
*
|
|
21
|
+
* Save unique segment Id in the localstorage.
|
|
22
22
|
*/
|
|
23
23
|
abstract saveTrackingId(segmentId: string): void;
|
|
24
24
|
/**
|
|
25
|
-
*
|
|
25
|
+
* Get/fetch unique segment Id from the localstorage.
|
|
26
26
|
*/
|
|
27
27
|
abstract getSegmentTrackingId(): Record<string, unknown>;
|
|
28
28
|
/**
|
|
29
|
-
* Track arbitrary event
|
|
29
|
+
* Track arbitrary event.
|
|
30
30
|
*/
|
|
31
|
-
abstract trackEvent(payload: AnalyticsTrackPayload): void
|
|
31
|
+
abstract trackEvent(payload: AnalyticsTrackPayload): Promise<void>;
|
|
32
32
|
}
|
|
33
33
|
/**
|
|
34
|
-
* Analytics adapter for Segment Analytics.js
|
|
34
|
+
* Analytics adapter for Segment Analytics.js.
|
|
35
35
|
*/
|
|
36
36
|
export declare class SegmentAnalytics implements AnalyticsFunction {
|
|
37
37
|
private analytics;
|
|
@@ -3,10 +3,10 @@ import type { Point } from './geometry';
|
|
|
3
3
|
declare const getExtremeLimits: (nodePositions: Point[]) => Point[];
|
|
4
4
|
declare const getMaxDistance: (extremeLimits?: Point[]) => number;
|
|
5
5
|
/**
|
|
6
|
-
* Gets the center
|
|
7
|
-
* @param
|
|
8
|
-
* @param
|
|
9
|
-
* @returns An object with the center x and y coordinates and the width and height
|
|
6
|
+
* Gets the center coordinates and the width and height for the given node positions.
|
|
7
|
+
* @param nodePositions - The node positions.
|
|
8
|
+
* @param maxNodeRadius - The maximum node radius.
|
|
9
|
+
* @returns An object with the center x and y coordinates and the width and height.
|
|
10
10
|
*/
|
|
11
11
|
declare const getPositionBoundaries: (nodePositions?: Point[] | Node[], maxNodeRadius?: number) => {
|
|
12
12
|
centerX: number;
|
|
@@ -15,35 +15,42 @@ declare const getPositionBoundaries: (nodePositions?: Point[] | Node[], maxNodeR
|
|
|
15
15
|
nodesHeight: number;
|
|
16
16
|
};
|
|
17
17
|
/**
|
|
18
|
-
* Gets the required zoom level for the given view and scene dimensions to fit the scene into the view
|
|
19
|
-
* @param
|
|
20
|
-
* @param
|
|
21
|
-
* @param
|
|
22
|
-
* @param
|
|
23
|
-
* @returns An object with the zoom level for the x and y axis
|
|
18
|
+
* Gets the required zoom level for the given view and scene dimensions to fit the scene into the view.
|
|
19
|
+
* @param viewWidth - The width of the required view.
|
|
20
|
+
* @param viewHeight - The height of the required view.
|
|
21
|
+
* @param sceneWidth - The width of the canvas scene.
|
|
22
|
+
* @param sceneHeight - The height of the canvas scene.
|
|
23
|
+
* @returns An object with the zoom level for the x and y axis.
|
|
24
24
|
*/
|
|
25
25
|
declare const getZoomLevel: (viewWidth: number, viewHeight: number, sceneWidth: number, sceneHeight: number) => {
|
|
26
26
|
zoomX: number;
|
|
27
27
|
zoomY: number;
|
|
28
28
|
};
|
|
29
29
|
/**
|
|
30
|
-
* Creates a zoom target based on the given zoom levels and the min and max zoom level
|
|
31
|
-
* @param
|
|
32
|
-
* @param
|
|
33
|
-
* @param
|
|
34
|
-
* @param
|
|
35
|
-
* @returns The zoom target
|
|
30
|
+
* Creates a zoom target based on the given zoom levels and the min and max zoom level.
|
|
31
|
+
* @param zoomX - The zoom level for the x axis.
|
|
32
|
+
* @param zoomY - The zoom level for the y axis.
|
|
33
|
+
* @param minZoom - The minimum zoom level.
|
|
34
|
+
* @param maxZoom - The maximum zoom level.
|
|
35
|
+
* @returns The zoom target.
|
|
36
36
|
*/
|
|
37
37
|
declare const createZoomTarget: (zoomX: number, zoomY: number, minZoom?: number, maxZoom?: number) => number;
|
|
38
38
|
/**
|
|
39
|
-
* Gets the zoom target to fit the given node positions into the scene
|
|
40
|
-
* @param
|
|
41
|
-
* @param
|
|
42
|
-
* @param
|
|
43
|
-
* @param
|
|
44
|
-
* @returns
|
|
39
|
+
* Gets the zoom target to fit the given node positions into the scene.
|
|
40
|
+
* @param nodePositions - The node positions.
|
|
41
|
+
* @param containerWidth - The width of the container NVL is displayed in.
|
|
42
|
+
* @param containerHeight - The height of the container NVL is displayed in.
|
|
43
|
+
* @param maxNodeRadius - The maximum node radius, which is added as margin to the scene (defaults to `50`).
|
|
44
|
+
* @returns The zoom and pan targets.
|
|
45
45
|
*/
|
|
46
|
-
declare const getZoomTargetForNodePositions: (nodePositions: Point[], containerWidth: number, containerHeight: number, maxNodeRadius?: number) =>
|
|
46
|
+
declare const getZoomTargetForNodePositions: (nodePositions: Point[], containerWidth: number, containerHeight: number, maxNodeRadius?: number) => {
|
|
47
|
+
/** The zoom level. */
|
|
48
|
+
zoom: number;
|
|
49
|
+
/** The x-coordinate of the pan. */
|
|
50
|
+
panX: number;
|
|
51
|
+
/** The y-coordinate of the pan. */
|
|
52
|
+
panY: number;
|
|
53
|
+
};
|
|
47
54
|
declare const getFlexibleZoomLimit: (nodePositions: Point[], rect: HTMLCanvasElement, maxNodeRadius: number) => number;
|
|
48
55
|
declare const getNewZoomWithinLimits: (newZoom: number, oldZoom: number, minZoom: number, maxZoom: number) => number;
|
|
49
56
|
declare const isZoomOutAtLimit: (newZoom: number, oldZoom: number, zoomOutLimit: number) => boolean;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@neo4j-nvl/base",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "1.0.0-08b14670",
|
|
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",
|
|
@@ -29,34 +29,35 @@
|
|
|
29
29
|
"postpack": "rm LICENSE.txt && rm CHANGELOG.md"
|
|
30
30
|
},
|
|
31
31
|
"dependencies": {
|
|
32
|
-
"@neo4j-nvl/layout-workers": "0.
|
|
33
|
-
"@segment/analytics-next": "
|
|
34
|
-
"color-string": "
|
|
35
|
-
"d3-force": "
|
|
36
|
-
"gl-matrix": "
|
|
37
|
-
"glsl-inject-defines": "
|
|
38
|
-
"lodash": "4.17.
|
|
39
|
-
"loglevel": "
|
|
40
|
-
"mobx": "
|
|
41
|
-
"node-pid-controller": "
|
|
42
|
-
"resizelistener": "
|
|
32
|
+
"@neo4j-nvl/layout-workers": "1.0.0-08b14670",
|
|
33
|
+
"@segment/analytics-next": "1.81.1",
|
|
34
|
+
"color-string": "1.9.1",
|
|
35
|
+
"d3-force": "3.0.0",
|
|
36
|
+
"gl-matrix": "3.4.4",
|
|
37
|
+
"glsl-inject-defines": "1.0.3",
|
|
38
|
+
"lodash": "4.17.23",
|
|
39
|
+
"loglevel": "1.9.2",
|
|
40
|
+
"mobx": "3.6.2",
|
|
41
|
+
"node-pid-controller": "1.0.1",
|
|
42
|
+
"resizelistener": "1.1.0",
|
|
43
43
|
"tinycolor2": "1.6.0",
|
|
44
|
-
"uuid": "
|
|
44
|
+
"uuid": "8.3.2"
|
|
45
45
|
},
|
|
46
46
|
"devDependencies": {
|
|
47
|
-
"@
|
|
48
|
-
"@types/
|
|
49
|
-
"@types/
|
|
47
|
+
"@babel/core": "7.28.5",
|
|
48
|
+
"@types/color-string": "1.5.5",
|
|
49
|
+
"@types/d3-force": "3.0.10",
|
|
50
|
+
"@types/lodash": "4.17.21",
|
|
50
51
|
"@types/segment-analytics": "0.0.38",
|
|
51
|
-
"@types/tinycolor2": "
|
|
52
|
-
"babel-loader": "
|
|
53
|
-
"copy-webpack-plugin": "
|
|
54
|
-
"neo4j-driver": "
|
|
55
|
-
"
|
|
56
|
-
"webpack": "
|
|
57
|
-
"webpack-cli": "^5.0.0"
|
|
52
|
+
"@types/tinycolor2": "1.4.6",
|
|
53
|
+
"babel-loader": "8.4.1",
|
|
54
|
+
"copy-webpack-plugin": "11.0.0",
|
|
55
|
+
"neo4j-driver": "5.28.2",
|
|
56
|
+
"webpack": "5.103.0",
|
|
57
|
+
"webpack-cli": "5.1.4"
|
|
58
58
|
},
|
|
59
59
|
"peerDependencies": {
|
|
60
60
|
"neo4j-driver": "*"
|
|
61
|
-
}
|
|
61
|
+
},
|
|
62
|
+
"stableVersion": "1.0.0"
|
|
62
63
|
}
|
|
@@ -1,93 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* A class capable of measuring performance.
|
|
3
|
-
* Usage:
|
|
4
|
-
* When you want to measure a block of code, start by calling
|
|
5
|
-
* performanceTesterInstance.startTest() or
|
|
6
|
-
* performanceTesterInstance.startTest('Some readable name') if you
|
|
7
|
-
* want to control how it prints.
|
|
8
|
-
* After the block of code ends, call performanceTesterInstance.endTest()
|
|
9
|
-
*/
|
|
10
|
-
export default class PerformanceTester {
|
|
11
|
-
disabled: boolean;
|
|
12
|
-
tree: PerformanceTree;
|
|
13
|
-
/**
|
|
14
|
-
* Starts a performance measurement. Every call to this method must be followed
|
|
15
|
-
* by a call to endTest(). Tests can be nested.
|
|
16
|
-
* @param {String} measurement String identifying this measurement. Only used for printing, so
|
|
17
|
-
* keep it human readable.
|
|
18
|
-
*/
|
|
19
|
-
startTest(measurement: string): void;
|
|
20
|
-
/**
|
|
21
|
-
* Ends the last started test, giving it an end time.
|
|
22
|
-
*/
|
|
23
|
-
endTest(): void;
|
|
24
|
-
/**
|
|
25
|
-
* Clears all performance measurements
|
|
26
|
-
*/
|
|
27
|
-
reset(): void;
|
|
28
|
-
/**
|
|
29
|
-
* Prints all the performance measurements to console by calling
|
|
30
|
-
* print() on the performance tree.
|
|
31
|
-
*/
|
|
32
|
-
print(): void;
|
|
33
|
-
}
|
|
34
|
-
/**
|
|
35
|
-
* A tree of PerformanceTreeNodes.
|
|
36
|
-
* @type {PerformanceTree}
|
|
37
|
-
*/
|
|
38
|
-
declare class PerformanceTree {
|
|
39
|
-
root: any;
|
|
40
|
-
current: any;
|
|
41
|
-
/**
|
|
42
|
-
* Empties the tree.
|
|
43
|
-
*/
|
|
44
|
-
clear(): void;
|
|
45
|
-
/**
|
|
46
|
-
* Adds a new node to the tree at the current open position, containing the
|
|
47
|
-
* data provided. It also sets the newly added node as the currently open one.
|
|
48
|
-
* @param {PerformanceData} data A PerformanceData object.
|
|
49
|
-
*/
|
|
50
|
-
add(data: PerformanceData): void;
|
|
51
|
-
/**
|
|
52
|
-
* The tree always maintains a pointer to the currently open node. This
|
|
53
|
-
* method closes that node, closes the data object in contains, and opens
|
|
54
|
-
* the parent node.
|
|
55
|
-
*/
|
|
56
|
-
close(): void;
|
|
57
|
-
/**
|
|
58
|
-
* Gets the data object of the currently open node.
|
|
59
|
-
* @return {PerformanceData} The data object of the currently open node.
|
|
60
|
-
*/
|
|
61
|
-
getCurrentData(): PerformanceData;
|
|
62
|
-
/**
|
|
63
|
-
* Prints this entire tree to the console.
|
|
64
|
-
*/
|
|
65
|
-
print(): void;
|
|
66
|
-
}
|
|
67
|
-
/**
|
|
68
|
-
* Performance measurement data.
|
|
69
|
-
* @type {PerformanceData}
|
|
70
|
-
*/
|
|
71
|
-
declare class PerformanceData {
|
|
72
|
-
/**
|
|
73
|
-
* Instantiates a data measurement, giving it the start time when constructor is called.
|
|
74
|
-
* Remember that you also have to call close on this object to make it valid.
|
|
75
|
-
* @param {String} name String identifying this measurement. Only used for printing, so
|
|
76
|
-
* keep it human readable.
|
|
77
|
-
* @return {PerformanceData} The data object
|
|
78
|
-
*/
|
|
79
|
-
constructor(name: string);
|
|
80
|
-
name: any;
|
|
81
|
-
startTime: any;
|
|
82
|
-
endTime: any;
|
|
83
|
-
/**
|
|
84
|
-
* Sets the endTime measurement on this data object.
|
|
85
|
-
*/
|
|
86
|
-
close(): void;
|
|
87
|
-
/**
|
|
88
|
-
* Gets the time spent on this measurement
|
|
89
|
-
* @return {Number} Time spent in ms
|
|
90
|
-
*/
|
|
91
|
-
_timeSpent(): number;
|
|
92
|
-
}
|
|
93
|
-
export {};
|
|
@@ -1,93 +0,0 @@
|
|
|
1
|
-
import type { NvlState } from '../../modules/state/types';
|
|
2
|
-
import type { Node } from '../../types/graph-element';
|
|
3
|
-
import type { Point } from '../../utils/geometry';
|
|
4
|
-
import type { HitTargetNode, HitTargetRelationship } from '../../utils/hittest';
|
|
5
|
-
import ArrowBundler from './arrows/ArrowBundler';
|
|
6
|
-
export default class CanvasRenderer {
|
|
7
|
-
arrowBundler: ArrowBundler;
|
|
8
|
-
private activeNodes;
|
|
9
|
-
private canvas;
|
|
10
|
-
private context;
|
|
11
|
-
private state;
|
|
12
|
-
private stateDisposers;
|
|
13
|
-
private relationshipThreshold;
|
|
14
|
-
private animationHandler;
|
|
15
|
-
private imageCache;
|
|
16
|
-
private needsRun;
|
|
17
|
-
private nodeVersion;
|
|
18
|
-
private relVersion;
|
|
19
|
-
private waypointVersion;
|
|
20
|
-
private ellipsisWidth;
|
|
21
|
-
/**
|
|
22
|
-
* Creates a new CanvasRenderer.
|
|
23
|
-
* @param canvas {HTMLCanvasElement} - The canvas to render on.
|
|
24
|
-
* @param context {CanvasRenderingContext2D} - The canvas context.
|
|
25
|
-
* @param state {NvlState} - The state.
|
|
26
|
-
* @param options {{ relationshipThreshold: number }} - The visualization options.
|
|
27
|
-
*/
|
|
28
|
-
constructor(canvas: HTMLCanvasElement, context: CanvasRenderingContext2D | null, state: NvlState, { relationshipThreshold }?: {
|
|
29
|
-
relationshipThreshold?: number;
|
|
30
|
-
});
|
|
31
|
-
/**
|
|
32
|
-
* Checks if the renderer needs to run.
|
|
33
|
-
* @returns {boolean} - Whether the renderer needs to run
|
|
34
|
-
*/
|
|
35
|
-
needsToRun(): boolean;
|
|
36
|
-
/**
|
|
37
|
-
* Processes the updates in nodes and relationships.
|
|
38
|
-
*/
|
|
39
|
-
processUpdates(): void;
|
|
40
|
-
/**
|
|
41
|
-
* Draws the nodes and relationships to their positions on the canvas.
|
|
42
|
-
* @param positionArray {Node[]} - The array of nodes to draw
|
|
43
|
-
* @param options {any} - The options for the render
|
|
44
|
-
*/
|
|
45
|
-
render(positionArray: Node[], options?: {
|
|
46
|
-
canvas?: HTMLCanvasElement;
|
|
47
|
-
context?: CanvasRenderingContext2D;
|
|
48
|
-
backgroundColor?: string;
|
|
49
|
-
ignoreAnimations?: boolean;
|
|
50
|
-
showCaptions?: boolean;
|
|
51
|
-
}): void;
|
|
52
|
-
private getRelationshipsToRender;
|
|
53
|
-
private getNodesToRender;
|
|
54
|
-
private renderNodes;
|
|
55
|
-
private renderRelationships;
|
|
56
|
-
/**
|
|
57
|
-
* Returns the nodes at the pointer position
|
|
58
|
-
* @param {Point} pointer - the position of the pointer
|
|
59
|
-
* @returns {HitTargetNode[]} - the nodes at the pointer position
|
|
60
|
-
* @todo Sort nodes by distance descending
|
|
61
|
-
*/
|
|
62
|
-
getNodesAt(pointer: Point, hitNodeMarginWidth?: number): HitTargetNode[];
|
|
63
|
-
/**
|
|
64
|
-
* Returns the relationships at the pointer position
|
|
65
|
-
* @param {Point} pointer - the position of the pointer
|
|
66
|
-
* @returns {HitTargetRelationship[]} - the relationships at the pointer position
|
|
67
|
-
* @todo: sort relationships by distance descending
|
|
68
|
-
*/
|
|
69
|
-
getRelsAt(pointer: Point): HitTargetRelationship[];
|
|
70
|
-
destroy(): void;
|
|
71
|
-
/**
|
|
72
|
-
* Checks if the bounding box is outside of the screen.
|
|
73
|
-
* @param boundingBox - The bounding box to check
|
|
74
|
-
* @param clientWidth - The client width of the canvas
|
|
75
|
-
* @param clientHeight - The client height of the canvas
|
|
76
|
-
* @returns Whether the bounding box is off screen
|
|
77
|
-
* @note This check doesn't catch all items that are off screen but its simple and removes many of them
|
|
78
|
-
*/
|
|
79
|
-
private isBoundingBoxOffScreen;
|
|
80
|
-
/**
|
|
81
|
-
* Handles the channel's additions, removals and updates and adds or removes the id from the active nodes.
|
|
82
|
-
* @param channel {Channel<Node>} - The channel to process
|
|
83
|
-
* @param fullData {DataSet<Node>} - The full data
|
|
84
|
-
* @param processUpdates {boolean} - Whether to process channel updates as well
|
|
85
|
-
*/
|
|
86
|
-
private handleChannelUpdate;
|
|
87
|
-
/**
|
|
88
|
-
* Handles zoom and pan on the canvas.
|
|
89
|
-
* @param context {CanvasRenderingContext2D} - The canvas context
|
|
90
|
-
* @param canvas {HTMLCanvasElement} - The canvas
|
|
91
|
-
*/
|
|
92
|
-
private zoomAndPan;
|
|
93
|
-
}
|
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
import type { BorderStyle, DisabledItemStyles } from '../../../modules/state/types';
|
|
2
|
-
import type { Node, Relationship } from '../../../types/graph-element';
|
|
3
|
-
import type { Point } from '../../../utils/geometry';
|
|
4
|
-
import type ImageCache from '../ImageCache';
|
|
5
|
-
import type ArrowBundle from './ArrowBundle';
|
|
6
|
-
/**
|
|
7
|
-
* This function calculates the difference in radius between two nodes.
|
|
8
|
-
* @param {number} toArrowGap - The gap between the node and the arrow on the to side.
|
|
9
|
-
* @param {number} fromArrowGap - The gap between the node and the arrow on the from side.
|
|
10
|
-
* @returns {number} The difference in radius between the two nodes.
|
|
11
|
-
* @comment can be affected for example by the label crust and selected ring
|
|
12
|
-
* as well as a gap between the node and the arrow on it's side.
|
|
13
|
-
*/
|
|
14
|
-
export declare const getRadiusDifference: (toArrowGap: number, fromArrowGap: number) => number;
|
|
15
|
-
/**
|
|
16
|
-
* This function calculates the coordinates of the via point
|
|
17
|
-
* between two nodes. The via point is used to bend the edge
|
|
18
|
-
* between the two nodes.
|
|
19
|
-
* @param {Node} fromNode - The node the edge starts from.
|
|
20
|
-
* @param {Node} toNode - The node the edge ends at.
|
|
21
|
-
* @param {number} fromArrowGap - The gap between the node and the arrow on the from side.
|
|
22
|
-
* @param {number} toArrowGap - The gap between the node and the arrow on the to side.
|
|
23
|
-
* @returns {Point} The coordinates of the via point.
|
|
24
|
-
*/
|
|
25
|
-
export declare const getViaCoordinates: (fromNode: Node, toNode: Node, fromArrowGap: number, toArrowGap: number, rel: Relationship, bundle: ArrowBundle) => Point;
|
|
26
|
-
export declare const getPointsForStraight: (rel: Relationship, bundle: ArrowBundle, fromNode: Node, toNode: Node, showLabel: boolean, curved?: boolean) => Point[];
|
|
27
|
-
/**
|
|
28
|
-
* Draws a label for a relationship
|
|
29
|
-
* @param {CanvasRenderingContext2D} ctx - the canvas context
|
|
30
|
-
* @param {number} x - the x coordinate of the label
|
|
31
|
-
* @param {number} y - the y coordinate of the label
|
|
32
|
-
* @param {number} angle - the angle of the label
|
|
33
|
-
* @param {number} maxWidth - the maximum width of the label
|
|
34
|
-
* @param {Relationship} rel - the relationship
|
|
35
|
-
* @param {ArrowBundle} bundle - the arrow bundle
|
|
36
|
-
* @param {DisabledItemStyles} disabledItemStyles - the styles for disabled items
|
|
37
|
-
* @param {string} fontColor - the color of the font
|
|
38
|
-
* @param {boolean} flip - whether to flip the label
|
|
39
|
-
*/
|
|
40
|
-
export declare const drawLabel: (ctx: CanvasRenderingContext2D, point: Point, angle: number, maxWidth: number, rel: Relationship, bundle: ArrowBundle, disabledItemStyles: DisabledItemStyles, fontColor: string, flip?: boolean) => void;
|
|
41
|
-
export declare const renderWaypointArrow: (ctx: CanvasRenderingContext2D, rel: Relationship, from: Node, to: Node, bundle: ArrowBundle, imageCache: ImageCache, showLabel: boolean, drawCurves: boolean, selectedBorderStyle: BorderStyle, disabledItemStyles: DisabledItemStyles, defaultRelationshipColor?: string) => void;
|
|
42
|
-
export declare const renderSelfArrow: (ctx: CanvasRenderingContext2D, rel: Relationship, node: Node, bundle: ArrowBundle, imageCache: ImageCache, showLabel: boolean, selectedBorderStyle: BorderStyle, disabledItemStyles: DisabledItemStyles, defaultRelationshipColor?: string) => void;
|
|
43
|
-
export declare const renderArrow: (ctx: CanvasRenderingContext2D, rel: Relationship, fromNode: Node, toNode: Node, bundle: ArrowBundle, imageCache: ImageCache, showLabel: boolean, selectedBorderStyle: BorderStyle, disabledItemStyles: DisabledItemStyles, defaultRelationshipColor: string, drawCurves?: boolean) => void;
|
|
44
|
-
export declare const distanceToEdge: (pos: Point, rel: Relationship, fromNode: Node, toNode: Node, bundle: ArrowBundle, showLabel: boolean, drawCurves?: boolean) => number;
|
|
45
|
-
/**
|
|
46
|
-
* Returns the bounding box of the arrow.
|
|
47
|
-
* @param {Relationship} rel - The relationship to get the bounding box for.
|
|
48
|
-
* @param {ArrowBundle} bundle - The arrow bundle the relationship is part of.
|
|
49
|
-
* @param {Node} fromNode - The node the relationship is coming from.
|
|
50
|
-
* @param {Node} toNode - The node the relationship is going to.
|
|
51
|
-
* @param {boolean} showLabel - Whether or not a label is shown.
|
|
52
|
-
* @param {boolean} drawCurves - Whether or the relationship is drawn as a curve.
|
|
53
|
-
* @returns {DOMRect} The bounding box of the arrow.
|
|
54
|
-
*/
|
|
55
|
-
export declare const getBoundingBox: (rel: Relationship, bundle: ArrowBundle, fromNode: Node, toNode: Node, showLabel?: boolean, drawCurves?: boolean) => DOMRect | null;
|
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
import type { BorderStyles, DisabledItemStyles } from '../../../modules/state/types';
|
|
2
|
-
import type { Node } from '../../../types/graph-element';
|
|
3
|
-
import type AnimationHandler from '../AnimationHandler';
|
|
4
|
-
type RingStyle = {
|
|
5
|
-
width: number;
|
|
6
|
-
color: string;
|
|
7
|
-
};
|
|
8
|
-
/**
|
|
9
|
-
* Returns an array of styles for the rings of a node.
|
|
10
|
-
* It takes the node as an argument, and an optional array of size animations.
|
|
11
|
-
* If the node is selected, it returns the selectedStyle.rings array.
|
|
12
|
-
* If the node is not selected, it returns an array containing only one object with
|
|
13
|
-
* a width of 0 and an empty color.
|
|
14
|
-
* @param node {Node} - The node to get the ring styles for.
|
|
15
|
-
* @param animationHandler {AnimationHandler} - The animation handler.
|
|
16
|
-
* @param nodeBorderStyles {BorderStyles} - The node border styles.
|
|
17
|
-
* @returns {{ width: number, color: string }[]} - An array of ring styles.
|
|
18
|
-
*/
|
|
19
|
-
export declare const getRingStyles: (node: Node, animationHandler: AnimationHandler, nodeBorderStyles: any) => RingStyle[];
|
|
20
|
-
/**
|
|
21
|
-
* Returns the bounding box of a node with the given x, y, and size properties.
|
|
22
|
-
* If no size is given, the default size is used.
|
|
23
|
-
* @param {Node} Node - The node to get the bounding box for.
|
|
24
|
-
* @returns {object} The bounding box of the node.
|
|
25
|
-
*/
|
|
26
|
-
export declare const getBoundingBox: ({ x, y, size }: Node) => DOMRect;
|
|
27
|
-
/**
|
|
28
|
-
* Returns the caption font size that should be used
|
|
29
|
-
* for the given info level and node diameter.
|
|
30
|
-
* @param infoLevel {number} - The info level.
|
|
31
|
-
* @param nodeRadius {number} - The radius of the node.
|
|
32
|
-
* @param captionSize {number} - The size of the caption.
|
|
33
|
-
* @returns {number} - The font size.
|
|
34
|
-
*/
|
|
35
|
-
export declare const infoLevelToFontSize: (infoLevel: number, nodeRadius?: number, captionSize?: number, hasIcon?: boolean) => number;
|
|
36
|
-
/**
|
|
37
|
-
* Returns maximum length of lines
|
|
38
|
-
* @param lines {array} - The lines info
|
|
39
|
-
* @returns {number} - The font size.
|
|
40
|
-
*/
|
|
41
|
-
export declare const findMaxLength: (lines: any[], ctx: CanvasRenderingContext2D, pixelRatio: number) => number;
|
|
42
|
-
/**
|
|
43
|
-
* Returns minimum length of lines
|
|
44
|
-
* @param lines {array} - The lines info
|
|
45
|
-
* @returns {number} - The font size.
|
|
46
|
-
*/
|
|
47
|
-
export declare const findMinLength: (lines: any[], ctx: CanvasRenderingContext2D, pixelRatio: number) => any;
|
|
48
|
-
/**
|
|
49
|
-
* Draws a node with the given context, node, and image cache.
|
|
50
|
-
* @param ctx {any} - The context to draw the node on.
|
|
51
|
-
* @param node {Node} - The node to draw.
|
|
52
|
-
* @param imageCache {any} - The image cache to use.
|
|
53
|
-
* @param animationHandler {AnimationHandler} - The animation handler.
|
|
54
|
-
* @param nodeBorderStyles {BorderStyles} - The node border styles.
|
|
55
|
-
* @param disabledItemStyles {DisabledItemStyles} - The styles for the disabled items.
|
|
56
|
-
* @param zoomLevel {number} - The current zoom level.
|
|
57
|
-
*/
|
|
58
|
-
export declare const drawNode: (ctx: CanvasRenderingContext2D, node: Node, imageCache: any, animationHandler: AnimationHandler, nodeBorderStyles: BorderStyles, disabledItemStyles: DisabledItemStyles, defaultNodeColor?: string, ellipsisWidth?: number, zoomLevel?: number) => void;
|
|
59
|
-
export {};
|
|
@@ -1,69 +0,0 @@
|
|
|
1
|
-
import type { Point } from '../../utils/geometry';
|
|
2
|
-
import type { TextSegment } from './types';
|
|
3
|
-
export declare const fontThresholds: [number, number][];
|
|
4
|
-
/**
|
|
5
|
-
* This function takes color in hex format or rgb() or rgba() format and overrides the opacity. Returns rgba() string.
|
|
6
|
-
* @param {string} color
|
|
7
|
-
* @param {number} opacity
|
|
8
|
-
* @returns {string} rgba() string with the given opacity
|
|
9
|
-
*/
|
|
10
|
-
export declare const overrideOpacity: (color: string, opacity: number) => string;
|
|
11
|
-
/**
|
|
12
|
-
* The parameters for drawing an arrowhead.
|
|
13
|
-
*/
|
|
14
|
-
type ArrowHeadParameters = {
|
|
15
|
-
headPosition: Point;
|
|
16
|
-
headAngle: number;
|
|
17
|
-
headHeight: number;
|
|
18
|
-
headChinHeight: number;
|
|
19
|
-
headWidth: number;
|
|
20
|
-
};
|
|
21
|
-
/**
|
|
22
|
-
* Creates an arrowhead shape using a polygon.
|
|
23
|
-
* @param {CanvasRenderingContext2D} ctx - The canvas context to draw on.
|
|
24
|
-
* @param {number} headLineWidth - The width of the arrowhead's outline.
|
|
25
|
-
* @param {string} color - The color of the arrowhead.
|
|
26
|
-
* @param {ArrowHeadParameters} arrowHeadParameters - The parameters for the arrowhead.
|
|
27
|
-
* @param {boolean} fill - Whether or not to fill the triangle.
|
|
28
|
-
* @param {boolean} stroke - Whether or not to stroke the triangle.
|
|
29
|
-
*/
|
|
30
|
-
export declare const drawArrowHead: (ctx: CanvasRenderingContext2D, headLineWidth: number, color: string, arrowHeadParameters: ArrowHeadParameters, fill?: boolean, stroke?: boolean) => void;
|
|
31
|
-
/**
|
|
32
|
-
* Draws borders around a node with a given array of border styles
|
|
33
|
-
* @param {CanvasRenderingContext2D} ctx - The canvas context
|
|
34
|
-
* @param {number} x - The x coordinate of the node
|
|
35
|
-
* @param {number} y - The y coordinate of the node
|
|
36
|
-
* @param {number} innerRadius - The inner radius of the node without any border
|
|
37
|
-
* @param {Array} borderStyles - An array of border styles
|
|
38
|
-
* @internal
|
|
39
|
-
*/
|
|
40
|
-
export declare const drawCircleBand: (ctx: CanvasRenderingContext2D, x: number, y: number, innerRadius: number, borderStyles: {
|
|
41
|
-
width: number;
|
|
42
|
-
color: string;
|
|
43
|
-
}[]) => void;
|
|
44
|
-
export declare const drawCircle: (ctx: CanvasRenderingContext2D, x: number, y: number, r: number) => void;
|
|
45
|
-
/**
|
|
46
|
-
* Fill a circle band with a gradient from a certain color to transparent
|
|
47
|
-
* @param {CanvasRenderingContext2D} ctx - The canvas context
|
|
48
|
-
* @param {number} x - The x coordinate of the node
|
|
49
|
-
* @param {number} y - The y coordinate of the node
|
|
50
|
-
* @param {string} color - The color of the gradient
|
|
51
|
-
* @param {number} radius - The inner radius of the node without any border
|
|
52
|
-
* @param {number} blur - The blur radius of the gradient
|
|
53
|
-
* @param {number} maxOpacity - The maximum opacity of the gradient
|
|
54
|
-
*/
|
|
55
|
-
export declare const drawGradientCircleBand: (ctx: CanvasRenderingContext2D, x: number, y: number, color: string, radius: number, blur: number, maxOpacity?: number) => void;
|
|
56
|
-
/**
|
|
57
|
-
* Draw a circle shape with a solid color
|
|
58
|
-
*/
|
|
59
|
-
export declare const drawSolidCircle: (ctx: CanvasRenderingContext2D, x: number, y: number, color: string, size: number) => void;
|
|
60
|
-
export declare function getIndividualInfoLevels(r: number, zoomLevel: number): {
|
|
61
|
-
nodeInfoLevel: number;
|
|
62
|
-
fontInfoLevel: number;
|
|
63
|
-
iconInfoLevel: number;
|
|
64
|
-
};
|
|
65
|
-
/**
|
|
66
|
-
* Prints the caption for a node
|
|
67
|
-
*/
|
|
68
|
-
export declare const drawNodeCaption: (ctx: CanvasRenderingContext2D, lines: TextSegment[], stylesPerChar: string[][], initialYPos: number, fontSize: number, fontFace: string, lineDistance: number, x: number, y: number, ellipsisWidth: number) => void;
|
|
69
|
-
export {};
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|