Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature RFC: Label Vertical Alignment #242

Open
forivall opened this issue Jan 3, 2017 · 3 comments
Open

Feature RFC: Label Vertical Alignment #242

forivall opened this issue Jan 3, 2017 · 3 comments
Assignees
Projects

Comments

@forivall
Copy link

forivall commented Jan 3, 2017

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).

@sverweij
Copy link
Owner

sverweij commented Jan 3, 2017

@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"];
}

@forivall
Copy link
Author

forivall commented Jan 4, 2017

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!

@sverweij
Copy link
Owner

sverweij commented Jan 4, 2017

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 sverweij self-assigned this Jan 12, 2017
sverweij added a commit that referenced this issue Jan 19, 2017
…tial alignment of texts on (regular only) arcs

As per #242
sverweij added a commit to mscgenjs/mscgenjs-cli that referenced this issue Jan 19, 2017
…tial alignment of texts on (regular only) arcs

(as mentioned in sverweij/mscgen_js#242)
sverweij added a commit to mscgenjs/mscgenjs-inpage that referenced this issue Jan 19, 2017
…tial alignment of texts on (regular only) arcs

as mentioned in sverweij/mscgen_js#242
@sverweij sverweij added this to todo in roadmap Apr 8, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Development

No branches or pull requests

2 participants