Merlive

The library / Class diagrams

Class diagrams, drawn twice

A class is a box that lists its attributes and its methods under its name. Held to the same measure, and to the rows each box lists and what each link ends in.

36 samples: 28 drawn as written, 8 drawn less something. Mermaid’s side is mermaid-cli 12.2.0 as it comes, on white. Merlive’s is 0.6.1 in its own look. What is read of a class diagram.

Members marked abstract or static

Drawn, less something Abstract and static are said in words at the end of the row, where Mermaid slants or underlines it

Mermaid
Members marked abstract or static, as Mermaid draws it
Merlive
Members marked abstract or static, as Merlive draws it
The Mermaid
classDiagram
  class Order{
    +String prefix$
    +total() Money*
    +count()$
    +next() int$
    +check()*
  }
Draw it yourself

The eight relations

Drawn

Mermaid
The eight relations, as Mermaid draws it
Merlive
The eight relations, as Merlive draws it
The Mermaid
classDiagram
  Document <|-- Order
  Order *-- OrderLine
  Warehouse o-- Product
  Invoice --> Order
  Supplier -- Contact
  Order ..> PriceList
  Payable <|.. Invoice
  Buyer .. Note
Draw it yourself

The eight relations written the other way round, each with words

Drawn, less something "Is a" is drawn from the parent down to the child, whichever way it was written

Mermaid
The eight relations written the other way round, each with words, as Mermaid draws it
Merlive
The eight relations written the other way round, each with words, as Merlive draws it
The Mermaid
classDiagram
  Order --|> Document : Inheritance
  OrderLine --* Order : Composition
  Product --o Warehouse : Aggregation
  Invoice --> Order : Association
  Supplier -- Contact : Link(Solid)
  Order ..> PriceList : Dependency
  Invoice ..|> Payable : Realization
  Buyer .. Note : Link(Dashed)
Draw it yourself

A lollipop interface

Drawn, less something A lollipop is drawn as a box of its own, named for the interface and marked «interface», with the circle on its line

Mermaid
A lollipop interface, as Mermaid draws it
Merlive
A lollipop interface, as Merlive draws it
The Mermaid
classDiagram
  class Invoice {
    Money total
    pay()
  }
  Payable ()-- Invoice
  Order --() Printable
Draw it yourself

A namespace

Drawn

Mermaid
A namespace, as Mermaid draws it
Merlive
A namespace, as Merlive draws it
The Mermaid
classDiagram
  namespace Buying {
    class Order
    class OrderLine {
      int quantity
      Money price
    }
  }
  Order *-- OrderLine
Draw it yourself

A namespace written inside another

Drawn

Mermaid
A namespace written inside another, as Mermaid draws it
Merlive
A namespace written inside another, as Merlive draws it
The Mermaid
classDiagram
  namespace Ordering {
    namespace Buying {
      class Order {
        +raise()
      }
    }
    namespace Paying {
      class Invoice {
        +pay()
      }
    }
    class Ledger {
      +post()
    }
  }
  Ledger --> Order : records
  Ledger --> Invoice : records
Draw it yourself

Namespaces inside one another, spelt with dots

Drawn

Mermaid
Namespaces inside one another, spelt with dots, as Mermaid draws it
Merlive
Namespaces inside one another, spelt with dots, as Merlive draws it
The Mermaid
classDiagram
  namespace Shop.Ordering.Buying {
    class Order {
      +raise()
    }
  }
  namespace Shop.Ordering.Paying {
    class Invoice {
      +pay()
    }
  }
  namespace Shop.Ordering {
    class Ledger {
      +post()
    }
  }
  Ledger --> Order : records
  Ledger --> Invoice : records
Draw it yourself

A direction for the whole diagram

Drawn, less something Drawn top to bottom: boxes of different heights are only placed that way yet

Mermaid
A direction for the whole diagram, as Mermaid draws it
Merlive
A direction for the whole diagram, as Merlive draws it
The Mermaid
classDiagram
  direction RL
  class Buyer {
    -badge : Badge
  }
  class Badge{
    -id : int
    -name : string
  }
  Buyer "1" --o "1" Badge : carries
Draw it yourself

A class that opens a link or calls a function when clicked

Drawn, less something The clicks are left out: a page of Merlive opens no links and runs no code of yours

Mermaid
A class that opens a link or calls a function when clicked, as Mermaid draws it
Merlive
A class that opens a link or calls a function when clicked, as Merlive draws it
The Mermaid
classDiagram
  class Order
  class Invoice
  class Supplier
  class Product
  link Order "https://example.com/orders" "Open the order"
  click Invoice href "https://example.com/invoices" "Open the invoice"
  callback Supplier "showSupplier" "Show the supplier"
  click Product call showProduct() "Show the product"
Draw it yourself

A class styled on its own

Drawn, less something Each outline is heavy or broken as written, in the design's own nearest colour; the fill is the design's

Mermaid
A class styled on its own, as Mermaid draws it
Merlive
A class styled on its own, as Merlive draws it
The Mermaid
classDiagram
  class Order
  class Invoice
  style Order fill:#f9f,stroke:#333,stroke-width:4px
  style Invoice fill:#bbf,stroke:#f66,stroke-width:2px,color:#fff,stroke-dasharray: 5 5
Draw it yourself

A style class made with classDef and given with cssClass

Drawn

Mermaid

Mermaid could not draw this: Error: Lexical error on line 7. Unrecognized text.

Merlive
A style class made with classDef and given with cssClass, as Merlive draws it
The Mermaid
classDiagram
  class Order
  class Invoice
  class Refund
  classDef late fill:#f9f,stroke:#c62828,stroke-width:4px;
  classDef held,parked stroke:#888,stroke-dasharray: 4 3;
  cssClass "Order" late;
  cssClass "Invoice,Refund" held;
Draw it yourself

A default style class for every class

Drawn, less something The default class is read past: the look is the design's

Mermaid
A default style class for every class, as Mermaid draws it
Merlive
A default style class for every class, as Merlive draws it
The Mermaid
classDiagram
  class Order:::quiet
  class Invoice
  classDef default fill:#f96,color:red
  classDef quiet color:#99f
Draw it yourself

A whole diagram: classes, what they list, what they inherit, and a note

Drawn

Mermaid
A whole diagram: classes, what they list, what they inherit, and a note, as Mermaid draws it
Merlive
A whole diagram: classes, what they list, what they inherit, and a note, as Merlive draws it
The Mermaid
---
title: Orders and what they hold
---
classDiagram
  note for Invoice "Sent when the order is delivered<br>Paid within thirty days"
  Document <|-- Order
  Document <|-- Invoice
  Document : +String number
  Document : +Date raised
  Document: +print()
  class Order{
    +String buyer
    +approve()
    +total() Money
  }
  class Invoice{
    -Money amountDue
    -pay()
  }
Draw it yourself