{"record":{"id":"1adbba8af57b1fc7","repo":"mermaid-js/mermaid","slug":"the-given-radii-are-too-small-to-create-an-arc-bet","errorCode":null,"errorMessage":"The given radii are too small to create an arc between the points.","messagePattern":"The given radii are too small to create an arc between the points\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/mermaid/src/rendering-util/rendering-elements/shapes/bowTieRect.ts","lineNumber":38,"sourceCode":"  const midY = (y1 + y2) / 2;\n\n  // Calculate the angle of the line connecting the points\n  const angle = Math.atan2(y2 - y1, x2 - x1);\n\n  // Calculate transformed coordinates for the ellipse\n  const dx = (x2 - x1) / 2;\n  const dy = (y2 - y1) / 2;\n\n  // Scale to unit circle\n  const transformedX = dx / rx;\n  const transformedY = dy / ry;\n\n  // Calculate the distance between points on the unit circle\n  const distance = Math.sqrt(transformedX ** 2 + transformedY ** 2);\n\n  // Check if the ellipse can be drawn with the given radii\n  if (distance > 1) {\n    throw new Error('The given radii are too small to create an arc between the points.');\n  }\n\n  // Calculate the distance from the midpoint to the center of the ellipse\n  const scaledCenterDistance = Math.sqrt(1 - distance ** 2);\n\n  // Calculate the center of the ellipse\n  const centerX = midX + scaledCenterDistance * ry * Math.sin(angle) * (clockwise ? -1 : 1);\n  const centerY = midY - scaledCenterDistance * rx * Math.cos(angle) * (clockwise ? -1 : 1);\n\n  // Calculate the start and end angles on the ellipse\n  const startAngle = Math.atan2((y1 - centerY) / ry, (x1 - centerX) / rx);\n  const endAngle = Math.atan2((y2 - centerY) / ry, (x2 - centerX) / rx);\n\n  // Adjust angles for clockwise/counterclockwise\n  let angleRange = endAngle - startAngle;\n  if (clockwise && angleRange < 0) {\n    angleRange += 2 * Math.PI;\n  }","sourceCodeStart":20,"sourceCodeEnd":56,"githubUrl":"https://github.com/mermaid-js/mermaid/blob/d93e9c88c01a599c062ee6a3f1462e3558ac6b90/packages/mermaid/src/rendering-util/rendering-elements/shapes/bowTieRect.ts#L20-L56","documentation":"Thrown by generateArcPoints in the bow-tie-rect shape when, after scaling the half-chord by the radii to the unit circle, the resulting distance exceeds 1. Geometrically this means the two endpoints are farther apart than the ellipse's radii can span, so no ellipse arc can connect them. It's a degenerate-geometry guard, not a user-syntax error.","triggerScenarios":"Computed bow-tie rect geometry where rx/ry (derived from totalHeight via calcEllipseRadius) are too small for the chord between the two arc endpoints. Because rx = ry/(2.5 + totalHeight/50) and ry = totalHeight/2, a very small or zero totalHeight (e.g. node.height=0 and an empty label bbox) makes the radii tiny relative to the half-height chord, pushing distance > 1.","commonSituations":"A bow-tie/stored-data node with an empty label and no explicit height/width (bbox collapses to ~0), an extremely small font, or a node whose dimensions were overridden to near-zero. Also a handDrawn vs neo look path with mismatched padding. This is internal geometry, so end-users usually trigger it via a minimal/empty bow-rect node.","solutions":["Give the bow-tie node a non-empty label or an explicit height/width so totalHeight is large enough that the computed radii exceed the chord.","If overriding node dimensions, ensure height > 0 and width > 0 with reasonable padding.","Switch the node to a different shape (e.g. cylinder/stored-data alias) if minimal sizing is unavoidable.","Reproduce by logging rx, ry, and the chord to confirm which dimension collapsed."],"exampleFix":"// before\nA[\"\"]:::bowTieRect // empty label → tiny bbox → degenerate radii\n// after\nA[\"Stored Data\"]:::bowTieRect // label gives bbox height, radii scale up","handlingStrategy":"validation","validationCode":"function canDrawArc(x1: number, y1: number, x2: number, y2: number, rx: number, ry: number): boolean {\n  const dx = (x2 - x1) / 2, dy = (y2 - y1) / 2;\n  return Math.sqrt((dx / rx) ** 2 + (dy / ry) ** 2) <= 1;\n}\nif (!canDrawArc(...points, rx, ry)) node.label = node.label || ' ';\n// or pick a different shape","typeGuard":"function hasNonZeroSize(node: { width?: number; height?: number; label?: string }): boolean { return (node.width ?? 0) > 0 || (node.height ?? 0) > 0 || (node.label?.length ?? 0) > 0; }","tryCatchPattern":"try { await bowTieRect(parent, node); } catch (e) { if (/radii are too small/.test(String(e))) { node.shape = 'squareRect'; /* re-render */ } else throw e; }","preventionTips":["Give bow-tie/stored-data nodes a non-empty label or explicit dimensions.","Avoid zero-height/zero-width node overrides.","Validate computed rx/ry against the chord before drawing."],"tags":["shapes","geometry","bow-tie","render"],"backgroundTag":null,"analyzedSha":"d93e9c88c01a599c062ee6a3f1462e3558ac6b90","analyzedAt":"2026-08-12T06:23:11.304Z","schemaVersion":2},"datasetVersion":"2026-08-12T13:17:24.610Z"}