Skip to content

Conversation

darshanr0107
Copy link
Contributor

@darshanr0107 darshanr0107 commented Jun 12, 2025

📑 Summary

This PR adds validation to handle negative values in pie charts:

  • Prevents parser crashes caused by negative values by introducing validation during parsing.

  • Provides clearer error messaging to guide users when invalid input is detected.

Resolves #6584

📏 Design Decisions

Validation moved to the AST level:

Instead of rejecting values in the grammar, the parser accepts all numbers and performs validation during AST traversal. This allows more informative and user-friendly error messages.

📋 Tasks

Make sure you

  • 📖 have read the contribution guidelines
  • 💻 have added necessary unit/e2e tests.
  • 📓 have added documentation. Make sure MERMAID_RELEASE_VERSION is used for all new features.
  • 🦋 If your PR makes a change that should be noted in one or more packages' changelogs, generate a changeset by running pnpm changeset and following the prompts. Changesets that add features should be minor and those that fix bugs should be patch. Please prefix changeset messages with feat:, fix:, or chore:.

Screenshots

Before
Before

After
After

Copy link

changeset-bot bot commented Jun 12, 2025

🦋 Changeset detected

Latest commit: 0823e08

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 2 packages
Name Type
mermaid Patch
@mermaid-js/examples Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

Copy link

netlify bot commented Jun 12, 2025

Deploy Preview for mermaid-js ready!

Name Link
🔨 Latest commit 0823e08
🔍 Latest deploy log https://app.netlify.com/projects/mermaid-js/deploys/68779c7d06f07400087da151
😎 Deploy Preview https://deploy-preview-6651--mermaid-js.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

Copy link

pkg-pr-new bot commented Jun 12, 2025

Open in StackBlitz

@mermaid-js/examples

npm i https://pkg.pr.new/mermaid-js/mermaid/@mermaid-js/examples@6651

mermaid

npm i https://pkg.pr.new/mermaid-js/mermaid@6651

@mermaid-js/layout-elk

npm i https://pkg.pr.new/mermaid-js/mermaid/@mermaid-js/layout-elk@6651

@mermaid-js/mermaid-zenuml

npm i https://pkg.pr.new/mermaid-js/mermaid/@mermaid-js/mermaid-zenuml@6651

@mermaid-js/parser

npm i https://pkg.pr.new/mermaid-js/mermaid/@mermaid-js/parser@6651

@mermaid-js/tiny

npm i https://pkg.pr.new/mermaid-js/mermaid/@mermaid-js/tiny@6651

commit: 0823e08

Copy link

argos-ci bot commented Jun 12, 2025

The latest updates on your projects. Learn more about Argos notifications ↗︎

Build Status Details Updated (UTC)
default (Inspect) 👍 Changes approved 1 added Jul 16, 2025, 12:47 PM

@darshanr0107 darshanr0107 requested review from sidharthv96 and removed request for sidharthv96 June 12, 2025 13:44
Copy link

codecov bot commented Jun 16, 2025

Codecov Report

❌ Patch coverage is 0% with 27 lines in your changes missing coverage. Please review.
✅ Project coverage is 3.71%. Comparing base (5b241bb) to head (0823e08).
⚠️ Report is 135 commits behind head on develop.

Files with missing lines Patch % Lines
packages/mermaid/src/diagrams/pie/pieRenderer.ts 0.00% 23 Missing ⚠️
packages/mermaid/src/diagrams/pie/pieDb.ts 0.00% 4 Missing ⚠️
Additional details and impacted files

Impacted file tree graph

@@           Coverage Diff           @@
##           develop   #6651   +/-   ##
=======================================
  Coverage     3.70%   3.71%           
=======================================
  Files          454     453    -1     
  Lines        44724   44715    -9     
  Branches       707     707           
=======================================
  Hits          1659    1659           
+ Misses       43065   43056    -9     
Flag Coverage Δ
unit 3.71% <0.00%> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
packages/mermaid/src/diagrams/pie/pieDb.ts 0.00% <0.00%> (ø)
packages/mermaid/src/diagrams/pie/pieRenderer.ts 0.71% <0.00%> (+0.01%) ⬆️

... and 1 file with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copy link
Member

@shubhamparikh2704 shubhamparikh2704 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add the screenshots for doc server changes you made.

@shubhamparikh2704 shubhamparikh2704 self-requested a review June 19, 2025 11:27
Copy link
Member

@shubhamparikh2704 shubhamparikh2704 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good 👍

@darshanr0107 darshanr0107 requested a review from sidharthv96 July 2, 2025 06:35
on-behalf-of: @Mermaid-Chart <hello@mermaidchart.com>
@darshanr0107 darshanr0107 requested a review from sidharthv96 July 16, 2025 11:58
Copy link
Collaborator

@knsv knsv left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good and all previus comments have been fixed

@knsv knsv added this pull request to the merge queue Aug 8, 2025
Merged via the queue into develop with commit e6574ef Aug 8, 2025
25 checks passed
@knsv knsv deleted the 6584-piechart-zero-negative-values branch August 8, 2025 10:02
This was referenced Aug 19, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Pie Chart: 0% Label Renders Awkwardly, and Negative Values Crash Parser with Unclear Error
4 participants