mscgen_js icon indicating copy to clipboard operation
mscgen_js copied to clipboard

Feature RFC: Label Vertical Alignment

Open forivall opened this issue 7 years ago • 3 comments

It would be great if an option was added to support vertical alignment of labels on arcs, like https://developer.mozilla.org/en-US/docs/Web/CSS/vertical-align.

My current workaround for top align is

  a -- b [
    linecolor="transparent",
    label="this is the label"
  ];
  a => b;

(and inverted for bottom align).

forivall avatar Jan 03 '17 20:01 forivall

@forivall Thanks for the suggestion. The philosophy behind mscgenjs is to take the hassle out of creating sequence diagrams. As any workaround to achieve a goal is a hassle, I'd like to fix it.

Before starting on it, I'd like to understand the why a little better:

  • What is (/ are) your use case(s) for having labels vertically aligned on top (or bottom, for that matter)? I see some, but they might be (and probably are) different from yours ...
  • Just to make sure I understand correctly - the current default is the first picture - you'd want to achieve what is on the second - check?

align-on-the-linealign-above-the-line

(The default for self-referencing arcs is to have the text above the arc so the arc remains visible. To create the second chart I temporarily expanded that behavior to other arcs.)

source of above chart, for own reference

msc {
    wordwraparcs=on;

    a [label="Mies"], b [label="Aap"];

    a =>> b [label="Message for aap from mies. It concerns a noot."];
    b >> a [label="Banana banana banana  banana banana banana banana"];
}

sverweij avatar Jan 03 '17 23:01 sverweij

Basically, my primary use case or user story is that I want the arcs to remain visible: exactly like the self-referencing arcs. Mainly, I personally find it more aesthetically pleasing; when the label is covering the arc, I find it less readable.

The diagram is exactly what I was thinking of. That's pretty awesome that the code is already there!

forivall avatar Jan 04 '17 00:01 forivall

Concur it looks a lot better than vertical alignment == middle in a lot of cases. The amount of extra vertical space I anticipated it would take seems to be negligible.

I'll try to implement this as an option in the render engine first, which means it's possible to steer this behavior externally (the sprocket in mscgen.js.org, the settings of the Atom package, a parameter in the cli, ...). If it works well enough it might become the default.

If that's implemented and after that it still necessary to tweak individual arcs, it might become a language level option as well.

It's a little more work than passing on an option b.t.w. - the layout will need some tweaking e.g. Middle: middle Above: above

B.t.w. Until this is implemented (this weekend D.v.): Another workaround for your original sample is to insert a few line breaks after the label. E.g when it wraps into two lines add two of em, like so:

msc {
  wordwraparcs=on;
  a,b; 
  a => b [label="this label will wrap over two lines\n\n"];
}

workaround

sverweij avatar Jan 04 '17 21:01 sverweij