Skip to content
WireVizDocsOpen editor
Library v0.4.1

WireViz Graphviz tweaks

Use the experimental tweak.override and tweak.append fields to adjust native Graphviz output, with exact value types, matching rules, and limitations.

The top-level tweak section modifies generated Graphviz source after WireViz has built its graph. It is an advanced, experimental facility in 0.4.1. Prefer ordinary connector, cable, image, and document options when they express the change you need. Tweaks affect the native rendering and do not rewrite the underlying harness connectivity or BOM. Pinned tweak implementation.

Complete schema

Field Type Purpose
override Mapping Map a generated DOT entry's leading name to a mapping of attribute changes.
append String or list of strings Append raw DOT statements to the graph body.

Both fields are optional. Within override, entry names and attribute names must be strings. Attribute values must be strings or null; YAML numbers and booleans are rejected by the type check. Empty strings are valid string values and differ from null.

Change graph spacing

connectors:
  X1: {pincount: 2}
  X2: {pincount: 2}
cables:
  W1:
    colors: [RD, BK]
    length: 0.5
connections:
  - - X1: [1, 2]
    - W1: [1, 2]
    - X2: [1, 2]
tweak:
  override:
    graph:
      ranksep: "1.2"
      nodesep: "0.5"

graph matches the generated graph-attribute statement. The values remain quoted YAML strings even though Graphviz interprets them numerically. The ordinary generated graph uses left-to-right rank direction; native Graphviz still decides the resulting layout.

How override matching works

WireViz examines generated DOT body entries with a leading name followed by an attribute list in square brackets. The leading name can be quoted in generated DOT. It looks up that name in tweak.override, then changes matching attributes.

  • An existing attribute is replaced.
  • An absent attribute is appended to the matched statement.
  • A null value removes an existing attribute and can warn if it was not present.
  • A string containing spaces, or an empty string, is quoted for DOT by the override routine.

For example, this fragment removes a generated edge style:

tweak:
  override:
    edge:
      style: null

The implementation performs regular-expression edits of DOT text rather than parsing a complete Graphviz syntax tree. Entries containing HTML-like attributes are documented as unsupported for this override mechanism. Connector and cable labels use HTML-like tables, so do not assume that every node attribute can safely be changed through an override. Export and inspect .gv when using advanced changes.

Use actual generated entry names. A WireViz template name that is never itself instantiated is not necessarily a node in the output. Anonymous generated designators are unstable across edits, making them poor long-term tweak targets.

Append DOT statements

append can be one multiline string:

tweak:
  append: |
    { rank=same; X1; X2; }

Or a list of strings:

tweak:
  append:
    - '{ rank=same; X1; X2; }'
    - 'X1 -- X2 [style=invis];'

These are fragments that refer to existing resolved component names. DOT added here is raw graph content. It can introduce visual edges or nodes that are not WireViz cable connections and do not contribute any material to the BOM. Do not use a decorative edge as a substitute for an electrical connection in connections.

Native and browser behavior

The interactive browser canvas has its own layout and drawing logic. A successful native tweak does not reposition that canvas or alter its controls. Review the generated engine output to judge the tweak's effect.

The browser adapter also restricts references to external or host resources. Native DOT capable of loading a local image or stylesheet is not automatically valid in the web runtime; use uploaded assets and supported document image properties. This is an application boundary, not a new upstream YAML feature.

For repeatable results, keep tweaks alongside the source file, retain the library version, and inspect the generated diagram after changes. Graphviz versions and fonts can affect layout independently of WireViz. Use wireviz -f gs harness.yml to produce the graph source and SVG together; see the CLI reference.