{"record":{"id":"f267a03e521740c3","repo":"parallax/jsPDF","slug":"invalid-arguments-passed-to-jspdf-circle","errorCode":null,"errorMessage":"Invalid arguments passed to jsPDF.circle","messagePattern":"Invalid arguments passed to jsPDF\\.circle","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"src/jspdf.js","lineNumber":4917,"sourceCode":"   * @param {number} y Coordinate (in units declared at inception of PDF document) against upper edge of the page\n   * @param {number} r Radius (in units declared at inception of PDF document)\n   * @param {string=} style A string specifying the painting style or null. Valid styles include:\n   * 'S' [default] - stroke,\n   * 'F' - fill,\n   * and 'DF' (or 'FD') -  fill then stroke.\n   * In \"compat\" API mode, a null value postpones setting the style so that a shape may be composed using multiple\n   * method calls. The last drawing method call used to define the shape should not have a null style argument.\n   *\n   * In \"advanced\" API mode this parameter is deprecated.\n   * @function\n   * @instance\n   * @returns {jsPDF}\n   * @memberof jsPDF#\n   * @name circle\n   */\n  API.__private__.circle = API.circle = function(x, y, r, style) {\n    if (isNaN(x) || isNaN(y) || isNaN(r) || !isValidStyle(style)) {\n      throw new Error(\"Invalid arguments passed to jsPDF.circle\");\n    }\n    return this.ellipse(x, y, r, r, style);\n  };\n\n  /**\n   * Sets text font face, variant for upcoming text elements.\n   * See output of jsPDF.getFontList() for possible font names, styles.\n   *\n   * @param {string} fontName Font name or family. Example: \"times\".\n   * @param {string} fontStyle Font style or variant. Example: \"italic\".\n   * @param {number | string} fontWeight Weight of the Font. Example: \"normal\" | 400\n   * @function\n   * @instance\n   * @returns {jsPDF}\n   * @memberof jsPDF#\n   * @name setFont\n   */\n  API.setFont = function(fontName, fontStyle, fontWeight) {","sourceCodeStart":4899,"sourceCodeEnd":4935,"githubUrl":"https://github.com/parallax/jsPDF/blob/a3930ce03a585a26b2c76d12a0f413ce96f6d1a3/src/jspdf.js#L4899-L4935","documentation":"Thrown by jsPDF.circle when x, y, or r is NaN or the style is invalid. All three must be finite numbers; style must pass isValidStyle (undefined, null, 'S', 'D', 'F', 'DF', 'FD', 'f', 'f*', 'B', 'B*', 'n'). circle delegates to ellipse with rx=ry=r.","triggerScenarios":"Calling circle() with an undefined radius, a non-numeric coordinate, or an unsupported style such as 'stroke', 'fill', or a number.","commonSituations":"Radius derived from missing data; friendly style names used instead of PDF operator codes; passing a diameter as the radius without numeric coercion.","solutions":["Pass finite numeric x, y, r and a supported style code.","Use 'S' to stroke, 'F' to fill, 'DF' for both, or null/undefined.","Coerce the radius with Number() and guard against NaN."],"exampleFix":"// before\npdf.circle(cx, cy, d, 'stroke'); // d may be undefined; 'stroke' invalid\n// after\npdf.circle(cx, cy, Number(d) || 0, 'S');","handlingStrategy":"validation","validationCode":"const VALID_STYLES = [undefined, null, 'S','D','F','DF','FD','f','f*','B','B*','n'];\nfunction safeCircle(doc, x, y, r, style) {\n  if (![x,y,r].every(Number.isFinite)) throw new Error('x,y,r must be finite');\n  return doc.circle(x, y, r, VALID_STYLES.includes(style) ? style : 'S');\n}","typeGuard":"function isValidStyle(s) { return [undefined,null,'S','D','F','DF','FD','f','f*','B','B*','n'].includes(s); }","tryCatchPattern":null,"preventionTips":["Ensure the radius is a finite number (pass radius, not diameter, unless intended).","Use 'S'/'F'/'DF' for style.","Default missing radius to 0 explicitly."],"tags":["validation","shapes","circle","style","api"],"backgroundTag":null,"analyzedSha":"a3930ce03a585a26b2c76d12a0f413ce96f6d1a3","analyzedAt":"2026-08-13T05:33:39.648Z","schemaVersion":2},"datasetVersion":"2026-08-13T09:17:06.757Z"}