@hpcc-js/graph 3.7.4 → 3.7.6

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 (78) hide show
  1. package/LICENSE +43 -43
  2. package/README.md +256 -256
  3. package/dist/assets/dagre-B-z4SP0u.js.map +1 -1
  4. package/dist/assets/graphviz-BkFKgQ-y.js.map +1 -0
  5. package/dist/index.js +26 -26
  6. package/dist/index.js.map +1 -1
  7. package/dist/index.umd.cjs +22 -22
  8. package/dist/index.umd.cjs.map +1 -1
  9. package/package.json +12 -10
  10. package/src/AdjacencyGraph.ts +224 -224
  11. package/src/Edge.css +22 -22
  12. package/src/Edge.ts +257 -257
  13. package/src/Graph.css +18 -18
  14. package/src/Graph.ts +1077 -1077
  15. package/src/GraphData.ts +187 -187
  16. package/src/GraphLayouts.ts +214 -214
  17. package/src/Sankey.css +44 -44
  18. package/src/Sankey.ts +304 -304
  19. package/src/Subgraph.css +9 -9
  20. package/src/Subgraph.ts +165 -165
  21. package/src/Vertex.css +2 -2
  22. package/src/Vertex.ts +282 -282
  23. package/src/__package__.ts +3 -3
  24. package/src/__tests__/data.ts +444 -444
  25. package/src/__tests__/index.ts +1 -1
  26. package/src/__tests__/test1.ts +18 -18
  27. package/src/__tests__/test2.ts +80 -80
  28. package/src/__tests__/test3.ts +46 -46
  29. package/src/__tests__/test4.ts +66 -66
  30. package/src/__tests__/test5.ts +85 -85
  31. package/src/common/graphT.css +38 -38
  32. package/src/common/graphT.ts +1363 -1363
  33. package/src/common/index.ts +3 -3
  34. package/src/common/layouts/circle.ts +37 -37
  35. package/src/common/layouts/dagre.ts +145 -145
  36. package/src/common/layouts/dagreWorker.ts +24 -24
  37. package/src/common/layouts/forceDirected.ts +117 -117
  38. package/src/common/layouts/forceDirectedWorker.ts +22 -22
  39. package/src/common/layouts/geoForceDirected.ts +112 -112
  40. package/src/common/layouts/graphviz.ts +137 -137
  41. package/src/common/layouts/graphvizWorker.ts +27 -27
  42. package/src/common/layouts/index.ts +7 -7
  43. package/src/common/layouts/layout.ts +147 -147
  44. package/src/common/layouts/null.ts +39 -39
  45. package/src/common/layouts/placeholders.ts +113 -113
  46. package/src/common/layouts/tree.ts +326 -326
  47. package/src/common/layouts/workers/dagre.ts +46 -46
  48. package/src/common/layouts/workers/dagreOptions.ts +35 -35
  49. package/src/common/layouts/workers/forceDirected.ts +38 -38
  50. package/src/common/layouts/workers/forceDirectedOptions.ts +30 -30
  51. package/src/common/layouts/workers/graphviz.ts +225 -225
  52. package/src/common/layouts/workers/graphvizOptions.ts +70 -70
  53. package/src/common/liteMap.ts +72 -72
  54. package/src/common/liteSVGZooom.ts +61 -61
  55. package/src/common/sankeyGraph.css +44 -44
  56. package/src/common/sankeyGraph.ts +345 -345
  57. package/src/html/annotation.ts +71 -71
  58. package/src/html/component.ts +18 -18
  59. package/src/html/edge.ts +15 -15
  60. package/src/html/graphHtml.ts +11 -11
  61. package/src/html/graphHtmlT.ts +117 -117
  62. package/src/html/icon.ts +64 -64
  63. package/src/html/image.ts +26 -26
  64. package/src/html/imageChar.ts +18 -18
  65. package/src/html/index.ts +8 -8
  66. package/src/html/intersection.ts +110 -110
  67. package/src/html/shape.ts +141 -141
  68. package/src/html/text.ts +59 -59
  69. package/src/html/textBox.ts +45 -45
  70. package/src/html/vertex.ts +67 -67
  71. package/src/index.ts +10 -10
  72. package/src/react/dataGraph.ts +345 -345
  73. package/src/react/graphReact.ts +177 -177
  74. package/src/react/graphReactT.ts +44 -44
  75. package/src/react/index.ts +4 -4
  76. package/src/react/subgraph.tsx +30 -30
  77. package/src/react/vertex.tsx +31 -31
  78. package/dist/assets/graphviz-BK7FEJlA.js.map +0 -1
@@ -1,46 +1,46 @@
1
- import { GraphLabel, graphlib, layout } from "dagre";
2
- import { Data, Options } from "./dagreOptions.js";
3
-
4
- function dagre(data: Data, options: Options) {
5
- const subgraphs = data.subgraphs;
6
- const nodes = data.nodes;
7
- const links = data.links;
8
- const hierarchy = data.hierarchy;
9
-
10
- const digraph = new graphlib.Graph({ multigraph: true, compound: true, directed: options.digraph !== false })
11
- .setGraph(options)
12
- .setDefaultNodeLabel(function () { return {}; })
13
- .setDefaultEdgeLabel(function () { return {}; })
14
- ;
15
- subgraphs.forEach(sp => {
16
- digraph.setNode(sp.id, sp);
17
- });
18
- nodes.forEach(vp => {
19
- digraph.setNode(vp.id, vp);
20
- });
21
- links.forEach(ep => {
22
- digraph.setEdge(ep.source.id, ep.target.id, ep, ep.id);
23
- });
24
- hierarchy.forEach(h => {
25
- digraph.setParent(h.child, h.parent);
26
- });
27
- layout(digraph, { debugTiming: false } as GraphLabel);
28
- const deltaX = (-digraph.graph().width / 2) || 0;
29
- const deltaY = -digraph.graph().height / 2;
30
- digraph.nodes().forEach(function (u) {
31
- const vp = digraph.node(u) as any;
32
- vp.x += deltaX;
33
- vp.y += deltaY;
34
- });
35
- digraph.edges().forEach(function (e) {
36
- const ep = digraph.edge(e) as any;
37
- ep.points = ep.points.map(p => [p.x + deltaX, p.y + deltaY]);
38
- });
39
-
40
- return { subgraphs, nodes, links };
41
- }
42
-
43
- self.onmessage = event => {
44
- const result = dagre.apply(undefined, event.data);
45
- self.postMessage(result);
46
- };
1
+ import { GraphLabel, graphlib, layout } from "dagre";
2
+ import { Data, Options } from "./dagreOptions.js";
3
+
4
+ function dagre(data: Data, options: Options) {
5
+ const subgraphs = data.subgraphs;
6
+ const nodes = data.nodes;
7
+ const links = data.links;
8
+ const hierarchy = data.hierarchy;
9
+
10
+ const digraph = new graphlib.Graph({ multigraph: true, compound: true, directed: options.digraph !== false })
11
+ .setGraph(options)
12
+ .setDefaultNodeLabel(function () { return {}; })
13
+ .setDefaultEdgeLabel(function () { return {}; })
14
+ ;
15
+ subgraphs.forEach(sp => {
16
+ digraph.setNode(sp.id, sp);
17
+ });
18
+ nodes.forEach(vp => {
19
+ digraph.setNode(vp.id, vp);
20
+ });
21
+ links.forEach(ep => {
22
+ digraph.setEdge(ep.source.id, ep.target.id, ep, ep.id);
23
+ });
24
+ hierarchy.forEach(h => {
25
+ digraph.setParent(h.child, h.parent);
26
+ });
27
+ layout(digraph, { debugTiming: false } as GraphLabel);
28
+ const deltaX = (-digraph.graph().width / 2) || 0;
29
+ const deltaY = -digraph.graph().height / 2;
30
+ digraph.nodes().forEach(function (u) {
31
+ const vp = digraph.node(u) as any;
32
+ vp.x += deltaX;
33
+ vp.y += deltaY;
34
+ });
35
+ digraph.edges().forEach(function (e) {
36
+ const ep = digraph.edge(e) as any;
37
+ ep.points = ep.points.map(p => [p.x + deltaX, p.y + deltaY]);
38
+ });
39
+
40
+ return { subgraphs, nodes, links };
41
+ }
42
+
43
+ self.onmessage = event => {
44
+ const result = dagre.apply(undefined, event.data);
45
+ self.postMessage(result);
46
+ };
@@ -1,35 +1,35 @@
1
- export interface Subgraph {
2
- id: string;
3
- text: string;
4
- }
5
-
6
- export interface Node {
7
- id: string;
8
- text: string;
9
- }
10
-
11
- export interface Link {
12
- id: string;
13
- source: Node;
14
- target: Node;
15
- }
16
-
17
- export interface Hierarchy {
18
- parent: string;
19
- child: string;
20
- }
21
-
22
- export interface Data {
23
- subgraphs: Subgraph[];
24
- nodes: Node[];
25
- links: Link[];
26
- hierarchy: Hierarchy[];
27
- }
28
-
29
- export interface Options {
30
- rankdir: "TB" | "BT" | "LR" | "RL";
31
- nodesep: number;
32
- edgesep: number;
33
- ranksep: number;
34
- digraph: boolean;
35
- }
1
+ export interface Subgraph {
2
+ id: string;
3
+ text: string;
4
+ }
5
+
6
+ export interface Node {
7
+ id: string;
8
+ text: string;
9
+ }
10
+
11
+ export interface Link {
12
+ id: string;
13
+ source: Node;
14
+ target: Node;
15
+ }
16
+
17
+ export interface Hierarchy {
18
+ parent: string;
19
+ child: string;
20
+ }
21
+
22
+ export interface Data {
23
+ subgraphs: Subgraph[];
24
+ nodes: Node[];
25
+ links: Link[];
26
+ hierarchy: Hierarchy[];
27
+ }
28
+
29
+ export interface Options {
30
+ rankdir: "TB" | "BT" | "LR" | "RL";
31
+ nodesep: number;
32
+ edgesep: number;
33
+ ranksep: number;
34
+ digraph: boolean;
35
+ }
@@ -1,38 +1,38 @@
1
- import { forceCenter, forceLink as d3ForceLink, forceManyBody as d3ForceManyBody, forceSimulation } from "d3-force";
2
- import "es6-promise/auto";
3
- import { Data, Options } from "./forceDirectedOptions.js";
4
-
5
- export function forceDirected(data: Data, options: Options) {
6
- const nodes = data.nodes;
7
- const links = data.links;
8
-
9
- const forceLink = d3ForceLink(links)
10
- .id(d => d.id)
11
- .distance(options.linkDistance)
12
- .strength(options.linkStrength)
13
- ;
14
-
15
- const forceManyBody = d3ForceManyBody()
16
- .strength(options.repulsionStrength)
17
- ;
18
-
19
- forceSimulation(nodes)
20
- .force("link", forceLink)
21
- .force("charge", forceManyBody)
22
- .force("center", forceCenter())
23
- .alpha(options.alpha)
24
- .alphaMin(options.alphaMin)
25
- .alphaDecay(options.alphaDecay)
26
- .velocityDecay(options.velocityDecay)
27
- .stop()
28
- .tick(options.iterations)
29
- ;
30
-
31
- return { nodes, links };
32
- }
33
-
34
- self.onmessage = event => {
35
- const result = forceDirected.apply(undefined, event.data);
36
- // @ts-ignore
37
- self.postMessage(result);
38
- };
1
+ import { forceCenter, forceLink as d3ForceLink, forceManyBody as d3ForceManyBody, forceSimulation } from "d3-force";
2
+ import "es6-promise/auto";
3
+ import { Data, Options } from "./forceDirectedOptions.js";
4
+
5
+ export function forceDirected(data: Data, options: Options) {
6
+ const nodes = data.nodes;
7
+ const links = data.links;
8
+
9
+ const forceLink = d3ForceLink(links)
10
+ .id(d => d.id)
11
+ .distance(options.linkDistance)
12
+ .strength(options.linkStrength)
13
+ ;
14
+
15
+ const forceManyBody = d3ForceManyBody()
16
+ .strength(options.repulsionStrength)
17
+ ;
18
+
19
+ forceSimulation(nodes)
20
+ .force("link", forceLink)
21
+ .force("charge", forceManyBody)
22
+ .force("center", forceCenter())
23
+ .alpha(options.alpha)
24
+ .alphaMin(options.alphaMin)
25
+ .alphaDecay(options.alphaDecay)
26
+ .velocityDecay(options.velocityDecay)
27
+ .stop()
28
+ .tick(options.iterations)
29
+ ;
30
+
31
+ return { nodes, links };
32
+ }
33
+
34
+ self.onmessage = event => {
35
+ const result = forceDirected.apply(undefined, event.data);
36
+ // @ts-ignore
37
+ self.postMessage(result);
38
+ };
@@ -1,30 +1,30 @@
1
- export interface Node {
2
- id: string;
3
- text: string;
4
- }
5
-
6
- export interface Link {
7
- id: string;
8
- source: Node;
9
- target: Node;
10
- }
11
-
12
- export interface Data {
13
- nodes: Node[];
14
- links: Link[];
15
- }
16
-
17
- export interface Options {
18
- alpha: number;
19
- alphaMin: number;
20
- alphaDecay: number;
21
- velocityDecay: number;
22
- repulsionStrength: number;
23
- linkDistance: number;
24
- linkStrength: number;
25
- iterations: number;
26
- pinCentroid: boolean;
27
- forceStrength: number;
28
- distanceMin: number;
29
- distanceMax: number;
30
- }
1
+ export interface Node {
2
+ id: string;
3
+ text: string;
4
+ }
5
+
6
+ export interface Link {
7
+ id: string;
8
+ source: Node;
9
+ target: Node;
10
+ }
11
+
12
+ export interface Data {
13
+ nodes: Node[];
14
+ links: Link[];
15
+ }
16
+
17
+ export interface Options {
18
+ alpha: number;
19
+ alphaMin: number;
20
+ alphaDecay: number;
21
+ velocityDecay: number;
22
+ repulsionStrength: number;
23
+ linkDistance: number;
24
+ linkStrength: number;
25
+ iterations: number;
26
+ pinCentroid: boolean;
27
+ forceStrength: number;
28
+ distanceMin: number;
29
+ distanceMax: number;
30
+ }