piev0.9.4

什么是饼图?

比例一目了然。

pie■ chrome 46%■ safari 22%■ firefox 18%□ other 14%
何时使用

Use a 饼图 when…

01

One-glance proportional comparisons

02

Survey results, share-of-voice

03

Quick stats in a slide

语法基础

The minimal syntax

Copy this and you have a working 饼图. Build from here.

pie.mmd
pie title Browser share (Apr 2026)
    class="code-str">"Chrome" : 46
    class="code-str">"Safari" : 22
    class="code-str">"Firefox" : 18
    class="code-str">"Other" : 14
■ chrome 46%■ safari 22%■ firefox 18%□ other 14%
常见写法

Patterns worth memorizing

Implicit percentages

Values can be raw counts — Mermaid normalizes to percentages automatically.

Show data

Add `showData` after `pie` (e.g. `pie showData`) to print values next to slices.

Order matters

Slices render in declared order, clockwise from 12 — put the largest first.

常见坑点

The things that will trip you up

Mermaid silently ignores misspellings — these are the failures we see most.

  1. 01

    No legend customization beyond label text.

  2. 02

    Pie charts with > 6 slices read poorly; split or use a bar chart elsewhere.

  3. 03

    Labels can't contain `:` — Mermaid uses it as the value separator.