Skip to content

Conversation

@milesspencer35
Copy link

📑 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.

  • Updated the Jison parser for sequence diagrams to accept decimal values to the hundredths place.
  • Updated how the sequenceIndex and sequenceIndexStep are added to remove floating-point errors.
  • Decrease the font size once a sequence number gets sufficiently long and spills out of the circle. I decided this was the best course of action because it was a simple fix for a rare use case.

📋 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:.

@changeset-bot
Copy link

changeset-bot bot commented Nov 18, 2025

🦋 Changeset detected

Latest commit: 50b2166

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

This PR includes changesets to release 1 package
Name Type
mermaid Minor

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

@netlify
Copy link

netlify bot commented Nov 18, 2025

Deploy Preview for mermaid-js ready!

Name Link
🔨 Latest commit 50b2166
🔍 Latest deploy log https://app.netlify.com/projects/mermaid-js/deploys/691cae3da27c2c00080e766e
😎 Deploy Preview https://deploy-preview-7174--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.

@github-actions github-actions bot added the Type: Enhancement New feature or request label Nov 18, 2025
@pkg-pr-new
Copy link

pkg-pr-new bot commented Nov 18, 2025

Open in StackBlitz

@mermaid-js/examples

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

mermaid

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

@mermaid-js/layout-elk

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

@mermaid-js/layout-tidy-tree

npm i https://pkg.pr.new/mermaid-js/mermaid/@mermaid-js/layout-tidy-tree@7174

@mermaid-js/mermaid-zenuml

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

@mermaid-js/parser

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

@mermaid-js/tiny

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

commit: 50b2166

@codecov
Copy link

codecov bot commented Nov 18, 2025

Codecov Report

❌ Patch coverage is 0% with 9 lines in your changes missing coverage. Please review.
✅ Project coverage is 3.55%. Comparing base (717d3b3) to head (50b2166).
⚠️ Report is 136 commits behind head on develop.

Files with missing lines Patch % Lines
.../mermaid/src/diagrams/sequence/sequenceRenderer.ts 0.00% 9 Missing ⚠️
Additional details and impacted files

Impacted file tree graph

@@            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     
Flag Coverage Δ
unit 3.55% <0.00%> (-0.01%) ⬇️

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

Files with missing lines Coverage Δ
.../mermaid/src/diagrams/sequence/sequenceRenderer.ts 0.06% <0.00%> (-0.01%) ⬇️

... and 13 files 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.

@argos-ci
Copy link

argos-ci bot commented Nov 18, 2025

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

Build Status Details Updated (UTC)
default (Inspect) ⚠️ Changes detected (Review) 1 added Nov 18, 2025, 5:45 PM

Copy link
Contributor

Copilot AI left a 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.

@omkarht
Copy link
Contributor

omkarht commented Dec 4, 2025

image
sequenceDiagram
    autonumber 10
    Server->>Client: Snapshot for tick 10
    autonumber 10.3
    Client->>Server: Command for tick 10.3
    Server->>Client: Test Command 
    Client->>Server: New Test Command 

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 !

@milesspencer35
Copy link
Author

milesspencer35 commented Dec 4, 2025

@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, autonumber 10 5 makes it so that the sequence number starts at 10 and increases by 5. If no increment value is set, then the default increment value is 1.

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 autonumber 10.3 0.1.

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!

@omkarht
Copy link
Contributor

omkarht commented Dec 8, 2025

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., autonumber 10.3 0.1), allowing fractional stepping when configured. That aligns with the expected use case.

Looks good from my side 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Type: Enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add support for decimal numbers with sequence diagram

2 participants