• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

mermaid-js / mermaid / 4740051045

pending completion
4740051045

Pull #4316

github

GitHub
Merge ff3104ad9 into 8dfad241c
Pull Request #4316: pie diagram mermaid module import fix

1711 of 2122 branches covered (80.63%)

Branch coverage included in aggregate %.

18546 of 33497 relevant lines covered (55.37%)

404.85 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

9.38
/packages/mermaid/src/dagre-wrapper/intersect/intersect-rect.js
1
const intersectRect = (node, point) => {
1✔
2
  var x = node.x;
×
3
  var y = node.y;
×
4

×
5
  // Rectangle intersection algorithm from:
×
6
  // https://math.stackexchange.com/questions/108113/find-edge-between-two-boxes
×
7
  var dx = point.x - x;
×
8
  var dy = point.y - y;
×
9
  var w = node.width / 2;
×
10
  var h = node.height / 2;
×
11

×
12
  var sx, sy;
×
13
  if (Math.abs(dy) * w > Math.abs(dx) * h) {
×
14
    // Intersection is top or bottom of rect.
×
15
    if (dy < 0) {
×
16
      h = -h;
×
17
    }
×
18
    sx = dy === 0 ? 0 : (h * dx) / dy;
×
19
    sy = h;
×
20
  } else {
×
21
    // Intersection is left or right of rect.
×
22
    if (dx < 0) {
×
23
      w = -w;
×
24
    }
×
25
    sx = w;
×
26
    sy = dx === 0 ? 0 : (w * dy) / dx;
×
27
  }
×
28

×
29
  return { x: x + sx, y: y + sy };
×
30
};
×
31

1✔
32
export default intersectRect;
1✔
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc