@hpcc-js/graph 3.6.5 → 3.7.0

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 (77) 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-DQ0E8zfY.js.map → graphviz-DJ070oMZ.js.map} +1 -1
  5. package/dist/index.js +4 -4
  6. package/dist/index.js.map +1 -1
  7. package/dist/index.umd.cjs +13 -13
  8. package/dist/index.umd.cjs.map +1 -1
  9. package/package.json +9 -9
  10. package/src/AdjacencyGraph.ts +224 -224
  11. package/src/Edge.css +23 -23
  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 +45 -46
  18. package/src/Sankey.ts +304 -304
  19. package/src/Subgraph.css +10 -10
  20. package/src/Subgraph.ts +165 -165
  21. package/src/Vertex.css +3 -3
  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 +45 -45
  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
@@ -1,45 +1,45 @@
1
- import { svg } from "lit-html";
2
- import { extend } from "./component.ts";
3
- import { rectangle } from "./shape.ts";
4
- import { Text, TextProps } from "./text.ts";
5
-
6
- export interface TextBoxProps {
7
- text: TextProps;
8
-
9
- padding?: number;
10
- fill?: string;
11
- stroke?: string;
12
- strokeWidth?: number;
13
- cornerRadius?: number;
14
- yOffset?: number;
15
- }
16
-
17
- export const TextBox = ({
18
- text,
19
-
20
- padding = 4,
21
- fill = "whitesmoke",
22
- stroke = "lightgray",
23
- strokeWidth = 1,
24
- cornerRadius,
25
- }: TextBoxProps) => {
26
- const textTpl = Text(text);
27
- const { width, height } = textTpl.extent;
28
- const rectTpl = rectangle({
29
- width: width + padding * 2,
30
- height: height + padding * 2,
31
- fill,
32
- stroke,
33
- strokeWidth,
34
- cornerRadius
35
- });
36
-
37
- return extend(svg`\
38
- ${rectTpl}
39
- ${textTpl}`,
40
- rectTpl.extent.width,
41
- rectTpl.extent.height,
42
- rectTpl.intersection
43
- );
44
- };
45
-
1
+ import { svg } from "lit-html";
2
+ import { extend } from "./component.ts";
3
+ import { rectangle } from "./shape.ts";
4
+ import { Text, TextProps } from "./text.ts";
5
+
6
+ export interface TextBoxProps {
7
+ text: TextProps;
8
+
9
+ padding?: number;
10
+ fill?: string;
11
+ stroke?: string;
12
+ strokeWidth?: number;
13
+ cornerRadius?: number;
14
+ yOffset?: number;
15
+ }
16
+
17
+ export const TextBox = ({
18
+ text,
19
+
20
+ padding = 4,
21
+ fill = "whitesmoke",
22
+ stroke = "lightgray",
23
+ strokeWidth = 1,
24
+ cornerRadius,
25
+ }: TextBoxProps) => {
26
+ const textTpl = Text(text);
27
+ const { width, height } = textTpl.extent;
28
+ const rectTpl = rectangle({
29
+ width: width + padding * 2,
30
+ height: height + padding * 2,
31
+ fill,
32
+ stroke,
33
+ strokeWidth,
34
+ cornerRadius
35
+ });
36
+
37
+ return extend(svg`\
38
+ ${rectTpl}
39
+ ${textTpl}`,
40
+ rectTpl.extent.width,
41
+ rectTpl.extent.height,
42
+ rectTpl.intersection
43
+ );
44
+ };
45
+
@@ -1,67 +1,67 @@
1
- import { svg } from "lit-html";
2
- import type { VertexBaseProps } from "../common/layouts/placeholders.ts";
3
- import { icon as litIcon, IconProps } from "./icon.ts";
4
- import { TextBox, TextBoxProps } from "./textBox.ts";
5
- import { annotations, AnnotationProps } from "./annotation.ts";
6
- import { Component, extend } from "./component.ts";
7
-
8
- export interface VertexProps extends VertexBaseProps {
9
- icon?: IconProps;
10
- iconOffset?: number;
11
- iconAnnotations?: AnnotationProps[];
12
- iconAnnotationsOffset?: number;
13
- textBox?: TextBoxProps;
14
- textBoxAnnotationsE?: AnnotationProps[];
15
- textBoxAnnotationsSE?: AnnotationProps[];
16
- textBoxAnnotationsS?: AnnotationProps[];
17
- textBoxAnnotationsOffset?: number
18
- }
19
-
20
- export const vertex: Component<VertexProps> = ({
21
- text,
22
- textBox,
23
- textBoxAnnotationsE = [],
24
- textBoxAnnotationsSE = [],
25
- textBoxAnnotationsS = [],
26
- textBoxAnnotationsOffset = 4,
27
- icon = {},
28
- iconOffset = 6,
29
- iconAnnotations = [],
30
- iconAnnotationsOffset = 0,
31
- }: VertexProps) => {
32
- const iconTpl = litIcon(icon);
33
- const iconAnnotationsTpl = annotations({
34
- annotations: iconAnnotations
35
- });
36
- const textBoxTpl = TextBox({ text: { text: text, ...textBox?.text } });
37
- const textBoxAnnotationsETpl = annotations({ annotations: textBoxAnnotationsE });
38
- const textBoxAnnotationsSETpl = annotations({ annotations: textBoxAnnotationsSE });
39
- const textBoxAnnotationsSTpl = annotations({ annotations: textBoxAnnotationsS });
40
-
41
- const yIconOffset = -iconOffset - (textBoxTpl.extent.height + iconTpl.extent.height) / 2;
42
-
43
- const radius = iconAnnotationsOffset + iconTpl.extent.width / 2;
44
- const xIconAnnotationOffset = radius * Math.cos(45 * (Math.PI / 180));
45
- const yIconAnnotationOffset = radius * Math.sin(45 * (Math.PI / 180));
46
- return extend(svg`\
47
- ${textBoxTpl}
48
- <g transform="translate(${textBoxTpl.extent.width / 2 + textBoxAnnotationsOffset + textBoxAnnotationsETpl.extent.width / 2})">
49
- ${textBoxAnnotationsETpl}
50
- </g>
51
- <g transform="translate(${textBoxTpl.extent.width / 2 + textBoxAnnotationsOffset + textBoxAnnotationsETpl.extent.width / 2} ${textBoxTpl.extent.height / 2 + textBoxAnnotationsOffset + textBoxAnnotationsSETpl.extent.height / 2})">
52
- ${textBoxAnnotationsSETpl}
53
- </g>
54
- <g transform="translate(0 ${textBoxTpl.extent.height / 2 + textBoxAnnotationsOffset + textBoxAnnotationsSTpl.extent.height / 2})">
55
- ${textBoxAnnotationsSTpl}
56
- </g>
57
- <g data-click="icon" data-click-data=${JSON.stringify(icon)} transform="translate(0 ${yIconOffset})">
58
- ${iconTpl}
59
- </g>
60
- <g transform="translate(${iconAnnotationsTpl.extent.width / 2 + xIconAnnotationOffset} ${yIconOffset - yIconAnnotationOffset})">
61
- ${iconAnnotationsTpl}
62
- </g>
63
- `, textBoxTpl.extent.width, textBoxTpl.extent.height, (pos, line) => {
64
- return iconTpl.intersection({ x: pos.x, y: yIconOffset + pos.y }, line) ??
65
- textBoxTpl.intersection({ x: pos.x, y: pos.y }, line);
66
- });
67
- };
1
+ import { svg } from "lit-html";
2
+ import type { VertexBaseProps } from "../common/layouts/placeholders.ts";
3
+ import { icon as litIcon, IconProps } from "./icon.ts";
4
+ import { TextBox, TextBoxProps } from "./textBox.ts";
5
+ import { annotations, AnnotationProps } from "./annotation.ts";
6
+ import { Component, extend } from "./component.ts";
7
+
8
+ export interface VertexProps extends VertexBaseProps {
9
+ icon?: IconProps;
10
+ iconOffset?: number;
11
+ iconAnnotations?: AnnotationProps[];
12
+ iconAnnotationsOffset?: number;
13
+ textBox?: TextBoxProps;
14
+ textBoxAnnotationsE?: AnnotationProps[];
15
+ textBoxAnnotationsSE?: AnnotationProps[];
16
+ textBoxAnnotationsS?: AnnotationProps[];
17
+ textBoxAnnotationsOffset?: number
18
+ }
19
+
20
+ export const vertex: Component<VertexProps> = ({
21
+ text,
22
+ textBox,
23
+ textBoxAnnotationsE = [],
24
+ textBoxAnnotationsSE = [],
25
+ textBoxAnnotationsS = [],
26
+ textBoxAnnotationsOffset = 4,
27
+ icon = {},
28
+ iconOffset = 6,
29
+ iconAnnotations = [],
30
+ iconAnnotationsOffset = 0,
31
+ }: VertexProps) => {
32
+ const iconTpl = litIcon(icon);
33
+ const iconAnnotationsTpl = annotations({
34
+ annotations: iconAnnotations
35
+ });
36
+ const textBoxTpl = TextBox({ text: { text: text, ...textBox?.text } });
37
+ const textBoxAnnotationsETpl = annotations({ annotations: textBoxAnnotationsE });
38
+ const textBoxAnnotationsSETpl = annotations({ annotations: textBoxAnnotationsSE });
39
+ const textBoxAnnotationsSTpl = annotations({ annotations: textBoxAnnotationsS });
40
+
41
+ const yIconOffset = -iconOffset - (textBoxTpl.extent.height + iconTpl.extent.height) / 2;
42
+
43
+ const radius = iconAnnotationsOffset + iconTpl.extent.width / 2;
44
+ const xIconAnnotationOffset = radius * Math.cos(45 * (Math.PI / 180));
45
+ const yIconAnnotationOffset = radius * Math.sin(45 * (Math.PI / 180));
46
+ return extend(svg`\
47
+ ${textBoxTpl}
48
+ <g transform="translate(${textBoxTpl.extent.width / 2 + textBoxAnnotationsOffset + textBoxAnnotationsETpl.extent.width / 2})">
49
+ ${textBoxAnnotationsETpl}
50
+ </g>
51
+ <g transform="translate(${textBoxTpl.extent.width / 2 + textBoxAnnotationsOffset + textBoxAnnotationsETpl.extent.width / 2} ${textBoxTpl.extent.height / 2 + textBoxAnnotationsOffset + textBoxAnnotationsSETpl.extent.height / 2})">
52
+ ${textBoxAnnotationsSETpl}
53
+ </g>
54
+ <g transform="translate(0 ${textBoxTpl.extent.height / 2 + textBoxAnnotationsOffset + textBoxAnnotationsSTpl.extent.height / 2})">
55
+ ${textBoxAnnotationsSTpl}
56
+ </g>
57
+ <g data-click="icon" data-click-data=${JSON.stringify(icon)} transform="translate(0 ${yIconOffset})">
58
+ ${iconTpl}
59
+ </g>
60
+ <g transform="translate(${iconAnnotationsTpl.extent.width / 2 + xIconAnnotationOffset} ${yIconOffset - yIconAnnotationOffset})">
61
+ ${iconAnnotationsTpl}
62
+ </g>
63
+ `, textBoxTpl.extent.width, textBoxTpl.extent.height, (pos, line) => {
64
+ return iconTpl.intersection({ x: pos.x, y: yIconOffset + pos.y }, line) ??
65
+ textBoxTpl.intersection({ x: pos.x, y: pos.y }, line);
66
+ });
67
+ };
package/src/index.ts CHANGED
@@ -1,10 +1,10 @@
1
- export * from "./__package__.ts";
2
- export * from "./AdjacencyGraph.ts";
3
- export * from "./Edge.ts";
4
- export * from "./Graph.ts";
5
- export * from "./Sankey.ts";
6
- export * from "./Subgraph.ts";
7
- export * from "./Vertex.ts";
8
- export * from "./common/index.ts";
9
- export * from "./html/index.ts";
10
- export * from "./react/index.ts";
1
+ export * from "./__package__.ts";
2
+ export * from "./AdjacencyGraph.ts";
3
+ export * from "./Edge.ts";
4
+ export * from "./Graph.ts";
5
+ export * from "./Sankey.ts";
6
+ export * from "./Subgraph.ts";
7
+ export * from "./Vertex.ts";
8
+ export * from "./common/index.ts";
9
+ export * from "./html/index.ts";
10
+ export * from "./react/index.ts";