@hpcc-js/graph 3.7.4 → 3.7.6
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-BkFKgQ-y.js.map +1 -0
- package/dist/index.js +26 -26
- package/dist/index.js.map +1 -1
- package/dist/index.umd.cjs +22 -22
- package/dist/index.umd.cjs.map +1 -1
- package/package.json +12 -10
- package/src/AdjacencyGraph.ts +224 -224
- package/src/Edge.css +22 -22
- 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 +44 -44
- package/src/Sankey.ts +304 -304
- package/src/Subgraph.css +9 -9
- package/src/Subgraph.ts +165 -165
- package/src/Vertex.css +2 -2
- 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 +44 -44
- 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/dist/assets/graphviz-BK7FEJlA.js.map +0 -1
package/src/common/liteMap.ts
CHANGED
|
@@ -1,72 +1,72 @@
|
|
|
1
|
-
import { select as d3Select, zoomTransform as d3ZoomTransform } from "@hpcc-js/common";
|
|
2
|
-
import { geoMercator as d3GeoMercator } from "d3-geo";
|
|
3
|
-
import { tile as d3Tile, tileWrap as d3TileWrap } from "d3-tile";
|
|
4
|
-
import { LiteSVGZoomWidget } from "./liteSVGZooom.ts";
|
|
5
|
-
|
|
6
|
-
function url(x, y, z) {
|
|
7
|
-
return `https://api.mapbox.com/styles/v1/mapbox/streets-v11/tiles/${z}/${x}/${y}${devicePixelRatio > 1 ? "@2x" : ""}?access_token=pk.eyJ1IjoibGVzY2htb28iLCJhIjoiY2psY2FqY3l3MDhqNDN3cDl1MzFmZnkwcCJ9.HRoFwmz1j80gyz18ruggqw`;
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
export class LiteMapWidget extends LiteSVGZoomWidget {
|
|
11
|
-
|
|
12
|
-
protected _mapVisible = false;
|
|
13
|
-
private _mapScale = 1 << 15;
|
|
14
|
-
|
|
15
|
-
protected _levels: any;
|
|
16
|
-
|
|
17
|
-
protected _projection = d3GeoMercator()
|
|
18
|
-
.scale(this._mapScale / (2 * Math.PI))
|
|
19
|
-
;
|
|
20
|
-
|
|
21
|
-
protected _tile = d3Tile()
|
|
22
|
-
.tileSize(512)
|
|
23
|
-
.clampX(false)
|
|
24
|
-
;
|
|
25
|
-
|
|
26
|
-
project(lat: number, lng: number): [number, number] {
|
|
27
|
-
return this._projection([lng, lat]);
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
enter(domNode, element) {
|
|
31
|
-
super.enter(domNode, element);
|
|
32
|
-
this._zoom.scaleExtent([0.0078125, 4096]);
|
|
33
|
-
const deltas = [-100, -4, -1, 0];
|
|
34
|
-
this._levels = this._svgElement.insert("g", "g")
|
|
35
|
-
.attr("pointer-events", "none")
|
|
36
|
-
.selectAll("g").data(deltas)
|
|
37
|
-
.join("g")
|
|
38
|
-
;
|
|
39
|
-
|
|
40
|
-
this.mapZoomed(d3ZoomTransform(this._svgElement.node()));
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
mapZoomed(transform) {
|
|
44
|
-
const { width, height } = this.size();
|
|
45
|
-
|
|
46
|
-
const context = this;
|
|
47
|
-
const mapTransform = transform.translate(width >> 1, height >> 1).scale(this._mapScale);
|
|
48
|
-
this._levels.each(function (delta) {
|
|
49
|
-
const tiles = context._mapVisible ? context._tile.zoomDelta(delta)(mapTransform) : [];
|
|
50
|
-
d3Select(this).selectAll("image").data(tiles, d => d as any)
|
|
51
|
-
.join("image")
|
|
52
|
-
.attr("xlink:href", d => {
|
|
53
|
-
const tmp = d3TileWrap(d) as [number, number, number];
|
|
54
|
-
return url(...tmp);
|
|
55
|
-
})
|
|
56
|
-
.attr("x", ([x]) => (x + tiles.translate[0]) * tiles.scale)
|
|
57
|
-
.attr("y", ([, y]) => (y + tiles.translate[1]) * tiles.scale)
|
|
58
|
-
.attr("width", tiles.scale)
|
|
59
|
-
.attr("height", tiles.scale)
|
|
60
|
-
;
|
|
61
|
-
});
|
|
62
|
-
|
|
63
|
-
this._projection
|
|
64
|
-
.translate([width >> 1, height >> 1])
|
|
65
|
-
;
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
zoomed(transform) {
|
|
69
|
-
super.zoomed(transform);
|
|
70
|
-
this.mapZoomed(transform);
|
|
71
|
-
}
|
|
72
|
-
}
|
|
1
|
+
import { select as d3Select, zoomTransform as d3ZoomTransform } from "@hpcc-js/common";
|
|
2
|
+
import { geoMercator as d3GeoMercator } from "d3-geo";
|
|
3
|
+
import { tile as d3Tile, tileWrap as d3TileWrap } from "d3-tile";
|
|
4
|
+
import { LiteSVGZoomWidget } from "./liteSVGZooom.ts";
|
|
5
|
+
|
|
6
|
+
function url(x, y, z) {
|
|
7
|
+
return `https://api.mapbox.com/styles/v1/mapbox/streets-v11/tiles/${z}/${x}/${y}${devicePixelRatio > 1 ? "@2x" : ""}?access_token=pk.eyJ1IjoibGVzY2htb28iLCJhIjoiY2psY2FqY3l3MDhqNDN3cDl1MzFmZnkwcCJ9.HRoFwmz1j80gyz18ruggqw`;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export class LiteMapWidget extends LiteSVGZoomWidget {
|
|
11
|
+
|
|
12
|
+
protected _mapVisible = false;
|
|
13
|
+
private _mapScale = 1 << 15;
|
|
14
|
+
|
|
15
|
+
protected _levels: any;
|
|
16
|
+
|
|
17
|
+
protected _projection = d3GeoMercator()
|
|
18
|
+
.scale(this._mapScale / (2 * Math.PI))
|
|
19
|
+
;
|
|
20
|
+
|
|
21
|
+
protected _tile = d3Tile()
|
|
22
|
+
.tileSize(512)
|
|
23
|
+
.clampX(false)
|
|
24
|
+
;
|
|
25
|
+
|
|
26
|
+
project(lat: number, lng: number): [number, number] {
|
|
27
|
+
return this._projection([lng, lat]);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
enter(domNode, element) {
|
|
31
|
+
super.enter(domNode, element);
|
|
32
|
+
this._zoom.scaleExtent([0.0078125, 4096]);
|
|
33
|
+
const deltas = [-100, -4, -1, 0];
|
|
34
|
+
this._levels = this._svgElement.insert("g", "g")
|
|
35
|
+
.attr("pointer-events", "none")
|
|
36
|
+
.selectAll("g").data(deltas)
|
|
37
|
+
.join("g")
|
|
38
|
+
;
|
|
39
|
+
|
|
40
|
+
this.mapZoomed(d3ZoomTransform(this._svgElement.node()));
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
mapZoomed(transform) {
|
|
44
|
+
const { width, height } = this.size();
|
|
45
|
+
|
|
46
|
+
const context = this;
|
|
47
|
+
const mapTransform = transform.translate(width >> 1, height >> 1).scale(this._mapScale);
|
|
48
|
+
this._levels.each(function (delta) {
|
|
49
|
+
const tiles = context._mapVisible ? context._tile.zoomDelta(delta)(mapTransform) : [];
|
|
50
|
+
d3Select(this).selectAll("image").data(tiles, d => d as any)
|
|
51
|
+
.join("image")
|
|
52
|
+
.attr("xlink:href", d => {
|
|
53
|
+
const tmp = d3TileWrap(d) as [number, number, number];
|
|
54
|
+
return url(...tmp);
|
|
55
|
+
})
|
|
56
|
+
.attr("x", ([x]) => (x + tiles.translate[0]) * tiles.scale)
|
|
57
|
+
.attr("y", ([, y]) => (y + tiles.translate[1]) * tiles.scale)
|
|
58
|
+
.attr("width", tiles.scale)
|
|
59
|
+
.attr("height", tiles.scale)
|
|
60
|
+
;
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
this._projection
|
|
64
|
+
.translate([width >> 1, height >> 1])
|
|
65
|
+
;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
zoomed(transform) {
|
|
69
|
+
super.zoomed(transform);
|
|
70
|
+
this.mapZoomed(transform);
|
|
71
|
+
}
|
|
72
|
+
}
|
|
@@ -1,61 +1,61 @@
|
|
|
1
|
-
import { d3Event, HTMLWidget, zoom as d3Zoom } from "@hpcc-js/common";
|
|
2
|
-
|
|
3
|
-
export class LiteSVGZoomWidget extends HTMLWidget {
|
|
4
|
-
|
|
5
|
-
protected _svgElement: any;
|
|
6
|
-
protected _svgDefs: any;
|
|
7
|
-
protected _zoomElement: any;
|
|
8
|
-
protected _zoom = d3Zoom();
|
|
9
|
-
protected _zoomScale = 1;
|
|
10
|
-
protected _zoomTranslate = [0, 0];
|
|
11
|
-
|
|
12
|
-
constructor() {
|
|
13
|
-
super();
|
|
14
|
-
this._tag = "div";
|
|
15
|
-
this._drawStartPos = "origin";
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
resize(size?) {
|
|
19
|
-
const retVal = super.resize(size);
|
|
20
|
-
if (this._svgElement) {
|
|
21
|
-
this._svgElement
|
|
22
|
-
.style("width", this._size.width + "px")
|
|
23
|
-
.style("height", this._size.height + "px")
|
|
24
|
-
;
|
|
25
|
-
}
|
|
26
|
-
return retVal;
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
zoomed(transform) {
|
|
30
|
-
this._zoomScale = transform.k;
|
|
31
|
-
this._zoomTranslate = [transform.x, transform.y];
|
|
32
|
-
this._zoomElement.attr("transform", transform);
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
enter(domNode, element) {
|
|
36
|
-
super.enter(domNode, element);
|
|
37
|
-
|
|
38
|
-
element
|
|
39
|
-
.style("position", "relative")
|
|
40
|
-
;
|
|
41
|
-
|
|
42
|
-
this._svgElement = element.append("svg");
|
|
43
|
-
this._svgDefs = this._svgElement.append("defs");
|
|
44
|
-
this._zoomElement = this._svgElement.append("g");
|
|
45
|
-
|
|
46
|
-
this.resize();
|
|
47
|
-
|
|
48
|
-
this._zoom.on("zoom", () => this.zoomed(d3Event().transform));
|
|
49
|
-
this._svgElement.call(this._zoom);
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
update(domNode, element) {
|
|
53
|
-
super.update(domNode, element);
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
exit(domNode, element) {
|
|
57
|
-
super.exit(domNode, element);
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
}
|
|
61
|
-
LiteSVGZoomWidget.prototype._class += " graph_SVGZoomLiteWidget";
|
|
1
|
+
import { d3Event, HTMLWidget, zoom as d3Zoom } from "@hpcc-js/common";
|
|
2
|
+
|
|
3
|
+
export class LiteSVGZoomWidget extends HTMLWidget {
|
|
4
|
+
|
|
5
|
+
protected _svgElement: any;
|
|
6
|
+
protected _svgDefs: any;
|
|
7
|
+
protected _zoomElement: any;
|
|
8
|
+
protected _zoom = d3Zoom();
|
|
9
|
+
protected _zoomScale = 1;
|
|
10
|
+
protected _zoomTranslate = [0, 0];
|
|
11
|
+
|
|
12
|
+
constructor() {
|
|
13
|
+
super();
|
|
14
|
+
this._tag = "div";
|
|
15
|
+
this._drawStartPos = "origin";
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
resize(size?) {
|
|
19
|
+
const retVal = super.resize(size);
|
|
20
|
+
if (this._svgElement) {
|
|
21
|
+
this._svgElement
|
|
22
|
+
.style("width", this._size.width + "px")
|
|
23
|
+
.style("height", this._size.height + "px")
|
|
24
|
+
;
|
|
25
|
+
}
|
|
26
|
+
return retVal;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
zoomed(transform) {
|
|
30
|
+
this._zoomScale = transform.k;
|
|
31
|
+
this._zoomTranslate = [transform.x, transform.y];
|
|
32
|
+
this._zoomElement.attr("transform", transform);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
enter(domNode, element) {
|
|
36
|
+
super.enter(domNode, element);
|
|
37
|
+
|
|
38
|
+
element
|
|
39
|
+
.style("position", "relative")
|
|
40
|
+
;
|
|
41
|
+
|
|
42
|
+
this._svgElement = element.append("svg");
|
|
43
|
+
this._svgDefs = this._svgElement.append("defs");
|
|
44
|
+
this._zoomElement = this._svgElement.append("g");
|
|
45
|
+
|
|
46
|
+
this.resize();
|
|
47
|
+
|
|
48
|
+
this._zoom.on("zoom", () => this.zoomed(d3Event().transform));
|
|
49
|
+
this._svgElement.call(this._zoom);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
update(domNode, element) {
|
|
53
|
+
super.update(domNode, element);
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
exit(domNode, element) {
|
|
57
|
+
super.exit(domNode, element);
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
}
|
|
61
|
+
LiteSVGZoomWidget.prototype._class += " graph_SVGZoomLiteWidget";
|
|
@@ -1,45 +1,45 @@
|
|
|
1
|
-
.graph_SankeyGraph .node rect {
|
|
2
|
-
cursor: move;
|
|
3
|
-
fill-opacity: .9;
|
|
4
|
-
shape-rendering: crispEdges;
|
|
5
|
-
stroke: darkgray;
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
.graph_SankeyGraph .node.selected rect {
|
|
9
|
-
stroke: red;
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
.graph_SankeyGraph .node.over rect {
|
|
13
|
-
stroke: orange;
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
.graph_SankeyGraph .node.selected.over rect {
|
|
17
|
-
stroke: red;
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
.graph_SankeyGraph .node text {
|
|
21
|
-
pointer-events: none;
|
|
22
|
-
text-shadow: 0 1px 0 #fff;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
.graph_SankeyGraph .node.selected text {
|
|
26
|
-
fill: red;
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
.graph_SankeyGraph .node.over text {
|
|
30
|
-
fill: orange;
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
.graph_SankeyGraph .node.selected.over text {
|
|
34
|
-
fill: red;
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
.graph_SankeyGraph .link {
|
|
38
|
-
fill: none;
|
|
39
|
-
stroke: #000;
|
|
40
|
-
stroke-opacity: .2;
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
.graph_SankeyGraph .link:hover {
|
|
44
|
-
stroke-opacity: .5;
|
|
1
|
+
.graph_SankeyGraph .node rect {
|
|
2
|
+
cursor: move;
|
|
3
|
+
fill-opacity: .9;
|
|
4
|
+
shape-rendering: crispEdges;
|
|
5
|
+
stroke: darkgray;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
.graph_SankeyGraph .node.selected rect {
|
|
9
|
+
stroke: red;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
.graph_SankeyGraph .node.over rect {
|
|
13
|
+
stroke: orange;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
.graph_SankeyGraph .node.selected.over rect {
|
|
17
|
+
stroke: red;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
.graph_SankeyGraph .node text {
|
|
21
|
+
pointer-events: none;
|
|
22
|
+
text-shadow: 0 1px 0 #fff;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
.graph_SankeyGraph .node.selected text {
|
|
26
|
+
fill: red;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
.graph_SankeyGraph .node.over text {
|
|
30
|
+
fill: orange;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
.graph_SankeyGraph .node.selected.over text {
|
|
34
|
+
fill: red;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
.graph_SankeyGraph .link {
|
|
38
|
+
fill: none;
|
|
39
|
+
stroke: #000;
|
|
40
|
+
stroke-opacity: .2;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
.graph_SankeyGraph .link:hover {
|
|
44
|
+
stroke-opacity: .5;
|
|
45
45
|
}
|