kieler / klayjs

(deprecated) KIELER's layout algorithms for JavaScript
Eclipse Public License 1.0
231 stars 22 forks source link

child edge positioning #26

Open forresto opened 7 years ago

forresto commented 7 years ago

In klayjs-svg, child edges are rendered as children of the translated group. This means that the edges are layered behind other groups.

child edge

{ children:
  [ { id: 'Parent1'
    , children:
      [ { id: 'Child1' }
      ]
    , edges:
      [ {source: 'Child1', target: 'Child2'}
      ]
    }
  , { id: 'Parent2'
    , children:
      [ { id: 'Child2' }
      ]
    }
  ]
, edges:
  [ {source: 'Parent1', target: 'Parent2'}
  ]
}

If I don't define the edges as child edges in the input graph, their positioning is still offset, so I'd have to walk the graph to find the edge's source node's parent's offset. This seems like a bug: edges defined on the root node should be positioned relative to the root.

root edge

{ children:
  [ { id: 'Parent1'
    , children:
      [ { id: 'Child1' }
      ]
    }
  , { id: 'Parent2'
    , children:
      [ { id: 'Child2' }
      ]
    }
  ]
, edges:
  [ {source: 'Parent1', target: 'Parent2'}
  , {source: 'Child1', target: 'Child2'}
  ]
}
uruuru commented 7 years ago

The calculated coordinates correspond to elk's coordinate system, in which the positions of an edge are relative to the edge's source node (with one exception). It's somewhat of a peculiarity of the js json version that edges can be specified anywhere (instead of as children of the source node). While I see your point, I'm not sure if it's a good idea to become inconsistent with the coordinate system used in the java version.

le-cds commented 7 years ago

We are currently changing the graph data structure in the ELK project. This issue is in fact one we're addressing there. We haven't decided yet whether the changes will find their way into the JSON specification of graphs.