@webviz/group-tree-plot 1.0.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.
@@ -0,0 +1,64 @@
1
+ /**
2
+ * Class to assemble Group tree visualization. Creates an _svg, and appends to the
3
+ * assigned HTML element. Draws the tree provided in datedTrees with the current flow rate,
4
+ * node info and date time.
5
+ *
6
+ * Provides methods to update selected date time, and change flow rate and node info.
7
+ */
8
+ export default class GroupTreeAssembler {
9
+ /**
10
+ * Initialize all trees in the group tree datastructure, once for the entire visualization.
11
+ *
12
+ */
13
+ static initHierarchies(tree_data: any, height: any): any;
14
+ /**
15
+ *
16
+ * @param dom_element_id - id of the HTML element to append the _svg to
17
+ * @param datedTrees - List of dated tree data structure containing the trees to visualize
18
+ * @param initialFlowRate - key identifying the initial selected flow rate for the tree edges
19
+ * @param initialNodeInfo - key identifying the initial selected node info for the tree nodes
20
+ * @param currentDateTime - the initial/current date time
21
+ * @param edgeMetadataList - List of metadata for the edge keys in the tree data structure
22
+ * @param nodeMetadataList - List of metadata for the node keys in the tree data structure
23
+ */
24
+ constructor(dom_element_id: any, datedTrees: any, initialFlowRate: any, initialNodeInfo: any, currentDateTime: any, edgeMetadataList: any, nodeMetadataList: any);
25
+ _propertyToLabelMap: Map<any, any>;
26
+ _currentFlowRate: any;
27
+ _currentNodeInfo: any;
28
+ _currentDateTime: any;
29
+ _transitionTime: number;
30
+ _path_scale: Map<any, any>;
31
+ _rectWidth: any;
32
+ _rectHeight: number;
33
+ _rectLeftMargin: number;
34
+ _rectTopMargin: number;
35
+ _treeWidth: number;
36
+ _svg: d3.Selection<SVGGElement, any, null, undefined>;
37
+ _textpaths: d3.Selection<SVGGElement, any, null, undefined>;
38
+ _renderTree: d3.TreeLayout<any>;
39
+ _data: any;
40
+ _currentTree: {};
41
+ /**
42
+ * @returns {*} -The initialized hierarchical group tree data structure
43
+ */
44
+ get data(): any;
45
+ /**
46
+ * Set the flowrate and update display of all edges accordingly.
47
+ *
48
+ * @param flowrate - key identifying the flowrate of the incoming edge
49
+ */
50
+ set flowrate(arg: any);
51
+ get flowrate(): any;
52
+ set nodeinfo(arg: any);
53
+ get nodeinfo(): any;
54
+ getEdgeStrokeWidth(key: any, val: any): string;
55
+ /**
56
+ * Sets the state of the current tree, and updates the tree visualization accordingly.
57
+ * The state is changed either due to a branch open/close, or that the tree is entirely changed
58
+ * when moving back and fourth in time.
59
+ *
60
+ * @param root
61
+ */
62
+ update(newDateTime: any): void;
63
+ }
64
+ import * as d3 from "d3";
@@ -0,0 +1,579 @@
1
+ /** This code is copied directly from
2
+ * https://github.com/anders-kiaer/webviz-subsurface-components/blob/dynamic_tree/src/lib/components/DynamicTree/group_tree.js
3
+ * This needs to be refactored to develop further
4
+ *
5
+ * 9 july 2021: refactored to use new format.
6
+ */
7
+ import * as d3 from "d3";
8
+ import "./group_tree.css";
9
+ import { cloneDeep } from "lodash";
10
+ /* eslint camelcase: "off" */
11
+ /* eslint array-callback-return: "off" */
12
+ /* eslint no-return-assign: "off" */
13
+ /* eslint no-use-before-define: "off" */
14
+ /* eslint no-useless-concat: "off" */
15
+ /* Fix this lint when rewriting the whole file */
16
+ /**
17
+ * Class to assemble Group tree visualization. Creates an _svg, and appends to the
18
+ * assigned HTML element. Draws the tree provided in datedTrees with the current flow rate,
19
+ * node info and date time.
20
+ *
21
+ * Provides methods to update selected date time, and change flow rate and node info.
22
+ */
23
+ export default class GroupTreeAssembler {
24
+ /**
25
+ *
26
+ * @param dom_element_id - id of the HTML element to append the _svg to
27
+ * @param datedTrees - List of dated tree data structure containing the trees to visualize
28
+ * @param initialFlowRate - key identifying the initial selected flow rate for the tree edges
29
+ * @param initialNodeInfo - key identifying the initial selected node info for the tree nodes
30
+ * @param currentDateTime - the initial/current date time
31
+ * @param edgeMetadataList - List of metadata for the edge keys in the tree data structure
32
+ * @param nodeMetadataList - List of metadata for the node keys in the tree data structure
33
+ */
34
+ constructor(dom_element_id, datedTrees, initialFlowRate, initialNodeInfo, currentDateTime, edgeMetadataList, nodeMetadataList) {
35
+ // Cloned as it is mutated within class
36
+ let clonedDatedTrees = cloneDeep(datedTrees);
37
+ // Add "#" if missing.
38
+ if (dom_element_id.charAt(0) !== "#") {
39
+ dom_element_id = "#" + dom_element_id;
40
+ }
41
+ // Map from property to [label/name, unit]
42
+ const metadataList = [...edgeMetadataList, ...nodeMetadataList];
43
+ this._propertyToLabelMap = new Map();
44
+ metadataList.forEach((elm) => {
45
+ var _a, _b;
46
+ this._propertyToLabelMap.set(elm.key, [
47
+ (_a = elm.label) !== null && _a !== void 0 ? _a : "",
48
+ (_b = elm.unit) !== null && _b !== void 0 ? _b : "",
49
+ ]);
50
+ });
51
+ // Represent possible empty data by single empty node.
52
+ if (clonedDatedTrees.length === 0) {
53
+ currentDateTime = "";
54
+ clonedDatedTrees = [
55
+ {
56
+ dates: [currentDateTime],
57
+ tree: {
58
+ node_label: "NO DATA",
59
+ edge_label: "NO DATA",
60
+ node_data: {},
61
+ edge_data: {},
62
+ },
63
+ },
64
+ ];
65
+ }
66
+ this._currentFlowRate = initialFlowRate;
67
+ this._currentNodeInfo = initialNodeInfo;
68
+ this._currentDateTime = currentDateTime;
69
+ this._transitionTime = 200;
70
+ const tree_values = {};
71
+ clonedDatedTrees.map((datedTree) => {
72
+ let tree = datedTree.tree;
73
+ d3.hierarchy(tree, (d) => d.children).each((node) => {
74
+ // edge_data
75
+ Object.keys(node.data.edge_data).forEach((key) => {
76
+ if (!tree_values[key]) {
77
+ tree_values[key] = [];
78
+ }
79
+ tree_values[key].push(node.data.edge_data[key]);
80
+ });
81
+ });
82
+ });
83
+ this._path_scale = new Map();
84
+ Object.keys(tree_values).forEach((key) => {
85
+ const extent = [0, d3.max(tree_values[key].flat())];
86
+ this._path_scale[key] = d3
87
+ .scaleLinear()
88
+ .domain(extent)
89
+ .range([2, 100]);
90
+ });
91
+ const margin = {
92
+ top: 10,
93
+ right: 90,
94
+ bottom: 30,
95
+ left: 90,
96
+ };
97
+ const select = d3.select(dom_element_id);
98
+ // Svg bounding client rect
99
+ this._rectWidth = select.node().getBoundingClientRect().width;
100
+ this._rectHeight = 700;
101
+ this._rectLeftMargin = -margin.left;
102
+ this._rectTopMargin = -margin.top;
103
+ const treeHeight = this._rectHeight - margin.top - margin.bottom;
104
+ this._treeWidth = this._rectWidth - margin.left - margin.right;
105
+ // Clear possible existing svg's.
106
+ d3.select(dom_element_id).selectAll("svg").remove();
107
+ this._svg = d3
108
+ .select(dom_element_id)
109
+ .append("svg")
110
+ .attr("width", this._treeWidth + margin.right + margin.left)
111
+ .attr("height", treeHeight + margin.top + margin.bottom)
112
+ .append("g")
113
+ .attr("transform", `translate(${margin.left},${margin.top})`);
114
+ this._textpaths = this._svg.append("g");
115
+ this._renderTree = d3.tree().size([treeHeight, this._treeWidth]);
116
+ this._data = GroupTreeAssembler.initHierarchies(clonedDatedTrees, treeHeight);
117
+ this._currentTree = {};
118
+ this.update(currentDateTime);
119
+ }
120
+ /**
121
+ * Initialize all trees in the group tree datastructure, once for the entire visualization.
122
+ *
123
+ */
124
+ static initHierarchies(tree_data, height) {
125
+ // generate the node-id used to match in the enter, update and exit selections
126
+ const getId = (d) => d.parent === null
127
+ ? d.data.node_label
128
+ : `${d.parent.id}_${d.data.node_label}`;
129
+ tree_data.map((datedTree) => {
130
+ let tree = datedTree.tree;
131
+ tree = d3.hierarchy(tree, (dd) => dd.children);
132
+ tree.descendants().map((n) => (n.id = getId(n)));
133
+ tree.x0 = height / 2;
134
+ tree.y0 = 0;
135
+ datedTree.tree = tree;
136
+ });
137
+ return tree_data;
138
+ }
139
+ /**
140
+ * @returns {*} -The initialized hierarchical group tree data structure
141
+ */
142
+ get data() {
143
+ return this._data;
144
+ }
145
+ /**
146
+ * Set the flowrate and update display of all edges accordingly.
147
+ *
148
+ * @param flowrate - key identifying the flowrate of the incoming edge
149
+ */
150
+ set flowrate(flowrate) {
151
+ this._currentFlowRate = flowrate;
152
+ const current_tree_index = this._data.findIndex((e) => {
153
+ return e.dates.includes(this._currentDateTime);
154
+ });
155
+ if (current_tree_index === -1) {
156
+ this._svg.selectAll("path.link").remove();
157
+ return;
158
+ }
159
+ const date_index = this._data[current_tree_index].dates.indexOf(this._currentDateTime);
160
+ if (date_index === -1) {
161
+ this._svg.selectAll("path.link").remove();
162
+ return;
163
+ }
164
+ this._svg
165
+ .selectAll("path.link")
166
+ .transition()
167
+ .duration(this._transitionTime)
168
+ .attr("class", () => `link grouptree_link grouptree_link__${flowrate}`)
169
+ .style("stroke-width", (d) => {
170
+ var _a, _b;
171
+ return this.getEdgeStrokeWidth(flowrate, (_b = (_a = d.data.edge_data[flowrate]) === null || _a === void 0 ? void 0 : _a[date_index]) !== null && _b !== void 0 ? _b : 0);
172
+ })
173
+ .style("stroke-dasharray", (d) => {
174
+ var _a, _b;
175
+ return ((_b = (_a = d.data.edge_data[flowrate]) === null || _a === void 0 ? void 0 : _a[date_index]) !== null && _b !== void 0 ? _b : 0) > 0
176
+ ? "none"
177
+ : "5,5";
178
+ });
179
+ }
180
+ get flowrate() {
181
+ return this._currentFlowRate;
182
+ }
183
+ set nodeinfo(nodeinfo) {
184
+ this._currentNodeInfo = nodeinfo;
185
+ const current_tree_index = this._data.findIndex((e) => {
186
+ return e.dates.includes(this._currentDateTime);
187
+ });
188
+ if (current_tree_index === -1) {
189
+ this._svg.selectAll("path.link").remove();
190
+ return;
191
+ }
192
+ const date_index = this._data[current_tree_index].dates.indexOf(this._currentDateTime);
193
+ if (date_index === -1) {
194
+ this._svg.selectAll("path.link").remove();
195
+ return;
196
+ }
197
+ this._svg
198
+ .selectAll(".grouptree__pressurelabel")
199
+ .text((d) => {
200
+ var _a, _b, _c, _d;
201
+ return (_d = (_c = (_b = (_a = d.data.node_data) === null || _a === void 0 ? void 0 : _a[nodeinfo]) === null || _b === void 0 ? void 0 : _b[date_index]) === null || _c === void 0 ? void 0 : _c.toFixed(0)) !== null && _d !== void 0 ? _d : "NA";
202
+ });
203
+ this._svg.selectAll(".grouptree__pressureunit").text(() => {
204
+ var _a;
205
+ const t = (_a = this._propertyToLabelMap.get(nodeinfo)) !== null && _a !== void 0 ? _a : ["", ""];
206
+ return t[1];
207
+ });
208
+ }
209
+ get nodeinfo() {
210
+ return this._currentNodeInfo;
211
+ }
212
+ getEdgeStrokeWidth(key, val) {
213
+ const normalized = this._path_scale[key] !== undefined
214
+ ? this._path_scale[key](val !== null && val !== void 0 ? val : 0)
215
+ : 2;
216
+ return `${normalized}px`;
217
+ }
218
+ /**
219
+ * Sets the state of the current tree, and updates the tree visualization accordingly.
220
+ * The state is changed either due to a branch open/close, or that the tree is entirely changed
221
+ * when moving back and fourth in time.
222
+ *
223
+ * @param root
224
+ */
225
+ update(newDateTime) {
226
+ var _a;
227
+ const self = this;
228
+ const new_tree_index = self._data.findIndex((e) => {
229
+ return e.dates.includes(newDateTime);
230
+ });
231
+ const root = self._data[new_tree_index];
232
+ const date_index = (_a = root === null || root === void 0 ? void 0 : root.dates.indexOf(newDateTime)) !== null && _a !== void 0 ? _a : -1;
233
+ // Invalid date gives invalid indices
234
+ const hasInvalidDate = !root || date_index === -1 || new_tree_index === -1;
235
+ if (hasInvalidDate) {
236
+ self._currentDateTime = newDateTime;
237
+ }
238
+ /**
239
+ * Assigns y coordinates to all tree nodes in the rendered tree.
240
+ * @param t - a rendered tree
241
+ * @param {int} width - the
242
+ * @returns a rendered tree width coordinates for all nodes.
243
+ */
244
+ function growNewTree(t, width) {
245
+ t.descendants().forEach((d) => {
246
+ d.y = (d.depth * width) / (t.height + 1);
247
+ });
248
+ return t;
249
+ }
250
+ function doPostUpdateOperations(tree) {
251
+ setEndPositions(tree.descendants());
252
+ setNodeVisibility(tree.descendants(), true);
253
+ return tree;
254
+ }
255
+ function findClosestVisibleParent(d) {
256
+ let c = d;
257
+ while (c.parent && !c.isvisible) {
258
+ c = c.parent;
259
+ }
260
+ return c;
261
+ }
262
+ function getClosestVisibleParentStartCoordinates(d) {
263
+ var _a, _b;
264
+ const p = findClosestVisibleParent(d);
265
+ return { x: (_a = p.x0) !== null && _a !== void 0 ? _a : 0, y: (_b = p.y0) !== null && _b !== void 0 ? _b : 0 };
266
+ }
267
+ function getClosestVisibleParentEndCoordinates(d) {
268
+ const p = findClosestVisibleParent(d);
269
+ return { x: p.x, y: p.y };
270
+ }
271
+ /**
272
+ * Implicitly alter the state of a node, by hiding its children
273
+ * @param node
274
+ */
275
+ function toggleBranch(node) {
276
+ if (node.children) {
277
+ node._children = node.children;
278
+ node.children = null;
279
+ }
280
+ else {
281
+ node.children = node._children;
282
+ node._children = null;
283
+ }
284
+ self.update(self._currentDateTime);
285
+ }
286
+ /**
287
+ * Toggles visibility of a node. This state determines if the node, and its children
288
+ * @param nodes
289
+ * @param visibility
290
+ */
291
+ function setNodeVisibility(nodes, visibility) {
292
+ nodes.forEach((d) => {
293
+ d.isvisible = visibility;
294
+ });
295
+ }
296
+ /**
297
+ * After node translation transition, save end position
298
+ * @param nodes
299
+ */
300
+ function setEndPositions(nodes) {
301
+ nodes.forEach((d) => {
302
+ d.x0 = d.x;
303
+ d.y0 = d.y;
304
+ });
305
+ }
306
+ function getToolTipText(data, date_index) {
307
+ if (data === undefined || date_index === undefined) {
308
+ return "";
309
+ }
310
+ const propNames = Object.keys(data);
311
+ let text = "";
312
+ propNames.forEach(function (s) {
313
+ var _a, _b, _c, _d;
314
+ const t = (_a = self._propertyToLabelMap.get(s)) !== null && _a !== void 0 ? _a : [s, ""];
315
+ const pre = t[0];
316
+ const unit = t[1];
317
+ text +=
318
+ pre +
319
+ " " +
320
+ ((_d = (_c = (_b = data[s]) === null || _b === void 0 ? void 0 : _b[date_index]) === null || _c === void 0 ? void 0 : _c.toFixed(0)) !== null && _d !== void 0 ? _d : "") +
321
+ " " +
322
+ unit +
323
+ "\n";
324
+ });
325
+ return text;
326
+ }
327
+ /**
328
+ * Clone old node start position to new node start position.
329
+ * Clone new node end position to old node end position.
330
+ * Clone old visibility to new.
331
+ *
332
+ * @param newRoot
333
+ * @param oldRoot
334
+ */
335
+ function cloneExistingNodeStates(newRoot, oldRoot) {
336
+ if (Object.keys(oldRoot).length > 0) {
337
+ oldRoot.descendants().forEach((oldNode) => {
338
+ newRoot.descendants().forEach((newNode) => {
339
+ if (oldNode.id === newNode.id) {
340
+ newNode.x0 = oldNode.x0;
341
+ newNode.y0 = oldNode.y0;
342
+ oldNode.x = newNode.x;
343
+ oldNode.y = newNode.y;
344
+ newNode.isvisible = oldNode.isvisible;
345
+ }
346
+ });
347
+ });
348
+ }
349
+ return newRoot;
350
+ }
351
+ /**
352
+ * Merge the existing tree, with nodes from a new tree.
353
+ * New nodes fold out from the closest visible parent.
354
+ * Old nodes are removed.
355
+ *
356
+ * @param nodes - list of nodes in a tree
357
+ */
358
+ function updateNodes(nodes, nodeinfo) {
359
+ const node = self._svg.selectAll("g.node").data(nodes, (d) => d.id);
360
+ const nodeEnter = node
361
+ .enter()
362
+ .append("g")
363
+ .attr("class", "node")
364
+ .attr("id", (d) => d.id)
365
+ .attr("transform", (d) => {
366
+ const c = getClosestVisibleParentStartCoordinates(d);
367
+ return `translate(${c.y},${c.x})`;
368
+ })
369
+ .on("click", toggleBranch);
370
+ nodeEnter
371
+ .append("circle")
372
+ .attr("id", (d) => d.id)
373
+ .attr("r", 6)
374
+ .transition()
375
+ .duration(self._transitionTime)
376
+ .attr("x", (d) => d.x)
377
+ .attr("y", (d) => d.y);
378
+ nodeEnter
379
+ .append("text")
380
+ .attr("class", "grouptree__nodelabel")
381
+ .attr("dy", ".35em")
382
+ .style("fill-opacity", 1)
383
+ .attr("x", (d) => (d.children || d._children ? -21 : 21))
384
+ .attr("text-anchor", (d) => d.children || d._children ? "end" : "start")
385
+ .text((d) => d.data.node_label);
386
+ nodeEnter
387
+ .append("text")
388
+ .attr("class", "grouptree__pressurelabel")
389
+ .attr("x", 0)
390
+ .attr("dy", "-.05em")
391
+ .attr("text-anchor", "middle")
392
+ .text((d) => {
393
+ var _a, _b, _c;
394
+ return (_c = (_b = (_a = d.data.node_data[nodeinfo]) === null || _a === void 0 ? void 0 : _a[date_index]) === null || _b === void 0 ? void 0 : _b.toFixed(0)) !== null && _c !== void 0 ? _c : "NA";
395
+ });
396
+ nodeEnter
397
+ .append("text")
398
+ .attr("class", "grouptree__pressureunit")
399
+ .attr("x", 0)
400
+ .attr("dy", ".04em")
401
+ .attr("dominant-baseline", "text-before-edge")
402
+ .attr("text-anchor", "middle")
403
+ .text(() => {
404
+ var _a;
405
+ const t = (_a = self._propertyToLabelMap.get(nodeinfo)) !== null && _a !== void 0 ? _a : [
406
+ "",
407
+ "",
408
+ ];
409
+ return t[1];
410
+ });
411
+ nodeEnter
412
+ .append("title")
413
+ .text((d) => getToolTipText(d.data.node_data, date_index));
414
+ const nodeUpdate = nodeEnter.merge(node);
415
+ // Nodes from earlier exit selection may reenter if transition is interupted. Restore state.
416
+ nodeUpdate
417
+ .filter(".exiting")
418
+ .interrupt()
419
+ .classed("exiting", false)
420
+ .attr("opacity", 1);
421
+ nodeUpdate
422
+ .select("text.grouptree__pressurelabel")
423
+ .text((d) => {
424
+ var _a, _b, _c;
425
+ return (_c = (_b = (_a = d.data.node_data[nodeinfo]) === null || _a === void 0 ? void 0 : _a[date_index]) === null || _b === void 0 ? void 0 : _b.toFixed(0)) !== null && _c !== void 0 ? _c : "NA";
426
+ });
427
+ nodeUpdate
428
+ .transition()
429
+ .duration(self._transitionTime)
430
+ .attr("transform", (d) => `translate(${d.y},${d.x})`);
431
+ nodeUpdate
432
+ .select("circle")
433
+ .attr("class", (d) => `${"grouptree__node" + " "}${d.children || d._children
434
+ ? "grouptree__node--withchildren"
435
+ : "grouptree__node"}`)
436
+ .transition()
437
+ .duration(self._transitionTime)
438
+ .attr("r", 15);
439
+ nodeUpdate
440
+ .select("title")
441
+ .text((d) => getToolTipText(d.data.node_data, date_index));
442
+ node.exit()
443
+ .classed("exiting", true)
444
+ .attr("opacity", 1)
445
+ .transition()
446
+ .duration(self._transitionTime)
447
+ .attr("opacity", 1e-6)
448
+ .attr("transform", (d) => {
449
+ d.isvisible = false;
450
+ const c = getClosestVisibleParentEndCoordinates(d);
451
+ return `translate(${c.y},${c.x})`;
452
+ })
453
+ .remove();
454
+ }
455
+ /**
456
+ * Draw new edges, and update existing ones.
457
+ *
458
+ * @param edges -list of edges in a tree
459
+ * @param flowrate - key identifying the flowrate of the incoming edge
460
+ */
461
+ function updateEdges(edges, flowrate) {
462
+ const link = self._svg
463
+ .selectAll("path.link")
464
+ .data(edges, (d) => d.id);
465
+ const linkEnter = link
466
+ .enter()
467
+ .insert("path", "g")
468
+ .attr("id", (d) => `path ${d.id}`)
469
+ .attr("d", (d) => {
470
+ const c = getClosestVisibleParentStartCoordinates(d);
471
+ return diagonal(c, c);
472
+ });
473
+ linkEnter
474
+ .append("title")
475
+ .text((d) => getToolTipText(d.data.edge_data, date_index));
476
+ const linkUpdate = linkEnter.merge(link);
477
+ linkUpdate
478
+ .attr("class", () => `link grouptree_link grouptree_link__${flowrate}`)
479
+ .transition()
480
+ .duration(self._transitionTime)
481
+ .attr("d", (d) => diagonal(d, d.parent))
482
+ .style("stroke-width", (d) => {
483
+ var _a, _b;
484
+ return self.getEdgeStrokeWidth(flowrate, (_b = (_a = d.data.edge_data[flowrate]) === null || _a === void 0 ? void 0 : _a[date_index]) !== null && _b !== void 0 ? _b : 0);
485
+ })
486
+ .style("stroke-dasharray", (d) => {
487
+ var _a, _b;
488
+ return ((_b = (_a = d.data.edge_data[flowrate]) === null || _a === void 0 ? void 0 : _a[date_index]) !== null && _b !== void 0 ? _b : 0) > 0
489
+ ? "none"
490
+ : "5,5";
491
+ });
492
+ linkUpdate
493
+ .select("title")
494
+ .text((d) => getToolTipText(d.data.edge_data, date_index));
495
+ link.exit()
496
+ .transition()
497
+ .duration(self._transitionTime)
498
+ .attr("d", (d) => {
499
+ d.isvisible = false;
500
+ const c = getClosestVisibleParentEndCoordinates(d);
501
+ return diagonal(c, c);
502
+ })
503
+ .remove();
504
+ /**
505
+ * Create the curve definition for the edge between node s and node d.
506
+ * @param s - source node
507
+ * @param d - destination node
508
+ */
509
+ function diagonal(s, d) {
510
+ return `M ${d.y} ${d.x}
511
+ C ${(d.y + s.y) / 2} ${d.x},
512
+ ${(d.y + s.y) / 2} ${s.x},
513
+ ${s.y} ${s.x}`;
514
+ }
515
+ }
516
+ /**
517
+ * Add new and update existing texts/textpaths on edges.
518
+ *
519
+ * @param edges - list of edges in a tree
520
+ */
521
+ function updateEdgeTexts(edges) {
522
+ const textpath = self._textpaths
523
+ .selectAll(".edge_info_text")
524
+ .data(edges, (d) => d.id);
525
+ const enter = textpath
526
+ .enter()
527
+ .insert("text")
528
+ .attr("dominant-baseline", "central")
529
+ .attr("text-anchor", "middle")
530
+ .append("textPath")
531
+ .attr("class", "edge_info_text")
532
+ .attr("startOffset", "50%")
533
+ .attr("xlink:href", (d) => `#path ${d.id}`);
534
+ enter
535
+ .merge(textpath)
536
+ .attr("fill-opacity", 1e-6)
537
+ .transition()
538
+ .duration(self._transitionTime)
539
+ .attr("fill-opacity", 1)
540
+ .text((d) => d.data.edge_label);
541
+ textpath.exit().remove();
542
+ }
543
+ // Clear any existing error overlay
544
+ this._svg
545
+ .selectAll(".error-overlay-background, .error-overlay")
546
+ .remove();
547
+ if (hasInvalidDate) {
548
+ // // Add opacity to overlay background
549
+ this._svg
550
+ .append("rect")
551
+ .attr("class", "error-overlay-background")
552
+ .attr("width", this._rectWidth)
553
+ .attr("height", this._rectHeight)
554
+ .attr("x", this._rectLeftMargin)
555
+ .attr("y", this._rectTopMargin)
556
+ .attr("fill", "rgba(255, 255, 255, 0.8)");
557
+ // Show overlay text with error message
558
+ this._svg
559
+ .append("text")
560
+ .attr("class", "error-overlay")
561
+ .attr("x", this._rectWidth / 2 + 2 * this._rectLeftMargin)
562
+ .attr("y", this._rectHeight / 2 + 2 * this._rectTopMargin)
563
+ .style("fill", "red")
564
+ .style("font-size", "16px")
565
+ .text("Date not found in data");
566
+ }
567
+ else {
568
+ // Grow new tree
569
+ const newTree = cloneExistingNodeStates(growNewTree(this._renderTree(root.tree), this._treeWidth), this._currentTree);
570
+ // execute visualization operations on enter, update and exit selections
571
+ updateNodes(newTree.descendants(), this.nodeinfo);
572
+ updateEdges(newTree.descendants().slice(1), this.flowrate);
573
+ updateEdgeTexts(newTree.descendants().slice(1));
574
+ // save the state of the now current tree, before next update
575
+ this._currentTree = doPostUpdateOperations(newTree);
576
+ }
577
+ }
578
+ }
579
+ //# sourceMappingURL=groupTreeAssembler.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"groupTreeAssembler.js","sourceRoot":"","sources":["../../src/GroupTreeAssembler/groupTreeAssembler.js"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,KAAK,EAAE,MAAM,IAAI,CAAC;AACzB,OAAO,kBAAkB,CAAC;AAC1B,OAAO,EAAE,SAAS,EAAE,MAAM,QAAQ,CAAC;AAEnC,6BAA6B;AAC7B,yCAAyC;AACzC,oCAAoC;AACpC,wCAAwC;AACxC,qCAAqC;AACrC,iDAAiD;AAEjD;;;;;;GAMG;AACH,MAAM,CAAC,OAAO,OAAO,kBAAkB;IACnC;;;;;;;;;OASG;IACH,YACI,cAAc,EACd,UAAU,EACV,eAAe,EACf,eAAe,EACf,eAAe,EACf,gBAAgB,EAChB,gBAAgB;QAEhB,uCAAuC;QACvC,IAAI,gBAAgB,GAAG,SAAS,CAAC,UAAU,CAAC,CAAC;QAE7C,sBAAsB;QACtB,IAAI,cAAc,CAAC,MAAM,CAAC,CAAC,CAAC,KAAK,GAAG,EAAE;YAClC,cAAc,GAAG,GAAG,GAAG,cAAc,CAAC;SACzC;QAED,0CAA0C;QAC1C,MAAM,YAAY,GAAG,CAAC,GAAG,gBAAgB,EAAE,GAAG,gBAAgB,CAAC,CAAC;QAChE,IAAI,CAAC,mBAAmB,GAAG,IAAI,GAAG,EAAE,CAAC;QACrC,YAAY,CAAC,OAAO,CAAC,CAAC,GAAG,EAAE,EAAE;;YACzB,IAAI,CAAC,mBAAm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,CAAC;YAEhD,6DAA6D;YAC7D,IAAI,CAAC,YAAY,GAAG,sBAAsB,CAAC,OAAO,CAAC,CAAC;SACvD;IACL,CAAC;CACJ"}
@@ -0,0 +1,59 @@
1
+ .link {
2
+ fill: none;
3
+ stroke: #5c5c5c;
4
+ opacity: 1;
5
+ }
6
+
7
+ .grouptree_link {
8
+ opacity: 0.3;
9
+ }
10
+
11
+ .grouptree_link__oilrate {
12
+ stroke: #60be6c;
13
+ }
14
+
15
+ .grouptree_link__waterrate {
16
+ stroke: #0d1b9e;
17
+ }
18
+
19
+ .grouptree_link__gasrate {
20
+ stroke: #c5221c;
21
+ }
22
+
23
+ .grouptree_link__waterinjrate {
24
+ stroke: #00c3ff;
25
+ }
26
+
27
+ .grouptree_link__gasinjrate {
28
+ stroke: #d6397a;
29
+ }
30
+
31
+ .grouptree__node {
32
+ fill: #fff;
33
+ stroke: #60be6c;
34
+ stroke-width: 1px;
35
+ cursor: default;
36
+ }
37
+
38
+ .grouptree__nodelabel {
39
+ font-size: 10px;
40
+ font-family: sans-serif;
41
+ }
42
+
43
+ .grouptree__pressurelabel {
44
+ font-size: 10px;
45
+ font-family: "Statoil Sans Light", Lucida, Arial, Helvetica, sans-serif;
46
+ }
47
+
48
+ .grouptree__pressureunit {
49
+ font-size: 9px;
50
+ }
51
+
52
+ .grouptree__grupnet_text {
53
+ font-size: 12px;
54
+ }
55
+
56
+ .grouptree__node--withchildren {
57
+ stroke-width: 2.5px;
58
+ cursor: pointer;
59
+ }
@@ -0,0 +1,12 @@
1
+ import React from "react";
2
+ import type { DatedTree, EdgeMetadata, NodeMetadata } from "./types";
3
+ export interface GroupTreePlotProps {
4
+ id: string;
5
+ edgeMetadataList: EdgeMetadata[];
6
+ nodeMetadataList: NodeMetadata[];
7
+ datedTrees: DatedTree[];
8
+ selectedEdgeKey: string;
9
+ selectedNodeKey: string;
10
+ selectedDateTime: string;
11
+ }
12
+ export declare const GroupTreePlot: React.FC<GroupTreePlotProps>;
@@ -0,0 +1,47 @@
1
+ import React from "react";
2
+ import GroupTreeAssembler from "./GroupTreeAssembler/groupTreeAssembler";
3
+ import { isEqual } from "lodash";
4
+ export const GroupTreePlot = (props) => {
5
+ const divRef = React.useRef(null);
6
+ const groupTreeAssemblerRef = React.useRef();
7
+ // State to ensure divRef is defined before creating GroupTree
8
+ const [isMounted, setIsMounted] = React.useState(false);
9
+ // Remove when typescript version is implemented using ref
10
+ const [prevId, setPrevId] = React.useState(null);
11
+ const [prevDatedTrees, setPrevDatedTrees] = React.useState(null);
12
+ const [prevSelectedEdgeKey, setPrevSelectedEdgeKey] = React.useState(props.selectedEdgeKey);
13
+ const [prevSelectedNodeKey, setPrevSelectedNodeKey] = React.useState(props.selectedNodeKey);
14
+ const [prevSelectedDateTime, setPrevSelectedDateTime] = React.useState(props.selectedDateTime);
15
+ React.useEffect(function initialRender() {
16
+ setIsMounted(true);
17
+ }, []);
18
+ if (isMounted &&
19
+ divRef.current &&
20
+ (!isEqual(prevDatedTrees, props.datedTrees) ||
21
+ prevId !== divRef.current.id)) {
22
+ setPrevDatedTrees(props.datedTrees);
23
+ setPrevId(divRef.current.id);
24
+ groupTreeAssemblerRef.current = new GroupTreeAssembler(divRef.current.id, props.datedTrees, props.selectedEdgeKey, props.selectedNodeKey, props.selectedDateTime, props.edgeMetadataList, props.nodeMetadataList);
25
+ }
26
+ if (prevSelectedEdgeKey !== props.selectedEdgeKey) {
27
+ setPrevSelectedEdgeKey(props.selectedEdgeKey);
28
+ if (groupTreeAssemblerRef.current) {
29
+ groupTreeAssemblerRef.current.flowrate = props.selectedEdgeKey;
30
+ }
31
+ }
32
+ if (prevSelectedNodeKey !== props.selectedNodeKey) {
33
+ setPrevSelectedNodeKey(props.selectedNodeKey);
34
+ if (groupTreeAssemblerRef.current) {
35
+ groupTreeAssemblerRef.current.nodeinfo = props.selectedNodeKey;
36
+ }
37
+ }
38
+ if (prevSelectedDateTime !== props.selectedDateTime) {
39
+ setPrevSelectedDateTime(props.selectedDateTime);
40
+ if (groupTreeAssemblerRef.current) {
41
+ groupTreeAssemblerRef.current.update(props.selectedDateTime);
42
+ }
43
+ }
44
+ return React.createElement("div", { id: props.id, ref: divRef });
45
+ };
46
+ GroupTreePlot.displayName = "GroupTreePlot";
47
+ //# sourceMappingURL=GroupTreePlot.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"GroupTreePlot.js","sourceRoot":"","sources":["../src/GroupTreePlot.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,kBAAkB,MAAM,yCAAyC,CAAC;AAEzE,OAAO,EAAE,OAAO,EAAE,MAAM,QAAQ,CAAC;AAYjC,MAAM,CAAC,MAAM,aAAa,GAAiC,CACvD,KAAyB,EAC3B,EAAE;IACA,MAAM,MAAM,GAAG,KAAK,CAAC,MAAM,CAAiB,IAAI,CAAC,CAAC;IAClD,MAAM,qBAAqB,GAAG,KAAK,CAAC,MAAM,EAAsB,CAAC;IAEjE,8DAA8D;IAC9D,MAAM,CAAC,SAAS,EAAE,YAAY,CAAC,GAAG,KAAK,CAAC,QAAQ,CAAU,KAAK,CAAC,CAAC;IAEjE,0DAA0D;IAC1D,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,GAAG,KAAK,CAAC,QAAQ,CAAgB,IAAI,CAAC,CAAC;IAEhE,MAAM,CAAC,cAAc,EAAE,iBAAiB,CAAC,GAAG,KAAK,CAAC,QAAQ,CAExD,IAAI,CAAC,CAAC;IAER,MAAM,CAAC,mBAAmB,EAAE,sBAAsB,CAAC,GAC/C,KAAK,CAAC,QAAQ,CAAS,KAAK,CAAC,eAAe,CAAC,CAAC;IAClD,MAAM,CAAC,mBAAmB,EAAE,sBAAsB,CAAC,GAC/C,KAAK,CAAC,QAAQ,CAAS,KAAK,CAAC,eAAe,CAAC,CAAC;IAClD,MAAM,CAAC,oBAAoB,EAAE,uBAAuB,CAAC,GACjD,KAAK,CAAC,QAAQ,CAAS,KAAK,CAAC,gBAA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AAC,OAAO,EAAE;YAC/B,qBAAqB,CAAC,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,gBAAgB,CAAC,CAAC;SAChE;KACJ;IAED,OAAO,6BAAK,EAAE,EAAE,KAAK,CAAC,EAAE,EAAE,GAAG,EAAE,MAAM,GAAI,CAAC;AAC9C,CAAC,CAAC;AAEF,aAAa,CAAC,WAAW,GAAG,eAAe,CAAC"}
@@ -0,0 +1,3 @@
1
+ export { GroupTreePlot } from "./GroupTreePlot";
2
+ export type { GroupTreePlotProps } from "./GroupTreePlot";
3
+ export type { NodeData, NodeDataPropTypes, NodeMetadata, NodeMetadataPropTypes, EdgeData, EdgeDataPropTypes, EdgeMetadata, EdgeMetadataPropTypes, RecursiveTreeNode, RecursiveTreeNodePropTypes, DatedTree, DatedTreePropTypes, } from "./types";
package/dist/index.js ADDED
@@ -0,0 +1,2 @@
1
+ export { GroupTreePlot } from "./GroupTreePlot";
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC"}
@@ -0,0 +1,51 @@
1
+ /// <reference types="react" />
2
+ import PropTypes from "prop-types";
3
+ export interface NodeData {
4
+ [key: string]: number[];
5
+ }
6
+ export interface NodeMetadata {
7
+ key: string;
8
+ label: string;
9
+ unit?: string;
10
+ }
11
+ export interface EdgeData {
12
+ [key: string]: number[];
13
+ }
14
+ export interface EdgeMetadata {
15
+ key: string;
16
+ label: string;
17
+ unit?: string;
18
+ }
19
+ export interface RecursiveTreeNode {
20
+ node_type: "Group" | "Well";
21
+ node_label: string;
22
+ edge_label: string;
23
+ node_data: NodeData;
24
+ edge_data: EdgeData;
25
+ children?: RecursiveTreeNode[];
26
+ }
27
+ export interface DatedTree {
28
+ dates: string[];
29
+ tree: RecursiveTreeNode;
30
+ }
31
+ export declare const NodeDataPropTypes: PropTypes.Requireable<{
32
+ [x: string]: number[];
33
+ }>;
34
+ export declare const NodeMetadataPropTypes: PropTypes.Requireable<PropTypes.InferProps<{
35
+ key: PropTypes.Validator<string>;
36
+ label: PropTypes.Validator<string>;
37
+ unit: PropTypes.Requireable<string>;
38
+ }>>;
39
+ export declare const EdgeDataPropTypes: PropTypes.Requireable<{
40
+ [x: string]: number[];
41
+ }>;
42
+ export declare const EdgeMetadataPropTypes: PropTypes.Requireable<PropTypes.InferProps<{
43
+ key: PropTypes.Validator<string>;
44
+ label: PropTypes.Validator<string>;
45
+ unit: PropTypes.Requireable<string>;
46
+ }>>;
47
+ export declare const RecursiveTreeNodePropTypes: PropTypes.Validator<NonNullable<PropTypes.InferProps<import("react").WeakValidationMap<RecursiveTreeNode>>>>;
48
+ export declare const DatedTreePropTypes: PropTypes.Requireable<PropTypes.InferProps<{
49
+ dates: PropTypes.Validator<(string | null | undefined)[]>;
50
+ tree: PropTypes.Validator<NonNullable<PropTypes.InferProps<import("react").WeakValidationMap<RecursiveTreeNode>>>>;
51
+ }>>;
package/dist/types.js ADDED
@@ -0,0 +1,34 @@
1
+ import PropTypes from "prop-types";
2
+ // --------------------------- PropTypes ---------------------------------------
3
+ export const NodeDataPropTypes = PropTypes.objectOf(PropTypes.arrayOf(PropTypes.number.isRequired).isRequired);
4
+ export const NodeMetadataPropTypes = PropTypes.shape({
5
+ key: PropTypes.string.isRequired,
6
+ label: PropTypes.string.isRequired,
7
+ unit: PropTypes.string,
8
+ });
9
+ export const EdgeDataPropTypes = PropTypes.objectOf(PropTypes.arrayOf(PropTypes.number.isRequired).isRequired);
10
+ export const EdgeMetadataPropTypes = PropTypes.shape({
11
+ key: PropTypes.string.isRequired,
12
+ label: PropTypes.string.isRequired,
13
+ unit: PropTypes.string,
14
+ });
15
+ // Note: This is a solution for recursive definition for RecursiveTreeNode, as children is an optional array of RecursiveTreeNode.
16
+ // - Object.assign() resolves the issue of children being optional.
17
+ // - PropTypes.arrayOf(PropTypes.shape(RecursiveTreeNode).isRequired) resolves the issue of children being recursive.
18
+ const RecursiveTreeNodeShape = {
19
+ node_label: PropTypes.string.isRequired,
20
+ edge_label: PropTypes.string.isRequired,
21
+ node_data: NodeDataPropTypes.isRequired,
22
+ edge_data: EdgeDataPropTypes.isRequired,
23
+ };
24
+ Object.assign(RecursiveTreeNodeShape, {
25
+ node_type: PropTypes.oneOf(["Group", "Well"]).isRequired,
26
+ children: PropTypes.arrayOf(PropTypes.shape(RecursiveTreeNodeShape).isRequired),
27
+ });
28
+ export const RecursiveTreeNodePropTypes = PropTypes.shape(RecursiveTreeNodeShape).isRequired;
29
+ // Collection of trees with dates
30
+ export const DatedTreePropTypes = PropTypes.shape({
31
+ dates: PropTypes.arrayOf(PropTypes.string).isRequired,
32
+ tree: RecursiveTreeNodePropTypes,
33
+ });
34
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,SAAS,MAAM,YAAY,CAAC;AAyCnC,iFAAiF;AAEjF,MAAM,CAAC,MAAM,iBAAiB,GAAG,SAAS,CAAC,QAAQ,CAC/C,SAAS,CAAC,OAAO,CAAC,SAAS,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC,UAAU,CAC5D,CAAC;AACF,MAAM,CAAC,MAAM,qBAAqB,GAAG,SAAS,CAAC,KAAK,CAAC;IACjD,GAAG,EAAE,SAAS,CAAC,MAAM,CAAC,UAAU;IAChC,KAAK,EAAE,SAAS,CAAC,MAAM,CAAC,UAAU;IAClC,IAAI,EAAE,SAAS,CAAC,MAAM;CACzB,CAAC,CAAC;AAEH,MAAM,CAAC,MAAM,iBAAiB,GAAG,SAAS,CAAC,QAAQ,CAC/C,SAAS,CAAC,OAAO,CAAC,SAAS,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC,UAAU,CAC5D,CAAC;AACF,MAAM,CAAC,MAAM,qBAAqB,GAAG,SAAS,CAAC,KAAK,CAAC;IACjD,GAAG,EAAE,SAAS,CAAC,MAAM,CAAC,UAAU;IAChC,KAAK,EAAE,SAAS,CAAC,MAAM,CAAC,UAAU;IAClC,IAAI,EAAE,SAAS,CAAC,MAAM;CACzB,CAAC,CAAC;AAEH,kIAAkI;AAClI,mEAAmE;AACnE,qHAAqH;AACrH,MAAM,sBAAsB,GAA+C;IACvE,UAAU,EAAE,SAAS,CAAC,MAAM,CAAC,UAAU;IACvC,UAAU,EAAE,SAAS,CAAC,MAAM,CAAC,UAAU;IACvC,SAAS,EAAE,iBAAiB,CAAC,UAAU;IACvC,SAAS,EAAE,iBAAiB,CAAC,UAAU;CAC1C,CAAC;AACF,MAAM,CAAC,MAAM,CAAC,sBAAsB,EAAE;IAClC,SAAS,EAAE,SAAS,CAAC,KAAK,CAAC,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC,CAAC,UAAU;IACxD,QAAQ,EAAE,SAAS,CAAC,OAAO,CACvB,SAAS,CAAC,KAAK,CAAC,sBAAsB,CAAC,CAAC,UAAU,CACrD;CACJ,CAAC,CAAC;AACH,MAAM,CAAC,MAAM,0BAA0B,GAAG,SAAS,CAAC,KAAK,CACrD,sBAAsB,CACzB,CAAC,UAAU,CAAC;AAEb,iCAAiC;AACjC,MAAM,CAAC,MAAM,kBAAkB,GAAG,SAAS,CAAC,KAAK,CAAC;IAC9C,KAAK,EAAE,SAAS,CAAC,OAAO,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC,UAAU;IACrD,IAAI,EAAE,0BAA0B;CACnC,CAAC,CAAC"}
package/package.json ADDED
@@ -0,0 +1,29 @@
1
+ {
2
+ "name": "@webviz/group-tree-plot",
3
+ "version": "1.0.0",
4
+ "description": "",
5
+ "main": "dist/index.js",
6
+ "types": "dist/index.d.ts",
7
+ "files": [
8
+ "/dist"
9
+ ],
10
+ "scripts": {
11
+ "transpile": "tsc --project ./tsconfig.json",
12
+ "copy-files": "copyfiles --up 1 \"src/**/*.css\" dist/",
13
+ "build": "git clean -xdff dist && npm run transpile && npm run copy-files",
14
+ "doc": "git clean -xdff docs && typedoc src"
15
+ },
16
+ "author": "Equinor <opensource@equinor.com>",
17
+ "license": "MPL-2.0",
18
+ "dependencies": {
19
+ "d3": "^7.8.2",
20
+ "lodash": "^4.17.21"
21
+ },
22
+ "peerDependencies": {
23
+ "react": "^17 || ^18",
24
+ "react-dom": "^17 || ^18"
25
+ },
26
+ "volta": {
27
+ "node": "18.17.0"
28
+ }
29
+ }