Mermaid: Support for dotted links

Created on 2 Dec 2014  路  16Comments  路  Source: mermaid-js/mermaid

Sometimes it would be really useful to use dotted links to specify a weak link or temporary break.
Syntax could be:
A-.->B;

Help wanted! Enhancement

Most helpful comment

In order to create dotted lines, you can try this:

linkStyle 0 stroke:#000,fill:none,stroke-width:2px,stroke-dasharray:3;

This turns the first link into a dotted line (it targets links using linkStyle: counting starts from 0): I have not been able to attach a class to a linkStyle yet.

mermaiddottedline

All 16 comments

I like the idea and I like the syntax!

What is the intent for this content? sounds like fun :)

For example a class hirarchy which shows abstract classes which inherit from their "real" parents.

Or a Workflow where one path is temporary unused. (Business logic could be changing or defect)

How about a organisation diagram which shows temporary workers as weak links?

There are so many use cases.

I've got a proposed solution for this. Funny thing is I figured out how to add the requisite lexer/linkStatement definitions, get passing tests for A-.->B, A-.-B, A-.-xB etc.

For the life of me, I cannot figure out how to add the stroke-dasharray property to the <path> in <edgePath... It has to be a property, can't do it using style alone (according to w3 schools svg stroke).

If you can let me know where to put that in main.js or in sequenceRenderer.js functions like setClass etc. I will submit a PR for review.

look in main.js in the addEdges function (row 110+). There some styles are applied. Perhaps you could apply the styles for the dotted line there.
Good luck.

Hey I'm new here

Hello @peacemaker1995 welcome.

@knsv - I tried that one actually - the issue is that it needs to have the the property stroke-dasharray - added (not modify the property style or class) so I think this requires something with the d3dagre methods - I just am not sure how or where to implement.

In order to create dotted lines, you can try this:

linkStyle 0 stroke:#000,fill:none,stroke-width:2px,stroke-dasharray:3;

This turns the first link into a dotted line (it targets links using linkStyle: counting starts from 0): I have not been able to attach a class to a linkStyle yet.

mermaiddottedline

Thats a good point. You can create dotted lines today by using code like the one provided by @Mercurius3. The dot notation would be a shortcut. simpler notation for a similar rendering.

@Anachron, you could apply styling as the one above when rendering the dotted links found during parsing.

@cerdman How are things progressing? Still stuck? If you want I could fix the style if you commit the grammar update. If you want to continue that is fine too!

Will look at this now

An implementation for this is in place and will be included in next release. The solution uses the following syntax:

dotted link: 
-.->

dotted link with text: 
-. text .-> 

thick link: 
==>

think link with text: 
== text ==> 

hey @knsv - yep sorry just saw this - that is as far as I got (grammar/syntax) and was pretty much the same - how did you get the style figured out?

Fixed with release 0.3.2

Awesome, thanks! @knsv

Was this page helpful?
0 / 5 - 0 ratings

Related issues

scchearn picture scchearn  路  21Comments

Remo picture Remo  路  27Comments

cristeab picture cristeab  路  16Comments

dotancohen picture dotancohen  路  14Comments

nfroidure picture nfroidure  路  26Comments