Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Treemaps

sirene draws Mermaid treemaps (treemap-beta) as images and as text. In text, the items are an outline, largest first, with each value and a bar for its share of the total:

---
config:
  treemap:
    valueFormat: "$,.2f"
    padding: 6
---
treemap-beta
"Housing"
  "Rent": 1800.5
  "Utilities": 210
"Food"
  "Groceries": 640:::big
  "Dining", 1,180
"Savings": 900:::calm
classDef big fill:#f96,stroke:#333,stroke-width:2px
classDef calm fill:#9cf,color:#036
the drawing of the mermaid source above

In the editor a treemap is read-only on the drawing side.

What is read

SyntaxDrawn as
"Name"a section holding the items indented under it
"Name": 10 or "Name", 10a leaf whose area is its value; , and _ in a value are ignored
'Name'single quotes work as well
"Name": 10:::clsa leaf or section styled by classDef cls (fill, stroke, stroke-width, color)
title, frontmatter titlethe title above
accTitle, accDescrread, not drawn
config.treemap.valueFormata d3-format string such as ",.2f", "$,", ".1%", or ".2s"
config.treemap.showValuesfalse leaves values out
config.treemapalso padding, diagramPadding, nodeWidth, and nodeHeight

A section’s value is the sum of its items. Several top-level items are allowed.

Errors

A value that is not a number, a missing value after :, a name not closed on its line, and a line that is not an item, classDef, or title are errors. A section with no items, a class with no classDef, and a bad config.treemap value are warnings.

Colors

Section colors can be overridden with themeVariables.cScale0 to cScale11; see Themes.