---
title: "diagram.add: Diagram — Board kit command — Kition"
description: "Makes a whole flow chart from nodes and edges without coordinates: sizes each box to its text, lays it out in layers and draws each connector between facing sides, in one step; answers each node key's element id."
canonical: "https://developer.kition.ai/docs/kits/board/commands/diagram.add"
---

> Canonical HTML: [https://developer.kition.ai/docs/kits/board/commands/diagram.add](https://developer.kition.ai/docs/kits/board/commands/diagram.add)

# diagram.add

**Diagram.** Makes a whole flow chart from nodes and edges without coordinates: sizes each box to its text, lays it out in layers and draws each connector between facing sides, in one step; answers each node key's element id.

- Kit: Board 0.1.0 (.kboard); reference: [Board kit commands](https://developer.kition.ai/docs/kits/board.md)
- Changes the document: yes

## Parameters

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| `at` | `number[] \| object` | no | [x, y] for the diagram's centre; right of the page's content when absent |
| `direction` | `"down" \| "right" \| "up" \| "left"` | no | Where the diagram grows: down (default), right, up or left |
| `edges` | `object[]` | no | The connectors, at most 1000, each from one node's key to another's (the same key: a loop) |
| `nodes` | `object[]` | yes | The boxes, at most 500, laid out for you (no coordinates) |
| `page` | `string` | no | The page's id; the shown page when absent |

## Call through board_run

```text
board_run {
  "path": "<file>.kboard",
  "steps": [{ "command": "diagram.add", "params": { "nodes": <object[]> } }]
}
```

The required parameters, with placeholders for their types: not a tested example. Optional: `at`, `direction`, `edges`, `page`. board_run answers the step’s result in `completed[i].result`.

## Result

The kit gives no result schema for this command.

## Parameter schema

```json
{
  "additionalProperties": false,
  "properties": {
    "at": {
      "description": "[x, y] for the diagram's centre; right of the page's content when absent",
      "oneOf": [
        {
          "items": {
            "description": "One component",
            "maximum": 1000000,
            "minimum": -1000000,
            "type": "number"
          },
          "type": "array"
        },
        {
          "additionalProperties": false,
          "properties": {
            "x": {
              "description": "One component",
              "maximum": 1000000,
              "minimum": -1000000,
              "type": "number"
            },
            "y": {
              "description": "One component",
              "maximum": 1000000,
              "minimum": -1000000,
              "type": "number"
            }
          },
          "required": [
            "x",
            "y"
          ],
          "type": "object"
        }
      ]
    },
    "direction": {
      "description": "Where the diagram grows: down (default), right, up or left",
      "enum": [
        "down",
        "right",
        "up",
        "left"
      ],
      "type": "string"
    },
    "edges": {
      "description": "The connectors, at most 1000, each from one node's key to another's (the same key: a loop)",
      "items": {
        "additionalProperties": false,
        "properties": {
          "from": {
            "description": "The key of the node it starts at",
            "type": "string"
          },
          "text": {
            "description": "Its label",
            "type": "string"
          },
          "to": {
            "description": "The key of the node it points to",
            "type": "string"
          }
        },
        "required": [
          "from",
          "to"
        ],
        "type": "object"
      },
      "type": "array"
    },
    "nodes": {
      "description": "The boxes, at most 500, laid out for you (no coordinates)",
      "items": {
        "additionalProperties": false,
        "properties": {
          "key": {
            "description": "A name for the node, unique in this list; edges and the answer use it",
            "type": "string"
          },
          "shape": {
            "description": "Its shape (rectangle by default; diamond for a decision, pill or ellipse for a start or an end)",
            "enum": [
              "rectangle",
              "ellipse",
              "triangle",
              "diamond",
              "hexagon",
              "pill",
              "parallelogram",
              "star",
              "cloud",
              "heart",
              "x-box",
              "check-box",
              "check",
              "arrow-left",
              "arrow-right",
              "arrow-up",
              "arrow-down",
              "line",
              "pentagon",
              "octagon",
              "trapezoid",
              "right-triangle",
              "cross",
              "chevron",
              "arrow-left-right",
              "arrow-up-down",
              "callout",
              "brace-left",
              "brace-right",
              "document",
              "multi-document",
              "predefined-process",
              "cylinder",
              "manual-input",
              "manual-operation",
              "delay",
              "display",
              "off-page",
              "stored-data",
              "internal-storage",
              "summing-junction",
              "or-junction",
              "note",
              "actor"
            ],
            "type": "string"
          },
          "text": {
            "description": "Its label (the key by default)",
            "type": "string"
          }
        },
        "required": [
          "key"
        ],
        "type": "object"
      },
      "type": "array"
    },
    "page": {
      "description": "The page's id; the shown page when absent",
      "type": "string",
      "x-khp-types": [
        "Page"
      ]
    }
  },
  "required": [
    "nodes"
  ],
  "type": "object"
}
```

Generated from the command list of @kition/board-darwin-arm64@0.1.0 and the kit itself (board_commands through @kition/cli@0.1.1, built from KitionAI/kition-board@e78c190).
