@hpcc-js/graph 3.7.4 → 3.7.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-BK7FEJlA.js.map +1 -1
  5. package/dist/index.js +1 -1
  6. package/dist/index.js.map +1 -1
  7. package/dist/index.umd.cjs +1 -1
  8. package/dist/index.umd.cjs.map +1 -1
  9. package/package.json +7 -7
  10. package/src/AdjacencyGraph.ts +224 -224
  11. package/src/Edge.css +22 -22
  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 +44 -44
  18. package/src/Sankey.ts +304 -304
  19. package/src/Subgraph.css +9 -9
  20. package/src/Subgraph.ts +165 -165
  21. package/src/Vertex.css +2 -2
  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 +44 -44
  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
package/src/Subgraph.ts CHANGED
@@ -1,165 +1,165 @@
1
- import { Icon, Palette, SVGWidget, Text } from "@hpcc-js/common";
2
- import "d3-transition";
3
-
4
- import "./Subgraph.css";
5
-
6
- const TITLE_SIZE = 14;
7
- const MINMAX_SIZE = 18;
8
-
9
- export type SubgraphMinState = "normal" | "partial";
10
-
11
- export class Subgraph extends SVGWidget {
12
- protected _border;
13
- protected _textWidget = new Text()
14
- .anchor("start")
15
- .fontSize(TITLE_SIZE)
16
- ;
17
- protected _buttonMin = new Icon()
18
- .diameter(MINMAX_SIZE)
19
- .shape_colorStroke("#1f77b4")
20
- .shape_colorFill("#dcf1ff")
21
- .image_colorFill("#1f77b4")
22
- .on("click", () => {
23
- this.minClick();
24
- }, true)
25
- .on("dblclick", () => {
26
- }, true)
27
- ;
28
-
29
- protected _minState: SubgraphMinState = "normal";
30
-
31
- constructor() {
32
- super();
33
- }
34
-
35
- minState(): SubgraphMinState;
36
- minState(_: SubgraphMinState): this;
37
- minState(_?: SubgraphMinState): SubgraphMinState | this {
38
- if (!arguments.length) return this._minState;
39
- this._minState = _;
40
- return this;
41
- }
42
-
43
- calcIcon() {
44
- switch (this._minState) {
45
- case "normal":
46
- return "\uf2d2";
47
- case "partial":
48
- return "\uf2d0";
49
- }
50
- }
51
-
52
- getBBox(refresh = false, round = false) {
53
- const width = this.width();
54
- const height = this.height();
55
- return {
56
- x: -width / 2,
57
- y: -height / 2 - TITLE_SIZE,
58
- width,
59
- height
60
- };
61
- }
62
-
63
- enter(domNode, element) {
64
- super.enter(domNode, element);
65
- this._border = element.append("rect").attr("class", "border");
66
- this._textWidget.target(domNode);
67
- this._buttonMin.target(domNode);
68
- }
69
-
70
- update(domNode, element) {
71
- super.update(domNode, element);
72
-
73
- const bbox = this.getBBox();
74
-
75
- this._border
76
- .attr("x", bbox.x)
77
- .attr("y", bbox.y)
78
- .attr("width", bbox.width)
79
- .attr("height", bbox.height)
80
- .style("fill", this.border_colorFill())
81
- .style("stroke", this.border_colorStroke())
82
- ;
83
-
84
- if (this.border_colorFill_exists() && !this.title_colorFill_exists()) {
85
- this.title_colorFill(Palette.textColor(this.border_colorFill()));
86
- }
87
- this._textWidget
88
- .pos({ x: bbox.x + 4, y: bbox.y + TITLE_SIZE })
89
- .width(this.width() - 8)
90
- .text(this.showTitle() ? this.title() : "")
91
- .render()
92
- ;
93
-
94
- this._buttonMin
95
- .visible(this.showMinMax())
96
- .pos({ x: bbox.x + bbox.width - (MINMAX_SIZE / 2 + 4), y: bbox.y + (MINMAX_SIZE / 2 + 4) })
97
- .faChar(this.calcIcon())
98
- .render()
99
- ;
100
- }
101
-
102
- exit(domNode, element) {
103
- this._buttonMin.target(null);
104
- this._textWidget.target(null);
105
- this._border.remove();
106
- super.exit(domNode, element);
107
- }
108
-
109
- intersection(pointA, pointB) {
110
- const hits = [];
111
- let nearest = null;
112
- hits.forEach(function (item) {
113
- if (nearest === null || nearest.d > item.d) {
114
- nearest = item;
115
- }
116
- });
117
- return nearest && nearest.i ? nearest.i : null;
118
- }
119
-
120
- click(d) {
121
- }
122
-
123
- minClick() {
124
- switch (this._minState) {
125
- case "normal":
126
- this._minState = "partial";
127
- break;
128
- case "partial":
129
- this._minState = "normal";
130
- break;
131
- }
132
- this._buttonMin
133
- .faChar(this.calcIcon()) // max:f2d0, restore: f2d2, min: f2d1
134
- .render()
135
- ;
136
- }
137
- }
138
- Subgraph.prototype._class += " graph_Subgraph";
139
-
140
- export interface Subgraph {
141
- border_colorStroke(): string;
142
- border_colorStroke(_: string): this;
143
- border_colorFill(): string;
144
- border_colorFill(_: string): this;
145
- border_colorFill_exists: () => boolean;
146
- showTitle(): boolean;
147
- showTitle(_: boolean): this;
148
- title(): string;
149
- title(_: string): this;
150
- titleFontSize(): string;
151
- titleFontSize(_: string): this;
152
- title_colorFill(): string;
153
- title_colorFill(_: string): this;
154
- title_colorFill_exists: () => boolean;
155
- showMinMax(): boolean;
156
- showMinMax(_: boolean): this;
157
- }
158
-
159
- Subgraph.prototype.publish("border_colorStroke", null, "html-color", "Stroke Color", null, { optional: true });
160
- Subgraph.prototype.publish("border_colorFill", null, "html-color", "Fill Color", null, { optional: true });
161
- Subgraph.prototype.publish("showTitle", true, "boolean", "Show Title", null, { tags: ["Basic"] });
162
- Subgraph.prototype.publish("title", "", "string", "Title", null, { tags: ["Basic"] });
163
- Subgraph.prototype.publishProxy("titleFontSize", "_textWidget", "fontSize");
164
- Subgraph.prototype.publishProxy("title_colorFill", "_textWidget", "colorFill");
165
- Subgraph.prototype.publish("showMinMax", false, "boolean", "Show Min/Max", null, { tags: ["Basic"] });
1
+ import { Icon, Palette, SVGWidget, Text } from "@hpcc-js/common";
2
+ import "d3-transition";
3
+
4
+ import "./Subgraph.css";
5
+
6
+ const TITLE_SIZE = 14;
7
+ const MINMAX_SIZE = 18;
8
+
9
+ export type SubgraphMinState = "normal" | "partial";
10
+
11
+ export class Subgraph extends SVGWidget {
12
+ protected _border;
13
+ protected _textWidget = new Text()
14
+ .anchor("start")
15
+ .fontSize(TITLE_SIZE)
16
+ ;
17
+ protected _buttonMin = new Icon()
18
+ .diameter(MINMAX_SIZE)
19
+ .shape_colorStroke("#1f77b4")
20
+ .shape_colorFill("#dcf1ff")
21
+ .image_colorFill("#1f77b4")
22
+ .on("click", () => {
23
+ this.minClick();
24
+ }, true)
25
+ .on("dblclick", () => {
26
+ }, true)
27
+ ;
28
+
29
+ protected _minState: SubgraphMinState = "normal";
30
+
31
+ constructor() {
32
+ super();
33
+ }
34
+
35
+ minState(): SubgraphMinState;
36
+ minState(_: SubgraphMinState): this;
37
+ minState(_?: SubgraphMinState): SubgraphMinState | this {
38
+ if (!arguments.length) return this._minState;
39
+ this._minState = _;
40
+ return this;
41
+ }
42
+
43
+ calcIcon() {
44
+ switch (this._minState) {
45
+ case "normal":
46
+ return "\uf2d2";
47
+ case "partial":
48
+ return "\uf2d0";
49
+ }
50
+ }
51
+
52
+ getBBox(refresh = false, round = false) {
53
+ const width = this.width();
54
+ const height = this.height();
55
+ return {
56
+ x: -width / 2,
57
+ y: -height / 2 - TITLE_SIZE,
58
+ width,
59
+ height
60
+ };
61
+ }
62
+
63
+ enter(domNode, element) {
64
+ super.enter(domNode, element);
65
+ this._border = element.append("rect").attr("class", "border");
66
+ this._textWidget.target(domNode);
67
+ this._buttonMin.target(domNode);
68
+ }
69
+
70
+ update(domNode, element) {
71
+ super.update(domNode, element);
72
+
73
+ const bbox = this.getBBox();
74
+
75
+ this._border
76
+ .attr("x", bbox.x)
77
+ .attr("y", bbox.y)
78
+ .attr("width", bbox.width)
79
+ .attr("height", bbox.height)
80
+ .style("fill", this.border_colorFill())
81
+ .style("stroke", this.border_colorStroke())
82
+ ;
83
+
84
+ if (this.border_colorFill_exists() && !this.title_colorFill_exists()) {
85
+ this.title_colorFill(Palette.textColor(this.border_colorFill()));
86
+ }
87
+ this._textWidget
88
+ .pos({ x: bbox.x + 4, y: bbox.y + TITLE_SIZE })
89
+ .width(this.width() - 8)
90
+ .text(this.showTitle() ? this.title() : "")
91
+ .render()
92
+ ;
93
+
94
+ this._buttonMin
95
+ .visible(this.showMinMax())
96
+ .pos({ x: bbox.x + bbox.width - (MINMAX_SIZE / 2 + 4), y: bbox.y + (MINMAX_SIZE / 2 + 4) })
97
+ .faChar(this.calcIcon())
98
+ .render()
99
+ ;
100
+ }
101
+
102
+ exit(domNode, element) {
103
+ this._buttonMin.target(null);
104
+ this._textWidget.target(null);
105
+ this._border.remove();
106
+ super.exit(domNode, element);
107
+ }
108
+
109
+ intersection(pointA, pointB) {
110
+ const hits = [];
111
+ let nearest = null;
112
+ hits.forEach(function (item) {
113
+ if (nearest === null || nearest.d > item.d) {
114
+ nearest = item;
115
+ }
116
+ });
117
+ return nearest && nearest.i ? nearest.i : null;
118
+ }
119
+
120
+ click(d) {
121
+ }
122
+
123
+ minClick() {
124
+ switch (this._minState) {
125
+ case "normal":
126
+ this._minState = "partial";
127
+ break;
128
+ case "partial":
129
+ this._minState = "normal";
130
+ break;
131
+ }
132
+ this._buttonMin
133
+ .faChar(this.calcIcon()) // max:f2d0, restore: f2d2, min: f2d1
134
+ .render()
135
+ ;
136
+ }
137
+ }
138
+ Subgraph.prototype._class += " graph_Subgraph";
139
+
140
+ export interface Subgraph {
141
+ border_colorStroke(): string;
142
+ border_colorStroke(_: string): this;
143
+ border_colorFill(): string;
144
+ border_colorFill(_: string): this;
145
+ border_colorFill_exists: () => boolean;
146
+ showTitle(): boolean;
147
+ showTitle(_: boolean): this;
148
+ title(): string;
149
+ title(_: string): this;
150
+ titleFontSize(): string;
151
+ titleFontSize(_: string): this;
152
+ title_colorFill(): string;
153
+ title_colorFill(_: string): this;
154
+ title_colorFill_exists: () => boolean;
155
+ showMinMax(): boolean;
156
+ showMinMax(_: boolean): this;
157
+ }
158
+
159
+ Subgraph.prototype.publish("border_colorStroke", null, "html-color", "Stroke Color", null, { optional: true });
160
+ Subgraph.prototype.publish("border_colorFill", null, "html-color", "Fill Color", null, { optional: true });
161
+ Subgraph.prototype.publish("showTitle", true, "boolean", "Show Title", null, { tags: ["Basic"] });
162
+ Subgraph.prototype.publish("title", "", "string", "Title", null, { tags: ["Basic"] });
163
+ Subgraph.prototype.publishProxy("titleFontSize", "_textWidget", "fontSize");
164
+ Subgraph.prototype.publishProxy("title_colorFill", "_textWidget", "colorFill");
165
+ Subgraph.prototype.publish("showMinMax", false, "boolean", "Show Min/Max", null, { tags: ["Basic"] });
package/src/Vertex.css CHANGED
@@ -1,3 +1,3 @@
1
- .graph_Vertex.selected .common_Shape {
2
- stroke: red !important;
1
+ .graph_Vertex.selected .common_Shape {
2
+ stroke: red !important;
3
3
  }