Skip to content
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

Fix: Could not find a suitable point for the given distance #6329

Conversation

yari-dewalt
Copy link
Collaborator

📑 Summary

Fixes an error thrown when calculating points for an edge: Could not find a suitable point for the given distance. This is caused by a division by zero error giving a NaN result for the point due to the vectorDistance between two points being zero (the points are stacked on top of each other) const distanceRatio = remainingDistance / vectorDistance; This is an issue only seen in Mermaid Chart where you can use the fixed layout as the regular layout algorithms won't have points in an edge with a distance of zero in between them.

📏 Design Decisions

If the vectorDistance is zero it will simply return the previous point avoiding errors.

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

Copy link

changeset-bot bot commented Feb 25, 2025

⚠️ No Changeset found

Latest commit: 5447a9f

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

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

@github-actions github-actions bot added the Type: Bug / Error Something isn't working or is incorrect label Feb 25, 2025
Copy link

netlify bot commented Feb 25, 2025

Deploy Preview for mermaid-js ready!

Name Link
🔨 Latest commit 5447a9f
🔍 Latest deploy log https://app.netlify.com/sites/mermaid-js/deploys/67be0ab7e5d5de0008286dec
😎 Deploy Preview https://deploy-preview-6329--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 site configuration.

Copy link

pkg-pr-new bot commented Feb 25, 2025

Open in Stackblitz

npm i https://pkg.pr.new/mermaid-js/mermaid@6329
npm i https://pkg.pr.new/mermaid-js/mermaid/@mermaid-js/mermaid-zenuml@6329
npm i https://pkg.pr.new/mermaid-js/mermaid/@mermaid-js/layout-elk@6329
npm i https://pkg.pr.new/mermaid-js/mermaid/@mermaid-js/parser@6329

commit: 5447a9f

Copy link

codecov bot commented Feb 25, 2025

Codecov Report

Attention: Patch coverage is 0% with 3 lines in your changes missing coverage. Please review.

Project coverage is 3.88%. Comparing base (60db05b) to head (5447a9f).
Report is 36 commits behind head on develop.

Files with missing lines Patch % Lines
packages/mermaid/src/utils.ts 0.00% 3 Missing ⚠️
Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##           develop   #6329      +/-   ##
==========================================
- Coverage     3.88%   3.88%   -0.01%     
==========================================
  Files          398     398              
  Lines        42040   42043       +3     
  Branches       637     637              
==========================================
  Hits          1634    1634              
- Misses       40406   40409       +3     
Flag Coverage Δ
unit 3.88% <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/utils.ts 18.08% <0.00%> (-0.10%) ⬇️

Copy link

argos-ci bot commented Feb 25, 2025

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

Build Status Details Updated (UTC)
default (Inspect) ✅ No changes detected - Feb 25, 2025, 6:32 PM

@knsv knsv self-requested a review February 26, 2025 11:57
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.

LGTM!

@ashishjain0512 ashishjain0512 merged commit 446f6a7 into mermaid-js:develop Feb 26, 2025
22 checks passed
@yari-dewalt yari-dewalt deleted the fix/could_not_find_a_suitable_point_for_the_given_distance branch February 26, 2025 18:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type: Bug / Error Something isn't working or is incorrect
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants