@neo4j-nvl/base 0.3.3-9ea79f41 → 0.3.3-e5d595c3

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  # Neo4j Visualization Library
2
2
 
3
- Welcome to NVL (Neo4j Visualization Library). NVL is a collection of libraries that can be used to build custom graph visualizations like [Neo4j Bloom](https://neo4j.com/product/bloom/). The NVL library is also available as a React component that can be used in React applications.
3
+ Welcome to the Neo4j Visualization Library, NVL for short. NVL is a collection of libraries that can be used to build custom graph visualizations like those used in [Neo4j Bloom and Explore(powered by Bloom)](https://neo4j.com/product/bloom/). NVL is written in TypeScript and can be used in any JavaScript project. It is also available as a React component that can be used in React applications.
4
4
 
5
5
  ## Consuming the library
6
6
 
@@ -12,18 +12,14 @@ You can install the library with your preferred package manager, for example
12
12
  npm install @neo4j-nvl/base
13
13
  ```
14
14
 
15
- If you want to add common interactivity to the graph, install the NVL interaction handlers. If you are planning to use NVL in a React app, be sure to check out the NVL React wrappers.
15
+ If you want to add common interactivity to the graph, you can install the [NVL interaction handlers](https://www.npmjs.com/package/@neo4j-nvl/interaction-handlers). If you are planning to use NVL in a React app, be sure to check out the [NVL React wrappers](https://www.npmjs.com/package/@neo4j-nvl/react).
16
16
 
17
17
  ### Using the library
18
18
 
19
19
  This is a basic setup for a NVL instance.
20
20
 
21
21
  ```js
22
- const nodes = [
23
- { id: '1', label: 'Node 1', color: '#e04141' },
24
- { id: '2', label: 'Node 2', color: '#e09c41' }
25
- ]
26
-
22
+ const nodes = [{ id: '1' }, { id: '2' }]
27
23
  const relationships = [{ id: '12', from: '1', to: '2' }]
28
24
 
29
25
  const options = {
@@ -43,3 +39,8 @@ You can find more instructions and examples on how to use NVL in the [docs](http
43
39
  ### Product analytics
44
40
 
45
41
  In order to improve the library we are collecting some information about the usage of NVL. If you prefer to disable this behavior set the parameter `disableTelemetry=true` as a parameter in `nvlOptions`.
42
+
43
+ ## Further Resources
44
+
45
+ - NVL documentation: https://neo4j.com/docs/nvl/current/
46
+ - NVL API docs: https://neo4j.com/docs/api/nvl/current/
@@ -1,6 +1,6 @@
1
1
  import type { ExternalCallbacks } from './modules/ExternalCallbackHandler';
2
2
  import type { ForceDirectedOptions, HierarchicalOptions, Layout, LayoutOptions, NvlOptions, NvlState, Renderer, ZoomOptions } from './modules/state';
3
- import { ForceDirectedLayoutType, FreeLayoutType, GridLayoutType, HierarchicalLayoutType, d3ForceLayoutType } from './modules/state';
3
+ import { CanvasRendererType, ForceDirectedLayoutType, FreeLayoutType, GridLayoutType, HierarchicalLayoutType, WebGLRendererType, d3ForceLayoutType } from './modules/state';
4
4
  import type { StyledCaption } from './renderers/canvasrenderer/types';
5
5
  import { drawCircleBand } from './renderers/canvasrenderer/util';
6
6
  import type { Node, PartialNode, PartialRelationship, Relationship } from './types/graph-element';
@@ -21,27 +21,27 @@ interface NvlMouseEvent extends MouseEvent {
21
21
  * ```ts
22
22
  * import { NVL } from '@neo4j-nvl/base'
23
23
  *
24
- * const nodes = [
25
- * { id: '1', label: 'Node 1', color: '#e04141' },
26
- * { id: '2', label: 'Node 2', color: '#e09c41' }
27
- * ]
28
- * const relationships = [
29
- * { id: '12', from: '1', to: '2' }
30
- * ]
24
+ * const nodes = [{ id: '1' }, { id: '2' }]
25
+ * const relationships = [{ id: '12', from: '1', to: '2' }]
26
+ *
31
27
  * const options = {
28
+ * layout: 'forceDirected',
32
29
  * initialZoom: 0.5
33
30
  * }
31
+ *
34
32
  * const callbacks = {
35
33
  * onLayoutDone: () => console.log('Layout done')
36
34
  * }
35
+ *
37
36
  * const nvl = new NVL(document.getElementById('frame'), nodes, relationships, options, callbacks)
38
37
  * ```
38
+ *
39
+ * For more examples, head to the {@link https://neo4j.com/docs/nvl/current/core-library/ NVL Base documentation page}.
39
40
  */
40
41
  declare class NVL {
41
42
  #private;
42
43
  /**
43
44
  * Creates a new NVL instance.
44
- * @constructor
45
45
  * @param {HTMLElement} frame - The DOM element to display the graph in
46
46
  * @param {Node[]} nvlNodes - An Array of nodes
47
47
  * @param {Relationship[]} nvlRels - An Array of relationships
@@ -53,16 +53,16 @@ declare class NVL {
53
53
  * Restarts the NVL instance.
54
54
  * @param {NvlOptions} options - new options for the NVL instance
55
55
  * @param {boolean} retainPositions - whether or not to retain the current node positions
56
- * @note new options will be merged with current options
56
+ * New options will be merged with current options
57
57
  */
58
58
  restart(options?: NvlOptions, retainPositions?: boolean): void;
59
59
  /**
60
60
  * Adds nodes and relationships to NVL and updates existing nodes and relationships.
61
61
  * @param {Node[] | PartialNode[]} nodes - An Array of nodes to be added or updated
62
62
  * @param {Relationship[] | PartialRelationship[]} relationships - An Array of relationships to be added or updated
63
- * @note To update nodes or relationships, they must have an id that matches the id of the
63
+ * To update nodes or relationships, they must have an id that matches the id of the
64
64
  * node or relationship to be updated.
65
- * @note Only the properties that are provided will be updated.
65
+ * Only the properties that are provided will be updated.
66
66
  * If an existing property is not provided, it will not be changed.
67
67
  * @example
68
68
  * Adding and updating nodes and relationships
@@ -99,10 +99,10 @@ declare class NVL {
99
99
  * Updates relationships in the current scene with the provided array of nodes and relationships.
100
100
  * @param {Node[] | PartialNode[]} nodes The updated nodes.
101
101
  * @param {Relationship[] | PartialRelationship[]} relationships The updated relationships.
102
- * @note ignores any nodes or relationships that do not exist in the current scene.
103
- * @note To update nodes or relationships, they must have an id that matches the id of the
102
+ * Ignores any nodes or relationships that do not exist in the current scene.
103
+ * To update nodes or relationships, they must have an id that matches the id of the
104
104
  * node or relationship to be updated.
105
- * @note Only the properties that are provided will be updated.
105
+ * Only the properties that are provided will be updated.
106
106
  * If an existing property is not provided, it will not be changed.
107
107
  * @example
108
108
  * Updating nodes and relationships
@@ -131,7 +131,7 @@ declare class NVL {
131
131
  /**
132
132
  * Removes the specified nodes from the current scene.
133
133
  * @param {string[]} nodeIds The node ids to be removed.
134
- * @note adjacent relationships will also be removed.
134
+ * Adjacent relationships will also be removed.
135
135
  */
136
136
  removeNodesWithIds(nodeIds: string[]): void;
137
137
  /**
@@ -140,9 +140,8 @@ declare class NVL {
140
140
  */
141
141
  removeRelationshipsWithIds(relationshipIds: string[]): void;
142
142
  /**
143
- * Returns the node data that is currently stored in the visualisation for a given id.
144
- * @param {string} id The id of the node that should be returned.
145
- * @returns {Node} The node or undefined if there is no node with the given id.
143
+ * Returns all nodes that is currently stored in the visualisation.
144
+ * @returns {Node[]} The array of nodes.
146
145
  */
147
146
  getNodes(): Node[];
148
147
  /**
@@ -185,7 +184,7 @@ declare class NVL {
185
184
  * Updates pan and zoom fit the specified nodes in the viewport.
186
185
  * @param {string[]} nodeIds The ids of the nodes to fit on the screen,
187
186
  * @param {NvlState['zoomOptions']} zoomOptions specific options on how to transition the zoom
188
- * @note If the zoom level required to fit the provided nodes is outside of the range provided by the
187
+ * If the zoom level required to fit the provided nodes is outside of the range provided by the
189
188
  * {@link NvlOptions.minZoom} and {@link NvlOptions.maxZoom} options,
190
189
  * and {@link NvlOptions.allowDynamicMinZoom} is set to `false`,
191
190
  * the zoom level will be set to the closest valid zoom level,
@@ -211,9 +210,8 @@ declare class NVL {
211
210
  /**
212
211
  * Restarts NVL with or without WebGL support.
213
212
  * @param {boolean} disabled Whether or not WebGL should be disabled.
214
- * @note not to be confused with {@link setUseWebGLRenderer}, which only affects the rendering method
213
+ * Not to be confused with {@link setUseWebGLRenderer}, which only affects the rendering method
215
214
  * @experimental
216
- * @internal
217
215
  */
218
216
  setDisableWebGL(disabled?: boolean): void;
219
217
  /**
@@ -238,7 +236,7 @@ declare class NVL {
238
236
  setLayoutOptions(options: LayoutOptions): void;
239
237
  /**
240
238
  * Returns the nodes that are currently in the visualization.
241
- * @note The `rels` property of the returned object is always empty.
239
+ * The `rels` property of the returned object is always empty.
242
240
  * @returns {{ nodes: Node[], rels: Relationship [] }} An array of the nodes in the visualization.
243
241
  */
244
242
  getNodesOnScreen(): {
@@ -268,7 +266,7 @@ declare class NVL {
268
266
  * @param {{ filename: string, backgroundColor: string }} options The filename and background color of the png.
269
267
  * @param {string} options.filename The filename of the png file.
270
268
  * @param {string} options.backgroundColor - The background color of the png file.
271
- * @note The size of the png file will be the size of the canvas in the DOM.
269
+ * The size of the png file will be the size of the canvas in the DOM.
272
270
  */
273
271
  saveToFile(options: {
274
272
  filename?: string;
@@ -279,7 +277,7 @@ declare class NVL {
279
277
  * @param {{ filename: string, backgroundColor: string }} options The filename and background color of the png.
280
278
  * @param {string} options.filename The filename of the png file.
281
279
  * @param {string} options.backgroundColor - The background color of the png file.
282
- * @note The size of the png file will be as large as the entire graph at the default zoom level.
280
+ * The size of the png file will be as large as the entire graph at the default zoom level.
283
281
  * Can result in a very large file.
284
282
  */
285
283
  saveFullGraphToLargeFile(options: {
@@ -289,13 +287,13 @@ declare class NVL {
289
287
  /**
290
288
  * Sets the zoom of the viewport to a specific value.
291
289
  * @param {number} absolute The desired zoom level.
292
- * @note When updating both the zoom level and pan coordinates,
290
+ * When updating both the zoom level and pan coordinates,
293
291
  * use {@link setZoomAndPan} instead of calling {@link setZoom} and {@link setPan}
294
292
  * separately to avoid jittering.
295
- * @note If the zoom level is outside of the range provided by the
293
+ * If the zoom level is outside of the range provided by the
296
294
  * {@link NvlOptions.minZoom} and {@link NvlOptions.maxZoom} options,
297
295
  * the zoom level will be set to the closest valid zoom level.
298
- * @note If {@link NvlOptions.allowDynamicMinZoom} is set to true,
296
+ * If {@link NvlOptions.allowDynamicMinZoom} is set to true,
299
297
  * the {@link NvlOptions.minZoom} option will be ignored of the current graph does not fit the viewport.
300
298
  */
301
299
  setZoom(absolute: number): void;
@@ -303,7 +301,7 @@ declare class NVL {
303
301
  * Sets the zoom of the viewport to a specific value.
304
302
  * @param {number} panX The desired panX value.
305
303
  * @param {number} panY The desired panY value.
306
- * @note When updating both the zoom level and pan coordinates,
304
+ * When updating both the zoom level and pan coordinates,
307
305
  * use {@link setZoomAndPan} instead of calling {@link setZoom} and {@link setPan}
308
306
  * separately to avoid jittering.
309
307
  */
@@ -313,11 +311,11 @@ declare class NVL {
313
311
  * @param {number} zoom The desired zoom level.
314
312
  * @param {number} panX The desired panX value.
315
313
  * @param {number} panY The desired panY value.
316
- * @note When only updating the zoom level or pan coordinates, use {@link setZoom} or {@link setPan} instead.
317
- * @note If the zoom level is outside of the range provided by the
314
+ * When only updating the zoom level or pan coordinates, use {@link setZoom} or {@link setPan} instead.
315
+ * If the zoom level is outside of the range provided by the
318
316
  * {@link NvlOptions.minZoom} and {@link NvlOptions.maxZoom} options,
319
317
  * the zoom level will be set to the closest valid zoom level.
320
- * @note If {@link NvlOptions.allowDynamicMinZoom} is set to true,
318
+ * If {@link NvlOptions.allowDynamicMinZoom} is set to true,
321
319
  * the {@link NvlOptions.minZoom} option will be ignored of the current graph does not fit the viewport.
322
320
  */
323
321
  setZoomAndPan(zoom: number, panX: number, panY: number): void;
@@ -369,5 +367,5 @@ declare const colorMapperFunctions: {
369
367
  textColorForBackground: (color: string) => string;
370
368
  };
371
369
  export default NVL;
372
- export type { NvlOptions, Renderer, Node, Relationship, PartialNode, PartialRelationship, Layout, LayoutOptions, ForceDirectedOptions, HierarchicalOptions, ExternalCallbacks, HitTargets, HitTargetNode, HitTargetRelationship, Point, NvlMouseEvent, ZoomOptions, StyledCaption };
370
+ export type { NvlOptions, Renderer, Node, Relationship, PartialNode, PartialRelationship, Layout, LayoutOptions, ForceDirectedOptions, HierarchicalOptions, ExternalCallbacks, HitTargets, HitTargetNode, HitTargetRelationship, Point, NvlMouseEvent, ZoomOptions, StyledCaption, WebGLRendererType, CanvasRendererType };
373
371
  export { NVL, colorMapperFunctions, CompatibilityError, ForceDirectedLayoutType, HierarchicalLayoutType, GridLayoutType, FreeLayoutType, d3ForceLayoutType, drawCircleBand };
@@ -19,7 +19,7 @@ export declare class CallbackHelper {
19
19
  * Register a callback function to be called when an event of that name happens
20
20
  * @param {string} name The name of the callback to register
21
21
  * @param {function} callback A function that will be called when an event of that name happens
22
- * @note If other callbacks are already registered for that name it is added to the list
22
+ * If other callbacks are already registered for that name it is added to the list
23
23
  */
24
24
  register(name: keyof ExternalCallbacks, callback: CallbackFunction): void;
25
25
  /**
@@ -117,11 +117,11 @@ export interface NvlOptions {
117
117
  /**
118
118
  * Whether or not to dynamically allow decreasing minimum zoom value
119
119
  * if current graph does not fit on screen at minimum zoom.
120
- * @note When set to true, zoom and fit operations will allow zooming out
120
+ * When set to true, zoom and fit operations will allow zooming out
121
121
  * further than the minimum zoom value if the graph does not fit on screen.
122
122
  * When set to false, zoom and fit operations will stop at the minimum zoom value,
123
123
  * even if the full graph does not fit on screen at that zoom level.
124
- * @default true
124
+ * @defaultValue true
125
125
  */
126
126
  allowDynamicMinZoom?: boolean;
127
127
  /**
@@ -143,14 +143,14 @@ export interface NvlOptions {
143
143
  /**
144
144
  * @deprecated use {@link renderer} instead
145
145
  * Whether to user the Canvas or WebGL renderer
146
- * @note will be ignored when {@link renderer} is set
146
+ * Will be ignored when {@link renderer} is set
147
147
  */
148
148
  useWebGL?: boolean;
149
149
  /**
150
150
  * What renderer to use
151
151
  * Possible values are 'webgl' or 'canvas'
152
152
  * @defaultValue 'webgl'
153
- * @note WebGL renderer uses GPU and has better performance.
153
+ * WebGL renderer uses GPU and has better performance.
154
154
  * Captions and arrowheads are only displayed when using the canvas renderer.
155
155
  */
156
156
  renderer?: Renderer;
@@ -177,7 +177,6 @@ export interface NvlOptions {
177
177
  selectedBorderColor?: string;
178
178
  /**
179
179
  * @internal
180
- * @experimental
181
180
  * Defines a time limit for how long layout iterations may run
182
181
  */
183
182
  layoutTimeLimit?: number;
@@ -7,8 +7,8 @@ import type { StyledCaption } from '../renderers/canvasrenderer/types';
7
7
  interface GraphElement {
8
8
  /**
9
9
  * The id of the current node or relationship.
10
- * @note ids need to be unique across all nodes and relationships.
11
- * @note ids need to be strings and cannot be empty.
10
+ * Ids need to be unique across all nodes and relationships.
11
+ * Ids need to be strings and cannot be empty.
12
12
  */
13
13
  readonly id: string;
14
14
  color?: string;
@@ -26,23 +26,23 @@ interface GraphElement {
26
26
  captionSize?: number;
27
27
  /**
28
28
  * The caption align.
29
- * @note Has no affect on self-referring relationships.
29
+ * Has no affect on self-referring relationships.
30
30
  */
31
31
  captionAlign?: 'top' | 'bottom' | 'center';
32
32
  /**
33
33
  * The caption text and font style.
34
- * @note Captions are only visible when using the 'canvas' renderer.
34
+ * Captions are only visible when using the 'canvas' renderer.
35
35
  */
36
36
  captions?: StyledCaption[];
37
37
  /**
38
38
  * An icon to be displayed anywhere on top of the graph element.
39
- * @note Icons are expected to be square.
39
+ * Icons are expected to be square.
40
40
  */
41
41
  overlayIcon?: {
42
42
  url: string;
43
43
  /**
44
44
  * The position of the icon relative to the node or relationship.
45
- * @note The position is a percentage of the node or relationship size.
45
+ * The position is a percentage of the node or relationship size.
46
46
  * `[1, 1]` is the bottom right corner of the node or relationship.
47
47
  * `[-1, -1]` is the top left corner of the node or relationship.
48
48
  * @defaultValue `[0, 0]`, the center of the node or relationship.
@@ -50,7 +50,7 @@ interface GraphElement {
50
50
  position?: number[];
51
51
  /**
52
52
  * The size of the icon relative to the node size or relationship caption size.
53
- * @note The size is a percentage of the node size or relationship caption size.
53
+ * The size is a percentage of the node size or relationship caption size.
54
54
  * @defaultValue `1`, the same size as the node size or relationship caption size.
55
55
  */
56
56
  size?: number;
@@ -73,9 +73,9 @@ interface Node extends GraphElement {
73
73
  activated?: boolean;
74
74
  /**
75
75
  * The url to an icon to display inside the node.
76
- * @note Icons are expected to be black. If the node's background color is dark,
76
+ * Icons are expected to be black. If the node's background color is dark,
77
77
  * the icon will be inverted to white.
78
- * @note Icons are expected to be square.
78
+ * Icons are expected to be square.
79
79
  */
80
80
  icon?: string;
81
81
  /**
@@ -106,7 +106,7 @@ interface Relationship extends GraphElement {
106
106
  /**
107
107
  * The DOM element to display on top of a relationship caption.
108
108
  * @experimental
109
- * @note The {@link captionSize} and {@link captionAlign} properties
109
+ * The {@link captionSize} and {@link captionAlign} properties
110
110
  * will affect the position and height of the html container element.
111
111
  */
112
112
  captionHtml?: HTMLElement;
@@ -2,7 +2,7 @@
2
2
  * Fixes the canvas size to match the parent element's size.
3
3
  * @param canvas The canvas to fix the size of.
4
4
  *
5
- * @note Make sure canvas pixel buffer is 1 to 1 vs screen pixels
5
+ * Make sure canvas pixel buffer is 1 to 1 vs screen pixels
6
6
  */
7
7
  export declare const fitCanvasSizeToParent: (canvas: HTMLCanvasElement) => void;
8
8
  export declare const addWebGLContextLostListener: (canvas: HTMLCanvasElement, contextLostCallback?: (e: WebGLContextEvent) => void) => void;
@@ -78,9 +78,9 @@ export declare class Segment {
78
78
  * @param {Point} lineStartToPointVector - The vector from the start of the line to the point.
79
79
  * @param {Point} lineVector - The vector of the line.
80
80
  * @returns {number} The projection of the point onto the line.
81
- * @note The projection ratio is a value between 0 and 1.
82
- * @note The projection ratio is 0 if the point is closest to the start of the line.
83
- * @note The projection ratio is 1 if the point is closest to the end of the line.
81
+ * The projection ratio is a value between 0 and 1.
82
+ * The projection ratio is 0 if the point is closest to the start of the line.
83
+ * The projection ratio is 1 if the point is closest to the end of the line.
84
84
  * @see {@link https://en.wikipedia.org/wiki/Vector_projection}
85
85
  */
86
86
  export declare const getProjectionRatio: (lineStartToPointVector: Point, lineVector: Point) => number;
@@ -90,7 +90,7 @@ export declare const getProjectionRatio: (lineStartToPointVector: Point, lineVec
90
90
  * @param {Point} lineEnd - The second point of the line.
91
91
  * @param {Point} point - The point to calculate the distance to.
92
92
  * @returns {number} The distance between the point and the line.
93
- * @note If the actual distance does not matter,
93
+ * If the actual distance does not matter,
94
94
  * if you only want to compare what this function
95
95
  * returns to other results of this function, you
96
96
  * can just return the squared distance instead
@@ -105,7 +105,7 @@ export declare const getDistanceToLine: (lineStart: Point, lineEnd: Point, point
105
105
  * @param {Point} p3 - Second point of second line
106
106
  * @returns {Point | null} Intersection point
107
107
  * @see https://github.com/bit101/CodingMath/blob/master/episode33/parallel.js
108
- * @note Returns null if lines are parallel
108
+ * Returns null if lines are parallel
109
109
  */
110
110
  export declare const getIntersection: (p0: Point, p1: Point, p2: Point, p3: Point) => Point | null;
111
111
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@neo4j-nvl/base",
3
- "version": "0.3.3-9ea79f41",
3
+ "version": "0.3.3-e5d595c3",
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",
@@ -27,14 +27,8 @@
27
27
  "prepack": "cp ../../LICENSE.txt ./",
28
28
  "postpack": "rm LICENSE.txt"
29
29
  },
30
- "typedoc": {
31
- "entryPoint": "./src/index.ts",
32
- "readmeFile": "./README.md",
33
- "displayName": "Base",
34
- "tsconfig": "./tsconfig.json"
35
- },
36
30
  "dependencies": {
37
- "@neo4j-nvl/layout-workers": "0.3.3-9ea79f41",
31
+ "@neo4j-nvl/layout-workers": "0.3.3-e5d595c3",
38
32
  "@segment/analytics-next": "^1.70.0",
39
33
  "color-string": "^1.9.1",
40
34
  "d3-force": "^3.0.0",