A Typst package to draw sequence diagrams with CeTZ
Go to file
2024-10-02 18:38:20 +02:00
docs added manual 2024-10-02 18:33:21 +02:00
gallery completed README 2024-09-30 15:19:36 +02:00
src updated typst.toml + bumped to 0.1.1 2024-10-02 18:38:20 +02:00
gallery.bash completed README 2024-09-30 15:19:36 +02:00
LICENSE Initial commit 2024-06-18 11:38:56 +00:00
manual.pdf updated typst.toml + bumped to 0.1.1 2024-10-02 18:38:20 +02:00
manual.typ added manual 2024-10-02 18:33:21 +02:00
README.md completed README 2024-09-30 15:19:36 +02:00
TODO.md fixed group sizing with syncs 2024-08-25 15:11:57 +02:00
typst.toml updated typst.toml + bumped to 0.1.1 2024-10-02 18:38:20 +02:00

chronos

A Typst package to draw sequence diagrams with CeTZ


This package lets you render sequence diagrams directly in Typst. The following boilerplate code creates an empty sequence diagram with two participants:

Typst Result
#import "@preview/chronos:0.1.0"
#chronos.diagram({
  import chronos: *
  _par("Alice")
  _par("Bob")
})

Disclaimer
The package cannot parse PlantUML syntax for the moment, and thus requires the use of element functions, as shown in the examples. A PlantUML parser is in the TODO list, just not the top priority

Basic sequences

You can make basic sequences using the _seq function:

Typst Result
#chronos.diagram({
  import chronos: *
  _par("Alice")
  _par("Bob")

  _seq("Alice", "Bob", comment: "Hello")
  _seq("Bob", "Bob", comment: "Think")
  _seq("Bob", "Alice", comment: "Hi")
})

You can make lifelines using the following parameters of the _seq function:

  • enable-dst: enables the destination lifeline
  • create-dst: creates the destination lifeline and participant
  • disable-dst: disables the destination lifeline
  • destroy-dst: destroys the destination lifeline and participant
  • disable-src: disables the source lifeline
  • destroy-src: destroy the source lifeline and participant
Typst Result
#chronos.diagram({
  import chronos: *
  _par("A", display-name: "Alice")
  _par("B", display-name: "Bob")
  _par("C", display-name: "Charlie")
  _par("D", display-name: "Derek")

  _seq("A", "B", comment: "hello", enable-dst: true)
  _seq("B", "B", comment: "self call", enable-dst: true)
  _seq("C", "B", comment: "hello from thread 2", enable-dst: true, lifeline-style: (fill: rgb("#005500")))
  _seq("B", "D", comment: "create", create-dst: true)
  _seq("B", "C", comment: "done in thread 2", disable-src: true, dashed: true)
  _seq("B", "B", comment: "rc", disable-src: true, dashed: true)
  _seq("B", "D", comment: "delete", destroy-dst: true)
  _seq("B", "A", comment: "success", disable-src: true, dashed: true)
})

Showcase

Several features have already been implemented in Chronos. Don't hesitate to checkout the examples in the gallery folder to see what you can do.

Quick example reference:

Example Features

example1
(PDF|Typst)

Simple cases, color sequences, groups, separators, gaps, self-sequences

example2
(PDF|Typst)

Lifelines, found/lost messages, synchronized sequences, slanted sequences

example3
(PDF|Typst)

Participant shapes, sequence tips, hidden partipicant ends

notes
(PDF|Typst)

Notes (duh), deferred participant creation

Note

Many examples were taken/adapted from the PlantUML documentation on sequence diagrams