terrastruct / d2

D2 is a modern diagram scripting language that turns text to diagrams.
https://d2lang.com
Mozilla Public License 2.0
17.1k stars 422 forks source link

How to make straight connections? #1537

Open eurodrew555 opened 1 year ago

eurodrew555 commented 1 year ago

I'm pretty new to d2 and experimenting with making various network diagrams.

For example, I would like to make a simple CLOS network diagram with 2x Spines and 4x Leafs. I am trying to make the connections completely straight, not curved or routed but I can't seem to find a way to do this.

The d2 text below makes routed connections using right angles with ELK. It is closer to what I want with Dagre but the lines are still curved.

Is there any style option available to change the connection to a completely straight line?

spine01
spine02
leaf01
leaf02
leaf03
leaf04

spine01 -- leaf*: {
  style: {
    border-radius: 0
  }
}
spine02 -- leaf*: {
  style: {
    border-radius: 0
  }
}
eurodrew555 commented 1 year ago

For reference, I would like to generate a diagram similar to this one:

image

viocha commented 5 months ago

still not supported

bo-ku-ra commented 5 months ago

c.f. https://d2lang.com/tour/grid-diagrams/#connections-between-grid-cells

box1 -> box2: {style.opacity: 0}

box1: "" {
  style.opacity: 0
  grid-rows: 1
  spine01
  spine02
}
box2: "" {
  style.opacity: 0
  grid-rows: 1
  leaf01
  leaf02
  leaf03
  leaf04
}

box1.spine01 -- box2.leaf*: {
  style: {
    border-radius: 0
  }
}

box1.spine02 -- box2.leaf*: {
  style: {
    border-radius: 0
  }
}

https://play.d2lang.com/?l=&script=nI9BCsIwFET3_xRDl0JCGl1l4V0SEyVQTEkqtpTcXWJaCxU37h7M8OZ_E8YW7AwTRqkwp2HqHA-9vvhhUhCZqDQUmgYzAfucgFv0lsXwTAptafT-7sRGkjJV-W_Fl6Rz-io-IFc4rnCi5TC-zIGx9wu8xAe1DVUETIjWRRa19Y9UV_NOIv-VvAIAAP__&