8000 Global attributes for DOT · Issue #118 · dominikbraun/graph · GitHub
[go: up one dir, main page]

Skip to content

Global attributes for DOT  #118

Open

Description

@jimidle

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.

Activity

  1. dominikbraun commented on May 3, 2023

    @dominikbraun
    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

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      0