UNPKG

@formant/ava-react

Version:

React components of AVA.

52 lines (50 loc) 1.63 kB
var __defProp = Object.defineProperty; var __getOwnPropDesc = Object.getOwnPropertyDescriptor; var __getOwnPropNames = Object.getOwnPropertyNames; var __hasOwnProp = Object.prototype.hasOwnProperty; var __export = (target, all) => { for (var name in all) __defProp(target, name, { get: all[name], enumerable: true }); }; var __copyProps = (to, from, except, desc) => { if (from && typeof from === "object" || typeof from === "function") { for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable }); } return to; }; var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod); // src/NarrativeTextVis/line-charts/proportion/getArcPath.ts var getArcPath_exports = {}; __export(getArcPath_exports, { getArcPath: () => getArcPath }); module.exports = __toCommonJS(getArcPath_exports); function normalizeProportion(data) { if (typeof data !== "number") return 0; if (data > 1) return 1; if (data < 0) return 0; return data; } function getArcPath(size, data) { const cx = size / 2; const cy = size / 2; const r = size / 2; const angle = normalizeProportion(data) * 2 * Math.PI; const dx = cx + r * Math.sin(angle); const dy = cy - r * Math.cos(angle); const path = ` M${cx} ${0} A ${cx} ${cy} 0 ${angle > Math.PI ? 1 : 0} 1 ${dx} ${dy} L ${cx} ${cy} Z `; return path; } // Annotate the CommonJS export names for ESM import in node: 0 && (module.exports = { getArcPath });