d2 icon indicating copy to clipboard operation
d2 copied to clipboard

Connecting element to another element inside a grid will result in arrows overlapping shapes

Open himazawa opened this issue 11 months ago • 3 comments

I noticed that using Dagre and ELK (and partially TALA) while linking an element to another that is inside a grid will result in a broken diagram.

This works correctly:

parent: {
  label: ""
  grid-columns: 1
  child1: {
    label: child1
  }

  child2: {
    label: child1
  }
}

parent2: {
  grid-columns: 1
  child1
  child2
}
parent3: {
  grid-columns: 1
  child1
  child2
}

user: {
  shape: person
}

user -> parent2
user -> parent
image

But when linking to the element inside the grid:

parent: {
  label: ""
  grid-columns: 1
  child1: {
    label: child1
  }

  child2: {
    label: child1
  }
}

parent2: {
  grid-columns: 1
  child1
  child2
}
parent3: {
  grid-columns: 1
  child1
  child2
}

user: {
  shape: person
}

user -> parent2
user -> parent.child1

instead of having just a longer arrow it will result in this: image

This issue is causing arrows to overlap with shapes in ELK and Dagre, in TALA doesn't but moves the shape in an unintended way (probably to avoid overlapping with the label):

TALA to parent: image

TALA to child: image

himazawa avatar Feb 29 '24 21:02 himazawa

i believe this is a specification.

user: {
  shape: person
}

parent: {
  label: ""
  grid-columns: 1
  child1: {
    label: child1
  }

  child2: {
    label: child1
  }
}

parent2: {
  grid-columns: 1
  child1
  child2
}
parent3: {
  grid-columns: 1
  child1
  child2
}

user -> parent2
user -> parent.child1

or

user: {
  shape: person
}

dummy: "" {
  style.opacity: 0
  parent: {
    label: ""
    grid-columns: 1
    child1: {
      label: child1
    }

    child2: {
      label: child1
    }
  }

  parent2: {
    grid-columns: 1
    child1
    child2
  }
  parent3: {
    grid-columns: 1
    child1
    child2
  }
}
user -> dummy.parent2
user -> dummy.parent.child1

bo-ku-ra avatar Mar 01 '24 09:03 bo-ku-ra

@bo-ku-ra the issue still exists tho. Because the arrows pointing to child1 are straight.

From your example, adding a link to another child will break anyway:

user: {
  shape: person
}

parent: {
  grid-columns: 1
  child1
  child2
}

parent2: {
  grid-columns: 1
  child1
  child2
}
parent3: {
  grid-columns: 1
  child1
  child2
}

user -> parent2.child2
user -> parent.child1

himazawa avatar Mar 01 '24 13:03 himazawa

indeed, it is nicer when not straight.

bo-ku-ra avatar Mar 01 '24 14:03 bo-ku-ra