Mermaid mindmap and pie chart: shapes, indent and Markmap
Mermaid includes two compact diagram types for quick summaries in Markdown: mindmap turns an indented list into a radial tree, and pie turns "Label" : value lines into a proportional chart. Both use standard mermaid code fences and render offline in MiaoYan on Mac, iPhone, and iPad. The catch with mindmap is its whitespace parser, where one stray tab or a second root line breaks the chart, and the catch with pie is that negative values fail while slices under one percent vanish from the wheel. Every example below opens in the Mermaid live editor, while standard Markdown outlines often fit the Markmap editor better.
A minimal Mermaid mindmap and how indentation works
```mermaid
mindmap
root((Notes))
Writing
Drafts
Published
Reading
Books
Articles
Work
Meetings
```
Unlike flowcharts, mindmap uses no arrows. Hierarchy comes entirely from leading whitespace. The first node after mindmap becomes the single root, and Mermaid records its indentation as the baseline level. For every line after that, Mermaid scans upward and attaches the node to the nearest preceding line with fewer leading whitespace characters.
That lookup rule explains both errors people hit immediately:
- Only one root is allowed. If a later line sits at or left of the root's indentation, Mermaid finds no parent and aborts with
There can be only one root. No parent could be found. Every branch must sit at least one space deeper than the root. - Mixing tabs and spaces warps the hierarchy. Mermaid counts raw characters in the leading whitespace string rather than visual tab stops. One tab counts as length
1, while two spaces count as length2. Indenting a parent with two spaces and its child with one tab looks deeper in a four-space editor, yet Mermaid reads1 < 2and rejects the child as a second root. Use two spaces per level everywhere.
Node shapes in mindmap
Plain text draws a default node. Wrapping a label in bracket pairs changes its shape so you can distinguish central topics, deliverables, open questions, and gates without CSS:
```mermaid
mindmap
root((Product launch))
plan[Planning]
(User guide)
[Landing page]
risks)Open questions(
{{Pricing tier}}
((Support load))
```
An optional identifier can precede the brackets, as in root((Product launch)), or you can wrap the label directly as (User guide). Mermaid 11.14.0 supports seven shapes:
| Syntax | Shape drawn | Typical use |
|---|---|---|
Plain text |
Default node | Ordinary leaf items |
[Text] |
Square rectangle | Concrete deliverables or files |
(Text) |
Rounded rectangle | Tasks and steps |
((Text)) |
Circle | Central root or key metric |
)Text( |
Cloud | Open questions or rough ideas |
))Text(( |
Bang (burst) | Blockers or risks |
{{Text}} |
Hexagon | Gate checks or decisions |
Notice the outward parentheses on )Cloud( and ))Bang((. Because brackets act as shape delimiters, an unquoted parenthesis inside a label such as (API (v2)) cuts the token early. Wrap labels containing punctuation in double quotes inside the shape markers, such as ["API (v2) spec"], or use "`Line one\nLine two`" for line breaks. Mermaid also defines ::icon(...), though icons require external icon stylesheets that MiaoYan omits to stay offline and private.
Mermaid pie charts, showData, and slice math
When three to six categories divide engineering hours, storage, or a budget, pie takes minimal syntax:
```mermaid
pie title Weekly engineering hours
"Feature work" : 22
"Bug fixes" : 9.5
"Code review" : 5.5
"Meetings" : 3
```
Start with pie and an optional title. Each slice puts its label in straight double quotes, followed by a colon and a positive number (up to two decimal places). Values need not sum to 100; Mermaid totals them and prints rounded whole percentages on the wedges.
Adding showData right after pie appends each raw number in square brackets beside its legend label:
```mermaid
pie showData
title Storage usage by folder (GB)
"Photos and media" : 42.5
"Project repos" : 18.25
"Local models" : 14.75
"Markdown notes" : 1.5
```
Three details in Mermaid 11.14.0 prevent surprises:
- Clockwise declaration order. Slices draw clockwise from twelve o'clock in the exact order written, without sorting largest first.
- Negative, zero, and sub-percent values. Negative numbers throw
Negative values are not allowed in pie charts. A0value, or any slice below1%of the total sum, is filtered out when building the SVG arcs, leaving a legend entry with no visible wedge. - Duplicate labels are skipped. Slices are stored by label key, so a second line with an identical label is ignored rather than added.
Mermaid mindmap vs Markmap
MiaoYan bundles both Mermaid (mermaid fence) and Markmap (markmap fence) offline, covered in Markmap: turn a Markdown outline into a mind map.
If your note is already an outline of # headings, - lists, inline code, or $x^2$ math, converting it to Mermaid mindmap means stripping every # and - marker. Wrapping that Markdown outline directly in a markmap fence draws a colored tree immediately:
# Product launch
## Planning
- User guide
- Landing page
## Open questions
- Pricing tier
- Support load
Choose Mermaid mindmap when you want cloud, hexagon, or circle shapes around a hub, or when publishing to GitHub READMEs, which render mermaid natively while showing markmap as source text. Choose Markmap for deeper outlines, inline math or code, and interactive folding in the Markmap editor. Other chart options are compared in Mermaid in Markdown.
What goes wrong and how to check
When a chart stays as raw code in MiaoYan (⌘3 or ⌘\), inspect these patterns:
%% Broken mindmap and pie patterns:
mindmap
Root A
Root B
pie ShowData
Storage : 40
"Cache" : -5
- Two roots in
mindmap. IndentRoot Bor place both under one root node. - Casing or quote errors in
pie. Write exact lowercaseshowDataand straight double quotes ("Storage" : 40), never curly quotes. - Too many slices. Mermaid cycles twelve palette colors, and more than six slices crowd percentage labels; group tiny items into
"Other"or use a Markdown table.
Type /mermaid or /markmap plus Tab on Mac to insert a template, or debug indentation in the Mermaid live editor. MiaoYan is on the App Store for Mac, iPhone, and iPad, and on GitHub.
FAQ
Why does mindmap say There can be only one root on a child line?
A tab mixed with spaces is the usual cause. Mermaid counts raw whitespace characters (1 for a tab vs 2 for two spaces), putting the tabbed line left of its parent. Replace tabs with spaces.
Can pie show raw numbers instead of percentages on the wedges?
Wedges always display rounded percentages, while pie showData prints each raw value in brackets next to its legend entry.
Do Mermaid mindmap and pie blocks render on GitHub?
Yes. GitHub renders both inside mermaid fences in READMEs, issues, and pull requests, whereas markmap fences stay plain code there.
How many slices work cleanly in a Mermaid pie chart?
Keep charts to two through six slices, each at least two percent of the total. Sub-percent slices drop off the wheel in Mermaid 11.14.0.
