BurntSushi / erd

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

Option to resize generated ERD, change aspect ratio #105

Open Baerbeisser opened 3 years ago

Baerbeisser commented 3 years ago

Problem: the font of an ERD with 2nd level relations ([main]--[2]--[3]) is barely readable in a presentation, but fills only the upper half of the display. Too wide, too less height.

I tried to set the font to a bigger size, hoping Erd would reorder the tables but:

Is there some way to tell Erd to generate images with different size/aspcet ratio, reordering the tables accordingly?

kukimik commented 3 years ago

I'd try to generate dot files using erd, then tweak them manually and run through Graphviz.

Some of the options that tell Graphviz how to layout the diagram are hardcoded in erd, and many of them are inacessible through erd's interface. If you don't mind that, you can tweak the code and recompile. You may for example try to remove A.RankDir A.FromLeft here: https://github.com/BurntSushi/erd/blob/d52f12e146cff816adf5329c25cf514a2eb970f1/app/Main.hs#L48 It worked for me with some more complex diagrams.


@mmzx @BurntSushi Maybe the user should be given the possibility to provide arbitrary graphviz attributes? I think this can be achieved without much cost using the UnknownAttribute constructor. The syntax could be e.g.

{ custom_graphviz-property-name: graphviz-property-value }

We don't validate this and just assume that the users know what they are doing.

I believe this could radically improve the usability without much implementation and maintenance cost.

mmzx commented 3 years ago

@kukimik I like the idea of custom properties, as long it would not introduce additional complexity regarding the configuration and consistency with existing switches. I am wondering...

kukimik commented 3 years ago

I was wrong. Using UnknownAttribute is not a good idea. Although this could work, the grapviz library docs forbid using the UnknownAttribute constructor for this. See the docs and sources of validUnknown.