react-minimal-pie-chart 8.3.0 → 8.4.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +19 -19
- package/dist/index.js +151 -152
- package/dist/index.js.map +1 -1
- package/es/index.js +145 -141
- package/es/index.js.map +1 -1
- package/lib/index.js +149 -150
- package/lib/index.js.map +1 -1
- package/package.json +52 -57
- package/types/Chart/Chart.d.ts +14 -29
- package/types/Chart/extendData.d.ts +2 -2
- package/types/Chart/index.d.ts +2 -1
- package/types/Chart/renderLabels.d.ts +3 -3
- package/types/Chart/renderSegments.d.ts +3 -3
- package/types/Label.d.ts +9 -7
- package/types/Path.d.ts +3 -2
- package/types/commonTypes.d.ts +7 -8
- package/types/index.d.ts +2 -1
- package/types/utils.d.ts +4 -1
package/lib/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../src/utils.ts","../src/Chart/extendData.ts","../src/Label.tsx","../src/Chart/renderLabels.tsx","../node_modules/svg-partial-circle/index.js","../src/Path.tsx","../src/Chart/renderSegments.tsx","../src/Chart/Chart.tsx"],"sourcesContent":["export function degreesToRadians(degrees: number) {\n return (degrees * Math.PI) / 180;\n}\n\nexport function valueBetween(value: number, min: number, max: number) {\n if (value > max) return max;\n if (value < min) return min;\n return value;\n}\n\nexport function extractPercentage(value: number, percentage: number) {\n return (percentage / 100) * value;\n}\n\nexport function bisectorAngle(startAngle: number, lengthAngle: number) {\n return startAngle + lengthAngle / 2;\n}\n\nexport function shiftVectorAlongAngle(angle: number, distance: number) {\n const angleRadians = degreesToRadians(angle);\n return {\n dx: distance * Math.cos(angleRadians),\n dy: distance * Math.sin(angleRadians),\n };\n}\n\nexport function isNumber(value: unknown): value is number {\n return typeof value === 'number';\n}\n\nexport function functionProp<Prop, Payload>(\n prop: Prop,\n payload?: Payload\n): Prop extends (...args: any) => any ? ReturnType<Prop> : Prop {\n return typeof prop === 'function' ? prop(payload) : prop;\n}\n","import { extractPercentage, valueBetween } from '../utils';\nimport type { Data, ExtendedData } from '../commonTypes';\nimport type { PropsWithDefaults as ChartProps } from './Chart';\n\nfunction sumValues(data: Data): number {\n let sum = 0;\n for (let i = 0; i < data.length; i++) {\n sum += data[i].value;\n }\n return sum;\n}\n\n// Append \"percentage\", \"degrees\" and \"startAngle\" to each data entry\nexport default function extendData({\n data,\n lengthAngle: totalAngle,\n totalValue,\n paddingAngle,\n startAngle: chartStartAngle,\n}: ChartProps): ExtendedData {\n const total = totalValue || sumValues(data);\n const normalizedTotalAngle = valueBetween(totalAngle, -360, 360);\n const numberOfPaddings =\n Math.abs(normalizedTotalAngle) === 360 ? data.length : data.length - 1;\n const singlePaddingDegrees = Math.abs(paddingAngle) * Math.sign(totalAngle);\n const degreesTakenByPadding = singlePaddingDegrees * numberOfPaddings;\n const degreesTakenByPaths = normalizedTotalAngle - degreesTakenByPadding;\n let lastSegmentEnd = 0;\n const extendedData = [];\n\n // @NOTE: Shall we evaluate percentage accordingly to dataEntry.value's sign?\n for (let i = 0; i < data.length; i++) {\n const dataEntry = data[i];\n const valueInPercentage = total === 0 ? 0 : (dataEntry.value / total) * 100;\n const degrees = extractPercentage(degreesTakenByPaths, valueInPercentage);\n const startAngle = lastSegmentEnd + chartStartAngle;\n lastSegmentEnd = lastSegmentEnd + degrees + singlePaddingDegrees;\n extendedData.push(\n Object.assign(\n {\n percentage: valueInPercentage,\n startAngle,\n degrees,\n },\n dataEntry\n )\n );\n }\n return extendedData;\n}\n","import React from 'react';\nimport type { CSSProperties, SVGProps } from 'react';\nimport type { ExtendedDataEntry } from './commonTypes';\n\nexport type LabelRenderProps = {\n x: number;\n y: number;\n dx: number;\n dy: number;\n textAnchor: string;\n dataEntry: ExtendedDataEntry;\n dataIndex: number;\n style?: CSSProperties;\n};\n\ntype Props = SVGProps<SVGTextElement> & LabelRenderProps;\n\nexport default function ReactMinimalPieChartLabel({\n dataEntry,\n dataIndex,\n ...props\n}: Props) {\n return <text dominantBaseline=\"central\" {...props} />;\n}\n","import React from 'react';\nimport DefaultLabel from '../Label';\nimport {\n bisectorAngle,\n extractPercentage,\n functionProp,\n shiftVectorAlongAngle,\n} from '../utils';\nimport type { PropsWithDefaults as ChartProps } from './Chart';\nimport type { LabelRenderProps } from '../Label';\nimport type { ExtendedData, LabelRenderFunction } from '../commonTypes';\n\nfunction round(number: number): number {\n const divisor = 1e14; // 14 decimals\n return Math.round((number + Number.EPSILON) * divisor) / divisor;\n}\n\nfunction evaluateTextAnchorPosition({\n labelPosition,\n lineWidth,\n labelHorizontalShift,\n}: {\n labelPosition: number;\n lineWidth: number;\n labelHorizontalShift: number;\n}) {\n const dx = round(labelHorizontalShift);\n // Label in the vertical center\n if (dx === 0) {\n return 'middle';\n }\n // Outward label\n if (labelPosition > 100) {\n return dx > 0 ? 'start' : 'end';\n }\n // Inward label\n const innerRadius = 100 - lineWidth;\n if (labelPosition < innerRadius) {\n return dx > 0 ? 'end' : 'start';\n }\n // Overlying label\n return 'middle';\n}\n\nfunction renderLabelElement(\n renderLabel: LabelRenderFunction,\n labelProps: LabelRenderProps\n): JSX.Element | null {\n const label = renderLabel(labelProps);\n if (typeof label === 'string' || typeof label === 'number') {\n return (\n <DefaultLabel\n key={`label-${labelProps.dataEntry.key || labelProps.dataIndex}`}\n {...labelProps}\n >\n {label}\n </DefaultLabel>\n );\n }\n\n if (React.isValidElement(label)) {\n return label;\n }\n return null;\n}\n\nexport default function renderLabels(data: ExtendedData, props: ChartProps) {\n return data.map((dataEntry, index) => {\n const segmentsShift = functionProp(props.segmentsShift, index) ?? 0;\n const distanceFromCenter =\n extractPercentage(props.radius, props.labelPosition) + segmentsShift;\n const { dx, dy } = shiftVectorAlongAngle(\n bisectorAngle(dataEntry.startAngle, dataEntry.degrees),\n distanceFromCenter\n );\n\n // This object is passed as argument to the \"label\" function prop\n const labelRenderProps = {\n x: props.center[0],\n y: props.center[1],\n dx,\n dy,\n textAnchor: evaluateTextAnchorPosition({\n labelPosition: props.labelPosition,\n lineWidth: props.lineWidth,\n labelHorizontalShift: dx,\n }),\n dataEntry,\n dataIndex: index,\n style: functionProp(props.labelStyle, index),\n };\n\n return props.label && renderLabelElement(props.label, labelRenderProps);\n });\n}\n","'use strict'\n\n// from http://stackoverflow.com/a/18473154\nconst partialCircle = (cx, cy, r, start, end) => {\n\tconst length = end - start\n\tif (length === 0) return []\n\n\tconst fromX = r * Math.cos(start) + cx\n\tconst fromY = r * Math.sin(start) + cy\n\tconst toX = r * Math.cos(end) + cx\n\tconst toY = r * Math.sin(end) + cy\n\tconst large = Math.abs(length) <= Math.PI ? '0' : '1'\n\tconst sweep = length < 0 ? '0' : '1'\n\n\treturn [\n\t\t['M', fromX, fromY],\n\t\t['A', r, r, 0, large, sweep, toX, toY]\n\t]\n}\n\nmodule.exports = partialCircle\n","import React from 'react';\nimport type { SVGProps } from 'react';\nimport partialCircle from 'svg-partial-circle';\nimport {\n bisectorAngle,\n degreesToRadians,\n extractPercentage,\n isNumber,\n shiftVectorAlongAngle,\n valueBetween,\n} from './utils';\n\nexport function makePathCommands(\n cx: number,\n cy: number,\n startAngle: number,\n lengthAngle: number,\n radius: number\n): string {\n const patchedLengthAngle = valueBetween(lengthAngle, -359.999, 359.999);\n\n return partialCircle(\n cx,\n cy, // center X and Y\n radius,\n degreesToRadians(startAngle),\n degreesToRadians(startAngle + patchedLengthAngle)\n )\n .map((command) => command.join(' '))\n .join(' ');\n}\n\ntype Props = SVGProps<SVGPathElement> & {\n cx: number;\n cy: number;\n lengthAngle: number;\n lineWidth: number;\n radius: number;\n reveal?: number;\n rounded?: boolean;\n shift?: number;\n startAngle: number;\n title?: string | number;\n};\n\nexport default function ReactMinimalPieChartPath({\n cx,\n cy,\n lengthAngle,\n lineWidth,\n radius,\n shift = 0,\n reveal,\n rounded,\n startAngle,\n title,\n ...props\n}: Props) {\n const pathRadius = radius - lineWidth / 2;\n //@NOTE This shift might be rendered as a translation in future\n const { dx, dy } = shiftVectorAlongAngle(\n bisectorAngle(startAngle, lengthAngle),\n shift\n );\n\n const pathCommands = makePathCommands(\n cx + dx,\n cy + dy,\n startAngle,\n lengthAngle,\n pathRadius\n );\n let strokeDasharray;\n let strokeDashoffset;\n\n // Animate/hide paths with \"stroke-dasharray\" + \"stroke-dashoffset\"\n // https://css-tricks.com/svg-line-animation-works/\n if (isNumber(reveal)) {\n const pathLength = degreesToRadians(pathRadius) * lengthAngle;\n strokeDasharray = Math.abs(pathLength);\n strokeDashoffset =\n strokeDasharray - extractPercentage(strokeDasharray, reveal);\n }\n\n return (\n <path\n d={pathCommands}\n fill=\"none\"\n strokeWidth={lineWidth}\n strokeDasharray={strokeDasharray}\n strokeDashoffset={strokeDashoffset}\n strokeLinecap={rounded ? 'round' : undefined}\n {...props}\n >\n {title && <title>{title}</title>}\n </path>\n );\n}\n","import React from 'react';\nimport type { CSSProperties } from 'react';\nimport Path from '../Path';\nimport { extractPercentage, functionProp, isNumber } from '../utils';\nimport type { ExtendedData } from '../commonTypes';\nimport type { PropsWithDefaults as ChartProps } from './Chart';\n\nfunction combineSegmentTransitionsStyle(\n duration: number,\n easing: string,\n customStyle?: CSSProperties\n): { transition: string } {\n // Merge chart's animation CSS transition with \"transition\" found to customStyle\n let transition = `stroke-dashoffset ${duration}ms ${easing}`;\n if (customStyle && customStyle.transition) {\n transition = `${transition},${customStyle.transition}`;\n }\n return {\n transition,\n };\n}\n\nfunction getRevealValue<Reveal>(props: { reveal?: Reveal; animate?: boolean }) {\n //@NOTE When animation is on, chart has to be fully revealed when reveal is not set\n if (props.animate && !isNumber(props.reveal)) {\n return 100;\n }\n return props.reveal;\n}\n\nfunction makeEventHandler<Event, EventHandler, Payload>(\n eventHandler: undefined | (EventHandler & Function),\n payload: Payload\n) {\n return (\n eventHandler &&\n ((e: Event) => {\n eventHandler(e, payload);\n })\n );\n}\n\nexport default function renderSegments(\n data: ExtendedData,\n props: ChartProps,\n revealOverride?: null | number\n) {\n // @NOTE this should go in Path component. Here for performance reasons\n const reveal = revealOverride ?? getRevealValue(props);\n const {\n radius,\n center: [cx, cy],\n } = props;\n const lineWidth = extractPercentage(radius, props.lineWidth);\n const paths = data.map((dataEntry, index) => {\n const segmentsStyle = functionProp(props.segmentsStyle, index);\n return (\n <Path\n cx={cx}\n cy={cy}\n key={dataEntry.key || index}\n lengthAngle={dataEntry.degrees}\n lineWidth={lineWidth}\n radius={radius}\n rounded={props.rounded}\n reveal={reveal}\n shift={functionProp(props.segmentsShift, index)}\n startAngle={dataEntry.startAngle}\n title={dataEntry.title}\n style={Object.assign(\n {},\n segmentsStyle,\n props.animate &&\n combineSegmentTransitionsStyle(\n props.animationDuration,\n props.animationEasing,\n segmentsStyle\n )\n )}\n stroke={dataEntry.color}\n tabIndex={props.segmentsTabIndex}\n onBlur={makeEventHandler(props.onBlur, index)}\n onClick={makeEventHandler(props.onClick, index)}\n onFocus={makeEventHandler(props.onFocus, index)}\n onKeyDown={makeEventHandler(props.onKeyDown, index)}\n onMouseOver={makeEventHandler(props.onMouseOver, index)}\n onMouseOut={makeEventHandler(props.onMouseOut, index)}\n />\n );\n });\n\n if (props.background) {\n paths.unshift(\n <Path\n cx={cx}\n cy={cy}\n key=\"bg\"\n lengthAngle={props.lengthAngle}\n lineWidth={lineWidth}\n radius={radius}\n rounded={props.rounded}\n startAngle={props.startAngle}\n stroke={props.background}\n />\n );\n }\n\n return paths;\n}\n","import React, { useState, useEffect } from 'react';\nimport type {\n CSSProperties,\n FocusEvent,\n KeyboardEvent,\n MouseEvent,\n ReactNode,\n} from 'react';\nimport extendData from './extendData';\nimport renderLabels from './renderLabels';\nimport renderSegments from './renderSegments';\nimport type { Data, EventHandler, LabelRenderFunction } from '../commonTypes';\n\ntype Props = {\n animate?: boolean;\n animationDuration?: number;\n animationEasing?: string;\n background?: string;\n center?: [number, number];\n children?: ReactNode;\n className?: string;\n data: Data;\n lengthAngle?: number;\n lineWidth?: number;\n label?: LabelRenderFunction;\n labelPosition?: number;\n labelStyle?:\n | CSSProperties\n | ((dataIndex: number) => CSSProperties | undefined);\n onBlur?: EventHandler<FocusEvent>;\n onClick?: EventHandler<MouseEvent>;\n onFocus?: EventHandler<FocusEvent>;\n onKeyDown?: EventHandler<KeyboardEvent>;\n onMouseOut?: EventHandler<MouseEvent>;\n onMouseOver?: EventHandler<MouseEvent>;\n paddingAngle?: number;\n radius?: number;\n reveal?: number;\n rounded?: boolean;\n segmentsShift?: number | ((dataIndex: number) => number | undefined);\n segmentsStyle?:\n | CSSProperties\n | ((dataIndex: number) => CSSProperties | undefined);\n segmentsTabIndex?: number;\n startAngle?: number;\n style?: CSSProperties;\n totalValue?: number;\n viewBoxSize?: [number, number];\n};\n\nconst defaultProps = {\n animationDuration: 500,\n animationEasing: 'ease-out',\n center: [50, 50] as [number, number],\n data: [] as Data,\n labelPosition: 50,\n lengthAngle: 360,\n lineWidth: 100,\n paddingAngle: 0,\n radius: 50,\n startAngle: 0,\n viewBoxSize: [100, 100] as [number, number],\n};\n\nexport type PropsWithDefaults = Props & typeof defaultProps;\n\nexport function ReactMinimalPieChart(props: PropsWithDefaults) {\n const [revealOverride, setRevealOverride] = useState(\n props.animate ? 0 : null\n );\n useEffect(() => {\n if (props.animate) {\n return startInitialAnimation();\n }\n\n function startInitialAnimation() {\n let animationTimerId: NodeJS.Timeout | null;\n let animationRAFId: number | null;\n animationTimerId = setTimeout(() => {\n animationTimerId = null;\n animationRAFId = requestAnimationFrame(() => {\n animationRAFId = null;\n setRevealOverride(null); // Start animation\n });\n });\n\n return () => {\n animationTimerId && clearTimeout(animationTimerId);\n animationRAFId && cancelAnimationFrame(animationRAFId);\n };\n }\n }, []);\n\n const extendedData = extendData(props);\n return (\n <svg\n viewBox={`0 0 ${props.viewBoxSize[0]} ${props.viewBoxSize[1]}`}\n width=\"100%\"\n height=\"100%\"\n className={props.className}\n style={props.style}\n >\n {renderSegments(extendedData, props, revealOverride)}\n {props.label && renderLabels(extendedData, props)}\n {props.children}\n </svg>\n );\n}\n\nReactMinimalPieChart.defaultProps = defaultProps;\n"],"names":["degreesToRadians","degrees","Math","PI","valueBetween","value","min","max","extractPercentage","percentage","bisectorAngle","startAngle","lengthAngle","shiftVectorAlongAngle","angle","distance","angleRadians","dx","cos","dy","sin","isNumber","functionProp","prop","payload","sumValues","data","sum","i","length","extendData","totalAngle","totalValue","paddingAngle","chartStartAngle","total","normalizedTotalAngle","numberOfPaddings","abs","singlePaddingDegrees","sign","degreesTakenByPadding","degreesTakenByPaths","lastSegmentEnd","extendedData","dataEntry","valueInPercentage","push","Object","assign","ReactMinimalPieChartLabel","dataIndex","props","React","round","number","divisor","Number","EPSILON","evaluateTextAnchorPosition","labelPosition","lineWidth","labelHorizontalShift","innerRadius","renderLabelElement","renderLabel","labelProps","label","DefaultLabel","key","isValidElement","renderLabels","map","index","segmentsShift","distanceFromCenter","radius","labelRenderProps","x","center","y","textAnchor","style","labelStyle","partialCircle","cx","cy","r","start","end","fromX","fromY","toX","toY","large","sweep","module","makePathCommands","patchedLengthAngle","command","join","ReactMinimalPieChartPath","shift","reveal","rounded","title","pathRadius","pathCommands","strokeDasharray","strokeDashoffset","pathLength","undefined","combineSegmentTransitionsStyle","duration","easing","customStyle","transition","getRevealValue","animate","makeEventHandler","eventHandler","e","renderSegments","revealOverride","paths","segmentsStyle","Path","animationDuration","animationEasing","color","segmentsTabIndex","onBlur","onClick","onFocus","onKeyDown","onMouseOver","onMouseOut","background","unshift","defaultProps","viewBoxSize","ReactMinimalPieChart","useState","setRevealOverride","useEffect","startInitialAnimation","animationTimerId","animationRAFId","setTimeout","requestAnimationFrame","clearTimeout","cancelAnimationFrame","className","children"],"mappings":";;;;;;;;;;AAAO,SAASA,gBAAT,CAA0BC,OAA1B,EAA2C;AAChD,SAAQA,OAAO,GAAGC,IAAI,CAACC,EAAhB,GAAsB,GAA7B;AACD;AAEM,SAASC,YAAT,CAAsBC,KAAtB,EAAqCC,GAArC,EAAkDC,GAAlD,EAA+D;AACpE,MAAIF,KAAK,GAAGE,GAAZ,E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AAhC;AACAC,QAAAA,cAAc,IAAII,oBAAoB,CAACJ,cAAD,CAAtC;AACD,OAHD;AAID;AACF,GArBQ,EAqBN,EArBM,CAAT;AAuBA,MAAMvG,YAAY,GAAGd,UAAU,CAACsB,KAAD,CAA/B;AACA,sBACEC;AACE,IAAA,OAAO,WAASD,KAAK,CAACwF,WAAN,CAAkB,CAAlB,CAAT,SAAiCxF,KAAK,CAACwF,WAAN,CAAkB,CAAlB,CAD1C;AAEE,IAAA,KAAK,EAAC,MAFR;AAGE,IAAA,MAAM,EAAC,MAHT;AAIE,IAAA,SAAS,EAAExF,KAAK,CAACoG,SAJnB;AAKE,IAAA,KAAK,EAAEpG,KAAK,CAAC8B;AALf,KAOGwC,cAAc,CAAC9E,YAAD,EAAeQ,KAAf,EAAsBuE,cAAtB,CAPjB,EAQGvE,KAAK,CAACe,KAAN,IAAeI,YAAY,CAAC3B,YAAD,EAAeQ,KAAf,CAR9B,EASGA,KAAK,CAACqG,QATT,CADF;AAaD;AAEDZ,oBAAoB,CAACF,YAArB,GAAoCA,YAApC;;;;"}
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../src/utils.ts","../src/Chart/extendData.ts","../src/Label.tsx","../src/Chart/renderLabels.tsx","../node_modules/svg-partial-circle/index.js","../src/Path.tsx","../src/Chart/renderSegments.tsx","../src/Chart/Chart.tsx"],"sourcesContent":["export function degreesToRadians(degrees: number) {\n return (degrees * Math.PI) / 180;\n}\n\nexport function valueBetween(value: number, min: number, max: number) {\n if (value > max) return max;\n if (value < min) return min;\n return value;\n}\n\nexport function extractPercentage(value: number, percentage: number) {\n return (percentage / 100) * value;\n}\n\nexport function bisectorAngle(startAngle: number, lengthAngle: number) {\n return startAngle + lengthAngle / 2;\n}\n\nexport function shiftVectorAlongAngle(angle: number, distance: number) {\n const angleRadians = degreesToRadians(angle);\n return {\n dx: distance * Math.cos(angleRadians),\n dy: distance * Math.sin(angleRadians),\n };\n}\n\nexport function isNumber(value: unknown): value is number {\n return typeof value === 'number';\n}\n\n/**\n * Conditionally return a prop or a function prop result\n */\nexport function functionProp<ReturnedProp, Payload>(\n prop: ((args: Payload) => ReturnedProp) | ReturnedProp,\n payload: Payload\n): ReturnedProp {\n return typeof prop === 'function'\n ? // @ts-expect-error: cannot find a way to type 2nd prop arg as anything-but-function\n prop(payload)\n : prop;\n}\n","import { extractPercentage, valueBetween } from '../utils';\nimport type { Data, BaseDataEntry, ExtendedData } from '../commonTypes';\nimport type { PropsWithDefaults as ChartProps } from './Chart';\n\nfunction sumValues<DataEntry extends BaseDataEntry>(\n data: Data<DataEntry>\n): number {\n let sum = 0;\n for (let i = 0; i < data.length; i++) {\n sum += data[i].value;\n }\n return sum;\n}\n\n// Append \"percentage\", \"degrees\" and \"startAngle\" to each data entry\nexport default function extendData<DataEntry extends BaseDataEntry>({\n data,\n lengthAngle: totalAngle,\n totalValue,\n paddingAngle,\n startAngle: chartStartAngle,\n}: ChartProps<DataEntry>): ExtendedData<DataEntry> {\n const total = totalValue || sumValues(data);\n const normalizedTotalAngle = valueBetween(totalAngle, -360, 360);\n const numberOfPaddings =\n Math.abs(normalizedTotalAngle) === 360 ? data.length : data.length - 1;\n const singlePaddingDegrees = Math.abs(paddingAngle) * Math.sign(totalAngle);\n const degreesTakenByPadding = singlePaddingDegrees * numberOfPaddings;\n const degreesTakenByPaths = normalizedTotalAngle - degreesTakenByPadding;\n let lastSegmentEnd = 0;\n const extendedData: ExtendedData<DataEntry> = [];\n\n // @NOTE: Shall we evaluate percentage accordingly to dataEntry.value's sign?\n for (let i = 0; i < data.length; i++) {\n const dataEntry = data[i];\n const valueInPercentage = total === 0 ? 0 : (dataEntry.value / total) * 100;\n const degrees = extractPercentage(degreesTakenByPaths, valueInPercentage);\n const startAngle = lastSegmentEnd + chartStartAngle;\n lastSegmentEnd = lastSegmentEnd + degrees + singlePaddingDegrees;\n extendedData.push(\n Object.assign(\n {\n percentage: valueInPercentage,\n startAngle,\n degrees,\n },\n dataEntry\n )\n );\n }\n return extendedData;\n}\n","import React from 'react';\nimport type { CSSProperties, SVGProps } from 'react';\nimport type {\n ExtendedData,\n BaseDataEntry,\n LabelRenderFunction,\n} from './commonTypes';\n\nexport type LabelRenderProps<DataEntry extends BaseDataEntry> = {\n x: number;\n y: number;\n dx: number;\n dy: number;\n textAnchor: string;\n dataEntry: ExtendedData<DataEntry>[number];\n dataIndex: number;\n style?: CSSProperties;\n};\n\nexport default function ReactMinimalPieChartLabel<\n DataEntry extends BaseDataEntry,\n>({\n renderLabel,\n labelProps,\n}: {\n renderLabel: LabelRenderFunction<DataEntry>;\n labelProps: LabelRenderProps<DataEntry>;\n}) {\n const label = renderLabel(labelProps);\n\n // Default label\n if (typeof label === 'string' || typeof label === 'number') {\n const { dataEntry, dataIndex, ...props } = labelProps;\n return (\n <text dominantBaseline=\"central\" {...props}>\n {label}\n </text>\n );\n }\n\n if (React.isValidElement(label)) {\n return label;\n }\n\n return null;\n}\n","import React from 'react';\nimport Label from '../Label';\nimport {\n bisectorAngle,\n extractPercentage,\n functionProp,\n shiftVectorAlongAngle,\n} from '../utils';\nimport type { PropsWithDefaults as ChartProps } from './Chart';\nimport type { LabelRenderProps } from '../Label';\nimport type { ExtendedData, BaseDataEntry } from '../commonTypes';\n\nfunction round(number: number): number {\n const divisor = 1e14; // 14 decimals\n return Math.round((number + Number.EPSILON) * divisor) / divisor;\n}\n\nfunction evaluateTextAnchorPosition({\n labelPosition,\n lineWidth,\n labelHorizontalShift,\n}: {\n labelPosition: number;\n lineWidth: number;\n labelHorizontalShift: number;\n}) {\n const dx = round(labelHorizontalShift);\n // Label in the vertical center\n if (dx === 0) {\n return 'middle';\n }\n // Outward label\n if (labelPosition > 100) {\n return dx > 0 ? 'start' : 'end';\n }\n // Inward label\n const innerRadius = 100 - lineWidth;\n if (labelPosition < innerRadius) {\n return dx > 0 ? 'end' : 'start';\n }\n // Overlying label\n return 'middle';\n}\n\nfunction makeLabelRenderProps<DataEntry extends BaseDataEntry>(\n data: ExtendedData<DataEntry>,\n props: ChartProps<DataEntry>\n): LabelRenderProps<DataEntry>[] {\n return data.map((dataEntry, index) => {\n const segmentsShift = functionProp(props.segmentsShift, index) ?? 0;\n const distanceFromCenter =\n extractPercentage(props.radius, props.labelPosition) + segmentsShift;\n const { dx, dy } = shiftVectorAlongAngle(\n bisectorAngle(dataEntry.startAngle, dataEntry.degrees),\n distanceFromCenter\n );\n\n // This object is passed as argument to the \"label\" function prop\n const labelRenderProps: LabelRenderProps<DataEntry> = {\n x: props.center[0],\n y: props.center[1],\n dx,\n dy,\n textAnchor: evaluateTextAnchorPosition({\n labelPosition: props.labelPosition,\n lineWidth: props.lineWidth,\n labelHorizontalShift: dx,\n }),\n dataEntry,\n dataIndex: index,\n style: functionProp(props.labelStyle, index),\n };\n\n return labelRenderProps;\n });\n}\n\nexport default function renderLabels<DataEntry extends BaseDataEntry>(\n data: ExtendedData<DataEntry>,\n props: ChartProps<DataEntry>\n) {\n const { label } = props;\n if (label) {\n return makeLabelRenderProps(data, props).map((labelRenderProps, index) => (\n <Label\n key={`label-${labelRenderProps.dataEntry.key || index}`}\n renderLabel={label}\n labelProps={labelRenderProps}\n />\n ));\n }\n}\n","'use strict'\n\n// from http://stackoverflow.com/a/18473154\nconst partialCircle = (cx, cy, r, start, end) => {\n\tconst length = end - start\n\tif (length === 0) return []\n\n\tconst fromX = r * Math.cos(start) + cx\n\tconst fromY = r * Math.sin(start) + cy\n\tconst toX = r * Math.cos(end) + cx\n\tconst toY = r * Math.sin(end) + cy\n\tconst large = Math.abs(length) <= Math.PI ? '0' : '1'\n\tconst sweep = length < 0 ? '0' : '1'\n\n\treturn [\n\t\t['M', fromX, fromY],\n\t\t['A', r, r, 0, large, sweep, toX, toY]\n\t]\n}\n\nmodule.exports = partialCircle\n","import React from 'react';\nimport type { SVGProps } from 'react';\nimport partialCircle from 'svg-partial-circle';\nimport {\n bisectorAngle,\n degreesToRadians,\n extractPercentage,\n isNumber,\n shiftVectorAlongAngle,\n valueBetween,\n} from './utils';\n\nexport function makePathCommands(\n cx: number,\n cy: number,\n startAngle: number,\n lengthAngle: number,\n radius: number\n): string {\n const patchedLengthAngle = valueBetween(lengthAngle, -359.999, 359.999);\n\n return partialCircle(\n cx,\n cy, // center X and Y\n radius,\n degreesToRadians(startAngle),\n degreesToRadians(startAngle + patchedLengthAngle)\n )\n .map((command) => command.join(' '))\n .join(' ');\n}\n\ntype Props = SVGProps<SVGPathElement> & {\n cx: number;\n cy: number;\n lengthAngle: number;\n lineWidth: number;\n radius: number;\n reveal?: number;\n rounded?: boolean;\n shift?: number;\n startAngle: number;\n title?: string | number;\n};\n\nexport default function ReactMinimalPieChartPath({\n cx,\n cy,\n lengthAngle,\n lineWidth,\n radius,\n shift = 0,\n reveal,\n rounded,\n startAngle,\n title,\n ...props\n}: Props) {\n const pathRadius = radius - lineWidth / 2;\n //@NOTE This shift might be rendered as a translation in future\n const { dx, dy } = shiftVectorAlongAngle(\n bisectorAngle(startAngle, lengthAngle),\n shift\n );\n\n const pathCommands = makePathCommands(\n cx + dx,\n cy + dy,\n startAngle,\n lengthAngle,\n pathRadius\n );\n let strokeDasharray;\n let strokeDashoffset;\n\n // Animate/hide paths with \"stroke-dasharray\" + \"stroke-dashoffset\"\n // https://css-tricks.com/svg-line-animation-works/\n if (isNumber(reveal)) {\n const pathLength = degreesToRadians(pathRadius) * lengthAngle;\n strokeDasharray = Math.abs(pathLength);\n strokeDashoffset =\n strokeDasharray - extractPercentage(strokeDasharray, reveal);\n }\n\n return (\n <path\n d={pathCommands}\n fill=\"none\"\n strokeWidth={lineWidth}\n strokeDasharray={strokeDasharray}\n strokeDashoffset={strokeDashoffset}\n strokeLinecap={rounded ? 'round' : undefined}\n {...props}\n >\n {title && <title>{title}</title>}\n </path>\n );\n}\n","import React from 'react';\nimport type { CSSProperties, SyntheticEvent } from 'react';\nimport Path from '../Path';\nimport { extractPercentage, functionProp, isNumber } from '../utils';\nimport type { ExtendedData, BaseDataEntry } from '../commonTypes';\nimport type { PropsWithDefaults as ChartProps } from './Chart';\n\nfunction combineSegmentTransitionsStyle(\n duration: number,\n easing: string,\n customStyle?: CSSProperties\n): { transition: string } {\n // Merge chart's animation CSS transition with \"transition\" found to customStyle\n let transition = `stroke-dashoffset ${duration}ms ${easing}`;\n if (customStyle && customStyle.transition) {\n transition = `${transition},${customStyle.transition}`;\n }\n return {\n transition,\n };\n}\n\nfunction getRevealValue({\n reveal,\n animate,\n}: Pick<ChartProps, 'reveal' | 'animate'>) {\n //@NOTE When animation is on, chart has to be fully revealed when reveal is not set\n if (animate && !isNumber(reveal)) {\n return 100;\n }\n return reveal;\n}\n\nfunction makeEventHandler<\n Event extends SyntheticEvent,\n Payload,\n EventHandler extends (event: Event, payload: Payload) => void,\n>(eventHandler: undefined | EventHandler, payload: Payload) {\n return (\n eventHandler &&\n ((e: Event) => {\n eventHandler(e, payload);\n })\n );\n}\n\nexport default function renderSegments<DataEntry extends BaseDataEntry>(\n data: ExtendedData<DataEntry>,\n props: ChartProps<DataEntry>,\n revealOverride?: null | number\n) {\n // @NOTE this should go in Path component. Here for performance reasons\n const reveal = revealOverride ?? getRevealValue(props);\n const {\n radius,\n center: [cx, cy],\n } = props;\n const lineWidth = extractPercentage(radius, props.lineWidth);\n const paths = data.map((dataEntry, index) => {\n const segmentsStyle = functionProp(props.segmentsStyle, index);\n return (\n <Path\n cx={cx}\n cy={cy}\n key={dataEntry.key || index}\n lengthAngle={dataEntry.degrees}\n lineWidth={lineWidth}\n radius={radius}\n rounded={props.rounded}\n reveal={reveal}\n shift={functionProp(props.segmentsShift, index)}\n startAngle={dataEntry.startAngle}\n title={dataEntry.title}\n style={Object.assign(\n {},\n segmentsStyle,\n props.animate &&\n combineSegmentTransitionsStyle(\n props.animationDuration,\n props.animationEasing,\n segmentsStyle\n )\n )}\n stroke={dataEntry.color}\n tabIndex={props.segmentsTabIndex}\n onBlur={makeEventHandler(props.onBlur, index)}\n onClick={makeEventHandler(props.onClick, index)}\n onFocus={makeEventHandler(props.onFocus, index)}\n onKeyDown={makeEventHandler(props.onKeyDown, index)}\n onMouseOver={makeEventHandler(props.onMouseOver, index)}\n onMouseOut={makeEventHandler(props.onMouseOut, index)}\n />\n );\n });\n\n if (props.background) {\n paths.unshift(\n <Path\n cx={cx}\n cy={cy}\n key=\"bg\"\n lengthAngle={props.lengthAngle}\n lineWidth={lineWidth}\n radius={radius}\n rounded={props.rounded}\n startAngle={props.startAngle}\n stroke={props.background}\n />\n );\n }\n\n return paths;\n}\n","import React, { useState, useEffect } from 'react';\nimport type {\n CSSProperties,\n FocusEvent,\n KeyboardEvent,\n MouseEvent,\n ReactNode,\n} from 'react';\nimport extendData from './extendData';\nimport renderLabels from './renderLabels';\nimport renderSegments from './renderSegments';\nimport type { Data, BaseDataEntry, LabelRenderFunction } from '../commonTypes';\n\nexport type Props<DataEntry extends BaseDataEntry = BaseDataEntry> = {\n animate?: boolean;\n animationDuration?: number;\n animationEasing?: string;\n background?: string;\n center?: [number, number];\n children?: ReactNode;\n className?: string;\n data: Data<DataEntry>;\n lengthAngle?: number;\n lineWidth?: number;\n label?: LabelRenderFunction<DataEntry>;\n labelPosition?: number;\n labelStyle?:\n | CSSProperties\n | ((dataIndex: number) => CSSProperties | undefined);\n onBlur?: (event: FocusEvent, dataIndex: number) => void;\n onClick?: (event: MouseEvent, dataIndex: number) => void;\n onFocus?: (event: FocusEvent, dataIndex: number) => void;\n onKeyDown?: (event: KeyboardEvent, dataIndex: number) => void;\n onMouseOut?: (event: MouseEvent, dataIndex: number) => void;\n onMouseOver?: (event: MouseEvent, dataIndex: number) => void;\n paddingAngle?: number;\n radius?: number;\n reveal?: number;\n rounded?: boolean;\n segmentsShift?: number | ((dataIndex: number) => number | undefined);\n segmentsStyle?:\n | CSSProperties\n | ((dataIndex: number) => CSSProperties | undefined);\n segmentsTabIndex?: number;\n startAngle?: number;\n style?: CSSProperties;\n totalValue?: number;\n viewBoxSize?: [number, number];\n};\n\nexport const defaultProps = {\n animationDuration: 500,\n animationEasing: 'ease-out',\n center: [50, 50] as [number, number],\n data: [] as Data,\n labelPosition: 50,\n lengthAngle: 360,\n lineWidth: 100,\n paddingAngle: 0,\n radius: 50,\n startAngle: 0,\n viewBoxSize: [100, 100] as [number, number],\n};\n\nexport type PropsWithDefaults<DataEntry extends BaseDataEntry = BaseDataEntry> =\n Props<DataEntry> & typeof defaultProps;\n\nfunction makePropsWithDefaults<DataEntry extends BaseDataEntry>(\n props: Props<DataEntry>\n): PropsWithDefaults<DataEntry> {\n const result: PropsWithDefaults<DataEntry> = Object.assign(\n {},\n defaultProps,\n props\n );\n\n // @NOTE Object.assign doesn't default properties with undefined value (like React defaultProps does)\n let key: keyof typeof defaultProps;\n for (key in defaultProps) {\n if (props[key] === undefined) {\n // @ts-expect-error: TS cannot ensure we're assigning the expected props accross abjects\n result[key] = defaultProps[key];\n }\n }\n\n return result;\n}\n\nexport function ReactMinimalPieChart<DataEntry extends BaseDataEntry>(\n originalProps: Props<DataEntry>\n) {\n const props = makePropsWithDefaults(originalProps);\n const [revealOverride, setRevealOverride] = useState(\n props.animate ? 0 : null\n );\n\n useEffect(() => {\n if (props.animate) {\n // Trigger initial animation\n setRevealOverride(null);\n }\n }, []);\n\n const extendedData = extendData(props);\n return (\n <svg\n viewBox={`0 0 ${props.viewBoxSize[0]} ${props.viewBoxSize[1]}`}\n width=\"100%\"\n height=\"100%\"\n className={props.className}\n style={props.style}\n >\n {renderSegments(extendedData, props, revealOverride)}\n {renderLabels(extendedData, props)}\n {props.children}\n </svg>\n );\n}\n"],"names":["degreesToRadians","degrees","Math","PI","valueBetween","value","min","max","extractPercentage","percentage","bisectorAngle","startAngle","lengthAngle","shiftVectorAlongAngle","angle","distance","angleRadians","dx","cos","dy","sin","isNumber","functionProp","prop","payload","sumValues","data","sum","i","length","extendData","_ref","totalAngle","totalValue","paddingAngle","chartStartAngle","total","normalizedTotalAngle","numberOfPaddings","abs","singlePaddingDegrees","sign","degreesTakenByPadding","degreesTakenByPaths","lastSegmentEnd","extendedData","dataEntry","valueInPercentage","push","Object","assign","ReactMinimalPieChartLabel","renderLabel","labelProps","label","dataIndex","props","_objectWithoutPropertiesLoose","_excluded","React","createElement","dominantBaseline","isValidElement","round","number","divisor","Number","EPSILON","evaluateTextAnchorPosition","labelPosition","lineWidth","labelHorizontalShift","innerRadius","makeLabelRenderProps","map","index","_functionProp","segmentsShift","distanceFromCenter","radius","_shiftVectorAlongAngl","labelRenderProps","x","center","y","textAnchor","style","labelStyle","renderLabels","Label","key","partialCircle","cx","cy","r","start","end","fromX","fromY","toX","toY","large","sweep","module","makePathCommands","patchedLengthAngle","command","join","ReactMinimalPieChartPath","_ref$shift","shift","reveal","rounded","title","pathRadius","pathCommands","strokeDasharray","strokeDashoffset","pathLength","d","fill","strokeWidth","strokeLinecap","undefined","combineSegmentTransitionsStyle","duration","easing","customStyle","transition","getRevealValue","animate","makeEventHandler","eventHandler","e","renderSegments","revealOverride","_props$center","paths","segmentsStyle","Path","animationDuration","animationEasing","stroke","color","tabIndex","segmentsTabIndex","onBlur","onClick","onFocus","onKeyDown","onMouseOver","onMouseOut","background","unshift","defaultProps","viewBoxSize","makePropsWithDefaults","result","ReactMinimalPieChart","originalProps","_useState","useState","setRevealOverride","useEffect","viewBox","width","height","className","children"],"mappings":";;;;AAAO,SAASA,gBAAgBA,CAACC,OAAe,EAAE;AAChD,EAAA,OAAQA,OAAO,GAAGC,IAAI,CAACC,EAAE,GAAI,GAAG;AAClC;AAEO,SAASC,YAAYA,CAACC,KAAa,EAAEC,GAAW,EAAEC,GAAW,EAAE;AACpE,EAAA,IAAIF,KAAK,GAAGE,GAAG,EAAE,OAAOA,GAAG;AAC3B,EAAA,IAAIF,KAAK,GAAGC,GAAG,EAAE,OAAOA,GAAG;AAC3B,EAAA,OAAOD,KAAK;AACd;AAEO,SAASG,iBAAiBA,CAACH,KAAa,EAAEI,UAAkB,EAAE;AACnE,EAAA,OAAQA,UAAU,GAAG,GAAG,GAAIJ,KAAK;AACnC;AAEO,SAASK,aA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IAAAA,iBAAiB,GAAAF,SAAA,CAAA,CAAA,CAAA;AAIxCG,EAAAA,eAAS,CAAC,YAAM;IACd,IAAI3G,KAAK,CAAC0E,OAAO,EAAE;AACjB;MACAgC,iBAAiB,CAAC,IAAI,CAAC;AACzB;GACD,EAAE,EAAE,CAAC;AAEN,EAAA,IAAMrH,YAAY,GAAGf,UAAU,CAAC0B,KAAK,CAAC;EACtC,oBACEG,KAAA,CAAAC,aAAA,CAAA,KAAA,EAAA;AACEwG,IAAAA,OAAO,EAAS5G,MAAAA,GAAAA,KAAK,CAACmG,WAAW,CAAC,CAAC,CAAC,GAAA,GAAA,GAAInG,KAAK,CAACmG,WAAW,CAAC,CAAC,CAAI;AAC/DU,IAAAA,KAAK,EAAC,MAAM;AACZC,IAAAA,MAAM,EAAC,MAAM;IACbC,SAAS,EAAE/G,KAAK,CAAC+G,SAAU;IAC3BjF,KAAK,EAAE9B,KAAK,CAAC8B;AAAM,GAAA,EAElBgD,cAAc,CAACzF,YAAY,EAAEW,KAAK,EAAE+E,cAAc,CAAC,EACnD/C,YAAY,CAAC3C,YAAY,EAAEW,KAAK,CAAC,EACjCA,KAAK,CAACgH,QACJ,CAAC;AAEV;;;;;","x_google_ignoreList":[4]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-minimal-pie-chart",
|
|
3
|
-
"version": "8.
|
|
3
|
+
"version": "8.4.1",
|
|
4
4
|
"description": "Lightweight but versatile SVG pie/donut charts for React",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"module": "es/index.js",
|
|
@@ -15,29 +15,27 @@
|
|
|
15
15
|
],
|
|
16
16
|
"sideEffects": false,
|
|
17
17
|
"scripts": {
|
|
18
|
-
"test": "jest ./src
|
|
18
|
+
"test": "jest ./src",
|
|
19
19
|
"test:bundles": "npm run test:bundles:snapshot && npm run test:bundles:unit && npm run test:bundles:es5 && npm run test:bundles:size",
|
|
20
20
|
"test:bundles:unit": "jest ./src --config ./jest/es.config.js && jest ./src --config ./jest/lib.config.js && jest ./src --config ./jest/dist.config.js",
|
|
21
21
|
"test:bundles:snapshot": "jest ./jest/__tests__/bundles-snapshot.test.js",
|
|
22
22
|
"test:bundles:es5": "es-check es5 './@(lib|dist)/*.js'",
|
|
23
23
|
"test:bundles:size": "size-limit",
|
|
24
24
|
"test:source": "npm run test:ts && npm t -- --coverage",
|
|
25
|
-
"test:ts": "tsc
|
|
26
|
-
"test:update": "npm run
|
|
25
|
+
"test:ts": "tsc --noEmit",
|
|
26
|
+
"test:update": "npm run build:source && npm run test:bundles:snapshot -- -u && git add ./jest/__tests__/__snapshots__",
|
|
27
27
|
"clean": "rm -rf lib es dist types",
|
|
28
|
-
"
|
|
29
|
-
"
|
|
30
|
-
"
|
|
31
|
-
"
|
|
32
|
-
"
|
|
33
|
-
"format": "prettier --write \"**/*.{js,ts,tsx,json,md}\"",
|
|
28
|
+
"build": "npm run clean && npm run build:types && npm run build:source",
|
|
29
|
+
"build:source": "rollup -c --bundleConfigAsCjs",
|
|
30
|
+
"build:types": "tsc -p tsconfig.build.json",
|
|
31
|
+
"format:check": "prettier . --check",
|
|
32
|
+
"format:fix": "npm run format:check -- --write",
|
|
34
33
|
"preversion": "npm run prepare",
|
|
35
34
|
"version": "git add package.json",
|
|
36
35
|
"postversion": "git push && git push --tags",
|
|
37
|
-
"prepare": "npx simple-git-hooks && npm run test:source && npm run
|
|
38
|
-
"start": "
|
|
39
|
-
"storybook:
|
|
40
|
-
"storybook:build": "build-storybook"
|
|
36
|
+
"prepare": "npx simple-git-hooks && npm run test:source && npm run build && npm run test:bundles",
|
|
37
|
+
"start": "storybook dev",
|
|
38
|
+
"storybook:build": "storybook build"
|
|
41
39
|
},
|
|
42
40
|
"keywords": [
|
|
43
41
|
"react",
|
|
@@ -57,44 +55,50 @@
|
|
|
57
55
|
"react": "^16.8.0 || ^17.0.0 || ^18",
|
|
58
56
|
"react-dom": "^16.8.0 || ^17.0.0 || ^18"
|
|
59
57
|
},
|
|
60
|
-
"dependencies": {},
|
|
61
58
|
"devDependencies": {
|
|
62
|
-
"@babel/core": "^7.
|
|
63
|
-
"@babel/plugin-transform-react-jsx": "^7.
|
|
64
|
-
"@babel/preset-env": "^7.
|
|
65
|
-
"@babel/preset-typescript": "^7.
|
|
66
|
-
"@
|
|
67
|
-
"@rollup/plugin-
|
|
68
|
-
"@rollup/plugin-
|
|
59
|
+
"@babel/core": "^7.24.7",
|
|
60
|
+
"@babel/plugin-transform-react-jsx": "^7.24.7",
|
|
61
|
+
"@babel/preset-env": "^7.24.7",
|
|
62
|
+
"@babel/preset-typescript": "^7.24.7",
|
|
63
|
+
"@changesets/cli": "^2.27.9",
|
|
64
|
+
"@rollup/plugin-babel": "^6.0.4",
|
|
65
|
+
"@rollup/plugin-commonjs": "^28.0.0",
|
|
66
|
+
"@rollup/plugin-node-resolve": "^15.2.3",
|
|
69
67
|
"@schwingbat/relative-angle": "^1.0.0",
|
|
70
|
-
"@size-limit/preset-small-lib": "^
|
|
71
|
-
"@storybook/addon-
|
|
72
|
-
"@storybook/react": "^
|
|
73
|
-
"@storybook/
|
|
74
|
-
"@
|
|
75
|
-
"@testing-library/
|
|
76
|
-
"@
|
|
77
|
-
"
|
|
78
|
-
"
|
|
79
|
-
"
|
|
80
|
-
"
|
|
81
|
-
"
|
|
82
|
-
"
|
|
83
|
-
"
|
|
84
|
-
"
|
|
85
|
-
"
|
|
86
|
-
"
|
|
87
|
-
"
|
|
88
|
-
"
|
|
89
|
-
"
|
|
90
|
-
"
|
|
68
|
+
"@size-limit/preset-small-lib": "^11.1.4",
|
|
69
|
+
"@storybook/addon-essentials": "^8.1.6",
|
|
70
|
+
"@storybook/react": "^8.1.6",
|
|
71
|
+
"@storybook/react-vite": "^8.1.6",
|
|
72
|
+
"@storybook/test": "^8.1.6",
|
|
73
|
+
"@testing-library/jest-dom": "^6.4.5",
|
|
74
|
+
"@testing-library/react": "^16.0.0",
|
|
75
|
+
"@tsconfig/node18": "^18.2.4",
|
|
76
|
+
"@types/jest": "^29.5.12",
|
|
77
|
+
"@types/node": "^22.8.6",
|
|
78
|
+
"@types/react": "^18.3.3",
|
|
79
|
+
"@types/react-dom": "^18.3.0",
|
|
80
|
+
"@types/svg-path-parser": "^1.1.6",
|
|
81
|
+
"babel-jest": "^29.7.0",
|
|
82
|
+
"es-check": "^7.2.1",
|
|
83
|
+
"jest": "^29.7.0",
|
|
84
|
+
"jest-environment-jsdom": "^29.7.0",
|
|
85
|
+
"prettier": "^3.2.5",
|
|
86
|
+
"react": "^18.3.1",
|
|
87
|
+
"react-dom": "^18.3.1",
|
|
88
|
+
"react-tooltip": "^4.5.1",
|
|
89
|
+
"rollup": "^4.18.0",
|
|
90
|
+
"simple-git-hooks": "^2.11.1",
|
|
91
|
+
"size-limit": "^11.1.4",
|
|
92
|
+
"storybook": "^8.1.6",
|
|
91
93
|
"svg-partial-circle": "1.0.0",
|
|
92
94
|
"svg-path-parser": "^1.1.0",
|
|
93
|
-
"typescript": "^4.
|
|
95
|
+
"typescript": "^5.4.5"
|
|
94
96
|
},
|
|
95
97
|
"jest": {
|
|
96
98
|
"testRegex": "/__tests__/.*\\.test\\.[jt]sx?$",
|
|
97
|
-
"
|
|
99
|
+
"testEnvironmentOptions": {
|
|
100
|
+
"url": "http://localhost/"
|
|
101
|
+
},
|
|
98
102
|
"testEnvironment": "jsdom",
|
|
99
103
|
"coverageReporters": [
|
|
100
104
|
"text",
|
|
@@ -105,12 +109,12 @@
|
|
|
105
109
|
"!**/__tests__/**"
|
|
106
110
|
],
|
|
107
111
|
"setupFilesAfterEnv": [
|
|
108
|
-
"<rootDir>/jest.setup.
|
|
112
|
+
"<rootDir>/jest.setup.ts"
|
|
109
113
|
]
|
|
110
114
|
},
|
|
111
115
|
"size-limit": [
|
|
112
116
|
{
|
|
113
|
-
"limit": "2 KB",
|
|
117
|
+
"limit": "2.5 KB",
|
|
114
118
|
"path": "./es/index.js",
|
|
115
119
|
"ignore": [
|
|
116
120
|
"react"
|
|
@@ -118,15 +122,6 @@
|
|
|
118
122
|
}
|
|
119
123
|
],
|
|
120
124
|
"simple-git-hooks": {
|
|
121
|
-
"pre-commit": "npm run
|
|
122
|
-
},
|
|
123
|
-
"lint-staged": {
|
|
124
|
-
"*.{js,ts,tsx}": [
|
|
125
|
-
"npm run test:update",
|
|
126
|
-
"prettier --write"
|
|
127
|
-
],
|
|
128
|
-
"*.{json,md}": [
|
|
129
|
-
"prettier --write"
|
|
130
|
-
]
|
|
125
|
+
"pre-commit": "npm run format:check && npm run test:source"
|
|
131
126
|
}
|
|
132
127
|
}
|
package/types/Chart/Chart.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
+
import React from 'react';
|
|
1
2
|
import type { CSSProperties, FocusEvent, KeyboardEvent, MouseEvent, ReactNode } from 'react';
|
|
2
|
-
import type { Data,
|
|
3
|
-
|
|
3
|
+
import type { Data, BaseDataEntry, LabelRenderFunction } from '../commonTypes';
|
|
4
|
+
export type Props<DataEntry extends BaseDataEntry = BaseDataEntry> = {
|
|
4
5
|
animate?: boolean;
|
|
5
6
|
animationDuration?: number;
|
|
6
7
|
animationEasing?: string;
|
|
@@ -8,18 +9,18 @@ declare type Props = {
|
|
|
8
9
|
center?: [number, number];
|
|
9
10
|
children?: ReactNode;
|
|
10
11
|
className?: string;
|
|
11
|
-
data: Data
|
|
12
|
+
data: Data<DataEntry>;
|
|
12
13
|
lengthAngle?: number;
|
|
13
14
|
lineWidth?: number;
|
|
14
|
-
label?: LabelRenderFunction
|
|
15
|
+
label?: LabelRenderFunction<DataEntry>;
|
|
15
16
|
labelPosition?: number;
|
|
16
17
|
labelStyle?: CSSProperties | ((dataIndex: number) => CSSProperties | undefined);
|
|
17
|
-
onBlur?:
|
|
18
|
-
onClick?:
|
|
19
|
-
onFocus?:
|
|
20
|
-
onKeyDown?:
|
|
21
|
-
onMouseOut?:
|
|
22
|
-
onMouseOver?:
|
|
18
|
+
onBlur?: (event: FocusEvent, dataIndex: number) => void;
|
|
19
|
+
onClick?: (event: MouseEvent, dataIndex: number) => void;
|
|
20
|
+
onFocus?: (event: FocusEvent, dataIndex: number) => void;
|
|
21
|
+
onKeyDown?: (event: KeyboardEvent, dataIndex: number) => void;
|
|
22
|
+
onMouseOut?: (event: MouseEvent, dataIndex: number) => void;
|
|
23
|
+
onMouseOver?: (event: MouseEvent, dataIndex: number) => void;
|
|
23
24
|
paddingAngle?: number;
|
|
24
25
|
radius?: number;
|
|
25
26
|
reveal?: number;
|
|
@@ -32,7 +33,7 @@ declare type Props = {
|
|
|
32
33
|
totalValue?: number;
|
|
33
34
|
viewBoxSize?: [number, number];
|
|
34
35
|
};
|
|
35
|
-
declare const defaultProps: {
|
|
36
|
+
export declare const defaultProps: {
|
|
36
37
|
animationDuration: number;
|
|
37
38
|
animationEasing: string;
|
|
38
39
|
center: [number, number];
|
|
@@ -45,21 +46,5 @@ declare const defaultProps: {
|
|
|
45
46
|
startAngle: number;
|
|
46
47
|
viewBoxSize: [number, number];
|
|
47
48
|
};
|
|
48
|
-
export
|
|
49
|
-
export declare function ReactMinimalPieChart(
|
|
50
|
-
export declare namespace ReactMinimalPieChart {
|
|
51
|
-
var defaultProps: {
|
|
52
|
-
animationDuration: number;
|
|
53
|
-
animationEasing: string;
|
|
54
|
-
center: [number, number];
|
|
55
|
-
data: Data;
|
|
56
|
-
labelPosition: number;
|
|
57
|
-
lengthAngle: number;
|
|
58
|
-
lineWidth: number;
|
|
59
|
-
paddingAngle: number;
|
|
60
|
-
radius: number;
|
|
61
|
-
startAngle: number;
|
|
62
|
-
viewBoxSize: [number, number];
|
|
63
|
-
};
|
|
64
|
-
}
|
|
65
|
-
export {};
|
|
49
|
+
export type PropsWithDefaults<DataEntry extends BaseDataEntry = BaseDataEntry> = Props<DataEntry> & typeof defaultProps;
|
|
50
|
+
export declare function ReactMinimalPieChart<DataEntry extends BaseDataEntry>(originalProps: Props<DataEntry>): React.JSX.Element;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import type { ExtendedData } from '../commonTypes';
|
|
1
|
+
import type { BaseDataEntry, ExtendedData } from '../commonTypes';
|
|
2
2
|
import type { PropsWithDefaults as ChartProps } from './Chart';
|
|
3
|
-
export default function extendData({ data, lengthAngle: totalAngle, totalValue, paddingAngle, startAngle: chartStartAngle, }: ChartProps): ExtendedData
|
|
3
|
+
export default function extendData<DataEntry extends BaseDataEntry>({ data, lengthAngle: totalAngle, totalValue, paddingAngle, startAngle: chartStartAngle, }: ChartProps<DataEntry>): ExtendedData<DataEntry>;
|
package/types/Chart/index.d.ts
CHANGED
|
@@ -1 +1,2 @@
|
|
|
1
|
-
export { ReactMinimalPieChart as PieChart } from './Chart';
|
|
1
|
+
export { ReactMinimalPieChart as PieChart, defaultProps as pieChartDefaultProps, } from './Chart';
|
|
2
|
+
export type { Props as PieChartProps } from './Chart';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
import React from 'react';
|
|
2
2
|
import type { PropsWithDefaults as ChartProps } from './Chart';
|
|
3
|
-
import type { ExtendedData } from '../commonTypes';
|
|
4
|
-
export default function renderLabels(data: ExtendedData
|
|
3
|
+
import type { ExtendedData, BaseDataEntry } from '../commonTypes';
|
|
4
|
+
export default function renderLabels<DataEntry extends BaseDataEntry>(data: ExtendedData<DataEntry>, props: ChartProps<DataEntry>): React.JSX.Element[] | undefined;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
import type { ExtendedData } from '../commonTypes';
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import type { ExtendedData, BaseDataEntry } from '../commonTypes';
|
|
3
3
|
import type { PropsWithDefaults as ChartProps } from './Chart';
|
|
4
|
-
export default function renderSegments(data: ExtendedData
|
|
4
|
+
export default function renderSegments<DataEntry extends BaseDataEntry>(data: ExtendedData<DataEntry>, props: ChartProps<DataEntry>, revealOverride?: null | number): React.JSX.Element[];
|
package/types/Label.d.ts
CHANGED
|
@@ -1,15 +1,17 @@
|
|
|
1
|
-
import
|
|
2
|
-
import type {
|
|
3
|
-
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import type { CSSProperties } from 'react';
|
|
3
|
+
import type { ExtendedData, BaseDataEntry, LabelRenderFunction } from './commonTypes';
|
|
4
|
+
export type LabelRenderProps<DataEntry extends BaseDataEntry> = {
|
|
4
5
|
x: number;
|
|
5
6
|
y: number;
|
|
6
7
|
dx: number;
|
|
7
8
|
dy: number;
|
|
8
9
|
textAnchor: string;
|
|
9
|
-
dataEntry:
|
|
10
|
+
dataEntry: ExtendedData<DataEntry>[number];
|
|
10
11
|
dataIndex: number;
|
|
11
12
|
style?: CSSProperties;
|
|
12
13
|
};
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
14
|
+
export default function ReactMinimalPieChartLabel<DataEntry extends BaseDataEntry>({ renderLabel, labelProps, }: {
|
|
15
|
+
renderLabel: LabelRenderFunction<DataEntry>;
|
|
16
|
+
labelProps: LabelRenderProps<DataEntry>;
|
|
17
|
+
}): React.JSX.Element | null;
|
package/types/Path.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
+
import React from 'react';
|
|
1
2
|
import type { SVGProps } from 'react';
|
|
2
3
|
export declare function makePathCommands(cx: number, cy: number, startAngle: number, lengthAngle: number, radius: number): string;
|
|
3
|
-
|
|
4
|
+
type Props = SVGProps<SVGPathElement> & {
|
|
4
5
|
cx: number;
|
|
5
6
|
cy: number;
|
|
6
7
|
lengthAngle: number;
|
|
@@ -12,5 +13,5 @@ declare type Props = SVGProps<SVGPathElement> & {
|
|
|
12
13
|
startAngle: number;
|
|
13
14
|
title?: string | number;
|
|
14
15
|
};
|
|
15
|
-
export default function ReactMinimalPieChartPath({ cx, cy, lengthAngle, lineWidth, radius, shift, reveal, rounded, startAngle, title, ...props }: Props): JSX.Element;
|
|
16
|
+
export default function ReactMinimalPieChartPath({ cx, cy, lengthAngle, lineWidth, radius, shift, reveal, rounded, startAngle, title, ...props }: Props): React.JSX.Element;
|
|
16
17
|
export {};
|
package/types/commonTypes.d.ts
CHANGED
|
@@ -1,18 +1,17 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { ReactNode } from 'react';
|
|
2
2
|
import type { LabelRenderProps } from './Label';
|
|
3
|
-
export
|
|
4
|
-
export
|
|
5
|
-
export declare type DataEntry = {
|
|
3
|
+
export type LabelRenderFunction<DataEntry extends BaseDataEntry> = (labelRenderProps: LabelRenderProps<DataEntry>) => ReactNode;
|
|
4
|
+
export type BaseDataEntry = {
|
|
6
5
|
title?: string | number;
|
|
7
6
|
color: string;
|
|
8
7
|
value: number;
|
|
9
8
|
key?: string | number;
|
|
10
|
-
[key: string]: any;
|
|
11
9
|
};
|
|
12
|
-
|
|
10
|
+
type BaseExtendedDataEntry<DataEntry extends BaseDataEntry = BaseDataEntry> = DataEntry & {
|
|
13
11
|
degrees: number;
|
|
14
12
|
startAngle: number;
|
|
15
13
|
percentage: number;
|
|
16
14
|
};
|
|
17
|
-
export
|
|
18
|
-
export
|
|
15
|
+
export type Data<DataEntry extends BaseDataEntry = BaseDataEntry> = DataEntry[];
|
|
16
|
+
export type ExtendedData<DataEntry extends BaseDataEntry = BaseDataEntry> = BaseExtendedDataEntry<DataEntry>[];
|
|
17
|
+
export {};
|
package/types/index.d.ts
CHANGED
|
@@ -1 +1,2 @@
|
|
|
1
|
-
export { PieChart } from './Chart';
|
|
1
|
+
export { PieChart, pieChartDefaultProps } from './Chart';
|
|
2
|
+
export type { PieChartProps } from './Chart';
|
package/types/utils.d.ts
CHANGED
|
@@ -7,4 +7,7 @@ export declare function shiftVectorAlongAngle(angle: number, distance: number):
|
|
|
7
7
|
dy: number;
|
|
8
8
|
};
|
|
9
9
|
export declare function isNumber(value: unknown): value is number;
|
|
10
|
-
|
|
10
|
+
/**
|
|
11
|
+
* Conditionally return a prop or a function prop result
|
|
12
|
+
*/
|
|
13
|
+
export declare function functionProp<ReturnedProp, Payload>(prop: ((args: Payload) => ReturnedProp) | ReturnedProp, payload: Payload): ReturnedProp;
|