Hide all relationship lines or labels in a view

Started by Mate, May 15, 2024, 18:01:17 PM

Previous topic - Next topic

Mate

Hi jArchi wizards...

I am using jArchi 1.6.1 in Archi 5.3, I have been a Patron for a few years, but only now starting to do more complex modeling, size-wise, with Archi

Confess I am a noob in Javascript and jArchi, but eager to learn. Have searched the forum and couldn't find a noob-level answer :)

I have a view with about 50 elements in it and their respective relationship connections. The relationship lines and labels make the visual very busy and they do not add any meaningful value to my Stakeholder Viewpoint and conversation. So I like to remove them from the view. In some views just the labels, while in others both labels and lines.

I can iterate through all the relationships in each selected view but don't know how to hide the labels (or labels and lines), via a jArchi script, without deleting the relationship from the model. Like I can do from the UI.

Any guidance is much appreciated. Thanks in advance.

Phil Beauvoir

#1
Hi,

You can delete ArchiMate connections from a View without deleting the model relationships with something like the following:

selectedView = ... // Get the View you want to work with

// Find each ArchiMate relation in the View and delete the visual connection
$(selectedView).find('relation').each(connection => {
    connection.delete();
});

When you say you want to remove the connection labels, a connection label will show if you have given the relationship a name. So you'd have to set the relation's name to the empty string:

selectedView = ... // Get the View you want to work with

// Find each ArchiMate relation in the View and reset name
$(selectedView).find('relation').each(connection => {
    connection.name = "";
});

If you want to keep the relation's name but hide it you could assign a bogus label expression that resolves to an empty string:

Edit - ignore this part, see answer below!

selectedView = ... // Get the View you want to work with

// Find each ArchiMate relation in the View and assign label expression
$(selectedView).find('relation').each(connection => {
    connection.labelExpression = "${property:empty}";
});

Hope that helps, and thanks for your support on Patreon!

Phil
If you value and use Archi, please consider making a donation!
Ask your ArchiMate related questions to the ArchiMate Community's Discussion Board.

Mate

@Phil Beauvoir: Thank you, Sir! This gets me successfully moving along on my learning journey. Appreciate the detailed response and your patience.

"When you say you want to remove the connection labels, a connection label will show if you have given the relationship a name. So you'd have to set the relation's name to the empty string:" -->  you are correct, it's the name that displays as a label. I don't want to delete the name from the model, just it's visibility in the view.  Under properties.appearance there is a checkbox option called "Show Label" that does what I want, so was wondering if that can be done programmatically.

I'll check out the option (ie bogus label) you suggest it seems like a good workaround.

Phil Beauvoir

Quote from: Mate on May 16, 2024, 22:38:54 PMUnder properties.appearance there is a checkbox option called "Show Label" that does what I want, so was wondering if that can be done programmatically.

Yes, I forgot about that option, sorry. Ignore what I said earlier. See https://github.com/archimatetool/archi-scripting-plugin/wiki/Visual-Connections#labelvisible

connection.labelVisible = false;
If you value and use Archi, please consider making a donation!
Ask your ArchiMate related questions to the ArchiMate Community's Discussion Board.

Mate