Jason S
Jason S

Reputation: 189776

how to get graphviz records to have cells that line up

I'm using a record node in graphviz to make a simple table, but it looks wrong:

   digraph g {
     node [shape = record,height=.08];
     node1[label = "{DBAT|{  0|1|2|3|4|5|6|7}|{8|9|10|11|12|13|14|15}|...|{248|249|250|251|252|253|254|255}}"];
   }

alt text

Is there any way to get the subrecords to line up?

Upvotes: 8

Views: 2549

Answers (2)

Weihang Jian
Weihang Jian

Reputation: 8755

In your case, it's impossible to do with only record labels, you should try HTML-like syntax.

https://graphviz.org/doc/info/shapes.html#html

enter image description here

Online Editor

digraph g {
    node2[shape="none" label=<
<TABLE BORDER="0" CELLBORDER="1" CELLSPACING="0" CELLPADDING="6" COLUMNS="*">
  <TR><TD COLSPAN="8">DBAT</TD></TR>
  <TR>
    <TD>0</TD>
    <TD>1</TD>
    <TD>2</TD>
    <TD>3</TD>
    <TD>4</TD>
    <TD>5</TD>
    <TD>6</TD>
    <TD>7</TD>
  </TR>
  <TR>
    <TD>8</TD>
    <TD>9</TD>
    <TD>10</TD>
    <TD>11</TD>
    <TD>12</TD>
    <TD>13</TD>
    <TD>14</TD>
    <TD>15</TD>
  </TR>
  <TR><TD COLSPAN="8">...</TD></TR>
  <TR>
    <TD>248</TD>
    <TD>249</TD>
    <TD>250</TD>
    <TD>251</TD>
    <TD>252</TD>
    <TD>253</TD>
    <TD>254</TD>
    <TD>255</TD>
  </TR>
</TABLE>>];
}

Upvotes: 1

Joe McMahon
Joe McMahon

Reputation: 3382

HTML-formatted nodes will probably make this easier. See http://www.graphviz.org/doc/info/shapes.html#html for details. Tables are supported.

Upvotes: 6

Related Questions