@hpcc-js/graph 3.2.1 → 3.3.1

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 (97) hide show
  1. package/dist/assets/{dagre-D0bY8RPD.js.map → dagre-BVMQn91n.js.map} +1 -1
  2. package/dist/assets/graphviz-CMhlTALo.js.map +1 -1
  3. package/dist/index.js +2630 -1994
  4. package/dist/index.js.map +1 -1
  5. package/dist/index.umd.cjs +81 -7
  6. package/dist/index.umd.cjs.map +1 -1
  7. package/package.json +7 -3
  8. package/src/__tests__/test5.ts +1 -1
  9. package/src/common/graphT.css +33 -0
  10. package/src/{graph2 → common}/graphT.ts +78 -47
  11. package/src/common/index.ts +3 -0
  12. package/src/{graph2 → common}/layouts/dagre.ts +16 -3
  13. package/src/{graph2 → common}/layouts/graphviz.ts +17 -4
  14. package/src/{graph2 → common}/layouts/layout.ts +48 -5
  15. package/src/common/layouts/pathIntersection.ts +67 -0
  16. package/src/{graph2 → common}/layouts/placeholders.ts +12 -0
  17. package/src/{graph2 → common}/layouts/tree.ts +2 -4
  18. package/src/{graph2 → common}/sankeyGraph.ts +2 -2
  19. package/src/html/annotation.ts +71 -0
  20. package/src/html/component.ts +14 -0
  21. package/src/html/graphHtml.ts +10 -0
  22. package/src/html/graphHtmlT.ts +49 -0
  23. package/src/html/icon.ts +64 -0
  24. package/src/html/image.ts +26 -0
  25. package/src/html/imageChar.ts +18 -0
  26. package/src/html/index.ts +8 -0
  27. package/src/html/shape.ts +136 -0
  28. package/src/html/text.ts +59 -0
  29. package/src/html/textBox.ts +41 -0
  30. package/src/html/vertex.ts +65 -0
  31. package/src/index.ts +3 -1
  32. package/src/{graph2 → react}/dataGraph.ts +11 -11
  33. package/src/{graph2/graph.ts → react/graphReact.ts} +65 -22
  34. package/src/{graph2 → react}/graphReactT.ts +1 -1
  35. package/src/react/index.ts +4 -0
  36. package/src/{graph2 → react}/subgraph.tsx +2 -1
  37. package/src/{graph2 → react}/vertex.tsx +2 -1
  38. package/types/{graph2 → common}/graphT.d.ts +9 -11
  39. package/types/common/index.d.ts +3 -0
  40. package/types/{graph2 → common}/layouts/layout.d.ts +18 -1
  41. package/types/common/layouts/pathIntersection.d.ts +24 -0
  42. package/types/{graph2 → common}/layouts/placeholders.d.ts +6 -0
  43. package/types/{graph2 → common}/sankeyGraph.d.ts +2 -2
  44. package/types/html/annotation.d.ts +13 -0
  45. package/types/html/component.d.ts +10 -0
  46. package/types/html/graphHtml.d.ts +5 -0
  47. package/types/html/graphHtmlT.d.ts +9 -0
  48. package/types/html/icon.d.ts +15 -0
  49. package/types/html/image.d.ts +8 -0
  50. package/types/html/imageChar.d.ts +2 -0
  51. package/types/html/index.d.ts +8 -0
  52. package/types/html/shape.d.ts +31 -0
  53. package/types/html/text.d.ts +10 -0
  54. package/types/html/textBox.d.ts +11 -0
  55. package/types/html/vertex.d.ts +17 -0
  56. package/types/index.d.ts +3 -1
  57. package/types/{graph2 → react}/dataGraph.d.ts +2 -2
  58. package/types/{graph2/graph.d.ts → react/graphReact.d.ts} +13 -3
  59. package/types/{graph2 → react}/graphReactT.d.ts +1 -1
  60. package/types/react/index.d.ts +4 -0
  61. package/types/{graph2 → react}/subgraph.d.ts +1 -1
  62. package/types/{graph2 → react}/vertex.d.ts +1 -1
  63. package/src/graph2/graph.css +0 -34
  64. package/src/graph2/index.ts +0 -7
  65. package/src/test.ts +0 -649
  66. package/types/graph2/index.d.ts +0 -7
  67. /package/src/{graph2 → common}/layouts/circle.ts +0 -0
  68. /package/src/{graph2 → common}/layouts/dagreWorker.ts +0 -0
  69. /package/src/{graph2 → common}/layouts/forceDirected.ts +0 -0
  70. /package/src/{graph2 → common}/layouts/forceDirectedWorker.ts +0 -0
  71. /package/src/{graph2 → common}/layouts/geoForceDirected.ts +0 -0
  72. /package/src/{graph2 → common}/layouts/graphvizWorker.ts +0 -0
  73. /package/src/{graph2 → common}/layouts/index.ts +0 -0
  74. /package/src/{graph2 → common}/layouts/null.ts +0 -0
  75. /package/src/{graph2 → common}/layouts/workers/dagre.ts +0 -0
  76. /package/src/{graph2 → common}/layouts/workers/dagreOptions.ts +0 -0
  77. /package/src/{graph2 → common}/layouts/workers/forceDirected.ts +0 -0
  78. /package/src/{graph2 → common}/layouts/workers/forceDirectedOptions.ts +0 -0
  79. /package/src/{graph2 → common}/layouts/workers/graphviz.ts +0 -0
  80. /package/src/{graph2 → common}/layouts/workers/graphvizOptions.ts +0 -0
  81. /package/src/{graph2 → common}/liteMap.ts +0 -0
  82. /package/src/{graph2 → common}/liteSVGZooom.ts +0 -0
  83. /package/src/{graph2 → common}/sankeyGraph.css +0 -0
  84. /package/types/{graph2 → common}/layouts/circle.d.ts +0 -0
  85. /package/types/{graph2 → common}/layouts/dagre.d.ts +0 -0
  86. /package/types/{graph2 → common}/layouts/dagreWorker.d.ts +0 -0
  87. /package/types/{graph2 → common}/layouts/forceDirected.d.ts +0 -0
  88. /package/types/{graph2 → common}/layouts/forceDirectedWorker.d.ts +0 -0
  89. /package/types/{graph2 → common}/layouts/geoForceDirected.d.ts +0 -0
  90. /package/types/{graph2 → common}/layouts/graphviz.d.ts +0 -0
  91. /package/types/{graph2 → common}/layouts/graphvizWorker.d.ts +0 -0
  92. /package/types/{graph2 → common}/layouts/index.d.ts +0 -0
  93. /package/types/{graph2 → common}/layouts/null.d.ts +0 -0
  94. /package/types/{graph2 → common}/layouts/tree.d.ts +0 -0
  95. /package/types/{graph2 → common}/layouts/workers/dagreOptions.d.ts +0 -0
  96. /package/types/{graph2 → common}/layouts/workers/forceDirectedOptions.d.ts +0 -0
  97. /package/types/{graph2 → common}/layouts/workers/graphvizOptions.d.ts +0 -0
@@ -0,0 +1,14 @@
1
+ import type { HTMLTemplateResult, SVGTemplateResult } from "lit-html";
2
+
3
+ export type TemplateResult = HTMLTemplateResult | SVGTemplateResult;
4
+ export type TemplateResultEx = TemplateResult & {
5
+ extent?: { width: number, height: number };
6
+ };
7
+ export function extend(result: TemplateResult, width: number, height: number): TemplateResultEx {
8
+ return {
9
+ ...result,
10
+ extent: { width, height }
11
+ };
12
+ }
13
+ export type Component<T> = (props: T) => TemplateResult;
14
+
@@ -0,0 +1,10 @@
1
+ import { GraphHtmlT, SubgraphBaseProps, EdgeBaseProps } from "./graphHtmlT.ts";
2
+ import { vertex, VertexProps } from "./vertex.ts";
3
+
4
+ export class GraphHtml extends GraphHtmlT<SubgraphBaseProps, VertexProps, EdgeBaseProps> {
5
+ constructor() {
6
+ super(undefined, vertex);
7
+ }
8
+
9
+ }
10
+ GraphHtml.prototype._class += " graph_GraphHtml";
@@ -0,0 +1,49 @@
1
+ import { html, svg, render } from "lit-html";
2
+ import type { BaseProps, EdgeBaseProps, SubgraphBaseProps, VertexBaseProps } from "../common/graphT.ts";
3
+ import { GraphT, RendererT } from "../common/graphT.ts";
4
+ import type { Component } from "./component.ts";
5
+ import { TextBox } from "./textBox.ts";
6
+ import { icon } from "./icon.ts";
7
+
8
+ export { html, svg, EdgeBaseProps, SubgraphBaseProps, VertexBaseProps };
9
+
10
+ export function adapter<T extends BaseProps>(component: Component<T>): RendererT<T> {
11
+ return (props: T, element: SVGGElement) => {
12
+ const componentTpl = component(props);
13
+ render(componentTpl, element as any);
14
+ return componentTpl;
15
+ };
16
+ }
17
+
18
+ const defaultSubgraphRenderer = ({
19
+ text = "",
20
+ }: SubgraphBaseProps) => {
21
+ return svg`<text font-family="monospace" font-size="10px" text-anchor="middle" dominant-baseline="middle" fill="black">${text}</text>`;
22
+ };
23
+
24
+ const defaultVertexRenderer = ({
25
+ text
26
+ }: VertexBaseProps) => {
27
+
28
+ return svg`\
29
+ ${icon({ imageChar: "" })}
30
+ ${TextBox({ text: { text } })}
31
+ `;
32
+ };
33
+
34
+ const defaultEdgeRenderer = ({
35
+ strokeWidth,
36
+ path,
37
+ markerStart,
38
+ markerEnd,
39
+ }: EdgeBaseProps<VertexBaseProps>) => {
40
+ return svg`<path d="${path}" marker-start="${markerStart}" marker-end="${markerEnd}" style="stroke-width:${strokeWidth}px"></path>`;
41
+ };
42
+
43
+ export class GraphHtmlT<SG extends SubgraphBaseProps, V extends VertexBaseProps, E extends EdgeBaseProps<V>> extends GraphT<SG, V, E> {
44
+
45
+ constructor(subgraphRenderer: Component<SG> = defaultSubgraphRenderer, vertexRenderer: Component<V> = defaultVertexRenderer, edgeRenderer: Component<E> = defaultEdgeRenderer) {
46
+ super(adapter(subgraphRenderer), adapter<V>(vertexRenderer), adapter(edgeRenderer));
47
+ }
48
+ }
49
+ GraphHtmlT.prototype._class += " graph_GraphHtmlT";
@@ -0,0 +1,64 @@
1
+ import { svg } from "lit-html";
2
+ import { Palette } from "@hpcc-js/common";
3
+ import { Image } from "./image.ts";
4
+ import { ImageChar } from "./imageChar.ts";
5
+ import { shape as litShape } from "./shape.ts";
6
+ import { extend } from "./component.ts";
7
+
8
+ export interface IconProps {
9
+ shape?: "circle" | "square" | "rectangle";
10
+ width?: number;
11
+ height?: number;
12
+ padding?: number;
13
+ fill?: string;
14
+ stroke?: string;
15
+ strokeWidth?: number;
16
+ imageUrl?: string;
17
+ imageFontFamily?: string;
18
+ imageChar?: string;
19
+ imageCharFill?: string;
20
+ cornerRadius?: number;
21
+ }
22
+
23
+ export function icon({
24
+ shape = "circle",
25
+ width,
26
+ height = 32,
27
+ fill = "transparent",
28
+ stroke = fill !== "transparent" ? "black" : undefined,
29
+ strokeWidth = stroke === undefined ? 0 : 1,
30
+ imageUrl = "",
31
+ imageFontFamily = "FontAwesome",
32
+ imageChar = "",
33
+ imageCharFill = Palette.textColor(fill),
34
+ padding = height / 5,
35
+ cornerRadius,
36
+ }: IconProps) {
37
+ const shapeTpl = litShape({
38
+ shape,
39
+ width,
40
+ height,
41
+ fill,
42
+ stroke,
43
+ strokeWidth,
44
+ cornerRadius
45
+ });
46
+ const imageTpl = imageUrl ?
47
+ Image({
48
+ href: imageUrl,
49
+ height: height - padding * 2
50
+ }) :
51
+ ImageChar({
52
+ text: imageChar,
53
+ fill: imageCharFill,
54
+ fontFamily: imageFontFamily,
55
+ fontSize: height - padding * 2,
56
+ });
57
+
58
+ return extend(svg`\
59
+ <g>
60
+ ${shapeTpl}
61
+ ${imageTpl}
62
+ </g>`, shapeTpl.extent.width, shapeTpl.extent.height);
63
+ };
64
+
@@ -0,0 +1,26 @@
1
+ import { svg } from "lit-html";
2
+ import { extend } from "./component.ts";
3
+
4
+ export interface ImageProps {
5
+ href: string;
6
+ x?: number;
7
+ y?: number;
8
+ height?: number;
9
+ yOffset?: number;
10
+ }
11
+
12
+ export const Image = ({
13
+ href,
14
+ x = 0,
15
+ y = 0,
16
+ height = 12
17
+ }: ImageProps) => {
18
+ return extend(svg`\
19
+ <image
20
+ xlink:href=${href}
21
+ x=${x - height / 2}
22
+ y=${y - height / 2}
23
+ width=${height}
24
+ height=${height}
25
+ ></image>`, height, height);
26
+ };
@@ -0,0 +1,18 @@
1
+ import { Utility } from "@hpcc-js/common";
2
+ import { TextLine, TextProps } from "./text.ts";
3
+
4
+ export const ImageChar = ({
5
+ text = "",
6
+ fill,
7
+ fontFamily = "FontAwesome",
8
+ fontSize = 12
9
+ }: TextProps) => {
10
+ const renderChar = fontFamily === "FontAwesome" ? Utility.faChar(text) : text;
11
+ return TextLine({
12
+ text: renderChar,
13
+ fill,
14
+ fontFamily,
15
+ fontSize,
16
+ dominantBaseline: fontFamily === "FontAwesome" ? "ideographic" : undefined
17
+ });
18
+ };
@@ -0,0 +1,8 @@
1
+ export * from "./annotation.ts";
2
+ export * from "./graphHtml.ts";
3
+ export * from "./icon.ts";
4
+ export * from "./image.ts";
5
+ export * from "./imageChar.ts";
6
+ export * from "./shape.ts";
7
+ export * from "./text.ts";
8
+ export * from "./vertex.ts";
@@ -0,0 +1,136 @@
1
+ import { svg } from "lit-html";
2
+ import { extend } from "./component.ts";
3
+
4
+ export const DEFAULT_SHAPE_SIZE = 32;
5
+
6
+ interface BaseProps {
7
+ fill?: string;
8
+ stroke?: string;
9
+ strokeWidth?: number;
10
+ shapeRendering?: "auto" | "optimizeSpeed" | "crispEdges" | "geometricPrecision";
11
+ }
12
+
13
+ export interface CircleProps extends BaseProps {
14
+ diameter?: number;
15
+ }
16
+ export const circle = ({
17
+ diameter = DEFAULT_SHAPE_SIZE,
18
+ fill = "whiteSmoke",
19
+ stroke = fill,
20
+ strokeWidth = 1,
21
+ shapeRendering = "auto"
22
+ }: CircleProps) => {
23
+ return extend(svg`\
24
+ <circle
25
+ r=${diameter / 2}
26
+ fill=${fill}
27
+ stroke=${stroke}
28
+ stroke-width=${strokeWidth}
29
+ shape-rendering=${shapeRendering}
30
+ />`, diameter, diameter);
31
+ };
32
+
33
+ export interface RectangleProps extends BaseProps {
34
+ width: number;
35
+ height: number;
36
+ cornerRadius?: number;
37
+ }
38
+
39
+ export const rectangle = ({
40
+ width = DEFAULT_SHAPE_SIZE,
41
+ height = DEFAULT_SHAPE_SIZE,
42
+ cornerRadius = 4,
43
+ fill = "whiteSmoke",
44
+ stroke = fill,
45
+ strokeWidth = 1,
46
+ shapeRendering = "crispEdges"
47
+ }: RectangleProps) => {
48
+ return extend(svg`\
49
+ <rect
50
+ x=${-width / 2}
51
+ y=${-height / 2}
52
+ rx=${cornerRadius}
53
+ ry=${cornerRadius}
54
+ width=${width}
55
+ height=${height}
56
+ fill=${fill}
57
+ stroke=${stroke}
58
+ stroke-width=${strokeWidth}
59
+ shape-rendering=${shapeRendering}
60
+ />`, width, height);
61
+ };
62
+
63
+ export interface SquareProps extends BaseProps {
64
+ width?: number;
65
+ cornerRadius?: number;
66
+ }
67
+
68
+ export const square = ({
69
+ width = DEFAULT_SHAPE_SIZE,
70
+ cornerRadius,
71
+ fill,
72
+ stroke,
73
+ strokeWidth,
74
+ shapeRendering
75
+ }: SquareProps) => {
76
+ return rectangle({
77
+ width,
78
+ height: width,
79
+ cornerRadius,
80
+ fill,
81
+ stroke,
82
+ strokeWidth,
83
+ shapeRendering
84
+ });
85
+ };
86
+
87
+ export interface ShapeProps extends BaseProps {
88
+ shape?: "circle" | "square" | "rectangle";
89
+ diameter?: number;
90
+ width?: number;
91
+ height?: number;
92
+ cornerRadius?: number;
93
+ }
94
+
95
+ export const shape = ({
96
+ shape = "circle",
97
+ diameter,
98
+ width,
99
+ height,
100
+ fill,
101
+ stroke,
102
+ strokeWidth = 1,
103
+ shapeRendering = "auto",
104
+ cornerRadius
105
+ }: ShapeProps) => {
106
+ switch (shape) {
107
+ case "square":
108
+ return square({
109
+ width: width ?? height ?? diameter ?? DEFAULT_SHAPE_SIZE,
110
+ fill,
111
+ stroke,
112
+ strokeWidth,
113
+ shapeRendering,
114
+ cornerRadius
115
+ });
116
+ case "rectangle":
117
+ return rectangle({
118
+ width: width ?? height ?? diameter ?? DEFAULT_SHAPE_SIZE,
119
+ height: height ?? width ?? diameter ?? DEFAULT_SHAPE_SIZE,
120
+ fill,
121
+ stroke,
122
+ strokeWidth,
123
+ shapeRendering,
124
+ cornerRadius
125
+ });
126
+ case "circle":
127
+ default:
128
+ return circle({
129
+ diameter: diameter ?? width ?? height ?? DEFAULT_SHAPE_SIZE,
130
+ fill,
131
+ stroke,
132
+ strokeWidth,
133
+ shapeRendering
134
+ });
135
+ }
136
+ };
@@ -0,0 +1,59 @@
1
+ import { svg } from "lit-html";
2
+ import { Utility } from "@hpcc-js/common";
3
+ import { extend } from "./component.ts";
4
+
5
+ export interface TextProps {
6
+ text: string;
7
+ anchor?: "left" | "middle" | "end";
8
+ fill?: string;
9
+ fontFamily?: string;
10
+ fontSize?: number;
11
+ dominantBaseline?: string;
12
+ }
13
+
14
+ export const TextLine = ({
15
+ text,
16
+ anchor = "middle",
17
+ fill = "black",
18
+ fontFamily = "Verdana",
19
+ fontSize = 12,
20
+ dominantBaseline = "middle",
21
+ }: TextProps) => {
22
+ const { width, height } = Utility.textSize(text, fontFamily, fontSize);
23
+ return extend(svg`\
24
+ <text y=${height / 2} font-family=${fontFamily} font-size=${`${fontSize}px`} text-anchor=${anchor} fill=${fill} dominant-baseline=${dominantBaseline}>
25
+ ${text}
26
+ </text>`, width, height);
27
+ };
28
+
29
+ export const Text = ({
30
+ text,
31
+ anchor = "middle",
32
+ fill = "black",
33
+ fontFamily = "Verdana",
34
+ fontSize = 12,
35
+ }: TextProps) => {
36
+ const parts = text.split("\n").map(line => TextLine({ text: line, anchor, fill, fontFamily, fontSize }));
37
+ const { width, height } = parts.reduce((acc, part) => {
38
+ return {
39
+ width: Math.max(acc.width, part.extent.width),
40
+ height: acc.height + part.extent.height
41
+ };
42
+ }, { width: 0, height: 0 });
43
+
44
+ let xOffset = 0;
45
+ if (anchor === "left") {
46
+ xOffset = -width / 2;
47
+ } else if (anchor === "end") {
48
+ xOffset = width / 2;
49
+ }
50
+ const lineHeight = height / parts.length;
51
+ const TextLines = parts.map((p, i) => {
52
+ return svg`\
53
+ <g key=${`key-${i}`} transform="translate(${xOffset} ${-height / 2 + i * lineHeight})">
54
+ ${p}
55
+ </g>`;
56
+ });
57
+
58
+ return extend(svg`${TextLines}`, width, height);
59
+ };
@@ -0,0 +1,41 @@
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}`, rectTpl.extent.width, rectTpl.extent.height);
40
+ };
41
+
@@ -0,0 +1,65 @@
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
+ id,
22
+ text,
23
+ textBox,
24
+ textBoxAnnotationsE = [],
25
+ textBoxAnnotationsSE = [],
26
+ textBoxAnnotationsS = [],
27
+ textBoxAnnotationsOffset = 4,
28
+ icon = {},
29
+ iconOffset = 6,
30
+ iconAnnotations = [],
31
+ iconAnnotationsOffset = 0,
32
+ }: VertexProps) => {
33
+ const iconTpl = litIcon(icon);
34
+ const iconAnnotationsTpl = annotations({
35
+ annotations: iconAnnotations
36
+ });
37
+ const textBoxTpl = TextBox({ text: { text: text, ...textBox?.text } });
38
+ const textBoxAnnotationsETpl = annotations({ annotations: textBoxAnnotationsE });
39
+ const textBoxAnnotationsSETpl = annotations({ annotations: textBoxAnnotationsSE });
40
+ const textBoxAnnotationsSTpl = annotations({ annotations: textBoxAnnotationsS });
41
+
42
+ const yIconOffset = -iconOffset - (textBoxTpl.extent.height + iconTpl.extent.height) / 2;
43
+
44
+ const radius = iconAnnotationsOffset + iconTpl.extent.width / 2;
45
+ const xIconAnnotationOffset = radius * Math.cos(45 * (Math.PI / 180));
46
+ const yIconAnnotationOffset = radius * Math.sin(45 * (Math.PI / 180));
47
+ return extend(svg`\
48
+ ${textBoxTpl}
49
+ <g transform="translate(${textBoxTpl.extent.width / 2 + textBoxAnnotationsOffset + textBoxAnnotationsETpl.extent.width / 2})">
50
+ ${textBoxAnnotationsETpl}
51
+ </g>
52
+ <g transform="translate(${textBoxTpl.extent.width / 2 + textBoxAnnotationsOffset + textBoxAnnotationsETpl.extent.width / 2} ${textBoxTpl.extent.height / 2 + textBoxAnnotationsOffset + textBoxAnnotationsSETpl.extent.height / 2})">
53
+ ${textBoxAnnotationsSETpl}
54
+ </g>
55
+ <g transform="translate(0 ${textBoxTpl.extent.height / 2 + textBoxAnnotationsOffset + textBoxAnnotationsSTpl.extent.height / 2})">
56
+ ${textBoxAnnotationsSTpl}
57
+ </g>
58
+ <g data-click="icon" data-click-data=${JSON.stringify(icon)} transform="translate(0 ${yIconOffset})">
59
+ ${iconTpl}
60
+ </g>
61
+ <g transform="translate(${iconAnnotationsTpl.extent.width / 2 + xIconAnnotationOffset} ${yIconOffset - yIconAnnotationOffset})">
62
+ ${iconAnnotationsTpl}
63
+ </g>
64
+ `, textBoxTpl.extent.width, textBoxTpl.extent.height);
65
+ };
package/src/index.ts CHANGED
@@ -5,4 +5,6 @@ export * from "./Graph.ts";
5
5
  export * from "./Sankey.ts";
6
6
  export * from "./Subgraph.ts";
7
7
  export * from "./Vertex.ts";
8
- export * from "./graph2/index.ts";
8
+ export * from "./common/index.ts";
9
+ export * from "./html/index.ts";
10
+ export * from "./react/index.ts";
@@ -1,8 +1,8 @@
1
1
  import { PropertyExt, Widget } from "@hpcc-js/common";
2
2
  import { Vertex3, CentroidVertex3, Vertex3Props, EdgeProps, SubgraphProps } from "@hpcc-js/react";
3
3
  import { compare2 } from "@hpcc-js/util";
4
- import { Graph2 } from "./graph.ts";
5
- import { HierarchyBase } from "./layouts/placeholders.ts";
4
+ import { GraphReact } from "./graphReact.ts";
5
+ import { HierarchyBase } from "../common/layouts/placeholders.ts";
6
6
 
7
7
  // Backward compatibility layer ---
8
8
  export type IVertex3 = Vertex3Props;
@@ -20,7 +20,7 @@ export class AnnotationColumn extends PropertyExt {
20
20
  owner(_: DataGraph): this;
21
21
  owner(_?: DataGraph): DataGraph | this {
22
22
  if (!arguments.length) return this._owner;
23
- this._owner = _;
23
+ this._owner = _!;
24
24
  return this;
25
25
  }
26
26
 
@@ -40,7 +40,7 @@ export interface AnnotationColumn {
40
40
  AnnotationColumn.prototype.publish("columnID", "", "set", "Annotation column (boolean)", function (this: AnnotationColumn) { return this._owner.vertexColumns(); });
41
41
  AnnotationColumn.prototype.publish("annotationID", "", "string", "Annotation ID");
42
42
 
43
- export class DataGraph extends Graph2 {
43
+ export class DataGraph extends GraphReact {
44
44
 
45
45
  constructor() {
46
46
  super();
@@ -311,13 +311,13 @@ export interface DataGraph {
311
311
  hierarchyChildIDColumn(_: string): this;
312
312
  }
313
313
 
314
- DataGraph.prototype.publish("subgraphColumns", [], "any", "Subgraph Columns", null, { internal: true });
315
- DataGraph.prototype.publish("subgraphs", [], "any", "Subgraphs", null, { internal: true });
314
+ DataGraph.prototype.publish("subgraphColumns", [], "any", "Subgraph Columns", undefined, { internal: true });
315
+ DataGraph.prototype.publish("subgraphs", [], "any", "Subgraphs", undefined, { internal: true });
316
316
  DataGraph.prototype.publish("subgraphIDColumn", "", "string", "Subgraph ID column");
317
317
  DataGraph.prototype.publish("subgraphLabelColumn", "", "string", "Subgraph Label column");
318
318
 
319
- DataGraph.prototype.publish("vertexColumns", [], "any", "Vertex Columns", null, { internal: true });
320
- DataGraph.prototype.publish("vertices", [], "any", "Vertices (Nodes)", null, { internal: true });
319
+ DataGraph.prototype.publish("vertexColumns", [], "any", "Vertex Columns", undefined, { internal: true });
320
+ DataGraph.prototype.publish("vertices", [], "any", "Vertices (Nodes)", undefined, { internal: true });
321
321
  DataGraph.prototype.publish("vertexCategoryColumn", "", "set", "Vertex Category ID column", function (this: DataGraph) { return this.vertexColumns(); }, { optional: true });
322
322
  DataGraph.prototype.publish("vertexIDColumn", "", "set", "Vertex ID column", function (this: DataGraph) { return this.vertexColumns(); }, { optional: true });
323
323
  DataGraph.prototype.publish("vertexLabelColumn", "", "set", "Vertex label column", function (this: DataGraph) { return this.vertexColumns(); }, { optional: true });
@@ -327,11 +327,11 @@ DataGraph.prototype.publish("vertexImageUrlColumn", "", "set", "Vertex image url
327
327
  DataGraph.prototype.publish("vertexFAChar", "?", "string", "Vertex default FAChar");
328
328
  DataGraph.prototype.publish("vertexFACharColumn", "", "set", "Vertex FAChar column", function (this: DataGraph) { return this.vertexColumns(); }, { optional: true });
329
329
  DataGraph.prototype.publish("vertexTooltipColumn", "", "set", "Vertex tooltip column", function (this: DataGraph) { return this.vertexColumns(); }, { optional: true });
330
- DataGraph.prototype.publish("vertexAnnotationColumns", [], "propertyArray", "Annotations", null, { autoExpand: AnnotationColumn });
330
+ DataGraph.prototype.publish("vertexAnnotationColumns", [], "propertyArray", "Annotations", undefined, { autoExpand: AnnotationColumn });
331
331
  DataGraph.prototype.publish("vertexExpansionFACharColumn", "", "set", "Vertex expansion FAChar column", function (this: DataGraph) { return this.vertexColumns(); }, { optional: true });
332
332
 
333
- DataGraph.prototype.publish("edgeColumns", [], "any", "Edge columns", null, { internal: true });
334
- DataGraph.prototype.publish("edges", [], "any", "Edges (Edges)", null, { internal: true });
333
+ DataGraph.prototype.publish("edgeColumns", [], "any", "Edge columns", undefined, { internal: true });
334
+ DataGraph.prototype.publish("edges", [], "any", "Edges (Edges)", undefined, { internal: true });
335
335
  DataGraph.prototype.publish("edgeIDColumn", "", "set", "Edge ID column", function (this: DataGraph) { return this.edgeColumns(); }, { optional: true });
336
336
  DataGraph.prototype.publish("edgeLabelColumn", "", "set", "Edge label column", function (this: DataGraph) { return this.edgeColumns(); }, { optional: true });
337
337
  DataGraph.prototype.publish("edgeSourceColumn", "", "set", "Edge source ID column", function (this: DataGraph) { return this.edgeColumns(); }, { optional: true });