ngx-relationship-visualiser 1.0.1 → 1.0.2

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.
Files changed (58) hide show
  1. package/.env +2 -0
  2. package/.vscode/settings.json +3 -0
  3. package/angular.json +111 -0
  4. package/dist/README.md +356 -0
  5. package/dist/ngx-relationship-visualiser-1.0.2.tgz +0 -0
  6. package/dist/src/styles.scss +7 -0
  7. package/docs/3rdpartylicenses.txt +1600 -0
  8. package/docs/favicon.ico +1 -0
  9. package/docs/index.html +15 -0
  10. package/docs/main.js +1 -0
  11. package/docs/polyfills.js +1 -0
  12. package/docs/runtime.js +1 -0
  13. package/docs/scripts.js +11 -0
  14. package/docs/styles.css +6 -0
  15. package/ng-package.json +19 -0
  16. package/package.json +30 -16
  17. package/projects/ngx-relationship-visualiser-lib/lib/db/graphDatabase.ts +30 -0
  18. package/projects/ngx-relationship-visualiser-lib/lib/models/data.interface.ts +35 -0
  19. package/projects/ngx-relationship-visualiser-lib/lib/models/mocked-data.ts +150 -0
  20. package/projects/ngx-relationship-visualiser-lib/lib/ngx-relationship-visualiser.module.ts +15 -0
  21. package/projects/ngx-relationship-visualiser-lib/lib/visualiser/services/dagre-layout.service.ts +182 -0
  22. package/projects/ngx-relationship-visualiser-lib/lib/visualiser/services/visualiser-graph.service.ts +1025 -0
  23. package/projects/ngx-relationship-visualiser-lib/lib/visualiser/visualiser-graph/visualiser-graph.component.html +23 -0
  24. package/projects/ngx-relationship-visualiser-lib/lib/visualiser/visualiser-graph/visualiser-graph.component.scss +58 -0
  25. package/projects/ngx-relationship-visualiser-lib/lib/visualiser/visualiser-graph/visualiser-graph.component.ts +132 -0
  26. package/public_api.ts +2 -0
  27. package/src/app/app.component.html +6 -0
  28. package/src/app/app.component.ts +17 -0
  29. package/src/app/app.module.ts +16 -0
  30. package/src/environments/environment.prod.ts +3 -0
  31. package/src/environments/environment.ts +16 -0
  32. package/src/favicon.ico +1 -0
  33. package/src/index.html +15 -0
  34. package/src/main.ts +12 -0
  35. package/src/polyfills.ts +97 -0
  36. package/src/tsconfig.app.json +7 -0
  37. package/src/tslint.json +17 -0
  38. package/tsconfig.json +24 -0
  39. package/tslint.json +131 -0
  40. package/ngx-relationship-visualiser-1.0.1.tgz +0 -0
  41. /package/{esm2022 → dist/esm2022}/ngx-relationship-visualiser.mjs +0 -0
  42. /package/{esm2022 → dist/esm2022}/projects/ngx-relationship-visualiser-lib/lib/db/graphDatabase.mjs +0 -0
  43. /package/{esm2022 → dist/esm2022}/projects/ngx-relationship-visualiser-lib/lib/models/data.interface.mjs +0 -0
  44. /package/{esm2022 → dist/esm2022}/projects/ngx-relationship-visualiser-lib/lib/ngx-relationship-visualiser.module.mjs +0 -0
  45. /package/{esm2022 → dist/esm2022}/projects/ngx-relationship-visualiser-lib/lib/visualiser/services/dagre-layout.service.mjs +0 -0
  46. /package/{esm2022 → dist/esm2022}/projects/ngx-relationship-visualiser-lib/lib/visualiser/services/visualiser-graph.service.mjs +0 -0
  47. /package/{esm2022 → dist/esm2022}/projects/ngx-relationship-visualiser-lib/lib/visualiser/visualiser-graph/visualiser-graph.component.mjs +0 -0
  48. /package/{esm2022 → dist/esm2022}/public_api.mjs +0 -0
  49. /package/{fesm2022 → dist/fesm2022}/ngx-relationship-visualiser.mjs +0 -0
  50. /package/{fesm2022 → dist/fesm2022}/ngx-relationship-visualiser.mjs.map +0 -0
  51. /package/{index.d.ts → dist/index.d.ts} +0 -0
  52. /package/{projects → dist/projects}/ngx-relationship-visualiser-lib/lib/db/graphDatabase.d.ts +0 -0
  53. /package/{projects → dist/projects}/ngx-relationship-visualiser-lib/lib/models/data.interface.d.ts +0 -0
  54. /package/{projects → dist/projects}/ngx-relationship-visualiser-lib/lib/ngx-relationship-visualiser.module.d.ts +0 -0
  55. /package/{projects → dist/projects}/ngx-relationship-visualiser-lib/lib/visualiser/services/dagre-layout.service.d.ts +0 -0
  56. /package/{projects → dist/projects}/ngx-relationship-visualiser-lib/lib/visualiser/services/visualiser-graph.service.d.ts +0 -0
  57. /package/{projects → dist/projects}/ngx-relationship-visualiser-lib/lib/visualiser/visualiser-graph/visualiser-graph.component.d.ts +0 -0
  58. /package/{public_api.d.ts → dist/public_api.d.ts} +0 -0
@@ -0,0 +1,150 @@
1
+ import { Data } from './data.interface';
2
+
3
+ export const MOCKEDDATA: Data = {
4
+ dataId: '1234',
5
+ nodes: [
6
+ {
7
+ id: '123',
8
+ label: ['John Doe', '01/01/1970'],
9
+ imageUrl: '',
10
+ icon: '\uf007',
11
+ fx: 1000,
12
+ fy: 400,
13
+ additionalIcon: '\uf3a5',
14
+ },
15
+ {
16
+ id: '456',
17
+ label: ['Richard Hill', '14/05/1982'],
18
+ imageUrl: 'https://randomuser.me/api/portraits/thumb/men/99.jpg',
19
+ icon: '',
20
+ fx: 332,
21
+ fy: 684,
22
+ additionalIcon: '',
23
+ },
24
+ {
25
+ id: '789',
26
+ label: ['Rick Smith', 'Software Developer'],
27
+ imageUrl: 'https://randomuser.me/api/portraits/thumb/men/21.jpg',
28
+ icon: '',
29
+ fx: 55,
30
+ fy: 60,
31
+ additionalIcon: '\uf2dc',
32
+ },
33
+ {
34
+ id: '4',
35
+ label: ['James Jones', 'BA'],
36
+ imageUrl: 'https://randomuser.me/api/portraits/thumb/men/9.jpg',
37
+ icon: '',
38
+ fx: 414,
39
+ fy: 369,
40
+ additionalIcon: '',
41
+ },
42
+ {
43
+ id: '423',
44
+ label: ['Aston Villa', 'Football Club', 'Founded 1874'],
45
+ imageUrl: 'https://houseofv.ghost.io/content/images/2024/01/GC72JKwWwAAuyGk.png',
46
+ icon: '',
47
+ fx: 313,
48
+ fy: 255,
49
+ additionalIcon: '\uf1e3',
50
+ },
51
+ ],
52
+ links: [
53
+ {
54
+ source: '123',
55
+ target: '456',
56
+ lineStyle: 'Dotted',
57
+ sourceArrow: false,
58
+ targetArrow: true,
59
+ linkId: '123_456',
60
+ relationships: [
61
+ {
62
+ labelIndex: 0,
63
+ label: 'Worked at IBM',
64
+ source: '123',
65
+ target: '456',
66
+ linkIcon: true,
67
+ },
68
+ {
69
+ labelIndex: 1,
70
+ label: 'Both in same scrum team',
71
+ source: '123',
72
+ target: '456',
73
+ linkIcon: true,
74
+ },
75
+ ],
76
+ },
77
+ {
78
+ source: '456',
79
+ target: '789',
80
+ lineStyle: 'Solid',
81
+ sourceArrow: true,
82
+ targetArrow: true,
83
+ linkId: '456_789',
84
+ relationships: [
85
+ {
86
+ labelIndex: 2,
87
+ label: 'Play in the same football team',
88
+ source: '456',
89
+ target: '789',
90
+ linkIcon: false,
91
+ },
92
+ {
93
+ labelIndex: 3,
94
+ label: 'Daughters in the same class at school',
95
+ source: '456',
96
+ target: '789',
97
+ linkIcon: true,
98
+ },
99
+ {
100
+ labelIndex: 4,
101
+ label: 'Went on a family holiday together last year',
102
+ source: '456',
103
+ target: '789',
104
+ linkIcon: false,
105
+ },
106
+ ],
107
+ },
108
+ {
109
+ source: '789',
110
+ target: '123',
111
+ lineStyle: 'Dotted',
112
+ sourceArrow: true,
113
+ targetArrow: true,
114
+ linkId: '789_123',
115
+ relationships: [
116
+ {
117
+ labelIndex: 5,
118
+ label: 'Drink in the same pub',
119
+ source: '789',
120
+ target: '123',
121
+ linkIcon: true,
122
+ },
123
+ {
124
+ labelIndex: 6,
125
+ label: 'Drinking friends',
126
+ source: '789',
127
+ target: '123',
128
+ linkIcon: false,
129
+ },
130
+ ],
131
+ },
132
+ {
133
+ source: '4',
134
+ target: '123',
135
+ lineStyle: 'Dotted',
136
+ sourceArrow: true,
137
+ targetArrow: false,
138
+ linkId: '4_123',
139
+ relationships: [
140
+ {
141
+ labelIndex: 7,
142
+ label: ['Same University'],
143
+ source: '4',
144
+ target: '123',
145
+ linkIcon: true,
146
+ },
147
+ ],
148
+ },
149
+ ],
150
+ };
@@ -0,0 +1,15 @@
1
+ import { NgModule } from '@angular/core';
2
+ import { BrowserModule } from '@angular/platform-browser';
3
+ import { VisualiserGraphComponent } from './visualiser/visualiser-graph/visualiser-graph.component';
4
+
5
+ @NgModule({
6
+ declarations: [
7
+ VisualiserGraphComponent
8
+ ],
9
+ imports: [
10
+ BrowserModule
11
+ ],
12
+ exports: [VisualiserGraphComponent]
13
+ })
14
+
15
+ export class NgxRelationshipVisualiserModule { }
@@ -0,0 +1,182 @@
1
+ import * as dagre from '@dagrejs/dagre';
2
+ import { Injectable } from '@angular/core';
3
+
4
+ export enum Orientation {
5
+ LEFT_TO_RIGHT = 'LR',
6
+ RIGHT_TO_LEFT = 'RL',
7
+ TOP_TO_BOTTOM = 'TB',
8
+ BOTTOM_TO_TOP = 'BT',
9
+ }
10
+
11
+ export enum Alignment {
12
+ CENTER = 'C',
13
+ UP_LEFT = 'UL',
14
+ UP_RIGHT = 'UR',
15
+ DOWN_LEFT = 'DL',
16
+ DOWN_RIGHT = 'DR',
17
+ }
18
+
19
+ export interface DagreSettings {
20
+ orientation?: Orientation;
21
+ marginX?: number;
22
+ marginY?: number;
23
+ edgePadding?: number;
24
+ rankPadding?: number;
25
+ nodePadding?: number;
26
+ align?: Alignment;
27
+ acyclicer?: 'greedy';
28
+ ranker?: 'network-simplex' | 'tight-tree' | 'longest-path';
29
+ multigraph?: boolean;
30
+ compound?: boolean;
31
+ }
32
+
33
+ @Injectable({
34
+ providedIn: 'root',
35
+ })
36
+ export class DagreNodesOnlyLayout {
37
+ defaultSettings = {
38
+ orientation: Orientation.LEFT_TO_RIGHT,
39
+ marginX: 70,
40
+ marginY: 70,
41
+ edgePadding: 200,
42
+ rankPadding: 300,
43
+ nodePadding: 100,
44
+ curveDistance: 20,
45
+ multigraph: true,
46
+ compound: true,
47
+ align: Alignment.UP_RIGHT,
48
+ acyclicer: undefined,
49
+ ranker: 'network-simplex',
50
+ };
51
+
52
+ dagreGraph: any;
53
+ dagreNodes: any;
54
+ dagreEdges: any;
55
+
56
+ public renderLayout(graph) {
57
+ this.createDagreGraph(graph);
58
+ dagre.layout(this.dagreGraph);
59
+
60
+ for (const dagreNodeId in this.dagreGraph._nodes) {
61
+ const dagreNode = this.dagreGraph._nodes[dagreNodeId];
62
+ const node = graph.nodes.find((n) => n.id === dagreNode.id);
63
+
64
+ if (node.fx === null && node.fy === null) {
65
+ // Check if the node has any associated edges
66
+ const hasAssociatedEdges = graph.links.some(
67
+ (link) => link.source === dagreNode.id || link.target === dagreNode.id
68
+ );
69
+ if (hasAssociatedEdges) {
70
+ node.fx = dagreNode.x;
71
+ node.fy = dagreNode.y;
72
+ }
73
+ }
74
+
75
+ node.dimension = {
76
+ width: dagreNode.width,
77
+ height: dagreNode.height,
78
+ };
79
+ }
80
+
81
+ return graph;
82
+ }
83
+
84
+ public initRenderLayout(graph) {
85
+ this.createDagreGraph(graph);
86
+ dagre.layout(this.dagreGraph);
87
+ let minFy = Infinity;
88
+ for (const dagreNodeId in this.dagreGraph._nodes) {
89
+ const dagreNode = this.dagreGraph._nodes[dagreNodeId];
90
+ const node = graph.nodes.find((n) => n.id === dagreNode.id);
91
+
92
+ // Check if the node has any associated edges
93
+ const hasAssociatedEdges = graph.links.some(
94
+ (link) => link.source === dagreNode.id || link.target === dagreNode.id
95
+ );
96
+
97
+ if (hasAssociatedEdges) {
98
+ node.fx = dagreNode.x;
99
+ node.fy = dagreNode.y;
100
+ minFy = Math.min(minFy, dagreNode.y - this.defaultSettings.marginY);
101
+ } else {
102
+ // Give them a null value to later random position them only when the layout button is pressed so they come into view
103
+ node.fx = null;
104
+ node.fy = null;
105
+ }
106
+
107
+ node.dimension = {
108
+ width: dagreNode.width,
109
+ height: dagreNode.height,
110
+ };
111
+ }
112
+
113
+ // Adjust the fy values to start from 0 if there are associated edges
114
+ if (minFy !== Infinity) {
115
+ for (const node of graph.nodes) {
116
+ if (node.fy !== null) {
117
+ node.fy -= minFy;
118
+ }
119
+ }
120
+ }
121
+
122
+ return graph;
123
+ }
124
+
125
+ public createDagreGraph(graph): any {
126
+ const settings = Object.assign({}, this.defaultSettings);
127
+ this.dagreGraph = new dagre.graphlib.Graph({
128
+ compound: settings.compound,
129
+ multigraph: settings.multigraph,
130
+ });
131
+ this.dagreGraph.setGraph({
132
+ rankdir: settings.orientation,
133
+ marginx: settings.marginX,
134
+ marginy: settings.marginY,
135
+ edgesep: settings.edgePadding,
136
+ ranksep: settings.rankPadding,
137
+ nodesep: settings.nodePadding,
138
+ align: settings.align,
139
+ acyclicer: settings.acyclicer,
140
+ ranker: settings.ranker,
141
+ multigraph: settings.multigraph,
142
+ compound: settings.compound,
143
+ });
144
+
145
+ this.dagreNodes = graph.nodes.map((n) => {
146
+ const node: any = Object.assign({}, n);
147
+ node.width = 20;
148
+ node.height = 20;
149
+ node.x = n.fx;
150
+ node.y = n.fy;
151
+ return node;
152
+ });
153
+
154
+ this.dagreEdges = graph.links.map((l) => {
155
+ const newLink: any = Object.assign({}, l);
156
+ return newLink;
157
+ });
158
+
159
+ for (const node of this.dagreNodes) {
160
+ if (!node.width) {
161
+ node.width = 20;
162
+ }
163
+ if (!node.height) {
164
+ node.height = 30;
165
+ }
166
+
167
+ // update dagre
168
+ this.dagreGraph.setNode(node.id, node);
169
+ }
170
+
171
+ // update dagre
172
+ for (const edge of this.dagreEdges) {
173
+ if (settings.multigraph) {
174
+ this.dagreGraph.setEdge(edge.source, edge.target, edge, edge.linkId);
175
+ } else {
176
+ this.dagreGraph.setEdge(edge.source, edge.target);
177
+ }
178
+ }
179
+
180
+ return this.dagreGraph;
181
+ }
182
+ }