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

Allow custom dot attributes in Diagram constructor #11

Merged
merged 1 commit into from
Feb 13, 2020

Conversation

deadmeu
Copy link
Contributor

@deadmeu deadmeu commented Feb 12, 2020

Allow custom graph, node, and edge attributes to be passed in to the Diagram constructor. This allows the user to configure the output image using whatever configuration of attributes they would like.

@mingrammer
Copy link
Owner

Could you please provide a practical example use custom options?

Because I want to hide the internal implementation-specific options to users who don't know or even who know the Graphviz.

The outformat, direction options are also dot attributes, but provided as normal arguments. So users don't have to know Graphviz options.

@deadmeu
Copy link
Contributor Author

deadmeu commented Feb 13, 2020

I was looking to render with a transparent background, though I think providing some mechanism to allow users to customise the rendered image is important.

Since Graphviz is a hard dependency of this project, and there is plenty of documentation available online, I figured it would be ok to allow users to pass in their own Graphviz configuration.

Copy link
Owner

@mingrammer mingrammer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Your opinions are persuasive to me. I accept it :)

Thanks for your contribution!

@mingrammer mingrammer merged commit 90c5243 into mingrammer:master Feb 13, 2020
@deadmeu
Copy link
Contributor Author

deadmeu commented Feb 13, 2020

Thanks, I really hate drawing diagrams using popular visual editors, so the natural language expression using python, along with the awesome pre-provided icons, intrigues me.

I found the changes in this PR to be quite compelling in being able to rapidly prototype the design. Take a look: https://streamable.com/f9zf1

Maybe as a future edition we could develop something like a DiagramOptions class, decoupling the Graphviz attributes from Diagrams? That way, we would only need to pass in a single options parameter into the constructor of the Diagrams class which would contain all of the configuration, including the existing outformat and direction options. I'm not very experienced with Python though so there may be a more Pythonic way to handle this.

@mingrammer
Copy link
Owner

Wow! I'm glad to see that someone makes a demo video using a library I made :) Thank you.

The idea of DiagramOptions class sounds good to me. We can more develop this idea. I'm willing to support option class in the future. (while keeping the backward compatibility)

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

Successfully merging this pull request may close these issues.

2 participants