BurntSushi / erd

Translates a plain text description of a relational database schema to a graphical entity-relationship diagram.
The Unlicense
1.8k stars 154 forks source link

different ways of distributing the models on the diagram #107

Open jmriego opened 3 years ago

jmriego commented 3 years ago

Hi! I was wondering if it's possible to organise the models in some way. When I don't add any relationships the models are stacked vertically but I'd prefer to change that if possible. If not, at least some hints to set the models left or right of the diagram would be useful

Thanks!

mmzx commented 3 years ago

Hi, The entities are placed in a way as GraphViz finds it appropriate to render. A specifically desired placement is probably difficult to achieve, influencing the placement may be possible: there could be parameters on the API of GraphViz but those are not supported directly by erd. Maybe you could apply post processing on the dot format which can be obtained by using erd with the -d switch? For instance: erd -i ./simple.er -d -f plain would produce:

graph 1 4.125 1.9306
node Person 0.80556 0.96528 1.6111 1.9306 "Person|name|height|weight|birth\ date|birth_place_id" solid record black lightgrey
node "Birth Place" 3.375 0.96528 1.5 1.6111 "Birth\ Place|id|birth\ city|birth\ state|birth\ country" solid record black lightgrey
edge Person "Birth Place" 4 1.6115 0.96528 1.9353 0.96528 2.3064 0.96528 2.6244 0.96528 dashed gray50
stop
jmriego commented 3 years ago

thanks @mmzx ! that looks indeed like an option

I am trying to understand how this works. I was looking at a similar program https://github.com/ehne/ERDot and it seems like they accept the rankAdjustments parameter to adjust this. Not sure if they can influence GraphViz directly or they do something else like modifying the positions directly

kukimik commented 3 years ago

It'd be really nice if ERD allowed to manually define the layout (at least in part). This feature is available e.g. in t2erd. With large diagrams the current output of ERD is, in practice, often unusable. This is basically the same problem as in #105.

jrouly commented 7 months ago

Just providing a complete example of using dot to do postprocessing as @mmzx described --

layout_engine=osage
docker run --rm -i ghcr.io/burntsushi/erd:latest -d -f dot < "foo.er" | dot -K$layout_engine -Tpng > foo.png