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E;AACD,KArBH,EAsBG,IAtBH,CAsBQ,EAtBR,CADA,IAwBC,aAAW,IAAI,CAAf,SAAoB,MAApB,UAAiC,EAxBlC,CADF;AA0BD","sourcesContent":["import { Point } from '../VSparkline'\nimport { checkCollinear, getDistance, moveTo } from './math'\n\n/**\n * From https://github.com/unsplash/react-trend/blob/master/src/helpers/DOM.helpers.js#L18\n */\nexport function genPath (points: Point[], radius: number, fill = false, height = 75) {\n const start = points.shift()!\n const end = points[points.length - 1]\n\n return (\n (fill ? `M${start.x} ${height} L${start.x} ${start.y}` : `M${start.x} ${start.y}`) +\n points\n .map((point, index) => {\n const next = points[index + 1]\n const prev = points[index - 1] || start\n const isCollinear = next && checkCollinear(next, point, prev)\n\n if (!next || isCollinear) {\n return `L${point.x} ${point.y}`\n }\n\n const threshold = Math.min(\n getDistance(prev, point),\n getDistance(next, point)\n )\n const isTooCloseForRadius = threshold / 2 < radius\n const radiusForPoint = isTooCloseForRadius ? threshold / 2 : radius\n\n const before = moveTo(prev, point, radiusForPoint)\n const after = moveTo(next, point, radiusForPoint)\n\n return `L${before.x} ${before.y}S${point.x} ${point.y} ${after.x} ${after.y}`\n })\n .join('') +\n (fill ? `L${end.x} ${height} Z` : ''))\n}\n"],"sourceRoot":""}
|