-
-
Notifications
You must be signed in to change notification settings - Fork 8k
Closed
Labels
Good first issue!Status: ApprovedIs ready to be worked onIs ready to be worked onType: Bug / ErrorSomething isn't working or is incorrectSomething isn't working or is incorrect
Description
Description
When using the pie
chart in Mermaid.js:
- A slice with a value of
0
is rendered with a0%
label that overlaps the edge of the chart. - A slice with a negative value causes a MermaidParseError with an unclear error message.
- The documentation does not mention these limitations, which may confuse users generating values dynamically.
Steps to reproduce
- Open the Mermaid Live Editor
- Paste the following diagram:
pie
title Zero and Negative Values
"Valid Slice" : 30
"Zero Slice" : 0
"Negative Slice" : -10
Actual Behavior
- Mermaid fails to render the diagram.
- Console shows a vague parser error:
MermaidParseError: Parsing failed: unexpected character: - at offset: 81
- The reason (negative value) is not explained.
If "Negative Slice" is removed:
pie
title Zero and Negative Values
"Valid Slice" : 30
"Zero Slice" : 0
- Diagram renders.
- The
"Zero Slice"
appears in the legend and shows a0%
label at the top, overlapping the chart's border. - This creates misleading visuals in a data visualization.
Screenshots
- Chart with awkward 0% label placement
- Console error for negative value
Code Sample
Setup
- Mermaid version: 11.6.0
- Browser: Chrome 124
- OS: Windows 11
Suggested Solutions
For Negative Values:
- Reject them at parse time with a clear error message, such as: "Negative values are not allowed in pie charts. All slice values must be ≥ 0."
For Zero Values:
- Option 1: Exclude them from the chart entirely.
- Option 2: Render them without label, or place label inside the pie in a non-overlapping position.
- Option 3: Add support for a
hideZeroSlices: true
flag in config.
Documentation:
Update Pie Chart Docs to explain behavior for 0
and negative values.
Additional Context
No response
Metadata
Metadata
Assignees
Labels
Good first issue!Status: ApprovedIs ready to be worked onIs ready to be worked onType: Bug / ErrorSomething isn't working or is incorrectSomething isn't working or is incorrect