jathanasiou commented on a change in pull request #255:
URL: https://github.com/apache/brooklyn-ui/pull/255#discussion_r674656310
##########
File path: ui-modules/blueprint-composer/app/components/util/d3-blueprint.js
##########
@@ -771,50 +774,37 @@ export function D3Blueprint(container, options) {
return node;
}
+ /**
+ * Draws new relationships as arcs and labels. Updates existing ones.
+ */
function drawRelationships() {
+
showRelationships();
- let relationData = _relationGroup.selectAll('.relation')
- .data(_d3DataHolder.visible.relationships, (d)=>(d.source._id +
'_related_to_' + d.target._id));
+ const getPathId = (d) => (d.source._id + '-' + d.target._id);
+ const getRelationId = (d) => (getPathId(d) + '-' + d.pathSelector);
+
+ // ====== RELATIONSHIP ARCS ===========
- let relationDataEntered = relationData.enter();
+ let arcsData =
Object.values(_d3DataHolder.visible.relationships.reduce((accumulator, d) => {
+ accumulator[getRelationId(d)] = {
+ source: d.source,
+ target: d.target,
+ pathSelector: d.pathSelector
+ };
+ return accumulator;
+ }, {}));
- // Draw the relationship path
- relationDataEntered.insert('path')
+ let relationArcs = _relationArcs.selectAll('.relation').data(arcsData,
(d) => getRelationId(d));
+
+ relationArcs.enter().insert('path')
Review comment:
Haven't touched D3 in a long time so not sure about how it interacts
with the DOM. If D3 itself is calling `drawRelationships` and dealing with DOM
updates, yeah it's probably not a good idea to bring angular templates into
this.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]