tinyactors graph

Draw each chart, or list its boxes and edges.

Usage

shell
tinyactors graph [options] INPUT...

Lays each chart out as nested boxes for its states and orthogonal routes for its transitions. With -f svg it writes the picture; the other formats list each box and edge. Reads one image (.tai), one snapshot, one system manifest or SCXML charts, compiled together into one image first. --segment picks a snapshot's image, and - reads standard input.

Options

  • -W, --warnings-as-errorsRefuse a chart that compiles with a warning.
  • -I, --include DIRSearch DIR for a src that is not beside the file naming it, in the order given. Repeatable.
  • -c, --chart NAMELook at the chart named NAME only. Repeatable.
  • -s, --segment NRead the image that segment N of a snapshot runs. Default: the newest live segment.
  • --direction DIRECTIONLay the states out in DIRECTION. Values: down (top to bottom) or right (left to right). Default: down.
  • --theme THEMEDraw the colours of THEME with -f svg. Values: auto (the reader's preference), light or dark. Default: auto.
  • --highlight STATEMark the box of STATE. Repeatable.
  • --pathMark the path the path command finds to --to from --from, its steps numbered.
  • -t, --to STATEEnd the path of --path at STATE.
  • --from STATEStart the path of --path at STATE. Default: the initial configuration.
  • -d, --depth NFold every compound or parallel state nested deeper than N levels into one box.
  • --fold STATEFold the compound or parallel state STATE into one box. Repeatable.

Configure output formats like -f json using the shared options on the command reference.

Examples

shell
tinyactors graph -f svg order.scxml > order.svg

Draw a chart as SVG.

tinyactors graph -f svg order.scxml > order.svg
shell
tinyactors graph -f svg --chart payment shop.tai > payment.svg

Draw one chart of an image.

tinyactors graph -f svg --chart payment shop.tai > payment.svg
shell
tinyactors graph -f svg --direction right --theme dark order.scxml > order.svg

Draw a chart left to right in dark colours.

tinyactors graph -f svg --direction right --theme dark order.scxml > order.svg
shell
tinyactors graph -f svg --path --to shipped --highlight cancelled order.scxml > shipping.svg

Mark the path to shipped and highlight cancelled.

tinyactors graph -f svg --path --to shipped --highlight cancelled order.scxml > shipping.svg
shell
tinyactors graph -f svg --depth 1 --fold checkout shop.scxml > overview.svg

Fold states nested deeper than one level, and checkout.

tinyactors graph -f svg --depth 1 --fold checkout shop.scxml > overview.svg
shell
tinyactors graph -f json order.tai
output
{
  "charts": [
    {
      "name": "order",
      "width": 821,
      "height": 432,
      "boxes": [
        {
          "state": "/scxml",
          "kind": "compound",
          "parent": "",
          "drawnAs": "root",
          "x": 0,
          "y": 0,
          "width": 821,
          "height": 432
        },
        {
          "state": "open",
          "kind": "atomic",
          "parent": "/scxml",
          "drawnAs": "atomic",
          "x": 508,
          "y": 40,
          "width": 276,
          "height": 58
        },
        {
          "state": "paying",
          "kind": "atomic",
          "parent": "/scxml",
          "drawnAs": "atomic",
          "x": 278,
          "y": 160,
          "width": 480,
          "height": 34
        },
        {
          "state": "paid",
          "kind": "atomic",
          "parent": "/scxml",
          "drawnAs": "atomic",
          "x": 413,
          "y": 298,
          "width": 78,
          "height": 34
        },
        {
          "state": "shipped",
          "kind": "final",
          "parent": "/scxml",
          "drawnAs": "final",
          "x": 414,
          "y": 384,
          "width": 77,
          "height": 34
        },
        {
          "state": "cancelled",
          "kind": "final",
          "parent": "/scxml",
          "drawnAs": "final",
          "x": 592,
          "y": 298,
          "width": 92,
          "height": 34
        }
      ],
      "edges": [
        {
          "source": "open",
          "target": "paying",
          "events": "checkout",
          "condition": "total > 0",
          "drawnAs": "forward",
          "route": "518,98 518,160"
        },
        {
          "source": "open",
          "target": "cancelled",
          "events": "cancel",
          "condition": "",
          "drawnAs": "forward",
          "route": "726,98 726,150 781,150 781,288 667,288 667,298"
        },
        {
          "source": "paying",
          "target": "paid",
          "events": "charge.ok",
          "condition": "",
          "drawnAs": "forward",
          "route": "398,194 398,278 452,278 452,298"
        },
        {
          "source": "paying",
          "target": "paying",
          "events": "charge.declined error.communication payment.timeout",
          "condition": "attempts < 3",
          "drawnAs": "self",
          "route": "463,194 463,210 573,210 573,194"
        },
        {
          "source": "paying",
          "target": "cancelled",
          "events": "charge.declined error.communication payment.timeout",
          "condition": "",
          "drawnAs": "forward",
          "route": "638,194 638,298"
        },
        {
          "source": "paid",
          "target": "shipped",
          "events": "shipped",
          "condition": "",
          "drawnAs": "forward",
          "route": "452,332 452,384"
        }
      ],
      "inside": [
        {
          "state": "open",
          "events": "item.added",
          "condition": "_event.data.price > 0",
          "targets": ""
        }
      ],
      "problems": [
        {
          "kind": "labelOnEdge",
          "subject": "paying → paying on charge.declined error.communication payment.timeout",
          "touches": "paying → paid on charge.ok"
        },
        {
          "kind": "labelOnEdge",
          "subject": "paying → cancelled on charge.declined error.communication payment.timeout",
          "touches": "open → cancelled on cancel"
        }
      ]
    },
    {
      "name": "payment",
      "width": 242,
      "height": 290,
      "boxes": [
        {
          "state": "/scxml",
          "kind": "compound",
          "parent": "",
          "drawnAs": "root",
          "x": 0,
          "y": 0,
          "width": 242,
          "height": 290
        },
        {
          "state": "pending",
          "kind": "atomic",
          "parent": "/scxml",
          "drawnAs": "atomic",
          "x": 64,
          "y": 40,
          "width": 164,
          "height": 34
        },
        {
          "state": "authorized",
          "kind": "atomic",
          "parent": "/scxml",
          "drawnAs": "atomic",
          "x": 37,
          "y": 136,
          "width": 130,
          "height": 34
        },
        {
          "state": "settled",
          "kind": "final",
          "parent": "/scxml",
          "drawnAs": "final",
          "x": 14,
          "y": 242,
          "width": 77,
          "height": 34
        },
        {
          "state": "declined",
          "kind": "final",
          "parent": "/scxml",
          "drawnAs": "final",
          "x": 109,
          "y": 242,
          "width": 85,
          "height": 34
        }
      ],
      "edges": [
        {
          "source": "pending",
          "target": "authorized",
          "events": "authorize",
          "condition": "",
          "drawnAs": "forward",
          "route": "102,74 102,136"
        },
        {
          "source": "pending",
          "target": "declined",
          "events": "decline",
          "condition": "",
          "drawnAs": "forward",
          "route": "189,74 189,126 190,126 190,232 177,232 177,242"
        },
        {
          "source": "authorized",
          "target": "settled",
          "events": "capture",
          "condition": "",
          "drawnAs": "forward",
          "route": "53,170 53,242"
        },
        {
          "source": "authorized",
          "target": "declined",
          "events": "void",
          "condition": "",
          "drawnAs": "forward",
          "route": "138,170 138,242"
        }
      ],
      "inside": [],
      "problems": []
    }
  ]
}

List the boxes and edges of an image's charts as JSON.

Exit status

  • 1An input is refused: it does not compile or verify, or it is damaged or of an unknown format.
  • 1With --path, no path reaches the --to state in any chart drawn.
  • 3A file cannot be read or written, or memory runs out.

Related pages