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

Connections used in a Legend #1992

Closed
amb007 opened this issue Jul 8, 2024 · 2 comments
Closed

Connections used in a Legend #1992

amb007 opened this issue Jul 8, 2024 · 2 comments

Comments

@amb007
Copy link

amb007 commented Jul 8, 2024

I have trouble adding a Legend to describe various kinds of connections. The best so far that I've come up with (dagre does not allow for width, for example) is silly padding, like

  g1: "" {
    class: pad
    #width: 400
    grid-rows: 1
#    grid-gap: 0
    source.class: legend-node
    p0.class: pad; p1.class: pad; p2.class: pad; p3.class: pad; p4.class: pad; p5.class: pad; p6.class: pad
    target.class: legend-node
    source -> target: data processed {
      label.near: top-left #ignored on a connection label, only a shape label works
      style.stroke-width: 3
    }
  }

which gives (in Chrome):
image
where the arrow is broken (I tried reducing grid-gap, but it does not seem related).
Is there a way to put the text above the horizontal line?
For completeness:

classes {
  pad {
    style {
      opacity: 0
      stroke-width: 0
      fill: transparent
    }
  }
  legend-node {
    shape: circle
    style {
      stroke-width: 0
      fill: transparent
    }
  }
}

EDIT: I found out that adding label: "" to the pad class, removes the breakages. Still, the general question is about connection support in legends.

@bo-ku-ra
Copy link
Contributor

bo-ku-ra commented Jul 8, 2024

forced..
https://play.d2lang.com/?l=&script=lI7BasMwDIbvfoqfHgMuLuwwVNi7eLaWmBnbyCqtG_LuI3S5bxchJL6PLybhoKkWgqR5UTNLinb2jeBeu9R7J1zMA9biuY9BWLuOzOfafEg6CG7b_x8YxjwJp-jVo0kN3DvHE9Z7iroQ3py7IvtPzufCXgj1pj1FtlqbDVyU5YqXuqvUb7a_oDvOXylngoovvXnhopsx0zQR1oX3fsLlfTMPQq83CXyE_t02COplZv0_-hMAAP__&

direction: right
grid-gap: 0
grid-rows: 1
x -- z -- y: {style.opacity: 0}
x -> y

z: "data processed" {width: 400; label.near: outside-top-center; style.stroke-width: 0; style.fill: transparent}

***: {height: 18}
x: source {style.stroke-width: 0; style.fill: transparent}
y: target {style.stroke-width: 0; style.fill: transparent}

@amb007 amb007 closed this as completed Jul 8, 2024
@amb007
Copy link
Author

amb007 commented Jul 8, 2024

I suppose the above solution (with variations) is as good as one can get. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Done
Development

No branches or pull requests

2 participants