Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

text alignment? #62

Closed
jonathan-chin opened this issue Nov 1, 2019 · 23 comments
Closed

text alignment? #62

jonathan-chin opened this issue Nov 1, 2019 · 23 comments

Comments

@jonathan-chin
Copy link

jonathan-chin commented Nov 1, 2019

I'm running this on OSX High Sierra, installed via Stack.

My attributes seem to be right aligned, whereas the sample pdf is left aligned. I think left aligned makes it so much easier to read.

How can I specify this? I don't think there's an option in the README.

This is what I get

@mmzx
Copy link
Collaborator

mmzx commented Nov 2, 2019

Could you perhaps paste/provide your erd file here?

@jonathan-chin
Copy link
Author

@mmzx I see it even with the example sample.er
Screen Shot 2019-11-03 at 2 56 58 PM

@mmzx
Copy link
Collaborator

mmzx commented Nov 3, 2019

@jonathan-chin , currently the text alignment is hard coded, that is, node specific alignment is not supported. You could e.g. do something like the following, which is only a partial solution - because globally applied for all nodes.
erd -i ./examples/simple.er -f dot | sed s/RIGHT/LEFT/g | dot -o"sample.pdf" -Tpdf
Results in:
image

@jonathan-chin
Copy link
Author

@mmzx I'm also curious because my keys and node titles don't get the same styling that you do (bold, underline, italics). Is it because of my OS? because I compiled it from Stack?

@mmzx
Copy link
Collaborator

mmzx commented Nov 3, 2019

@jonathan-chin , compiling it via stack or something else would not affect outcome.
If you would post your erd file and intermediate html (dot) we might understand more. I do not have access to osx, so looking at these intermediates could help.

@jonathan-chin
Copy link
Author

jonathan-chin commented Nov 3, 2019

@mmzx here is my ERD file (it's the one from the repo; just including it for completeness sake)

# Entities are declared in '[' ... ']'. All attributes after the entity header
# up until the end of the file (or the next entity declaration) correspond
# to this entity.
[Person]
*name
height
weight
`birth date`
+birth_place_id

[`Birth Place`]
*id
`birth city`
'birth state'
"birth country"

# Each relationship must be between exactly two entities, which need not
# be distinct. Each entity in the relationship has exactly one of four
# possible cardinalities:
#
# Cardinality    Syntax
# 0 or 1         ?
# exactly 1      1
# 0 or more      *
# 1 or more      +
Person *--1 `Birth Place`

here (I believe) is the dot file generated by erd -i ./simple.er -f dot > simple.dot

graph {
	graph [rankdir=LR,
		splines=spline
	];
	node [label="\N",
		shape=plaintext
	];
	edge [color=gray50,
		minlen=2,
		style=dashed
	];
	Person	 [label=<<FONT FACE="Helvetica"><TABLE BORDER="0" CELLBORDER="1" CELLPADDING="4" CELLSPACING="0"><TR><TD><B><FONT POINT-SIZE="16">Person</FONT></B></TD></TR><TR><TD ALIGN="RIGHT"><U><FONT>name</FONT></U></TD></TR><TR><TD ALIGN="RIGHT"><FONT>height</FONT></TD></TR><TR><TD ALIGN="RIGHT"><FONT>weight</FONT></TD></TR><TR><TD ALIGN="RIGHT"><FONT>birth date</FONT></TD></TR><TR><TD ALIGN="RIGHT"><I><FONT>birth_place_id</FONT></I></TD></TR></TABLE></FONT>>];
	"Birth Place"	 [label=<<FONT FACE="Helvetica"><TABLE BORDER="0" CELLBORDER="1" CELLPADDING="4" CELLSPACING="0"><TR><TD><B><FONT POINT-SIZE="16">Birth Place</FONT></B></TD></TR><TR><TD ALIGN="RIGHT"><U><FONT>id</FONT></U></TD></TR><TR><TD ALIGN="RIGHT"><FONT>birth city</FONT></TD></TR><TR><TD ALIGN="RIGHT"><FONT>birth state</FONT></TD></TR><TR><TD ALIGN="RIGHT"><FONT>birth country</FONT></TD></TR></TABLE></FONT>>];
	Person -- "Birth Place"	 [headlabel=<<FONT>1</FONT>>,
		taillabel=<<FONT>0..N</FONT>>];
}

@mmzx
Copy link
Collaborator

mmzx commented Nov 5, 2019

The dot file is correct, generated as it should be. So my assumption will be that it is your local setup that contributes to the differences.
What is your version of dot (dot -V)?
Maybe you could try other output format(s), e.g. svg, which can be checked in a web-browser.

@jonathan-chin
Copy link
Author

Thanks. I do notice that in the dot file, there's <TD ALIGN="RIGHT">

my dot version is dot - graphviz version 2.40.1 (20161225.0304)

I also just tried some other output formats (png, jpg, gif, svg, pdf) and it's the same. right aligned, no other styling on keys.

@mmzx
Copy link
Collaborator

mmzx commented Nov 5, 2019

  • The default is to generate right aligned text, that is what is shown in your generated erd file.

  • Currently it is not supported to change the alignment of the text by erd via command or by other means.

  • Would you want to change the alignment of the text, via the above suggested workaround (using sed) you shall be able to do that. It is to be expected to bring, provide you different output when applied correctly.

  • Your graphviz version is excellent.

Other than that, if all above fails I would say it has something to do with the local setup of yours.

Have you tried the above workaround with sed?

@jonathan-chin
Copy link
Author

@mmzx the above workaround works for left aligning but the primary and foreign keys are not being formatted. I noticed this in the README:

NB OSX users: for text formatting of keys (bold and italics) you may need to reinstall graphviz with pango support:

However, after doing what it suggested (brew install graphviz), the keys are still not formatted. is the issue (alignment and formatting) with pango support?

@jonathan-chin
Copy link
Author

following up on this. I installed ERD on a new machine (completely different from previous). Now running Ubuntu 18.04LTS

color and styling work but everything is right aligned like before. this happens, again, with just the sample ERD file.

@mmzx
Copy link
Collaborator

mmzx commented Dec 3, 2019

Okay. I had some commits that were not pushed from recent days. It is now explicitly defined to align to the left, which is the default anyway.
Could you please check again? You would need to build erd by cloning the master branch and building a binary.

git clone https://github.com/BurntSushi/erd.git
cd erd
stack build     # or install

@jonathan-chin
Copy link
Author

thanks @mmzx ! my ubuntu system works perfectly now.
on osx, the text alignment is fixed but some of the other styling isn't showing through (underlining and italics primary / foreign keys). this is the example simple.er:

simple

any idea why? it's not a dealbreaker; honestly, the text alignment was a deal breaker and I was just about to learn graphwiz myself, but now I think I'll stick with erd.

I'd love to help but I dived into the source code yesterday and realized I have no idea how Haskell works.

@mmzx
Copy link
Collaborator

mmzx commented Dec 4, 2019

Yeah, stick with erd! :P
I suspect these differences are related to local settings, which I think is inherently difficult to be prepared for. There is some work/idea in preparation to explicitly define more of these properties. In such situations we should compare output files. So, the resulted dot file is the following via the command erd -i simple.er -f dot on my machine:

graph {
        graph [rankdir=LR,
                splines=spline
        ];
        node [label="\N",
                shape=plaintext
        ];
        edge [color=gray50,
                minlen=2,
                style=dashed
        ];
        Person   [label=<<FONT FACE="Helvetica"><TABLE BORDER="0" CELLBORDER="1" CELLPADDING="4" CELLSPACING="0"><TR><TD><B><FONT POINT-SIZE="16">Person</FONT></B></TD></TR><TR><TD ALIGN="LEFT"><U><FONT>name</FONT></U></TD></TR><TR><TD ALIGN="LEFT"><FONT>height</FONT></TD></TR><TR><TD ALIGN="LEFT"><FONT>weight</FONT></TD></TR><TR><TD ALIGN="LEFT"><FONT>birth date</FONT></TD></TR><TR><TD ALIGN="LEFT"><I><FONT>birth_place_id</FONT></I></TD></TR></TABLE></FONT>>];
        "Birth Place"    [label=<<FONT FACE="Helvetica"><TABLE BORDER="0" CELLBORDER="1" CELLPADDING="4" CELLSPACING="0"><TR><TD><B><FONT POINT-SIZE="16">Birth Place</FONT></B></TD></TR><TR><TD ALIGN="LEFT"><U><FONT>id</FONT></U></TD></TR><TR><TD ALIGN="LEFT"><FONT>birth city</FONT></TD></TR><TR><TD ALIGN="LEFT"><FONT>birth state</FONT></TD></TR><TR><TD ALIGN="LEFT"><FONT>birth country</FONT></TD></TR></TABLE></FONT>>];
        Person -- "Birth Place"  [headlabel=<<FONT>1</FONT>>,
                taillabel=<<FONT>0..N</FONT>>];
}

Interpreting the dot file goes beyond erd itself. I will try to see whether I can find out more about it, but I myself can't reproduce the issue.

I am happy that your alignment issue is resolved then!

@jonathan-chin
Copy link
Author

here's what I get with the same command:

graph {
	graph [rankdir=LR,
		splines=spline
	];
	node [label="\N",
		shape=plaintext
	];
	edge [color=gray50,
		minlen=2,
		style=dashed
	];
	Person	 [label=<<FONT FACE="Helvetica"><TABLE BORDER="0" CELLBORDER="1" CELLPADDING="4" CELLSPACING="0"><TR><TD><B><FONT POINT-SIZE="16">Person</FONT></B></TD></TR><TR><TD ALIGN="LEFT"><U><FONT>name</FONT></U></TD></TR><TR><TD ALIGN="LEFT"><FONT>height</FONT></TD></TR><TR><TD ALIGN="LEFT"><FONT>weight</FONT></TD></TR><TR><TD ALIGN="LEFT"><FONT>birth date</FONT></TD></TR><TR><TD ALIGN="LEFT"><I><FONT>birth_place_id</FONT></I></TD></TR></TABLE></FONT>>];
	"Birth Place"	 [label=<<FONT FACE="Helvetica"><TABLE BORDER="0" CELLBORDER="1" CELLPADDING="4" CELLSPACING="0"><TR><TD><B><FONT POINT-SIZE="16">Birth Place</FONT></B></TD></TR><TR><TD ALIGN="LEFT"><U><FONT>id</FONT></U></TD></TR><TR><TD ALIGN="LEFT"><FONT>birth city</FONT></TD></TR><TR><TD ALIGN="LEFT"><FONT>birth state</FONT></TD></TR><TR><TD ALIGN="LEFT"><FONT>birth country</FONT></TD></TR></TABLE></FONT>>];
	Person -- "Birth Place"	 [headlabel=<<FONT>1</FONT>>,
		taillabel=<<FONT>0..N</FONT>>];
}

So our dot's are the same. What's the next step in processing?

@mmzx
Copy link
Collaborator

mmzx commented Dec 8, 2019

I have just done some searching in the hope there will be straightforward answer(s). I believe we are dealing with the same type of situation as described in [1].

The content of the dot file match up against the expected content: that's how far erd itself can go; the rendered result may differ based on platform related differences.

My current recommendation for the short therm would be to stick with something that works as expected. Alternatively docker or the statically built version of erd [2]. On the long-term, we would need to see whether this can be influenced and, first of all, to be reproduced.

In [2] now, there are binaries for 64bit systems statically and dynamically linked ones. I do understand that it would not solve osx related issues, but the static binary is there for the purpose to have something which behaves equally well.

1, stackoverflow; graphviz

2, v0.2.1.0-RC1

@jonathan-chin
Copy link
Author

jonathan-chin commented Dec 8, 2019 via email

@mmzx
Copy link
Collaborator

mmzx commented Dec 8, 2019

If you could help finding out the dirty details that would be great at least to know the reasons to have an explanation.

@jonathan-chin
Copy link
Author

jonathan-chin commented Dec 8, 2019 via email

@mmzx
Copy link
Collaborator

mmzx commented Dec 9, 2019

I have created a ticket, hopefully we will gain some insights.

@mmzx
Copy link
Collaborator

mmzx commented Dec 9, 2019

@jonathan-chin , would you mind if you (we) continue the discussion on the gitlab ticket, specifically anything that is related to dot itself?

@mmzx
Copy link
Collaborator

mmzx commented Dec 11, 2019

Hell, yeah! Thank you!

I am going to update the readme based on the inputs you have kindly provided.
If you think all of your issues has been resolved, I would like to close this. Please let me know!

@jonathan-chin
Copy link
Author

jonathan-chin commented Dec 11, 2019 via email

@mmzx mmzx closed this as completed Dec 11, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants