@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.
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-CjmNyQgU.js.map → graphviz-DQ0E8zfY.js.map} +1 -1
  5. package/dist/index.js +2 -2
  6. package/dist/index.js.map +1 -1
  7. package/dist/index.umd.cjs +2 -2
  8. package/dist/index.umd.cjs.map +1 -1
  9. package/package.json +8 -8
  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 +46 -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,177 +1,177 @@
1
- import { IconEx, Icons, render } from "@hpcc-js/react";
2
- import { React, Subgraph, SubgraphProps, Vertex, VertexProps, Edge, EdgeProps } from "@hpcc-js/react";
3
- import { GraphReactT } from "./graphReactT.ts";
4
- import { GraphDataProps, HierarchyBase } from "../common/graphT.ts";
5
-
6
- // Backward compatibility layer ---
7
- export type ISubgraph = SubgraphProps;
8
- export type IVertex = VertexProps;
9
- export type IEdge = EdgeProps;
10
- export type IHierarchy = HierarchyBase<ISubgraph, IVertex>;
11
- export type IGraphData2 = GraphDataProps<ISubgraph, IVertex, IEdge>;
12
-
13
- export class GraphReact extends GraphReactT<ISubgraph, IVertex, IEdge> {
14
-
15
- constructor() {
16
- super(Subgraph, Vertex, Edge);
17
- this._reactCentroidRenderer = Vertex;
18
- this._reactVertexRenderer2 = Vertex;
19
- super.vertexRenderer((props) => {
20
- return props.centroid ? this._reactCentroidRenderer(props) : this._reactVertexRenderer2(props);
21
- });
22
- }
23
-
24
- protected _categories: IconEx[] = [];
25
- categories(): IconEx[];
26
- categories(_: IconEx[]): this;
27
- categories(_?: IconEx[]): IconEx[] | this {
28
- if (_ === void 0) return this._categories;
29
- this._categories = _;
30
- return this;
31
- }
32
-
33
- protected _annotations: IconEx[] = [];
34
- annotations(): IconEx[];
35
- annotations(_: IconEx[]): this;
36
- annotations(_?: IconEx[]): IconEx[] | this {
37
- if (_ === void 0) return this._annotations;
38
- this._annotations = _;
39
- return this;
40
- }
41
-
42
- calcProps(_props: VertexProps): VertexProps {
43
- const props = super.calcProps(_props);
44
- if (!props.icon) props.icon = {};
45
- if (props.centroid) {
46
- props.textHeight = props.textHeight ? props.textHeight : this.centroidTextHeight() * this.centroidScale();
47
- props.textPadding = props.textPadding ? props.textPadding : this.centroidTextPadding() * this.centroidScale();
48
- props.textFontFamily = props.textFontFamily ? props.textFontFamily : this.centroidLabelFontFamily();
49
- props.icon.height = props.icon.height ? props.icon.height : this.centroidIconHeight() * this.centroidScale();
50
- props.icon.padding = props.icon.padding ? props.icon.padding : this.centroidIconPadding() * this.centroidScale();
51
- props.icon.strokeWidth = props.icon.strokeWidth ? props.icon.strokeWidth : this.centroidIconStrokeWidth();
52
- props.icon.imageFontFamily = props.icon.imageFontFamily ? props.icon.imageFontFamily : this.centroidIconFontFamily();
53
- } else {
54
- props.textHeight = props.textHeight ? props.textHeight : this.vertexTextHeight();
55
- props.textPadding = props.textPadding ? props.textPadding : this.vertexTextPadding();
56
- props.textFontFamily = props.textFontFamily ? props.textFontFamily : this.vertexLabelFontFamily();
57
- props.icon.height = props.icon.height ? props.icon.height : this.vertexIconHeight();
58
- props.icon.padding = props.icon.padding ? props.icon.padding : this.vertexIconPadding();
59
- props.icon.strokeWidth = props.icon.strokeWidth ? props.icon.strokeWidth : this.vertexIconStrokeWidth();
60
- props.icon.imageFontFamily = props.icon.imageFontFamily ? props.icon.imageFontFamily : this.vertexIconFontFamily();
61
- }
62
- const text = props.icon.imageChar;
63
- const fontFamily = props.icon.imageFontFamily;
64
- const fontSize = props.icon.height - props.icon.padding;
65
- const rect = this.textRect(text, fontFamily, fontSize);
66
-
67
- props.icon.yOffset = -(rect.top - (fontSize / 2)) - (rect.height / 2) + (props.icon.padding > 0 ? fontSize / props.icon.padding / 2 : 0);
68
- return props;
69
- }
70
-
71
- protected _reactVertexRenderer2: React.FunctionComponent<any>;
72
- vertexRenderer<T extends VertexProps>(): React.FunctionComponent<T>;
73
- vertexRenderer<T extends VertexProps>(_: React.FunctionComponent<T>): this;
74
- vertexRenderer<T extends VertexProps>(_?: React.FunctionComponent<T>): this | React.FunctionComponent<T> {
75
- if (!arguments.length) return this._reactVertexRenderer2;
76
- this._reactVertexRenderer2 = _;
77
- return this;
78
- }
79
-
80
- protected _reactCentroidRenderer: React.FunctionComponent<any>;
81
- centroidRenderer<T extends VertexProps>(): React.FunctionComponent<T>;
82
- centroidRenderer<T extends VertexProps>(_: React.FunctionComponent<T>): this;
83
- centroidRenderer<T extends VertexProps>(_?: React.FunctionComponent<T>): this | React.FunctionComponent<T> {
84
- if (!arguments.length) return this._reactCentroidRenderer;
85
- this._reactCentroidRenderer = _;
86
- return this;
87
- }
88
-
89
- enter(domNode, element) {
90
- super.enter(domNode, element);
91
- }
92
-
93
- updateCategories() {
94
- render(Icons, {
95
- icons: this._categories.map((c): IconEx => ({
96
- ...c,
97
- id: this.categoryID(c.id),
98
- fill: c.fill || "transparent",
99
- imageCharFill: c.imageCharFill || this._catPalette(c.id)
100
- }))
101
- }, this._svgDefsCat.node());
102
- }
103
-
104
- updateAnnotations() {
105
- render(Icons, {
106
- icons: this._annotations.map((c): IconEx => ({
107
- ...c,
108
- id: this.categoryID(c.id, "ann"),
109
- shape: c.shape || "square",
110
- height: c.height || 12,
111
- fill: c.fill || this._catPalette(c.id)
112
- }))
113
- }, this._svgDefsAnn.node());
114
- }
115
-
116
- update(domNode, element) {
117
- super.update(domNode, element);
118
- this._centroidFilter.update(this.centroidColor());
119
- }
120
- }
121
- GraphReact.prototype._class += " graph_GraphReact";
122
-
123
- export interface GraphReact {
124
- vertexTextHeight(): number;
125
- vertexTextHeight(_: number): this;
126
- vertexTextPadding(): number;
127
- vertexTextPadding(_: number): this;
128
- vertexIconHeight(): number;
129
- vertexIconHeight(_: number): this;
130
- vertexIconPadding(): number;
131
- vertexIconPadding(_: number): this;
132
- vertexIconStrokeWidth(): number;
133
- vertexIconStrokeWidth(_: number): this;
134
- vertexIconFontFamily(): string;
135
- vertexIconFontFamily(_: string): this;
136
- vertexLabelFontFamily(): string;
137
- vertexLabelFontFamily(_: string): this;
138
-
139
- centroidColor(): string;
140
- centroidColor(_: string): this;
141
- centroidScale(): number;
142
- centroidScale(_: number): this;
143
- centroidTextHeight(): number;
144
- centroidTextHeight(_: number): this;
145
- centroidTextPadding(): number;
146
- centroidTextPadding(_: number): this;
147
- centroidIconHeight(): number;
148
- centroidIconHeight(_: number): this;
149
- centroidIconPadding(): number;
150
- centroidIconPadding(_: number): this;
151
- centroidIconStrokeWidth(): number;
152
- centroidIconStrokeWidth(_: number): this;
153
- centroidIconFontFamily(): string;
154
- centroidIconFontFamily(_: string): this;
155
- centroidLabelFontFamily(): string;
156
- centroidLabelFontFamily(_: string): this;
157
- }
158
-
159
- GraphReact.prototype.publish("vertexTextHeight", 10, "number", "Vertex Text Height");
160
- GraphReact.prototype.publish("vertexTextPadding", 4, "number", "Vertex Text Padding");
161
- GraphReact.prototype.publish("vertexIconHeight", 50, "number", "Vertex Icon Height");
162
- GraphReact.prototype.publish("vertexIconPadding", 10, "number", "Vertex Icon Padding");
163
- GraphReact.prototype.publish("vertexIconStrokeWidth", 0, "number", "Vertex Icon Stroke Width");
164
- GraphReact.prototype.publish("vertexIconFontFamily", "FontAwesome", "string", "Vertex Icon Font Family");
165
- GraphReact.prototype.publish("vertexLabelFontFamily", "Verdana", "string", "Vertex Label Font Family");
166
-
167
- GraphReact.prototype.publish("centroidColor", "#00A000", "html-color", "Centroid Glow Color");
168
- GraphReact.prototype.publish("centroidScale", 1, "number", "Centroid Scale");
169
- GraphReact.prototype.publish("centroidTextHeight", 12, "number", "Centroid Text Height");
170
- GraphReact.prototype.publish("centroidTextPadding", 4, "number", "Centroid Text Padding");
171
- GraphReact.prototype.publish("centroidIconHeight", 50, "number", "Centroid Icon Height");
172
- GraphReact.prototype.publish("centroidIconPadding", 10, "number", "Centroid Icon Padding");
173
- GraphReact.prototype.publish("centroidIconStrokeWidth", 4, "number", "Centroid Icon Stroke Width");
174
- GraphReact.prototype.publish("centroidIconFontFamily", "FontAwesome", "string", "Centroid Icon Font Family");
175
- GraphReact.prototype.publish("centroidLabelFontFamily", "Verdana", "string", "Centroid Label Font Family");
176
-
177
- export const Graph2 = GraphReact;
1
+ import { IconEx, Icons, render } from "@hpcc-js/react";
2
+ import { React, Subgraph, SubgraphProps, Vertex, VertexProps, Edge, EdgeProps } from "@hpcc-js/react";
3
+ import { GraphReactT } from "./graphReactT.ts";
4
+ import { GraphDataProps, HierarchyBase } from "../common/graphT.ts";
5
+
6
+ // Backward compatibility layer ---
7
+ export type ISubgraph = SubgraphProps;
8
+ export type IVertex = VertexProps;
9
+ export type IEdge = EdgeProps;
10
+ export type IHierarchy = HierarchyBase<ISubgraph, IVertex>;
11
+ export type IGraphData2 = GraphDataProps<ISubgraph, IVertex, IEdge>;
12
+
13
+ export class GraphReact extends GraphReactT<ISubgraph, IVertex, IEdge> {
14
+
15
+ constructor() {
16
+ super(Subgraph, Vertex, Edge);
17
+ this._reactCentroidRenderer = Vertex;
18
+ this._reactVertexRenderer2 = Vertex;
19
+ super.vertexRenderer((props) => {
20
+ return props.centroid ? this._reactCentroidRenderer(props) : this._reactVertexRenderer2(props);
21
+ });
22
+ }
23
+
24
+ protected _categories: IconEx[] = [];
25
+ categories(): IconEx[];
26
+ categories(_: IconEx[]): this;
27
+ categories(_?: IconEx[]): IconEx[] | this {
28
+ if (_ === void 0) return this._categories;
29
+ this._categories = _;
30
+ return this;
31
+ }
32
+
33
+ protected _annotations: IconEx[] = [];
34
+ annotations(): IconEx[];
35
+ annotations(_: IconEx[]): this;
36
+ annotations(_?: IconEx[]): IconEx[] | this {
37
+ if (_ === void 0) return this._annotations;
38
+ this._annotations = _;
39
+ return this;
40
+ }
41
+
42
+ calcProps(_props: VertexProps): VertexProps {
43
+ const props = super.calcProps(_props);
44
+ if (!props.icon) props.icon = {};
45
+ if (props.centroid) {
46
+ props.textHeight = props.textHeight ? props.textHeight : this.centroidTextHeight() * this.centroidScale();
47
+ props.textPadding = props.textPadding ? props.textPadding : this.centroidTextPadding() * this.centroidScale();
48
+ props.textFontFamily = props.textFontFamily ? props.textFontFamily : this.centroidLabelFontFamily();
49
+ props.icon.height = props.icon.height ? props.icon.height : this.centroidIconHeight() * this.centroidScale();
50
+ props.icon.padding = props.icon.padding ? props.icon.padding : this.centroidIconPadding() * this.centroidScale();
51
+ props.icon.strokeWidth = props.icon.strokeWidth ? props.icon.strokeWidth : this.centroidIconStrokeWidth();
52
+ props.icon.imageFontFamily = props.icon.imageFontFamily ? props.icon.imageFontFamily : this.centroidIconFontFamily();
53
+ } else {
54
+ props.textHeight = props.textHeight ? props.textHeight : this.vertexTextHeight();
55
+ props.textPadding = props.textPadding ? props.textPadding : this.vertexTextPadding();
56
+ props.textFontFamily = props.textFontFamily ? props.textFontFamily : this.vertexLabelFontFamily();
57
+ props.icon.height = props.icon.height ? props.icon.height : this.vertexIconHeight();
58
+ props.icon.padding = props.icon.padding ? props.icon.padding : this.vertexIconPadding();
59
+ props.icon.strokeWidth = props.icon.strokeWidth ? props.icon.strokeWidth : this.vertexIconStrokeWidth();
60
+ props.icon.imageFontFamily = props.icon.imageFontFamily ? props.icon.imageFontFamily : this.vertexIconFontFamily();
61
+ }
62
+ const text = props.icon.imageChar;
63
+ const fontFamily = props.icon.imageFontFamily;
64
+ const fontSize = props.icon.height - props.icon.padding;
65
+ const rect = this.textRect(text, fontFamily, fontSize);
66
+
67
+ props.icon.yOffset = -(rect.top - (fontSize / 2)) - (rect.height / 2) + (props.icon.padding > 0 ? fontSize / props.icon.padding / 2 : 0);
68
+ return props;
69
+ }
70
+
71
+ protected _reactVertexRenderer2: React.FunctionComponent<any>;
72
+ vertexRenderer<T extends VertexProps>(): React.FunctionComponent<T>;
73
+ vertexRenderer<T extends VertexProps>(_: React.FunctionComponent<T>): this;
74
+ vertexRenderer<T extends VertexProps>(_?: React.FunctionComponent<T>): this | React.FunctionComponent<T> {
75
+ if (!arguments.length) return this._reactVertexRenderer2;
76
+ this._reactVertexRenderer2 = _;
77
+ return this;
78
+ }
79
+
80
+ protected _reactCentroidRenderer: React.FunctionComponent<any>;
81
+ centroidRenderer<T extends VertexProps>(): React.FunctionComponent<T>;
82
+ centroidRenderer<T extends VertexProps>(_: React.FunctionComponent<T>): this;
83
+ centroidRenderer<T extends VertexProps>(_?: React.FunctionComponent<T>): this | React.FunctionComponent<T> {
84
+ if (!arguments.length) return this._reactCentroidRenderer;
85
+ this._reactCentroidRenderer = _;
86
+ return this;
87
+ }
88
+
89
+ enter(domNode, element) {
90
+ super.enter(domNode, element);
91
+ }
92
+
93
+ updateCategories() {
94
+ render(Icons, {
95
+ icons: this._categories.map((c): IconEx => ({
96
+ ...c,
97
+ id: this.categoryID(c.id),
98
+ fill: c.fill || "transparent",
99
+ imageCharFill: c.imageCharFill || this._catPalette(c.id)
100
+ }))
101
+ }, this._svgDefsCat.node());
102
+ }
103
+
104
+ updateAnnotations() {
105
+ render(Icons, {
106
+ icons: this._annotations.map((c): IconEx => ({
107
+ ...c,
108
+ id: this.categoryID(c.id, "ann"),
109
+ shape: c.shape || "square",
110
+ height: c.height || 12,
111
+ fill: c.fill || this._catPalette(c.id)
112
+ }))
113
+ }, this._svgDefsAnn.node());
114
+ }
115
+
116
+ update(domNode, element) {
117
+ super.update(domNode, element);
118
+ this._centroidFilter.update(this.centroidColor());
119
+ }
120
+ }
121
+ GraphReact.prototype._class += " graph_GraphReact";
122
+
123
+ export interface GraphReact {
124
+ vertexTextHeight(): number;
125
+ vertexTextHeight(_: number): this;
126
+ vertexTextPadding(): number;
127
+ vertexTextPadding(_: number): this;
128
+ vertexIconHeight(): number;
129
+ vertexIconHeight(_: number): this;
130
+ vertexIconPadding(): number;
131
+ vertexIconPadding(_: number): this;
132
+ vertexIconStrokeWidth(): number;
133
+ vertexIconStrokeWidth(_: number): this;
134
+ vertexIconFontFamily(): string;
135
+ vertexIconFontFamily(_: string): this;
136
+ vertexLabelFontFamily(): string;
137
+ vertexLabelFontFamily(_: string): this;
138
+
139
+ centroidColor(): string;
140
+ centroidColor(_: string): this;
141
+ centroidScale(): number;
142
+ centroidScale(_: number): this;
143
+ centroidTextHeight(): number;
144
+ centroidTextHeight(_: number): this;
145
+ centroidTextPadding(): number;
146
+ centroidTextPadding(_: number): this;
147
+ centroidIconHeight(): number;
148
+ centroidIconHeight(_: number): this;
149
+ centroidIconPadding(): number;
150
+ centroidIconPadding(_: number): this;
151
+ centroidIconStrokeWidth(): number;
152
+ centroidIconStrokeWidth(_: number): this;
153
+ centroidIconFontFamily(): string;
154
+ centroidIconFontFamily(_: string): this;
155
+ centroidLabelFontFamily(): string;
156
+ centroidLabelFontFamily(_: string): this;
157
+ }
158
+
159
+ GraphReact.prototype.publish("vertexTextHeight", 10, "number", "Vertex Text Height");
160
+ GraphReact.prototype.publish("vertexTextPadding", 4, "number", "Vertex Text Padding");
161
+ GraphReact.prototype.publish("vertexIconHeight", 50, "number", "Vertex Icon Height");
162
+ GraphReact.prototype.publish("vertexIconPadding", 10, "number", "Vertex Icon Padding");
163
+ GraphReact.prototype.publish("vertexIconStrokeWidth", 0, "number", "Vertex Icon Stroke Width");
164
+ GraphReact.prototype.publish("vertexIconFontFamily", "FontAwesome", "string", "Vertex Icon Font Family");
165
+ GraphReact.prototype.publish("vertexLabelFontFamily", "Verdana", "string", "Vertex Label Font Family");
166
+
167
+ GraphReact.prototype.publish("centroidColor", "#00A000", "html-color", "Centroid Glow Color");
168
+ GraphReact.prototype.publish("centroidScale", 1, "number", "Centroid Scale");
169
+ GraphReact.prototype.publish("centroidTextHeight", 12, "number", "Centroid Text Height");
170
+ GraphReact.prototype.publish("centroidTextPadding", 4, "number", "Centroid Text Padding");
171
+ GraphReact.prototype.publish("centroidIconHeight", 50, "number", "Centroid Icon Height");
172
+ GraphReact.prototype.publish("centroidIconPadding", 10, "number", "Centroid Icon Padding");
173
+ GraphReact.prototype.publish("centroidIconStrokeWidth", 4, "number", "Centroid Icon Stroke Width");
174
+ GraphReact.prototype.publish("centroidIconFontFamily", "FontAwesome", "string", "Centroid Icon Font Family");
175
+ GraphReact.prototype.publish("centroidLabelFontFamily", "Verdana", "string", "Centroid Label Font Family");
176
+
177
+ export const Graph2 = GraphReact;
@@ -1,44 +1,44 @@
1
- import { render, React, SubgraphProps, VertexProps, EdgeProps } from "@hpcc-js/react";
2
- import { GraphT, RendererT } from "../common/graphT.ts";
3
-
4
- function adapter<T>(reactRenderer: React.FunctionComponent<T>): RendererT<T> {
5
- return (props: T, element: SVGGElement) => render(reactRenderer, props, element);
6
- }
7
-
8
- export class GraphReactT<SG extends SubgraphProps, V extends VertexProps, E extends EdgeProps<V>> extends GraphT<SG, V, E> {
9
-
10
- constructor(subgraphRenderer: React.FunctionComponent<SG>, vertexRenderer: React.FunctionComponent<V>, edgeRenderer: React.FunctionComponent<E>) {
11
- super(adapter(subgraphRenderer), adapter(vertexRenderer), adapter(edgeRenderer));
12
- }
13
-
14
- private _reactSubgraphRenderer: React.FunctionComponent<SG>;
15
- subgraphRenderer(): React.FunctionComponent<SG>;
16
- subgraphRenderer(_: React.FunctionComponent<SG>): this;
17
- subgraphRenderer(_?: React.FunctionComponent<SG>): this | React.FunctionComponent<SG> {
18
- if (!arguments.length) return this._reactSubgraphRenderer;
19
- this._reactSubgraphRenderer = _;
20
- super.subgraphRenderer(adapter(this._reactSubgraphRenderer));
21
- return this;
22
- }
23
-
24
- private _reactVertexRenderer: React.FunctionComponent<V>;
25
- vertexRenderer(): React.FunctionComponent<V>;
26
- vertexRenderer(_: React.FunctionComponent<V>): this;
27
- vertexRenderer(_?: React.FunctionComponent<V>): this | React.FunctionComponent<V> {
28
- if (!arguments.length) return this._reactVertexRenderer;
29
- this._reactVertexRenderer = _;
30
- super.vertexRenderer((props: V, element: SVGGElement) => render(this._reactVertexRenderer, props, element));
31
- return this;
32
- }
33
-
34
- private _reactEdgeRenderer: React.FunctionComponent<E>;
35
- edgeRenderer(): React.FunctionComponent<E>;
36
- edgeRenderer(_: React.FunctionComponent<E>): this;
37
- edgeRenderer(_?: React.FunctionComponent<E>): this | React.FunctionComponent<E> {
38
- if (!arguments.length) return this._reactEdgeRenderer;
39
- this._reactEdgeRenderer = _;
40
- super.edgeRenderer((props: E, element: SVGGElement) => render(this._reactEdgeRenderer, props, element));
41
- return this;
42
- }
43
- }
44
- GraphReactT.prototype._class += " graph_GraphReactT";
1
+ import { render, React, SubgraphProps, VertexProps, EdgeProps } from "@hpcc-js/react";
2
+ import { GraphT, RendererT } from "../common/graphT.ts";
3
+
4
+ function adapter<T>(reactRenderer: React.FunctionComponent<T>): RendererT<T> {
5
+ return (props: T, element: SVGGElement) => render(reactRenderer, props, element);
6
+ }
7
+
8
+ export class GraphReactT<SG extends SubgraphProps, V extends VertexProps, E extends EdgeProps<V>> extends GraphT<SG, V, E> {
9
+
10
+ constructor(subgraphRenderer: React.FunctionComponent<SG>, vertexRenderer: React.FunctionComponent<V>, edgeRenderer: React.FunctionComponent<E>) {
11
+ super(adapter(subgraphRenderer), adapter(vertexRenderer), adapter(edgeRenderer));
12
+ }
13
+
14
+ private _reactSubgraphRenderer: React.FunctionComponent<SG>;
15
+ subgraphRenderer(): React.FunctionComponent<SG>;
16
+ subgraphRenderer(_: React.FunctionComponent<SG>): this;
17
+ subgraphRenderer(_?: React.FunctionComponent<SG>): this | React.FunctionComponent<SG> {
18
+ if (!arguments.length) return this._reactSubgraphRenderer;
19
+ this._reactSubgraphRenderer = _;
20
+ super.subgraphRenderer(adapter(this._reactSubgraphRenderer));
21
+ return this;
22
+ }
23
+
24
+ private _reactVertexRenderer: React.FunctionComponent<V>;
25
+ vertexRenderer(): React.FunctionComponent<V>;
26
+ vertexRenderer(_: React.FunctionComponent<V>): this;
27
+ vertexRenderer(_?: React.FunctionComponent<V>): this | React.FunctionComponent<V> {
28
+ if (!arguments.length) return this._reactVertexRenderer;
29
+ this._reactVertexRenderer = _;
30
+ super.vertexRenderer((props: V, element: SVGGElement) => render(this._reactVertexRenderer, props, element));
31
+ return this;
32
+ }
33
+
34
+ private _reactEdgeRenderer: React.FunctionComponent<E>;
35
+ edgeRenderer(): React.FunctionComponent<E>;
36
+ edgeRenderer(_: React.FunctionComponent<E>): this;
37
+ edgeRenderer(_?: React.FunctionComponent<E>): this | React.FunctionComponent<E> {
38
+ if (!arguments.length) return this._reactEdgeRenderer;
39
+ this._reactEdgeRenderer = _;
40
+ super.edgeRenderer((props: E, element: SVGGElement) => render(this._reactEdgeRenderer, props, element));
41
+ return this;
42
+ }
43
+ }
44
+ GraphReactT.prototype._class += " graph_GraphReactT";
@@ -1,4 +1,4 @@
1
- export * from "./graphReactT.ts";
2
- export * from "./graphReact.ts";
3
- export * from "./subgraph.tsx";
4
- export * from "./vertex.tsx";
1
+ export * from "./graphReactT.ts";
2
+ export * from "./graphReact.ts";
3
+ export * from "./subgraph.tsx";
4
+ export * from "./vertex.tsx";
@@ -1,30 +1,30 @@
1
- import { React, Text } from "@hpcc-js/react";
2
- import { SubgraphBaseProps } from "../common/layouts/placeholders.ts";
3
-
4
- export interface BasicSubgraphProps extends SubgraphBaseProps {
5
- label?: string;
6
- labelFill?: string;
7
- labelHeight?: number,
8
- rectFill?: string;
9
- rectStroke?: string;
10
- rectStrokeWidth?: number;
11
- }
12
-
13
- export const BasicSubgraph: React.FunctionComponent<BasicSubgraphProps> = ({
14
- label = "",
15
- labelFill = "black",
16
- labelHeight = 12,
17
- width = 0,
18
- height = 0,
19
- rectFill: fill,
20
- rectStroke: stroke = "#627ae7",
21
- rectStrokeWidth: strokeWidth = 2
22
- }) => {
23
- return <g transform={`translate(${-width / 2} ${-height / 2})`}>
24
- <rect width={width} height={height} fill={fill} stroke={stroke} style={{ strokeWidth }} />
25
- <g transform={`translate(8 ${8 + labelHeight})`}>
26
- {/* @ts-ignore */}
27
- <Text text={label} fill={labelFill} height={labelHeight} />
28
- </g>
29
- </g>;
30
- };
1
+ import { React, Text } from "@hpcc-js/react";
2
+ import { SubgraphBaseProps } from "../common/layouts/placeholders.ts";
3
+
4
+ export interface BasicSubgraphProps extends SubgraphBaseProps {
5
+ label?: string;
6
+ labelFill?: string;
7
+ labelHeight?: number,
8
+ rectFill?: string;
9
+ rectStroke?: string;
10
+ rectStrokeWidth?: number;
11
+ }
12
+
13
+ export const BasicSubgraph: React.FunctionComponent<BasicSubgraphProps> = ({
14
+ label = "",
15
+ labelFill = "black",
16
+ labelHeight = 12,
17
+ width = 0,
18
+ height = 0,
19
+ rectFill: fill,
20
+ rectStroke: stroke = "#627ae7",
21
+ rectStrokeWidth: strokeWidth = 2
22
+ }) => {
23
+ return <g transform={`translate(${-width / 2} ${-height / 2})`}>
24
+ <rect width={width} height={height} fill={fill} stroke={stroke} style={{ strokeWidth }} />
25
+ <g transform={`translate(8 ${8 + labelHeight})`}>
26
+ {/* @ts-ignore */}
27
+ <Text text={label} fill={labelFill} height={labelHeight} />
28
+ </g>
29
+ </g>;
30
+ };
@@ -1,31 +1,31 @@
1
- import { React, Text } from "@hpcc-js/react";
2
- import { VertexBaseProps } from "../common/layouts/placeholders.ts";
3
-
4
- export interface BasicVertexProps extends VertexBaseProps {
5
- textFill?: string;
6
- textHeight?: number,
7
- scale?: number,
8
- circleRadius?: number,
9
- circleFill?: string,
10
- circleStroke?: string,
11
- circleStrokeWidth?: number
12
- }
13
-
14
- export const BasicVertex: React.FunctionComponent<BasicVertexProps> = ({
15
- text,
16
- textFill = "black",
17
- textHeight = 12,
18
- scale = 1,
19
- circleRadius = 16,
20
- circleFill = "#a2bcf9",
21
- circleStroke = "#627ae7",
22
- circleStrokeWidth = 2
23
- }) => {
24
- return <g transform={`scale(${scale})`}>
25
- <circle cx="0" cy="0" r={circleRadius} fill={circleFill} stroke={circleStroke} style={{ strokeWidth: circleStrokeWidth }} />
26
- <g transform={`translate(0 ${circleRadius + textHeight})`}>
27
- {/* @ts-ignore */}
28
- <Text text={text} fill={textFill} height={textHeight} />
29
- </g>
30
- </g>;
31
- };
1
+ import { React, Text } from "@hpcc-js/react";
2
+ import { VertexBaseProps } from "../common/layouts/placeholders.ts";
3
+
4
+ export interface BasicVertexProps extends VertexBaseProps {
5
+ textFill?: string;
6
+ textHeight?: number,
7
+ scale?: number,
8
+ circleRadius?: number,
9
+ circleFill?: string,
10
+ circleStroke?: string,
11
+ circleStrokeWidth?: number
12
+ }
13
+
14
+ export const BasicVertex: React.FunctionComponent<BasicVertexProps> = ({
15
+ text,
16
+ textFill = "black",
17
+ textHeight = 12,
18
+ scale = 1,
19
+ circleRadius = 16,
20
+ circleFill = "#a2bcf9",
21
+ circleStroke = "#627ae7",
22
+ circleStrokeWidth = 2
23
+ }) => {
24
+ return <g transform={`scale(${scale})`}>
25
+ <circle cx="0" cy="0" r={circleRadius} fill={circleFill} stroke={circleStroke} style={{ strokeWidth: circleStrokeWidth }} />
26
+ <g transform={`translate(0 ${circleRadius + textHeight})`}>
27
+ {/* @ts-ignore */}
28
+ <Text text={text} fill={textFill} height={textHeight} />
29
+ </g>
30
+ </g>;
31
+ };