algairim commented on a change in pull request #255:
URL: https://github.com/apache/brooklyn-ui/pull/255#discussion_r673899404
##########
File path: ui-modules/blueprint-composer/app/components/util/d3-blueprint.js
##########
@@ -774,18 +774,38 @@ export function D3Blueprint(container, options) {
function drawRelationships() {
showRelationships();
+ // Generates unique relation ID string.
+ const getRelationId = (relationDataItem) =>
(relationDataItem.source._id + '_related_to_' + relationDataItem.target._id);
+
+ // Group relationships per direction, as a key.
+ let relationshipsPerDirection = new Map();
+ _d3DataHolder.visible.relationships.forEach(relation => {
+ const directionKey = getRelationId(relation);
+ if (!relationshipsPerDirection.has(directionKey)) {
+ relationshipsPerDirection.set(directionKey, []);
+ }
+ relationshipsPerDirection.get(directionKey).push(relation.label);
+ });
+
+ // Calculates offset for label, based on number of labels in the same
direction.
+ const getLabelOffset = (relationDataItem) => {
+ const directionKey = getRelationId(relationDataItem);
+ let labelIndex =
relationshipsPerDirection.get(directionKey).findIndex(label => label ===
relationDataItem.label);
Review comment:
Improved in 8fa7e4decb16d1a1abd7eb93bd0bae088f44023b
--
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]