@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/Vertex.ts
CHANGED
|
@@ -1,282 +1,282 @@
|
|
|
1
|
-
import { Icon, SVGWidget, TextBox } from "@hpcc-js/common";
|
|
2
|
-
import { select as d3Select } from "d3-selection";
|
|
3
|
-
|
|
4
|
-
import "../src/Vertex.css";
|
|
5
|
-
|
|
6
|
-
export interface IAnnotation {
|
|
7
|
-
faChar?: string;
|
|
8
|
-
imageUrl?: string;
|
|
9
|
-
tooltip?: string;
|
|
10
|
-
diameter?: number;
|
|
11
|
-
paddingPercent?: number;
|
|
12
|
-
shape_colorFill?: string;
|
|
13
|
-
shape_colorStroke?: string;
|
|
14
|
-
image_colorFill?: string;
|
|
15
|
-
fontFamily?: string;
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
export class Vertex extends SVGWidget {
|
|
19
|
-
protected _icon: Icon;
|
|
20
|
-
protected _textBox: TextBox;
|
|
21
|
-
protected _annotationWidgets: object;
|
|
22
|
-
protected _graphID;
|
|
23
|
-
|
|
24
|
-
constructor() {
|
|
25
|
-
super();
|
|
26
|
-
|
|
27
|
-
this._icon = new Icon();
|
|
28
|
-
this._textBox = new TextBox();
|
|
29
|
-
this._annotationWidgets = {};
|
|
30
|
-
this.pos({ x: undefined, y: undefined });
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
getIconBBox() {
|
|
34
|
-
const iconBBox = this._icon.getBBox(true);
|
|
35
|
-
const textBoxBBox = this._textBox.getBBox(true);
|
|
36
|
-
switch (this.iconAnchor()) {
|
|
37
|
-
case "start":
|
|
38
|
-
return {
|
|
39
|
-
x: -(textBoxBBox.width / 2) + (iconBBox.width / 3),
|
|
40
|
-
y: -(textBoxBBox.height / 2) - (iconBBox.height / 3),
|
|
41
|
-
width: iconBBox.width,
|
|
42
|
-
height: iconBBox.height
|
|
43
|
-
};
|
|
44
|
-
case "middle":
|
|
45
|
-
return {
|
|
46
|
-
x: 0,
|
|
47
|
-
y: -(textBoxBBox.height / 2) - (iconBBox.height / 3),
|
|
48
|
-
width: iconBBox.width,
|
|
49
|
-
height: iconBBox.height
|
|
50
|
-
};
|
|
51
|
-
case "end":
|
|
52
|
-
return {
|
|
53
|
-
x: (textBoxBBox.width / 2) - (iconBBox.width / 3),
|
|
54
|
-
y: -(textBoxBBox.height / 2) - (iconBBox.height / 3),
|
|
55
|
-
width: iconBBox.width,
|
|
56
|
-
height: iconBBox.height
|
|
57
|
-
};
|
|
58
|
-
case "left":
|
|
59
|
-
return {
|
|
60
|
-
x: -(textBoxBBox.width / 2) - iconBBox.width / 2,
|
|
61
|
-
y: 0,
|
|
62
|
-
width: iconBBox.width,
|
|
63
|
-
height: iconBBox.height
|
|
64
|
-
};
|
|
65
|
-
default:
|
|
66
|
-
}
|
|
67
|
-
return {
|
|
68
|
-
x: 0,
|
|
69
|
-
y: 0,
|
|
70
|
-
width: iconBBox.width,
|
|
71
|
-
height: iconBBox.height
|
|
72
|
-
};
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
getBBox(refresh = false, round = false) {
|
|
76
|
-
const iconBBox = this.getIconBBox();
|
|
77
|
-
const textBoxBBox = this._textBox.getBBox(true);
|
|
78
|
-
const x = Math.min(iconBBox.x, textBoxBBox.x);
|
|
79
|
-
const y = Math.min(iconBBox.y, textBoxBBox.y);
|
|
80
|
-
const right = Math.max(iconBBox.x + iconBBox.width, textBoxBBox.x + textBoxBBox.width);
|
|
81
|
-
const bottom = Math.max(iconBBox.y + iconBBox.height, textBoxBBox.y + textBoxBBox.height);
|
|
82
|
-
return {
|
|
83
|
-
x,
|
|
84
|
-
y,
|
|
85
|
-
width: right - x,
|
|
86
|
-
height: bottom - y
|
|
87
|
-
};
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
enter(domNode, element) {
|
|
91
|
-
super.enter(domNode, element);
|
|
92
|
-
delete this._prevHash;
|
|
93
|
-
this._icon
|
|
94
|
-
.target(domNode)
|
|
95
|
-
;
|
|
96
|
-
this._textBox
|
|
97
|
-
.target(domNode)
|
|
98
|
-
;
|
|
99
|
-
element
|
|
100
|
-
.on("mouseover", d => this.mouseover(d.data()))
|
|
101
|
-
.on("mouseout", d => this.mouseout(d.data()))
|
|
102
|
-
;
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
_prevHash;
|
|
106
|
-
update(domNode, element) {
|
|
107
|
-
super.update(domNode, element);
|
|
108
|
-
const hash = this.hashSum();
|
|
109
|
-
if (this._prevHash !== hash) {
|
|
110
|
-
this._prevHash = hash;
|
|
111
|
-
element.classed("centroid", this.centroid());
|
|
112
|
-
element.style("filter", this.centroid() ? "url(#" + this._graphID + "_glow)" : null);
|
|
113
|
-
this._icon
|
|
114
|
-
.tooltip(this.iconTooltip() ? this.iconTooltip() : this.tooltip())
|
|
115
|
-
.render()
|
|
116
|
-
;
|
|
117
|
-
this._textBox
|
|
118
|
-
.tooltip(this.tooltip())
|
|
119
|
-
.render()
|
|
120
|
-
;
|
|
121
|
-
|
|
122
|
-
const iconBBox = this.getIconBBox();
|
|
123
|
-
this._icon.move(iconBBox);
|
|
124
|
-
|
|
125
|
-
const context = this;
|
|
126
|
-
const annotations = element.selectAll(".annotation").data(this.annotationIcons());
|
|
127
|
-
const annotationsEnter = annotations.enter().append("g")
|
|
128
|
-
.attr("class", "annotation")
|
|
129
|
-
.each(function (this: HTMLElement, _d, idx) {
|
|
130
|
-
context._annotationWidgets[idx] = new Icon()
|
|
131
|
-
.target(this)
|
|
132
|
-
.shape("square")
|
|
133
|
-
;
|
|
134
|
-
})
|
|
135
|
-
;
|
|
136
|
-
const bbox = this._textBox.getBBox(true);
|
|
137
|
-
let xOffset = bbox.width / 2;
|
|
138
|
-
const yOffset = bbox.height / 2;
|
|
139
|
-
annotationsEnter.merge(annotations)
|
|
140
|
-
.each(function (d, idx) {
|
|
141
|
-
const annotationWidget = context._annotationWidgets[idx];
|
|
142
|
-
annotationWidget
|
|
143
|
-
.diameter(context.annotationDiameter())
|
|
144
|
-
.shape_colorFill(context.textbox_shape_colorFill())
|
|
145
|
-
.shape_colorStroke(context.textbox_shape_colorStroke())
|
|
146
|
-
;
|
|
147
|
-
for (const key in d) {
|
|
148
|
-
if (annotationWidget[key]) {
|
|
149
|
-
annotationWidget[key](d[key]);
|
|
150
|
-
} else if (globalThis.__hpcc_debug) {
|
|
151
|
-
console.warn("Invalid annotation property: " + key);
|
|
152
|
-
}
|
|
153
|
-
}
|
|
154
|
-
annotationWidget.render();
|
|
155
|
-
|
|
156
|
-
const aBBox = annotationWidget.getBBox(true);
|
|
157
|
-
annotationWidget
|
|
158
|
-
.move({
|
|
159
|
-
x: xOffset - aBBox.width / 2 + 4,
|
|
160
|
-
y: yOffset + aBBox.height / 2 - 4
|
|
161
|
-
})
|
|
162
|
-
;
|
|
163
|
-
xOffset -= aBBox.width + context.annotationSpacing();
|
|
164
|
-
})
|
|
165
|
-
;
|
|
166
|
-
annotations.exit()
|
|
167
|
-
.each(function (this: HTMLElement, _d, idx) {
|
|
168
|
-
const element2 = d3Select(this);
|
|
169
|
-
context._annotationWidgets[idx].target(null);
|
|
170
|
-
delete context._annotationWidgets[idx];
|
|
171
|
-
element2.remove();
|
|
172
|
-
})
|
|
173
|
-
;
|
|
174
|
-
}
|
|
175
|
-
}
|
|
176
|
-
|
|
177
|
-
exit(domNode, element) {
|
|
178
|
-
for (const key in this._annotationWidgets) {
|
|
179
|
-
this._annotationWidgets[key].target(null);
|
|
180
|
-
}
|
|
181
|
-
this._icon.target(null);
|
|
182
|
-
this._textBox.target(null);
|
|
183
|
-
super.exit(domNode, element);
|
|
184
|
-
}
|
|
185
|
-
|
|
186
|
-
// Methods ---
|
|
187
|
-
contains(point): boolean {
|
|
188
|
-
return this._icon.contains(point) || this._textBox.contains(point);
|
|
189
|
-
}
|
|
190
|
-
|
|
191
|
-
intersection(pointA, pointB) {
|
|
192
|
-
const i1 = this._icon.intersection(pointA, pointB);
|
|
193
|
-
const i2 = this._textBox.intersection(pointA, pointB);
|
|
194
|
-
if (i1 && i2) {
|
|
195
|
-
return this.distance(i1, pointB) < this.distance(i2, pointB) ? i1 : i2;
|
|
196
|
-
}
|
|
197
|
-
return i1 || i2;
|
|
198
|
-
}
|
|
199
|
-
|
|
200
|
-
// Events ---
|
|
201
|
-
mouseover(d) {
|
|
202
|
-
}
|
|
203
|
-
|
|
204
|
-
mouseout(d) {
|
|
205
|
-
}
|
|
206
|
-
}
|
|
207
|
-
Vertex.prototype._class += " graph_Vertex";
|
|
208
|
-
|
|
209
|
-
export interface Vertex {
|
|
210
|
-
faChar(): string;
|
|
211
|
-
faChar(_: string): this;
|
|
212
|
-
imageUrl(): string;
|
|
213
|
-
imageUrl(_: string): this;
|
|
214
|
-
icon_diameter(): number;
|
|
215
|
-
icon_diameter(_: number): this;
|
|
216
|
-
icon_paddingPercent(): number;
|
|
217
|
-
icon_paddingPercent(_: number): this;
|
|
218
|
-
icon_shape_colorFill(): string;
|
|
219
|
-
icon_shape_colorFill(_: string): this;
|
|
220
|
-
icon_shape_colorStroke(): string;
|
|
221
|
-
icon_shape_colorStroke(_: string): this;
|
|
222
|
-
icon_image_colorFill(): string;
|
|
223
|
-
icon_image_colorFill(_: string): this;
|
|
224
|
-
icon_fontFamily(): string;
|
|
225
|
-
icon_fontFamily(_: string): this;
|
|
226
|
-
|
|
227
|
-
centroid(): boolean;
|
|
228
|
-
centroid(_: boolean): this;
|
|
229
|
-
|
|
230
|
-
text(): string;
|
|
231
|
-
text(_: string): this;
|
|
232
|
-
anchor(): string;
|
|
233
|
-
anchor(_: string): this;
|
|
234
|
-
textbox_shape_colorStroke(): string;
|
|
235
|
-
textbox_shape_colorStroke(_: string): this;
|
|
236
|
-
textbox_shape_colorFill(): string;
|
|
237
|
-
textbox_shape_colorFill(_: string): this;
|
|
238
|
-
textbox_text_colorFill(): string;
|
|
239
|
-
textbox_text_colorFill(_: string): this;
|
|
240
|
-
|
|
241
|
-
iconAnchor(): "" | "start" | "middle" | "end" | "left";
|
|
242
|
-
iconAnchor(_: "" | "start" | "middle" | "end" | "left"): this;
|
|
243
|
-
iconTooltip(): string;
|
|
244
|
-
iconTooltip(_: string): this;
|
|
245
|
-
|
|
246
|
-
tooltip(): string;
|
|
247
|
-
tooltip(_: string): this;
|
|
248
|
-
|
|
249
|
-
annotationDiameter(): number;
|
|
250
|
-
annotationDiameter(_: number): this;
|
|
251
|
-
annotationSpacing(): number;
|
|
252
|
-
annotationSpacing(_: number): this;
|
|
253
|
-
annotationIcons(): IAnnotation[];
|
|
254
|
-
annotationIcons(_: IAnnotation[]): this;
|
|
255
|
-
}
|
|
256
|
-
|
|
257
|
-
Vertex.prototype.publishProxy("faChar", "_icon");
|
|
258
|
-
Vertex.prototype.publishProxy("imageUrl", "_icon");
|
|
259
|
-
Vertex.prototype.publishProxy("icon_diameter", "_icon", "diameter");
|
|
260
|
-
Vertex.prototype.publishProxy("icon_paddingPercent", "_icon", "paddingPercent");
|
|
261
|
-
Vertex.prototype.publishProxy("icon_shape_colorFill", "_icon", "shape_colorFill");
|
|
262
|
-
Vertex.prototype.publishProxy("icon_shape_colorStroke", "_icon", "shape_colorStroke");
|
|
263
|
-
Vertex.prototype.publishProxy("icon_image_colorFill", "_icon", "image_colorFill");
|
|
264
|
-
Vertex.prototype.publishProxy("icon_fontFamily", "_icon", "fontFamily");
|
|
265
|
-
|
|
266
|
-
Vertex.prototype.publish("centroid", false, "boolean", "Centroid Vertex");
|
|
267
|
-
|
|
268
|
-
Vertex.prototype.publishProxy("text", "_textBox");
|
|
269
|
-
Vertex.prototype.publishProxy("anchor", "_textBox");
|
|
270
|
-
Vertex.prototype.publishProxy("textbox_shape_colorStroke", "_textBox", "shape_colorStroke");
|
|
271
|
-
Vertex.prototype.publishProxy("textbox_shape_colorFill", "_textBox", "shape_colorFill");
|
|
272
|
-
Vertex.prototype.publishProxy("textbox_text_colorFill", "_textBox", "text_colorFill");
|
|
273
|
-
Vertex.prototype.publishProxy("textbox_text_fontFamily", "_textBox", "text_fontFamily");
|
|
274
|
-
|
|
275
|
-
Vertex.prototype.publish("iconAnchor", "start", "set", "Horizontal anchor position of icon", ["", "start", "middle", "end", "left"], { tags: ["Basic"] });
|
|
276
|
-
Vertex.prototype.publish("iconTooltip", "", "string", "iconTooltip", null, { tags: ["Private"] });
|
|
277
|
-
|
|
278
|
-
Vertex.prototype.publish("tooltip", "", "string", "Tooltip", null, { tags: ["Private"] });
|
|
279
|
-
|
|
280
|
-
Vertex.prototype.publish("annotationDiameter", 14, "number", "Annotation Diameter", null, { tags: ["Private"] });
|
|
281
|
-
Vertex.prototype.publish("annotationSpacing", 3, "number", "Annotation Spacing", null, { tags: ["Private"] });
|
|
282
|
-
Vertex.prototype.publish("annotationIcons", [], "array", "Annotations", null, { tags: ["Private"] });
|
|
1
|
+
import { Icon, SVGWidget, TextBox } from "@hpcc-js/common";
|
|
2
|
+
import { select as d3Select } from "d3-selection";
|
|
3
|
+
|
|
4
|
+
import "../src/Vertex.css";
|
|
5
|
+
|
|
6
|
+
export interface IAnnotation {
|
|
7
|
+
faChar?: string;
|
|
8
|
+
imageUrl?: string;
|
|
9
|
+
tooltip?: string;
|
|
10
|
+
diameter?: number;
|
|
11
|
+
paddingPercent?: number;
|
|
12
|
+
shape_colorFill?: string;
|
|
13
|
+
shape_colorStroke?: string;
|
|
14
|
+
image_colorFill?: string;
|
|
15
|
+
fontFamily?: string;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export class Vertex extends SVGWidget {
|
|
19
|
+
protected _icon: Icon;
|
|
20
|
+
protected _textBox: TextBox;
|
|
21
|
+
protected _annotationWidgets: object;
|
|
22
|
+
protected _graphID;
|
|
23
|
+
|
|
24
|
+
constructor() {
|
|
25
|
+
super();
|
|
26
|
+
|
|
27
|
+
this._icon = new Icon();
|
|
28
|
+
this._textBox = new TextBox();
|
|
29
|
+
this._annotationWidgets = {};
|
|
30
|
+
this.pos({ x: undefined, y: undefined });
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
getIconBBox() {
|
|
34
|
+
const iconBBox = this._icon.getBBox(true);
|
|
35
|
+
const textBoxBBox = this._textBox.getBBox(true);
|
|
36
|
+
switch (this.iconAnchor()) {
|
|
37
|
+
case "start":
|
|
38
|
+
return {
|
|
39
|
+
x: -(textBoxBBox.width / 2) + (iconBBox.width / 3),
|
|
40
|
+
y: -(textBoxBBox.height / 2) - (iconBBox.height / 3),
|
|
41
|
+
width: iconBBox.width,
|
|
42
|
+
height: iconBBox.height
|
|
43
|
+
};
|
|
44
|
+
case "middle":
|
|
45
|
+
return {
|
|
46
|
+
x: 0,
|
|
47
|
+
y: -(textBoxBBox.height / 2) - (iconBBox.height / 3),
|
|
48
|
+
width: iconBBox.width,
|
|
49
|
+
height: iconBBox.height
|
|
50
|
+
};
|
|
51
|
+
case "end":
|
|
52
|
+
return {
|
|
53
|
+
x: (textBoxBBox.width / 2) - (iconBBox.width / 3),
|
|
54
|
+
y: -(textBoxBBox.height / 2) - (iconBBox.height / 3),
|
|
55
|
+
width: iconBBox.width,
|
|
56
|
+
height: iconBBox.height
|
|
57
|
+
};
|
|
58
|
+
case "left":
|
|
59
|
+
return {
|
|
60
|
+
x: -(textBoxBBox.width / 2) - iconBBox.width / 2,
|
|
61
|
+
y: 0,
|
|
62
|
+
width: iconBBox.width,
|
|
63
|
+
height: iconBBox.height
|
|
64
|
+
};
|
|
65
|
+
default:
|
|
66
|
+
}
|
|
67
|
+
return {
|
|
68
|
+
x: 0,
|
|
69
|
+
y: 0,
|
|
70
|
+
width: iconBBox.width,
|
|
71
|
+
height: iconBBox.height
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
getBBox(refresh = false, round = false) {
|
|
76
|
+
const iconBBox = this.getIconBBox();
|
|
77
|
+
const textBoxBBox = this._textBox.getBBox(true);
|
|
78
|
+
const x = Math.min(iconBBox.x, textBoxBBox.x);
|
|
79
|
+
const y = Math.min(iconBBox.y, textBoxBBox.y);
|
|
80
|
+
const right = Math.max(iconBBox.x + iconBBox.width, textBoxBBox.x + textBoxBBox.width);
|
|
81
|
+
const bottom = Math.max(iconBBox.y + iconBBox.height, textBoxBBox.y + textBoxBBox.height);
|
|
82
|
+
return {
|
|
83
|
+
x,
|
|
84
|
+
y,
|
|
85
|
+
width: right - x,
|
|
86
|
+
height: bottom - y
|
|
87
|
+
};
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
enter(domNode, element) {
|
|
91
|
+
super.enter(domNode, element);
|
|
92
|
+
delete this._prevHash;
|
|
93
|
+
this._icon
|
|
94
|
+
.target(domNode)
|
|
95
|
+
;
|
|
96
|
+
this._textBox
|
|
97
|
+
.target(domNode)
|
|
98
|
+
;
|
|
99
|
+
element
|
|
100
|
+
.on("mouseover", d => this.mouseover(d.data()))
|
|
101
|
+
.on("mouseout", d => this.mouseout(d.data()))
|
|
102
|
+
;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
_prevHash;
|
|
106
|
+
update(domNode, element) {
|
|
107
|
+
super.update(domNode, element);
|
|
108
|
+
const hash = this.hashSum();
|
|
109
|
+
if (this._prevHash !== hash) {
|
|
110
|
+
this._prevHash = hash;
|
|
111
|
+
element.classed("centroid", this.centroid());
|
|
112
|
+
element.style("filter", this.centroid() ? "url(#" + this._graphID + "_glow)" : null);
|
|
113
|
+
this._icon
|
|
114
|
+
.tooltip(this.iconTooltip() ? this.iconTooltip() : this.tooltip())
|
|
115
|
+
.render()
|
|
116
|
+
;
|
|
117
|
+
this._textBox
|
|
118
|
+
.tooltip(this.tooltip())
|
|
119
|
+
.render()
|
|
120
|
+
;
|
|
121
|
+
|
|
122
|
+
const iconBBox = this.getIconBBox();
|
|
123
|
+
this._icon.move(iconBBox);
|
|
124
|
+
|
|
125
|
+
const context = this;
|
|
126
|
+
const annotations = element.selectAll(".annotation").data(this.annotationIcons());
|
|
127
|
+
const annotationsEnter = annotations.enter().append("g")
|
|
128
|
+
.attr("class", "annotation")
|
|
129
|
+
.each(function (this: HTMLElement, _d, idx) {
|
|
130
|
+
context._annotationWidgets[idx] = new Icon()
|
|
131
|
+
.target(this)
|
|
132
|
+
.shape("square")
|
|
133
|
+
;
|
|
134
|
+
})
|
|
135
|
+
;
|
|
136
|
+
const bbox = this._textBox.getBBox(true);
|
|
137
|
+
let xOffset = bbox.width / 2;
|
|
138
|
+
const yOffset = bbox.height / 2;
|
|
139
|
+
annotationsEnter.merge(annotations)
|
|
140
|
+
.each(function (d, idx) {
|
|
141
|
+
const annotationWidget = context._annotationWidgets[idx];
|
|
142
|
+
annotationWidget
|
|
143
|
+
.diameter(context.annotationDiameter())
|
|
144
|
+
.shape_colorFill(context.textbox_shape_colorFill())
|
|
145
|
+
.shape_colorStroke(context.textbox_shape_colorStroke())
|
|
146
|
+
;
|
|
147
|
+
for (const key in d) {
|
|
148
|
+
if (annotationWidget[key]) {
|
|
149
|
+
annotationWidget[key](d[key]);
|
|
150
|
+
} else if (globalThis.__hpcc_debug) {
|
|
151
|
+
console.warn("Invalid annotation property: " + key);
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
annotationWidget.render();
|
|
155
|
+
|
|
156
|
+
const aBBox = annotationWidget.getBBox(true);
|
|
157
|
+
annotationWidget
|
|
158
|
+
.move({
|
|
159
|
+
x: xOffset - aBBox.width / 2 + 4,
|
|
160
|
+
y: yOffset + aBBox.height / 2 - 4
|
|
161
|
+
})
|
|
162
|
+
;
|
|
163
|
+
xOffset -= aBBox.width + context.annotationSpacing();
|
|
164
|
+
})
|
|
165
|
+
;
|
|
166
|
+
annotations.exit()
|
|
167
|
+
.each(function (this: HTMLElement, _d, idx) {
|
|
168
|
+
const element2 = d3Select(this);
|
|
169
|
+
context._annotationWidgets[idx].target(null);
|
|
170
|
+
delete context._annotationWidgets[idx];
|
|
171
|
+
element2.remove();
|
|
172
|
+
})
|
|
173
|
+
;
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
exit(domNode, element) {
|
|
178
|
+
for (const key in this._annotationWidgets) {
|
|
179
|
+
this._annotationWidgets[key].target(null);
|
|
180
|
+
}
|
|
181
|
+
this._icon.target(null);
|
|
182
|
+
this._textBox.target(null);
|
|
183
|
+
super.exit(domNode, element);
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
// Methods ---
|
|
187
|
+
contains(point): boolean {
|
|
188
|
+
return this._icon.contains(point) || this._textBox.contains(point);
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
intersection(pointA, pointB) {
|
|
192
|
+
const i1 = this._icon.intersection(pointA, pointB);
|
|
193
|
+
const i2 = this._textBox.intersection(pointA, pointB);
|
|
194
|
+
if (i1 && i2) {
|
|
195
|
+
return this.distance(i1, pointB) < this.distance(i2, pointB) ? i1 : i2;
|
|
196
|
+
}
|
|
197
|
+
return i1 || i2;
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
// Events ---
|
|
201
|
+
mouseover(d) {
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
mouseout(d) {
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
Vertex.prototype._class += " graph_Vertex";
|
|
208
|
+
|
|
209
|
+
export interface Vertex {
|
|
210
|
+
faChar(): string;
|
|
211
|
+
faChar(_: string): this;
|
|
212
|
+
imageUrl(): string;
|
|
213
|
+
imageUrl(_: string): this;
|
|
214
|
+
icon_diameter(): number;
|
|
215
|
+
icon_diameter(_: number): this;
|
|
216
|
+
icon_paddingPercent(): number;
|
|
217
|
+
icon_paddingPercent(_: number): this;
|
|
218
|
+
icon_shape_colorFill(): string;
|
|
219
|
+
icon_shape_colorFill(_: string): this;
|
|
220
|
+
icon_shape_colorStroke(): string;
|
|
221
|
+
icon_shape_colorStroke(_: string): this;
|
|
222
|
+
icon_image_colorFill(): string;
|
|
223
|
+
icon_image_colorFill(_: string): this;
|
|
224
|
+
icon_fontFamily(): string;
|
|
225
|
+
icon_fontFamily(_: string): this;
|
|
226
|
+
|
|
227
|
+
centroid(): boolean;
|
|
228
|
+
centroid(_: boolean): this;
|
|
229
|
+
|
|
230
|
+
text(): string;
|
|
231
|
+
text(_: string): this;
|
|
232
|
+
anchor(): string;
|
|
233
|
+
anchor(_: string): this;
|
|
234
|
+
textbox_shape_colorStroke(): string;
|
|
235
|
+
textbox_shape_colorStroke(_: string): this;
|
|
236
|
+
textbox_shape_colorFill(): string;
|
|
237
|
+
textbox_shape_colorFill(_: string): this;
|
|
238
|
+
textbox_text_colorFill(): string;
|
|
239
|
+
textbox_text_colorFill(_: string): this;
|
|
240
|
+
|
|
241
|
+
iconAnchor(): "" | "start" | "middle" | "end" | "left";
|
|
242
|
+
iconAnchor(_: "" | "start" | "middle" | "end" | "left"): this;
|
|
243
|
+
iconTooltip(): string;
|
|
244
|
+
iconTooltip(_: string): this;
|
|
245
|
+
|
|
246
|
+
tooltip(): string;
|
|
247
|
+
tooltip(_: string): this;
|
|
248
|
+
|
|
249
|
+
annotationDiameter(): number;
|
|
250
|
+
annotationDiameter(_: number): this;
|
|
251
|
+
annotationSpacing(): number;
|
|
252
|
+
annotationSpacing(_: number): this;
|
|
253
|
+
annotationIcons(): IAnnotation[];
|
|
254
|
+
annotationIcons(_: IAnnotation[]): this;
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
Vertex.prototype.publishProxy("faChar", "_icon");
|
|
258
|
+
Vertex.prototype.publishProxy("imageUrl", "_icon");
|
|
259
|
+
Vertex.prototype.publishProxy("icon_diameter", "_icon", "diameter");
|
|
260
|
+
Vertex.prototype.publishProxy("icon_paddingPercent", "_icon", "paddingPercent");
|
|
261
|
+
Vertex.prototype.publishProxy("icon_shape_colorFill", "_icon", "shape_colorFill");
|
|
262
|
+
Vertex.prototype.publishProxy("icon_shape_colorStroke", "_icon", "shape_colorStroke");
|
|
263
|
+
Vertex.prototype.publishProxy("icon_image_colorFill", "_icon", "image_colorFill");
|
|
264
|
+
Vertex.prototype.publishProxy("icon_fontFamily", "_icon", "fontFamily");
|
|
265
|
+
|
|
266
|
+
Vertex.prototype.publish("centroid", false, "boolean", "Centroid Vertex");
|
|
267
|
+
|
|
268
|
+
Vertex.prototype.publishProxy("text", "_textBox");
|
|
269
|
+
Vertex.prototype.publishProxy("anchor", "_textBox");
|
|
270
|
+
Vertex.prototype.publishProxy("textbox_shape_colorStroke", "_textBox", "shape_colorStroke");
|
|
271
|
+
Vertex.prototype.publishProxy("textbox_shape_colorFill", "_textBox", "shape_colorFill");
|
|
272
|
+
Vertex.prototype.publishProxy("textbox_text_colorFill", "_textBox", "text_colorFill");
|
|
273
|
+
Vertex.prototype.publishProxy("textbox_text_fontFamily", "_textBox", "text_fontFamily");
|
|
274
|
+
|
|
275
|
+
Vertex.prototype.publish("iconAnchor", "start", "set", "Horizontal anchor position of icon", ["", "start", "middle", "end", "left"], { tags: ["Basic"] });
|
|
276
|
+
Vertex.prototype.publish("iconTooltip", "", "string", "iconTooltip", null, { tags: ["Private"] });
|
|
277
|
+
|
|
278
|
+
Vertex.prototype.publish("tooltip", "", "string", "Tooltip", null, { tags: ["Private"] });
|
|
279
|
+
|
|
280
|
+
Vertex.prototype.publish("annotationDiameter", 14, "number", "Annotation Diameter", null, { tags: ["Private"] });
|
|
281
|
+
Vertex.prototype.publish("annotationSpacing", 3, "number", "Annotation Spacing", null, { tags: ["Private"] });
|
|
282
|
+
Vertex.prototype.publish("annotationIcons", [], "array", "Annotations", null, { tags: ["Private"] });
|
package/src/__package__.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export const PKG_NAME = "__PACKAGE_NAME__";
|
|
2
|
-
export const PKG_VERSION = "__PACKAGE_VERSION__";
|
|
3
|
-
export const BUILD_VERSION = "__BUILD_VERSION__";
|
|
1
|
+
export const PKG_NAME = "__PACKAGE_NAME__";
|
|
2
|
+
export const PKG_VERSION = "__PACKAGE_VERSION__";
|
|
3
|
+
export const BUILD_VERSION = "__BUILD_VERSION__";
|