@hpcc-js/graph 3.6.5 → 3.7.0

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-DQ0E8zfY.js.map → graphviz-DJ070oMZ.js.map} +1 -1
  5. package/dist/index.js +4 -4
  6. package/dist/index.js.map +1 -1
  7. package/dist/index.umd.cjs +13 -13
  8. package/dist/index.umd.cjs.map +1 -1
  9. package/package.json +9 -9
  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 +45 -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
package/src/Sankey.ts CHANGED
@@ -1,304 +1,304 @@
1
- import { Palette, PropertyExt, SVGWidget, Utility, max as d3Max, mean as d3Mean, median as d3Median, min as d3Min, sum as d3Sum } from "@hpcc-js/common";
2
- import { sankey as d3Sankey, sankeyLinkHorizontal as d3SankeyLinkHorizontal } from "d3-sankey";
3
- import { select as d3Select } from "d3-selection";
4
-
5
- import "../src/Sankey.css";
6
-
7
- const d3Aggr = {
8
- mean: d3Mean,
9
- median: d3Median,
10
- min: d3Min,
11
- max: d3Max,
12
- sum: d3Sum
13
- };
14
-
15
- export class SankeyColumn extends PropertyExt {
16
- _owner: Sankey;
17
-
18
- constructor() {
19
- super();
20
- }
21
-
22
- owner(): Sankey;
23
- owner(_: Sankey): this;
24
- owner(_?: Sankey): Sankey | this {
25
- if (!arguments.length) return this._owner;
26
- this._owner = _;
27
- return this;
28
- }
29
-
30
- valid(): boolean {
31
- return !!this.column();
32
- }
33
-
34
- aggregate(values) {
35
- switch (this.aggrType()) {
36
- case null:
37
- case undefined:
38
- case "":
39
- return values.length;
40
- default:
41
- const columns = this._owner.columns();
42
- const colIdx = columns.indexOf(this.aggrColumn());
43
- return d3Aggr[this.aggrType()](values, function (value) {
44
- return +value[colIdx];
45
- });
46
- }
47
- }
48
- }
49
- SankeyColumn.prototype._class += " graph_Sankey.SankeyColumn";
50
-
51
- export interface SankeyColumn {
52
- column(): string;
53
- column(_: string): this;
54
- aggrType(): string;
55
- aggrType(_: string): this;
56
- aggrColumn(): string;
57
- aggrColumn(_: string): this;
58
- }
59
-
60
- SankeyColumn.prototype.publish("column", null, "set", "Field", function (this: SankeyColumn) { return this._owner ? this._owner.columns() : []; }, { optional: true });
61
- SankeyColumn.prototype.publish("aggrType", null, "set", "Aggregation Type", [null, "mean", "median", "sum", "min", "max"], { optional: true, disable: w => !w._owner || w._owner.mappings().indexOf(w) === 0 });
62
- SankeyColumn.prototype.publish("aggrColumn", null, "set", "Aggregation Field", function (this: SankeyColumn) { return this._owner ? this._owner.columns() : []; }, { optional: true, disable: w => !w._owner || !w.aggrType() || w._owner.mappings().indexOf(w) === 0 });
63
-
64
- export class Sankey extends SVGWidget {
65
- Column;
66
- _d3Sankey;
67
- _d3SankeyPath;
68
- _selection;
69
-
70
- constructor() {
71
- super();
72
- Utility.SimpleSelectionMixin.call(this, false);
73
- this._drawStartPos = "origin";
74
- }
75
-
76
- sankeyData() {
77
- const retVal = {
78
- vertices: [],
79
- edges: []
80
- };
81
- if (this.data().length === 0) return retVal;
82
- const vertexIndex = {};
83
- const valueIdx = 2;
84
- const mappings = this.mappings().filter(mapping => mapping.valid());
85
- mappings.forEach((mapping, idx) => {
86
- const view = this._db.rollupView([mapping.column()]);
87
- view.entries().forEach(function (row) {
88
- const id = mapping.column() + ":" + idx + ":" + row.key;
89
- if (!vertexIndex[id]) {
90
- retVal.vertices.push({
91
- __id: id,
92
- __category: mapping.column(),
93
- name: row.key,
94
- origRow: row.value,
95
- value: row.value[idx][valueIdx]
96
- });
97
- vertexIndex[id] = retVal.vertices.length - 1;
98
- }
99
- }, this);
100
- });
101
- mappings.forEach((mapping, idx) => {
102
- if (idx < mappings.length - 1) {
103
- const mapping2 = mappings[idx + 1];
104
- const view = this._db.rollupView([mapping.column(), mapping2.column()]);
105
- view.entries().forEach(function (row) {
106
- const sourceID = mapping.column() + ":" + idx + ":" + row.key;
107
- row.values.forEach(function (value) {
108
- const targetID = mapping2.column() + ":" + (idx + 1) + ":" + value.key;
109
- retVal.edges.push({
110
- __id: sourceID + "_" + targetID,
111
- source: vertexIndex[sourceID],
112
- target: vertexIndex[targetID],
113
- value: value.value[0][valueIdx]
114
- });
115
- });
116
- });
117
- }
118
- });
119
-
120
- return retVal;
121
- }
122
- enter(domNode, element) {
123
- super.enter(domNode, element);
124
-
125
- this._d3Sankey = new d3Sankey();
126
- this._selection.widgetElement(element);
127
- }
128
-
129
- update(domNode, element) {
130
- super.update(domNode, element);
131
-
132
- this._palette = this._palette.switch(this.paletteID());
133
-
134
- const strokeWidth = this.vertexStrokeWidth();
135
-
136
- const sankeyData = this.sankeyData();
137
- const sw2 = strokeWidth * 2;
138
- this._d3Sankey
139
- .extent([
140
- [strokeWidth, strokeWidth],
141
- [this.width() - sw2, this.height() - sw2]
142
- ])
143
- .nodeWidth(this.vertexWidth())
144
- .nodePadding(this.vertexPadding())
145
- ;
146
- this._d3Sankey({
147
- nodes: sankeyData.vertices,
148
- links: sankeyData.edges
149
- });
150
- const context = this;
151
-
152
- // Links ---
153
- const link = element.selectAll(".link").data(sankeyData.edges);
154
- link.enter().append("path")
155
- .attr("class", "link")
156
- .each(function (this: HTMLElement) {
157
- d3Select(this)
158
- .append("title")
159
- ;
160
- })
161
- .merge(link)
162
- .attr("d", d3SankeyLinkHorizontal())
163
- .style("stroke-width", function (d) {
164
- return Math.max(1, d.width);
165
- })
166
- .sort(function (a, b) { return b.width - a.width; })
167
- .select("title")
168
- .text(function (d) {
169
- return d.source.name + " → " + d.target.name + "\n" + d.value;
170
- })
171
- ;
172
- link.exit().remove();
173
- // Nodes ---
174
- const node = element.selectAll(".node").data(sankeyData.vertices);
175
- node.enter().append("g")
176
- .attr("class", "node")
177
- .call(this._selection.enter.bind(this._selection))
178
- .on("click", function (this: HTMLElement, d) {
179
- context.click(context.rowToObj(d.origRow[0]), "", context._selection.selected(this));
180
- })
181
- .on("dblclick", function (this: HTMLElement, d) {
182
- context.dblclick(context.rowToObj(d.origRow[0]), "", context._selection.selected(this));
183
- })
184
- .each(function (this: HTMLElement) {
185
- const gElement = d3Select(this);
186
- gElement.append("rect");
187
- gElement.append("text");
188
- })
189
- /*
190
- .call(d3.behavior.drag()
191
- .origin(function (d) { return d; })
192
- .on("dragstart", function () {
193
- this.parentNode.appendChild(this);
194
- })
195
- .on("drag", dragmove)
196
- )
197
- */
198
- .merge(node)
199
- .attr("transform", function (d) {
200
- let _x = 0;
201
- let _y = 0;
202
- if (d.x0) _x = d.x0;
203
- if (d.y0) _y = d.y0;
204
- return "translate(" + (_x + strokeWidth) + "," + (_y + strokeWidth) + ")";
205
- })
206
- .each(function (this: HTMLElement) {
207
- const n = d3Select(this);
208
- n.select("rect")
209
- .attr("height", function (d: any) { return d.y1 - d.y0; })
210
- .attr("width", context._d3Sankey.nodeWidth())
211
- .style("fill", function (d: any) { return context._palette(d.name); })
212
- .style("stroke", function (d: any) { return context.vertexStrokeColor(); })
213
- .style("stroke-width", function (d: any) { return strokeWidth; })
214
- .style("cursor", (context.xAxisMovement() || context.yAxisMovement()) ? null : "default")
215
- ;
216
- n.select("text")
217
- .attr("x", -6)
218
- .attr("y", function (d: any) {
219
- return (d.y1 - d.y0) / 2;
220
- })
221
- .attr("dy", ".35em")
222
- .attr("text-anchor", "end")
223
- .attr("transform", null)
224
- .text(function (d: any) { return d.name; })
225
- .filter(function (d: any) { return d.x0 < context.width() / 2; })
226
- .attr("x", 6 + context._d3Sankey.nodeWidth())
227
- .attr("text-anchor", "start")
228
- ;
229
- });
230
- node.exit().remove();
231
-
232
- /*
233
- function dragmove(d) {
234
- var gElement = d3.select(this);
235
- if (context.xAxisMovement()) {
236
- d.x = Math.max(0, Math.min(context.width() - d.dx, d3.event.x));
237
- }
238
- if (context.yAxisMovement()) {
239
- d.y = Math.max(0, Math.min(context.height() - d.dy, d3.event.y));
240
- }
241
- gElement.attr("transform", "translate(" + d.x + "," + d.y + ")");
242
- context._d3Sankey.relayout();
243
- link.attr("d", context._d3SankeyPath);
244
-
245
- gElement.select("text")
246
- .attr("x", -6)
247
- .attr("y", function (d) { return d.dy / 2; })
248
- .attr("dy", ".35em")
249
- .attr("text-anchor", "end")
250
- .attr("transform", null)
251
- .text(function (d) { return d.name; })
252
- .filter(function (d) { return d.x < context.width() / 2; })
253
- .attr("x", 6 + context._d3Sankey.nodeWidth())
254
- .attr("text-anchor", "start")
255
- ;
256
- }
257
- */
258
- }
259
-
260
- exit(domNode, element) {
261
- super.exit(domNode, element);
262
- }
263
-
264
- // Events ---
265
- click(row, column, selected) {
266
- }
267
-
268
- dblclick(row, column, selected) {
269
- }
270
- }
271
- Sankey.prototype._class += " graph_Sankey";
272
- Sankey.prototype.Column = SankeyColumn;
273
- Sankey.prototype.mixin(Utility.SimpleSelectionMixin);
274
-
275
- export interface Sankey {
276
- _palette;
277
- paletteID(): string;
278
- paletteID(_: string): this;
279
- mappings(): SankeyColumn[];
280
- mappings(_: SankeyColumn[]): this;
281
- vertexStrokeWidth(): number;
282
- vertexStrokeWidth(_: number): this;
283
- vertexStrokeColor(): string;
284
- vertexStrokeColor(_: string): this;
285
- vertexWidth(): number;
286
- vertexWidth(_: number): this;
287
- vertexPadding(): number;
288
- vertexPadding(_: number): this;
289
- xAxisMovement(): boolean;
290
- xAxisMovement(_: boolean): this;
291
- yAxisMovement(): boolean;
292
- yAxisMovement(_: boolean): this;
293
- }
294
-
295
- Sankey.prototype._palette = Palette.ordinal("default");
296
-
297
- Sankey.prototype.publish("paletteID", "default", "set", "Color palette for this widget", Sankey.prototype._palette.switch());
298
- Sankey.prototype.publish("mappings", [], "propertyArray", "Source Columns", null, { autoExpand: SankeyColumn });
299
- Sankey.prototype.publish("vertexStrokeWidth", 1, "number", "Vertex Stroke Width");
300
- Sankey.prototype.publish("vertexStrokeColor", "darkgray", "string", "Vertex Stroke Color");
301
- Sankey.prototype.publish("vertexWidth", 36, "number", "Vertex Width");
302
- Sankey.prototype.publish("vertexPadding", 40, "number", "Vertex Padding");
303
- Sankey.prototype.publish("xAxisMovement", false, "boolean", "Enable x-axis movement");
304
- Sankey.prototype.publish("yAxisMovement", false, "boolean", "Enable y-axis movement");
1
+ import { Palette, PropertyExt, SVGWidget, Utility, max as d3Max, mean as d3Mean, median as d3Median, min as d3Min, sum as d3Sum } from "@hpcc-js/common";
2
+ import { sankey as d3Sankey, sankeyLinkHorizontal as d3SankeyLinkHorizontal } from "d3-sankey";
3
+ import { select as d3Select } from "d3-selection";
4
+
5
+ import "../src/Sankey.css";
6
+
7
+ const d3Aggr = {
8
+ mean: d3Mean,
9
+ median: d3Median,
10
+ min: d3Min,
11
+ max: d3Max,
12
+ sum: d3Sum
13
+ };
14
+
15
+ export class SankeyColumn extends PropertyExt {
16
+ _owner: Sankey;
17
+
18
+ constructor() {
19
+ super();
20
+ }
21
+
22
+ owner(): Sankey;
23
+ owner(_: Sankey): this;
24
+ owner(_?: Sankey): Sankey | this {
25
+ if (!arguments.length) return this._owner;
26
+ this._owner = _;
27
+ return this;
28
+ }
29
+
30
+ valid(): boolean {
31
+ return !!this.column();
32
+ }
33
+
34
+ aggregate(values) {
35
+ switch (this.aggrType()) {
36
+ case null:
37
+ case undefined:
38
+ case "":
39
+ return values.length;
40
+ default:
41
+ const columns = this._owner.columns();
42
+ const colIdx = columns.indexOf(this.aggrColumn());
43
+ return d3Aggr[this.aggrType()](values, function (value) {
44
+ return +value[colIdx];
45
+ });
46
+ }
47
+ }
48
+ }
49
+ SankeyColumn.prototype._class += " graph_Sankey.SankeyColumn";
50
+
51
+ export interface SankeyColumn {
52
+ column(): string;
53
+ column(_: string): this;
54
+ aggrType(): string;
55
+ aggrType(_: string): this;
56
+ aggrColumn(): string;
57
+ aggrColumn(_: string): this;
58
+ }
59
+
60
+ SankeyColumn.prototype.publish("column", null, "set", "Field", function (this: SankeyColumn) { return this._owner ? this._owner.columns() : []; }, { optional: true });
61
+ SankeyColumn.prototype.publish("aggrType", null, "set", "Aggregation Type", [null, "mean", "median", "sum", "min", "max"], { optional: true, disable: w => !w._owner || w._owner.mappings().indexOf(w) === 0 });
62
+ SankeyColumn.prototype.publish("aggrColumn", null, "set", "Aggregation Field", function (this: SankeyColumn) { return this._owner ? this._owner.columns() : []; }, { optional: true, disable: w => !w._owner || !w.aggrType() || w._owner.mappings().indexOf(w) === 0 });
63
+
64
+ export class Sankey extends SVGWidget {
65
+ Column;
66
+ _d3Sankey;
67
+ _d3SankeyPath;
68
+ _selection;
69
+
70
+ constructor() {
71
+ super();
72
+ Utility.SimpleSelectionMixin.call(this, false);
73
+ this._drawStartPos = "origin";
74
+ }
75
+
76
+ sankeyData() {
77
+ const retVal = {
78
+ vertices: [],
79
+ edges: []
80
+ };
81
+ if (this.data().length === 0) return retVal;
82
+ const vertexIndex = {};
83
+ const valueIdx = 2;
84
+ const mappings = this.mappings().filter(mapping => mapping.valid());
85
+ mappings.forEach((mapping, idx) => {
86
+ const view = this._db.rollupView([mapping.column()]);
87
+ view.entries().forEach(function (row) {
88
+ const id = mapping.column() + ":" + idx + ":" + row.key;
89
+ if (!vertexIndex[id]) {
90
+ retVal.vertices.push({
91
+ __id: id,
92
+ __category: mapping.column(),
93
+ name: row.key,
94
+ origRow: row.value,
95
+ value: row.value[idx][valueIdx]
96
+ });
97
+ vertexIndex[id] = retVal.vertices.length - 1;
98
+ }
99
+ }, this);
100
+ });
101
+ mappings.forEach((mapping, idx) => {
102
+ if (idx < mappings.length - 1) {
103
+ const mapping2 = mappings[idx + 1];
104
+ const view = this._db.rollupView([mapping.column(), mapping2.column()]);
105
+ view.entries().forEach(function (row) {
106
+ const sourceID = mapping.column() + ":" + idx + ":" + row.key;
107
+ row.values.forEach(function (value) {
108
+ const targetID = mapping2.column() + ":" + (idx + 1) + ":" + value.key;
109
+ retVal.edges.push({
110
+ __id: sourceID + "_" + targetID,
111
+ source: vertexIndex[sourceID],
112
+ target: vertexIndex[targetID],
113
+ value: value.value[0][valueIdx]
114
+ });
115
+ });
116
+ });
117
+ }
118
+ });
119
+
120
+ return retVal;
121
+ }
122
+ enter(domNode, element) {
123
+ super.enter(domNode, element);
124
+
125
+ this._d3Sankey = new d3Sankey();
126
+ this._selection.widgetElement(element);
127
+ }
128
+
129
+ update(domNode, element) {
130
+ super.update(domNode, element);
131
+
132
+ this._palette = this._palette.switch(this.paletteID());
133
+
134
+ const strokeWidth = this.vertexStrokeWidth();
135
+
136
+ const sankeyData = this.sankeyData();
137
+ const sw2 = strokeWidth * 2;
138
+ this._d3Sankey
139
+ .extent([
140
+ [strokeWidth, strokeWidth],
141
+ [this.width() - sw2, this.height() - sw2]
142
+ ])
143
+ .nodeWidth(this.vertexWidth())
144
+ .nodePadding(this.vertexPadding())
145
+ ;
146
+ this._d3Sankey({
147
+ nodes: sankeyData.vertices,
148
+ links: sankeyData.edges
149
+ });
150
+ const context = this;
151
+
152
+ // Links ---
153
+ const link = element.selectAll(".link").data(sankeyData.edges);
154
+ link.enter().append("path")
155
+ .attr("class", "link")
156
+ .each(function (this: HTMLElement) {
157
+ d3Select(this)
158
+ .append("title")
159
+ ;
160
+ })
161
+ .merge(link)
162
+ .attr("d", d3SankeyLinkHorizontal())
163
+ .style("stroke-width", function (d) {
164
+ return Math.max(1, d.width);
165
+ })
166
+ .sort(function (a, b) { return b.width - a.width; })
167
+ .select("title")
168
+ .text(function (d) {
169
+ return d.source.name + " → " + d.target.name + "\n" + d.value;
170
+ })
171
+ ;
172
+ link.exit().remove();
173
+ // Nodes ---
174
+ const node = element.selectAll(".node").data(sankeyData.vertices);
175
+ node.enter().append("g")
176
+ .attr("class", "node")
177
+ .call(this._selection.enter.bind(this._selection))
178
+ .on("click", function (this: HTMLElement, d) {
179
+ context.click(context.rowToObj(d.origRow[0]), "", context._selection.selected(this));
180
+ })
181
+ .on("dblclick", function (this: HTMLElement, d) {
182
+ context.dblclick(context.rowToObj(d.origRow[0]), "", context._selection.selected(this));
183
+ })
184
+ .each(function (this: HTMLElement) {
185
+ const gElement = d3Select(this);
186
+ gElement.append("rect");
187
+ gElement.append("text");
188
+ })
189
+ /*
190
+ .call(d3.behavior.drag()
191
+ .origin(function (d) { return d; })
192
+ .on("dragstart", function () {
193
+ this.parentNode.appendChild(this);
194
+ })
195
+ .on("drag", dragmove)
196
+ )
197
+ */
198
+ .merge(node)
199
+ .attr("transform", function (d) {
200
+ let _x = 0;
201
+ let _y = 0;
202
+ if (d.x0) _x = d.x0;
203
+ if (d.y0) _y = d.y0;
204
+ return "translate(" + (_x + strokeWidth) + "," + (_y + strokeWidth) + ")";
205
+ })
206
+ .each(function (this: HTMLElement) {
207
+ const n = d3Select(this);
208
+ n.select("rect")
209
+ .attr("height", function (d: any) { return d.y1 - d.y0; })
210
+ .attr("width", context._d3Sankey.nodeWidth())
211
+ .style("fill", function (d: any) { return context._palette(d.name); })
212
+ .style("stroke", function (d: any) { return context.vertexStrokeColor(); })
213
+ .style("stroke-width", function (d: any) { return strokeWidth; })
214
+ .style("cursor", (context.xAxisMovement() || context.yAxisMovement()) ? null : "default")
215
+ ;
216
+ n.select("text")
217
+ .attr("x", -6)
218
+ .attr("y", function (d: any) {
219
+ return (d.y1 - d.y0) / 2;
220
+ })
221
+ .attr("dy", ".35em")
222
+ .attr("text-anchor", "end")
223
+ .attr("transform", null)
224
+ .text(function (d: any) { return d.name; })
225
+ .filter(function (d: any) { return d.x0 < context.width() / 2; })
226
+ .attr("x", 6 + context._d3Sankey.nodeWidth())
227
+ .attr("text-anchor", "start")
228
+ ;
229
+ });
230
+ node.exit().remove();
231
+
232
+ /*
233
+ function dragmove(d) {
234
+ var gElement = d3.select(this);
235
+ if (context.xAxisMovement()) {
236
+ d.x = Math.max(0, Math.min(context.width() - d.dx, d3.event.x));
237
+ }
238
+ if (context.yAxisMovement()) {
239
+ d.y = Math.max(0, Math.min(context.height() - d.dy, d3.event.y));
240
+ }
241
+ gElement.attr("transform", "translate(" + d.x + "," + d.y + ")");
242
+ context._d3Sankey.relayout();
243
+ link.attr("d", context._d3SankeyPath);
244
+
245
+ gElement.select("text")
246
+ .attr("x", -6)
247
+ .attr("y", function (d) { return d.dy / 2; })
248
+ .attr("dy", ".35em")
249
+ .attr("text-anchor", "end")
250
+ .attr("transform", null)
251
+ .text(function (d) { return d.name; })
252
+ .filter(function (d) { return d.x < context.width() / 2; })
253
+ .attr("x", 6 + context._d3Sankey.nodeWidth())
254
+ .attr("text-anchor", "start")
255
+ ;
256
+ }
257
+ */
258
+ }
259
+
260
+ exit(domNode, element) {
261
+ super.exit(domNode, element);
262
+ }
263
+
264
+ // Events ---
265
+ click(row, column, selected) {
266
+ }
267
+
268
+ dblclick(row, column, selected) {
269
+ }
270
+ }
271
+ Sankey.prototype._class += " graph_Sankey";
272
+ Sankey.prototype.Column = SankeyColumn;
273
+ Sankey.prototype.mixin(Utility.SimpleSelectionMixin);
274
+
275
+ export interface Sankey {
276
+ _palette;
277
+ paletteID(): string;
278
+ paletteID(_: string): this;
279
+ mappings(): SankeyColumn[];
280
+ mappings(_: SankeyColumn[]): this;
281
+ vertexStrokeWidth(): number;
282
+ vertexStrokeWidth(_: number): this;
283
+ vertexStrokeColor(): string;
284
+ vertexStrokeColor(_: string): this;
285
+ vertexWidth(): number;
286
+ vertexWidth(_: number): this;
287
+ vertexPadding(): number;
288
+ vertexPadding(_: number): this;
289
+ xAxisMovement(): boolean;
290
+ xAxisMovement(_: boolean): this;
291
+ yAxisMovement(): boolean;
292
+ yAxisMovement(_: boolean): this;
293
+ }
294
+
295
+ Sankey.prototype._palette = Palette.ordinal("default");
296
+
297
+ Sankey.prototype.publish("paletteID", "default", "set", "Color palette for this widget", Sankey.prototype._palette.switch());
298
+ Sankey.prototype.publish("mappings", [], "propertyArray", "Source Columns", null, { autoExpand: SankeyColumn });
299
+ Sankey.prototype.publish("vertexStrokeWidth", 1, "number", "Vertex Stroke Width");
300
+ Sankey.prototype.publish("vertexStrokeColor", "darkgray", "string", "Vertex Stroke Color");
301
+ Sankey.prototype.publish("vertexWidth", 36, "number", "Vertex Width");
302
+ Sankey.prototype.publish("vertexPadding", 40, "number", "Vertex Padding");
303
+ Sankey.prototype.publish("xAxisMovement", false, "boolean", "Enable x-axis movement");
304
+ Sankey.prototype.publish("yAxisMovement", false, "boolean", "Enable y-axis movement");
package/src/Subgraph.css CHANGED
@@ -1,10 +1,10 @@
1
- .graph_Subgraph .border {
2
- fill: none;
3
- stroke: #1f77b4;
4
- stroke-width: 1.0px;
5
- pointer-events: none;
6
- }
7
-
8
- .graph_Subgraph.selected > rect {
9
- stroke:red !important;
10
- }
1
+ .graph_Subgraph .border {
2
+ fill: none;
3
+ stroke: #1f77b4;
4
+ stroke-width: 1.0px;
5
+ pointer-events: none;
6
+ }
7
+
8
+ .graph_Subgraph.selected>rect {
9
+ stroke: red !important;
10
+ }