# How to create a new node type?

**URL:** <https://forum.graphviz.org/t/how-to-create-a-new-node-type/1096>\
**Category:** Dev\
**Created:** [March 28, 2022, 8:20pm UTC](https://forum.graphviz.org/t/how-to-create-a-new-node-type/1096 "2022-03-28T20:20:00Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Vithanco](https://sea2.discourse-cdn.com/graphviz/user_avatar/forum.graphviz.org/vithanco/32/292_2.png) [@Vithanco](https://forum.graphviz.org/u/Vithanco)\
**Post date:** [March 28, 2022, 8:20pm UTC](https://forum.graphviz.org/t/how-to-create-a-new-node-type/1096/1 "2022-03-28T20:20:00Z")

</div>

I consider to create this kind of node type within Graphviz.

 ![Basic-Steps](https://global.discourse-cdn.com/graphviz/original/1X/768b20fa82f8148a8598b9a7503c942cea2e6ddf.jpeg)  
I would like to have:

- a type label with a dedicated colour (here “Step” with green color) and/or
- inclusion of icons (e.g. SVG)

What would be the necessary steps I would need to follow to give such an attempt a chance?

Many thanks in advance!

---

<div class="post-metadata">

**Author:** ![steveroush](https://avatars.discourse-cdn.com/v4/letter/s/a9adbd/32.png) [@steveroush](https://forum.graphviz.org/u/steveroush)\
**Post date:** [March 29, 2022, 12:51am UTC](https://forum.graphviz.org/t/how-to-create-a-new-node-type/1096/2 "2022-03-29T00:51:28Z")

</div>

I believe that record-style labels fail in two ways:

- no embedded images
- no multi-color nodes.

Html-like labels get much closer.

- background colors work fine
- rounded edges work in theory, but had problems with background colors
- images can be embedded - in a separate cell
- image sizing can be a problem It is probably best to explicitly size/resize the image outside of Graphviz and not mess with **fixedsize** , **height** and **width**.
- needs some work on the edges

```auto
digraph i{
 {rank=same
  n1 [shape=plaintext,label=<
  <TABLE CELLSPACING="0" CELLPADDING="0" BORDER="1" cellborder="0"> 
  <TR><TD colspan="1" bgcolor="green1">Step</TD></TR>
  <TR><TD>some text</TD></TR>
  </TABLE>
  >
  ]

  n2 [shape=plaintext,label=<
  <TABLE CELLSPACING="0" CELLPADDING="0" BORDER="1" cellborder="0" >
  <TR><TD colspan="2" bgcolor="green1">Step</TD></TR>
  <TR><TD FIXEDSIZE="true" height="20" width="20"><IMG SRC="cow.png" scale="true"/></TD><TD>some text</TD></TR>
  </TABLE>
  >
  ]
  n1 -> n2
  }
} 

```

Giving:  
 ![yaSimpleTable](https://global.discourse-cdn.com/graphviz/original/1X/82eb1fbadf008fdade1e7bec22b60176d3369933.png)

---

<div class="post-metadata">

**Author:** ![Vithanco](https://sea2.discourse-cdn.com/graphviz/user_avatar/forum.graphviz.org/vithanco/32/292_2.png) [@Vithanco](https://forum.graphviz.org/u/Vithanco)\
**Post date:** [March 29, 2022, 4:11am UTC](https://forum.graphviz.org/t/how-to-create-a-new-node-type/1096/3 "2022-03-29T04:11:48Z")

</div>

Thanks Steve! This is a lot closer to what I was able to achieve. It looks good! I will use this. 🙂

I thought that it is tricky to do it with the current abilities. I was therefore looking for guidance to do some coding. If I/anyone would want to extend the Graphviz code for a new type of node then what do I need to consider? is there any documentation on this?

I see that my question doesn’t fully show my intention.

Thanks for providing me this.

---

<div class="post-metadata">

**Author:** ![steveroush](https://avatars.discourse-cdn.com/v4/letter/s/a9adbd/32.png) [@steveroush](https://forum.graphviz.org/u/steveroush)\
**Post date:** [March 29, 2022, 5:29am UTC](https://forum.graphviz.org/t/how-to-create-a-new-node-type/1096/4 "2022-03-29T05:29:35Z")

</div>

See this: [FAQ | Graphviz](https://graphviz.org/faq/#FaqCustShape)  
Any general-purpose or even kind-of general purpose additions would be great.  
However, before you get into the guts of the code, consider these possibilities:

- Creating (complex) images outside of Graphviz and than using the **image** attribute
- The **class** attribute ([class | Graphviz](https://graphviz.org/docs/attrs/class/))
- Positioning nodes on top of each other
  - [Stupid Dot tricks](https://forum.graphviz.org/t/stupid-dot-tricks/31)
  - [Onion Diagram (Nested Ellipses) - #6 by steveroush](https://forum.graphviz.org/t/onion-diagram-nested-ellipses/541/6)

---

<div class="post-metadata">

**Author:** ![Vithanco](https://sea2.discourse-cdn.com/graphviz/user_avatar/forum.graphviz.org/vithanco/32/292_2.png) [@Vithanco](https://forum.graphviz.org/u/Vithanco)\
**Post date:** [March 29, 2022, 6:20am UTC](https://forum.graphviz.org/t/how-to-create-a-new-node-type/1096/5 "2022-03-29T06:20:01Z")

</div>

Great resources. Thank you! I will need to play around with these possibilities.
