-
-
Notifications
You must be signed in to change notification settings - Fork 8.4k
Feature/7078 make changes to allow for decimal values for sequence numbers #7174
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: develop
Are you sure you want to change the base?
Feature/7078 make changes to allow for decimal values for sequence numbers #7174
Conversation
…corresponding unit tests, and updated docs.
🦋 Changeset detectedLatest commit: 50b2166 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
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 |
✅ Deploy Preview for mermaid-js ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
@mermaid-js/examples
mermaid
@mermaid-js/layout-elk
@mermaid-js/layout-tidy-tree
@mermaid-js/mermaid-zenuml
@mermaid-js/parser
@mermaid-js/tiny
commit: |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## develop #7174 +/- ##
==========================================
- Coverage 3.55% 3.55% -0.01%
==========================================
Files 474 473 -1
Lines 47453 47504 +51
Branches 730 731 +1
==========================================
Hits 1687 1687
- Misses 45766 45817 +51
Flags with carried forward coverage won't be shown. Click here to find out more.
🚀 New features to boost your workflow:
|
|
The latest updates on your projects. Learn more about Argos notifications ↗︎
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR adds support for decimal sequence numbers in sequence diagrams, allowing both the start value and increment value for the autonumber directive to use decimal numbers with precision up to the hundredths place (e.g., autonumber 10.1 0.01). This enhancement provides more flexibility for users who need fine-grained control over sequence numbering.
Key Changes
- Updated the Jison parser to accept decimal values (tenths or hundredths place) for sequence numbers
- Implemented floating-point precision handling using rounding to prevent arithmetic errors
- Added dynamic font sizing for sequence number display to handle longer numeric strings
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
packages/mermaid/src/diagrams/sequence/parser/sequenceDiagram.jison |
Updated NUM token regex to match decimal numbers with up to 2 decimal places |
packages/mermaid/src/diagrams/sequence/sequenceRenderer.ts |
Added Math.round() logic to handle floating-point precision and dynamic font sizing for sequence numbers |
packages/mermaid/src/diagrams/sequence/sequenceDiagram.spec.js |
Added unit tests for decimal value parsing, validation, and increment calculations |
cypress/integration/rendering/sequencediagram.spec.js |
Added E2E test for visual rendering of decimal sequence numbers |
packages/mermaid/src/docs/syntax/sequenceDiagram.md |
Added documentation for the new decimal value support in autonumber |
docs/syntax/sequenceDiagram.md |
Added documentation for the new decimal value support in autonumber |
.changeset/dark-bats-build.md |
Added changeset documenting this minor feature addition |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Great work @milesspencer35 on enabling decimal autonumber seeds — the formatting and parsing improvements look solid. One thing I wanted to confirm: currently, autonumber increases by whole numbers even when seeded with a decimal (e.g., 10.3 → 11.3 → 12.3). There’s no fractional stepping, and decimals only affect the display formatting. Was this an intentional, or should the increment behavior differ depending on the decimal precision? (Example: some users may expect 10.3 → 10.4 → 10.5 rather than 11.3.) Just checking whether the current behavior aligns with the feature expectations. Thanks ! |
|
@omkarht thank you for taking the time to look at my PR. Currently, how autonumber works is that you can set a start and increment value. For example, This PR allows for both the start and increment values to be decimals, with the default increment number still being 1. So, for the example you gave above, if you wanted your diagram to increase 10.3 -> 10.4 -> 10.5, you would do So I believe the use case you are thinking of is covered! Please let me know if I can clarify more or if this doesn't answer your question! |
|
Thanks for the clarification @milesspencer35, that makes the behaviour clear. It’s great that both the start and increment values can be decimals (e.g., Looks good from my side 👍 |

📑 Summary
Added support for sequence numbers in sequence diagrams to use decimal values up to the hundredths place, and enabled incrementing using decimal values to the same precision. Other PR had issues, so this is a new one.
Resolves #7078
📏 Design Decisions
Describe the way your implementation works or what design decisions you made if applicable.
📋 Tasks
Make sure you
MERMAID_RELEASE_VERSIONis used for all new features.pnpm changesetand following the prompts. Changesets that add features should beminorand those that fix bugs should bepatch. Please prefix changeset messages withfeat:,fix:, orchore:.