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

Global attributes for DOT #118

Open
jimidle opened this issue May 3, 2023 · 1 comment
Open

Global attributes for DOT #118

jimidle opened this issue May 3, 2023 · 1 comment
Labels
enhancement New feature or request

Comments

@jimidle
Copy link

jimidle commented May 3, 2023

It is often convenient to give some default options for graph, nodes and edges, as in:

strict digraph {
    graph [bgcolor = gray10, fontcolor = white, fontname = "Arial"]
    node [shape = circle, color = green4, style = filled, fillcolor = cadetblue1, fontname = "Arial", fontsize=12, fixedsize=false, penwidth=3]
    edge [color = white, fontcolor = white, fontname = "Arial", fontsize = 12, penwidth=3]

      6 [rank="max" label="JIM" ]
      ...

But as things stand, this cannot be achieved. If you try and "fool" it, as so:

...
draw.GraphAttribute("graph", "[bgcolor = gray10, fontcolor = white, fontname = Arial]")
...

Then you get:

...
graph="[bgcolor = gray10, fontcolor = white, fontname = Arial]"
...

Which is obviously incorrect syntax, and it is easy to see why from the template of course. This would require an extra type or two, which I would have called GraphAttribute, NodeAttribute, etc. But of course these functional options names have been taken. Perhaps just:

 WithDefaults("graph", "[x=y, b=c, ...]"

This seems like a fairly easy thing to implement and is preferable to having to add attributes to every individual node and edge.

@dominikbraun dominikbraun added the enhancement New feature or request label May 3, 2023
@dominikbraun
Copy link
Owner

Thanks a lot, great suggestion! I'll add this in one of the next releases.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants