dagrejs / dagre-d3

A D3-based renderer for Dagre
MIT License
2.83k stars 588 forks source link

Add `labelLocation` option #358

Open futpib opened 5 years ago

lutzroeder commented 5 years ago

Can you provide some context why this is needed and how it is used?

futpib commented 5 years ago
  1. Before this patch label position was always derived from label's bbox. I don't want this, I want to position the label "manually" (in my code), as my labels have unpredictable bboxes (I exclusively use the new labelLocation: 'origin' now). Even when all labels have equal bboxes and they don't change between updates, the positioning can be weird, like in this example: https://dagrejs.github.io/project/dagre-d3/latest/demo/etl-status.html, even when it stabilizes, zooming or resizing the window will make labels jump all over the place again)
  2. Before this patch there was no way to set any label position except the default "center". You can check this by searching for addLabel calls: all values passed as the 3rd location argument are: node.clusterLabelPos, 0 and undefined (while the switch had "top" and "bottom" cases). I had to add node.labelLocation the the switch to make it work without clusters