Colorize table name in Graphviz entity-relationship diagram [duplicate]

StackOverflow https://stackoverflow.com/questions/22673352

  •  22-06-2023
  •  | 
  •  

Domanda

This Graphviz code:

digraph models_diagram {

  graph[rankdir=LR, overlap=false, splines=true]
  struct1 [shape=record, label="Table 0|<f0> ID: integer|<f1> TABLE_1_ID: integer"]
  struct2 [shape=record, label="Table 1|<f0> ID: integer|<f1> NAME: string"]
  struct2:f0 -> struct1:f1;

}

Will create this ERD:

enter image description here

I would like to apply special formatting (e.g. back-ground color; font weight) to each rectangle's header (e.g. "Table 1").

I thought about embedding one shape within another, then I could set style=filled, color=lightgrey on one of the shapes, but I can't get the syntax to work.

Is this possible?

È stato utile?

Soluzione

This:

digraph models_diagram{
    graph[rankdir=LR, overlap=false, splines=true];
    node [shape=record, fontsize=9, fontname="Verdana"];
    edge [style=dashed];
  table0 [shape=none, margin=0, label=<
    <table border="0" cellborder="1" cellspacing="0" cellpadding="4">
        <tr><td bgcolor="lightblue">Table 0</td></tr>
        <tr><td port="0" align="left">ID: integer</td></tr>
        <tr><td port="2" align="left">TABLE_1_ID: integer</td></tr>
    </table>>];
  table1 [shape=none, margin=0, label=<
    <table border="0" cellborder="1" cellspacing="0" cellpadding="4">
        <tr><td bgcolor="lightblue">Table 1</td></tr>
        <tr><td port="0" align="left">ID: integer</td></tr>
        <tr><td port="1" align="left">NAME: string</td></tr>
    </table>>];
  table1:0 -> table0:2;
}

Leads to this:

enter image description here

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top