collab/mermaid/docs/syntax/pie.mdblame
View source
6dd74de1> **Warning**
6dd74de2>
6dd74de3> ## THIS IS AN AUTOGENERATED FILE. DO NOT EDIT.
6dd74de4>
6dd74de5> ## Please edit the corresponding file in [/packages/mermaid/src/docs/syntax/pie.md](../../packages/mermaid/src/docs/syntax/pie.md).
6dd74de6
6dd74de7# Pie chart diagrams
6dd74de8
6dd74de9> A pie chart (or a circle chart) is a circular statistical graphic, which is divided into slices to illustrate numerical proportion. In a pie chart, the arc length of each slice (and consequently its central angle and area), is proportional to the quantity it represents. While it is named for its resemblance to a pie which has been sliced, there are variations on the way it can be presented. The earliest known pie chart is generally credited to William Playfair's Statistical Breviary of 1801
6dd74de10> -Wikipedia
6dd74de11
6dd74de12Mermaid can render Pie Chart diagrams.
6dd74de13
6dd74de14```mermaid-example
6dd74de15pie title Pets adopted by volunteers
6dd74de16 "Dogs" : 386
6dd74de17 "Cats" : 85
6dd74de18 "Rats" : 15
6dd74de19```
6dd74de20
6dd74de21```mermaid
6dd74de22pie title Pets adopted by volunteers
6dd74de23 "Dogs" : 386
6dd74de24 "Cats" : 85
6dd74de25 "Rats" : 15
6dd74de26```
6dd74de27
6dd74de28## Syntax
6dd74de29
6dd74de30Drawing a pie chart is really simple in mermaid.
6dd74de31
6dd74de32- Start with `pie` keyword to begin the diagram
6dd74de33 - `showData` to render the actual data values after the legend text. This is **_OPTIONAL_**
6dd74de34- Followed by `title` keyword and its value in string to give a title to the pie-chart. This is **_OPTIONAL_**
6dd74de35- Followed by dataSet. Pie slices will be ordered clockwise in the same order as the labels.
6dd74de36 - `label` for a section in the pie diagram within `" "` quotes.
6dd74de37 - Followed by `:` colon as separator
6dd74de38 - Followed by `positive numeric value` (supported up to two decimal places)
6dd74de39
6dd74de40**Note:**
6dd74de41
6dd74de42> Pie chart values must be **positive numbers greater than zero**.
6dd74de43> **Negative values are not allowed** and will result in an error.
6dd74de44
6dd74de45\[pie] \[showData] (OPTIONAL)
6dd74de46\[title] \[titlevalue] (OPTIONAL)
6dd74de47"\[datakey1]" : \[dataValue1]
6dd74de48"\[datakey2]" : \[dataValue2]
6dd74de49"\[datakey3]" : \[dataValue3]
6dd74de50.
6dd74de51.
6dd74de52
6dd74de53## Example
6dd74de54
6dd74de55```mermaid-example
6dd74de56---
6dd74de57config:
6dd74de58 pie:
6dd74de59 textPosition: 0.5
6dd74de60 themeVariables:
6dd74de61 pieOuterStrokeWidth: "5px"
6dd74de62---
6dd74de63pie showData
6dd74de64 title Key elements in Product X
6dd74de65 "Calcium" : 42.96
6dd74de66 "Potassium" : 50.05
6dd74de67 "Magnesium" : 10.01
6dd74de68 "Iron" : 5
6dd74de69```
6dd74de70
6dd74de71```mermaid
6dd74de72---
6dd74de73config:
6dd74de74 pie:
6dd74de75 textPosition: 0.5
6dd74de76 themeVariables:
6dd74de77 pieOuterStrokeWidth: "5px"
6dd74de78---
6dd74de79pie showData
6dd74de80 title Key elements in Product X
6dd74de81 "Calcium" : 42.96
6dd74de82 "Potassium" : 50.05
6dd74de83 "Magnesium" : 10.01
6dd74de84 "Iron" : 5
6dd74de85```
6dd74de86
6dd74de87## Configuration
6dd74de88
6dd74de89Possible pie diagram configuration parameters:
6dd74de90
6dd74de91| Parameter | Description | Default value |
6dd74de92| -------------- | ------------------------------------------------------------------------------------------------------------ | ------------- |
6dd74de93| `textPosition` | The axial position of the pie slice labels, from 0.0 at the center to 1.0 at the outside edge of the circle. | `0.75` |