@hpcc-js/graph 3.6.3 → 3.6.5
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/LICENSE +43 -43
- package/README.md +256 -256
- package/dist/assets/dagre-B-z4SP0u.js.map +1 -1
- package/dist/assets/{graphviz-CjmNyQgU.js.map → graphviz-DQ0E8zfY.js.map} +1 -1
- package/dist/index.js +2 -2
- package/dist/index.js.map +1 -1
- package/dist/index.umd.cjs +2 -2
- package/dist/index.umd.cjs.map +1 -1
- package/package.json +8 -8
- package/src/AdjacencyGraph.ts +224 -224
- package/src/Edge.css +23 -23
- package/src/Edge.ts +257 -257
- package/src/Graph.css +18 -18
- package/src/Graph.ts +1077 -1077
- package/src/GraphData.ts +187 -187
- package/src/GraphLayouts.ts +214 -214
- package/src/Sankey.css +46 -46
- package/src/Sankey.ts +304 -304
- package/src/Subgraph.css +10 -10
- package/src/Subgraph.ts +165 -165
- package/src/Vertex.css +3 -3
- package/src/Vertex.ts +282 -282
- package/src/__package__.ts +3 -3
- package/src/__tests__/data.ts +444 -444
- package/src/__tests__/index.ts +1 -1
- package/src/__tests__/test1.ts +18 -18
- package/src/__tests__/test2.ts +80 -80
- package/src/__tests__/test3.ts +46 -46
- package/src/__tests__/test4.ts +66 -66
- package/src/__tests__/test5.ts +85 -85
- package/src/common/graphT.css +38 -38
- package/src/common/graphT.ts +1363 -1363
- package/src/common/index.ts +3 -3
- package/src/common/layouts/circle.ts +37 -37
- package/src/common/layouts/dagre.ts +145 -145
- package/src/common/layouts/dagreWorker.ts +24 -24
- package/src/common/layouts/forceDirected.ts +117 -117
- package/src/common/layouts/forceDirectedWorker.ts +22 -22
- package/src/common/layouts/geoForceDirected.ts +112 -112
- package/src/common/layouts/graphviz.ts +137 -137
- package/src/common/layouts/graphvizWorker.ts +27 -27
- package/src/common/layouts/index.ts +7 -7
- package/src/common/layouts/layout.ts +147 -147
- package/src/common/layouts/null.ts +39 -39
- package/src/common/layouts/placeholders.ts +113 -113
- package/src/common/layouts/tree.ts +326 -326
- package/src/common/layouts/workers/dagre.ts +46 -46
- package/src/common/layouts/workers/dagreOptions.ts +35 -35
- package/src/common/layouts/workers/forceDirected.ts +38 -38
- package/src/common/layouts/workers/forceDirectedOptions.ts +30 -30
- package/src/common/layouts/workers/graphviz.ts +225 -225
- package/src/common/layouts/workers/graphvizOptions.ts +70 -70
- package/src/common/liteMap.ts +72 -72
- package/src/common/liteSVGZooom.ts +61 -61
- package/src/common/sankeyGraph.css +45 -45
- package/src/common/sankeyGraph.ts +345 -345
- package/src/html/annotation.ts +71 -71
- package/src/html/component.ts +18 -18
- package/src/html/edge.ts +15 -15
- package/src/html/graphHtml.ts +11 -11
- package/src/html/graphHtmlT.ts +117 -117
- package/src/html/icon.ts +64 -64
- package/src/html/image.ts +26 -26
- package/src/html/imageChar.ts +18 -18
- package/src/html/index.ts +8 -8
- package/src/html/intersection.ts +110 -110
- package/src/html/shape.ts +141 -141
- package/src/html/text.ts +59 -59
- package/src/html/textBox.ts +45 -45
- package/src/html/vertex.ts +67 -67
- package/src/index.ts +10 -10
- package/src/react/dataGraph.ts +345 -345
- package/src/react/graphReact.ts +177 -177
- package/src/react/graphReactT.ts +44 -44
- package/src/react/index.ts +4 -4
- package/src/react/subgraph.tsx +30 -30
- package/src/react/vertex.tsx +31 -31
package/src/html/textBox.ts
CHANGED
|
@@ -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
|
+
|
package/src/html/vertex.ts
CHANGED
|
@@ -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";
|