react-minimal-pie-chart 8.2.0 → 8.4.0
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 +17 -11
- package/dist/index.js +104 -128
- package/dist/index.js.map +1 -1
- package/es/index.js +97 -116
- package/es/index.js.map +1 -1
- package/lib/index.js +102 -126
- package/lib/index.js.map +1 -1
- package/package.json +39 -36
- package/types/Chart/Chart.d.ts +14 -30
- package/types/Chart/extendData.d.ts +2 -2
- package/types/Chart/index.d.ts +2 -1
- package/types/Chart/renderLabels.d.ts +2 -2
- package/types/Chart/renderSegments.d.ts +2 -2
- package/types/Label.d.ts +8 -7
- package/types/commonTypes.d.ts +7 -8
- package/types/index.d.ts +2 -1
- package/types/utils.d.ts +1 -0
- package/CHANGELOG.md +0 -254
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\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\nexport function makePropsWithDefaults<Result extends Object>(\n props: Partial<Result>,\n defaultProps: Result\n): Result {\n const result: Result = Object.assign({}, defaultProps, props);\n\n // @NOTE Object.assign doesn't default properties with undefined value (like React defaultProps does)\n for (const key in defaultProps) {\n if (props[key] === undefined) {\n result[key] = defaultProps[key];\n }\n }\n\n return result;\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<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<\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';\nimport { makePropsWithDefaults } from '../utils';\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<\n DataEntry extends BaseDataEntry\n> = Props<DataEntry> & typeof defaultProps;\n\nexport function ReactMinimalPieChart<DataEntry extends BaseDataEntry>(\n originalProps: Props<DataEntry>\n) {\n const props = makePropsWithDefaults<PropsWithDefaults<DataEntry>>(\n originalProps,\n // @ts-expect-error: defaultProps.data is typed as BaseDataEntry\n defaultProps\n );\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","makePropsWithDefaults","props","defaultProps","result","Object","assign","key","undefined","sumValues","data","sum","i","length","extendData","totalAngle","totalValue","paddingAngle","chartStartAngle","total","normalizedTotalAngle","numberOfPaddings","abs","singlePaddingDegrees","sign","degreesTakenByPadding","degreesTakenByPaths","lastSegmentEnd","extendedData","dataEntry","valueInPercentage","push","ReactMinimalPieChartLabel","renderLabel","labelProps","label","dataIndex","React","isValidElement","round","number","divisor","Number","EPSILON","evaluateTextAnchorPosition","labelPosition","lineWidth","labelHorizontalShift","innerRadius","makeLabelRenderProps","map","index","segmentsShift","distanceFromCenter","radius","labelRenderProps","x","center","y","textAnchor","style","labelStyle","renderLabels","Label","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","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","viewBoxSize","ReactMinimalPieChart","originalProps","useState","setRevealOverride","useEffect","className","children"],"mappings":";;;;AAAO,SAASA,gBAAgB,CAACC,OAAe,EAAE;AAChD,EAAA,OAAQA,OAAO,GAAGC,IAAI,CAACC,EAAE,GAAI,GAAG,CAAA;AAClC,CAAA;AAEO,SAASC,YAAY,CAACC,KAAa,EAAEC,GAAW,EAAEC,GAAW,EAAE;AACpE,EAAA,IAAIF,KAAK,GAAGE,GAAG,EAAE,OAAOA,GAAG,CAAA;AAC3B,EAAA,IAAIF,KAAK,GAAGC,GAAG,EAAE,OAAOA,GAAG,CAAA;AAC3B,EAAA,OAAOD,KAAK,CAAA;AACd,CAAA;AAEO,SAASG,iBAAiB,CAACH,KAAa,EAAEI,UAAkB,EAAE;AACnE,EAAA,OAAQA,UAAU,GAAG,GAAG,GAAIJ,KAAK,CAAA;AACnC,CAAA;AAEO,SAASK,aAAa,CAACC,UAAkB,EAAEC,WAAmB,EAAE;AACrE,EAAA,OAAOD,UAAU,GAAGC,WAAW,GAAG,CAAC,CAAA;AACrC,CAAA;AAEO,SAASC,qBAAqB,CAACC,KAAa,EAAEC,QAAgB,EAAE;AACrE,EAAA,IAAMC,YAAY,GAAGhB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CAAC+F,OAAO,GAAG,CAAC,GAAG,IAAI,CACzB;IAFMK,cAAc,GAAA,SAAA,CAAA,CAAA,CAAA;IAAEoB,iBAAiB,GAAA,SAAA,CAAA,CAAA,CAAA,CAAA;AAIxCC,EAAAA,eAAS,CAAC,YAAM;IACd,IAAIzH,KAAK,CAAC+F,OAAO,EAAE;AACjB;MACAyB,iBAAiB,CAAC,IAAI,CAAC,CAAA;AACzB,KAAA;GACD,EAAE,EAAE,CAAC,CAAA;AAEN,EAAA,IAAM9F,YAAY,GAAGd,UAAU,CAACZ,KAAK,CAAC,CAAA;EACtC,oBACE,KAAA,CAAA,aAAA,CAAA,KAAA,EAAA;AACE,IAAA,OAAO,EAASA,MAAAA,GAAAA,KAAK,CAACoH,WAAW,CAAC,CAAC,CAAC,GAAA,GAAA,GAAIpH,KAAK,CAACoH,WAAW,CAAC,CAAC,CAAI;AAC/D,IAAA,KAAK,EAAC,MAAM;AACZ,IAAA,MAAM,EAAC,MAAM;IACb,SAAS,EAAEpH,KAAK,CAAC0H,SAAU;IAC3B,KAAK,EAAE1H,KAAK,CAAC0D,KAAAA;AAAM,GAAA,EAElByC,cAAc,CAACzE,YAAY,EAAE1B,KAAK,EAAEoG,cAAc,CAAC,EACnDxC,YAAY,CAAClC,YAAY,EAAE1B,KAAK,CAAC,EACjCA,KAAK,CAAC2H,QAAQ,CACX,CAAA;AAEV;;;;;"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-minimal-pie-chart",
|
|
3
|
-
"version": "8.
|
|
3
|
+
"version": "8.4.0",
|
|
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,7 +15,7 @@
|
|
|
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",
|
|
@@ -26,7 +26,7 @@
|
|
|
26
26
|
"test:update": "npm run compile:source && npm run test:bundles:snapshot -- -u && git add ./jest/__tests__/__snapshots__",
|
|
27
27
|
"clean": "rm -rf lib es dist types",
|
|
28
28
|
"compile": "npm run clean && npm run compile:types && npm run compile:source",
|
|
29
|
-
"compile:source": "rollup -c",
|
|
29
|
+
"compile:source": "rollup -c --bundleConfigAsCjs",
|
|
30
30
|
"compile:types": "tsc -p tsconfig.build.json",
|
|
31
31
|
"contrib:add": "all-contributors add",
|
|
32
32
|
"contrib:generate": "all-contributors generate",
|
|
@@ -34,7 +34,7 @@
|
|
|
34
34
|
"preversion": "npm run prepare",
|
|
35
35
|
"version": "git add package.json",
|
|
36
36
|
"postversion": "git push && git push --tags",
|
|
37
|
-
"prepare": "npm run test:source && npm run compile && npm run test:bundles",
|
|
37
|
+
"prepare": "npx simple-git-hooks && npm run test:source && npm run compile && npm run test:bundles",
|
|
38
38
|
"start": "start-storybook -p 9001 -c .storybook",
|
|
39
39
|
"storybook:deploy": "storybook-to-ghpages",
|
|
40
40
|
"storybook:build": "build-storybook"
|
|
@@ -54,48 +54,53 @@
|
|
|
54
54
|
"author": "Andrea Carraro <me@andreacarraro.it>",
|
|
55
55
|
"license": "MIT",
|
|
56
56
|
"peerDependencies": {
|
|
57
|
-
"react": "^16.8.0 || ^17.0.0",
|
|
58
|
-
"react-dom": "^16.8.0 || ^17.0.0"
|
|
57
|
+
"react": "^16.8.0 || ^17.0.0 || ^18",
|
|
58
|
+
"react-dom": "^16.8.0 || ^17.0.0 || ^18"
|
|
59
|
+
},
|
|
60
|
+
"dependencies": {
|
|
61
|
+
"@types/svg-path-parser": "^1.1.3"
|
|
59
62
|
},
|
|
60
|
-
"dependencies": {},
|
|
61
63
|
"devDependencies": {
|
|
62
64
|
"@babel/core": "^7.12.10",
|
|
63
65
|
"@babel/plugin-transform-react-jsx": "^7.12.12",
|
|
64
66
|
"@babel/preset-env": "^7.12.11",
|
|
65
67
|
"@babel/preset-typescript": "^7.12.7",
|
|
66
|
-
"@rollup/plugin-babel": "^
|
|
67
|
-
"@rollup/plugin-commonjs": "^
|
|
68
|
-
"@rollup/plugin-node-resolve": "^
|
|
68
|
+
"@rollup/plugin-babel": "^6.0.2",
|
|
69
|
+
"@rollup/plugin-commonjs": "^23.0.2",
|
|
70
|
+
"@rollup/plugin-node-resolve": "^15.0.1",
|
|
69
71
|
"@schwingbat/relative-angle": "^1.0.0",
|
|
70
|
-
"@size-limit/preset-small-lib": "^
|
|
71
|
-
"@storybook/addon-actions": "^6.
|
|
72
|
-
"@storybook/react": "^6.
|
|
73
|
-
"@storybook/storybook-deployer": "^2.8.
|
|
74
|
-
"@testing-library/jest-dom": "^5.
|
|
75
|
-
"@testing-library/react": "^
|
|
76
|
-
"@types/react": "^
|
|
72
|
+
"@size-limit/preset-small-lib": "^5.0.5",
|
|
73
|
+
"@storybook/addon-actions": "^6.5.13",
|
|
74
|
+
"@storybook/react": "^6.5.13",
|
|
75
|
+
"@storybook/storybook-deployer": "^2.8.16",
|
|
76
|
+
"@testing-library/jest-dom": "^5.16.5",
|
|
77
|
+
"@testing-library/react": "^13.4.0",
|
|
78
|
+
"@types/react": "^18.0.24",
|
|
79
|
+
"@types/react-dom": "^18.0.8",
|
|
77
80
|
"all-contributors-cli": "^6.19.0",
|
|
78
|
-
"babel-jest": "^
|
|
81
|
+
"babel-jest": "^29.2.2",
|
|
79
82
|
"babel-loader": "^8.2.2",
|
|
80
|
-
"
|
|
81
|
-
"
|
|
82
|
-
"
|
|
83
|
-
"
|
|
84
|
-
"lint-staged": "^10.5.3",
|
|
83
|
+
"es-check": "^6.0.0",
|
|
84
|
+
"jest": "^29.2.2",
|
|
85
|
+
"jest-environment-jsdom": "^29.2.2",
|
|
86
|
+
"lint-staged": "^11.1.2",
|
|
85
87
|
"prettier": "^2.2.1",
|
|
86
|
-
"
|
|
87
|
-
"react": "^
|
|
88
|
-
"react-
|
|
89
|
-
"
|
|
90
|
-
"
|
|
91
|
-
"size-limit": "^
|
|
88
|
+
"react": "^18.2.0",
|
|
89
|
+
"react-dom": "^18.2.0",
|
|
90
|
+
"react-tooltip": "^4.4.3",
|
|
91
|
+
"rollup": "^3.2.3",
|
|
92
|
+
"simple-git-hooks": "^2.4.1",
|
|
93
|
+
"size-limit": "^5.0.5",
|
|
92
94
|
"svg-partial-circle": "1.0.0",
|
|
93
95
|
"svg-path-parser": "^1.1.0",
|
|
94
|
-
"typescript": "^4.
|
|
96
|
+
"typescript": "^4.8.4"
|
|
95
97
|
},
|
|
96
98
|
"jest": {
|
|
97
99
|
"testRegex": "/__tests__/.*\\.test\\.[jt]sx?$",
|
|
98
|
-
"
|
|
100
|
+
"testEnvironmentOptions": {
|
|
101
|
+
"url": "http://localhost/"
|
|
102
|
+
},
|
|
103
|
+
"testEnvironment": "jsdom",
|
|
99
104
|
"coverageReporters": [
|
|
100
105
|
"text",
|
|
101
106
|
"lcov"
|
|
@@ -105,7 +110,7 @@
|
|
|
105
110
|
"!**/__tests__/**"
|
|
106
111
|
],
|
|
107
112
|
"setupFilesAfterEnv": [
|
|
108
|
-
"<rootDir>/jest.setup.
|
|
113
|
+
"<rootDir>/jest.setup.ts"
|
|
109
114
|
]
|
|
110
115
|
},
|
|
111
116
|
"size-limit": [
|
|
@@ -117,10 +122,8 @@
|
|
|
117
122
|
]
|
|
118
123
|
}
|
|
119
124
|
],
|
|
120
|
-
"
|
|
121
|
-
"
|
|
122
|
-
"pre-commit": "npm run test:source && lint-staged"
|
|
123
|
-
}
|
|
125
|
+
"simple-git-hooks": {
|
|
126
|
+
"pre-commit": "npm run test:source && npx lint-staged"
|
|
124
127
|
},
|
|
125
128
|
"lint-staged": {
|
|
126
129
|
"*.{js,ts,tsx}": [
|
package/types/Chart/Chart.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { CSSProperties, FocusEvent, KeyboardEvent, MouseEvent, ReactNode } from 'react';
|
|
2
|
-
import type { Data,
|
|
3
|
-
declare type Props = {
|
|
2
|
+
import type { Data, BaseDataEntry, LabelRenderFunction } from '../commonTypes';
|
|
3
|
+
export declare type Props<DataEntry extends BaseDataEntry = BaseDataEntry> = {
|
|
4
4
|
animate?: boolean;
|
|
5
5
|
animationDuration?: number;
|
|
6
6
|
animationEasing?: string;
|
|
@@ -8,18 +8,18 @@ declare type Props = {
|
|
|
8
8
|
center?: [number, number];
|
|
9
9
|
children?: ReactNode;
|
|
10
10
|
className?: string;
|
|
11
|
-
data: Data
|
|
11
|
+
data: Data<DataEntry>;
|
|
12
12
|
lengthAngle?: number;
|
|
13
13
|
lineWidth?: number;
|
|
14
|
-
label?: LabelRenderFunction
|
|
14
|
+
label?: LabelRenderFunction<DataEntry>;
|
|
15
15
|
labelPosition?: number;
|
|
16
16
|
labelStyle?: CSSProperties | ((dataIndex: number) => CSSProperties | undefined);
|
|
17
|
-
onBlur?:
|
|
18
|
-
onClick?:
|
|
19
|
-
onFocus?:
|
|
20
|
-
onKeyDown?:
|
|
21
|
-
onMouseOut?:
|
|
22
|
-
onMouseOver?:
|
|
17
|
+
onBlur?: (event: FocusEvent, dataIndex: number) => void;
|
|
18
|
+
onClick?: (event: MouseEvent, dataIndex: number) => void;
|
|
19
|
+
onFocus?: (event: FocusEvent, dataIndex: number) => void;
|
|
20
|
+
onKeyDown?: (event: KeyboardEvent, dataIndex: number) => void;
|
|
21
|
+
onMouseOut?: (event: MouseEvent, dataIndex: number) => void;
|
|
22
|
+
onMouseOver?: (event: MouseEvent, dataIndex: number) => void;
|
|
23
23
|
paddingAngle?: number;
|
|
24
24
|
radius?: number;
|
|
25
25
|
reveal?: number;
|
|
@@ -32,11 +32,11 @@ declare type Props = {
|
|
|
32
32
|
totalValue?: number;
|
|
33
33
|
viewBoxSize?: [number, number];
|
|
34
34
|
};
|
|
35
|
-
declare const defaultProps: {
|
|
35
|
+
export declare const defaultProps: {
|
|
36
36
|
animationDuration: number;
|
|
37
37
|
animationEasing: string;
|
|
38
38
|
center: [number, number];
|
|
39
|
-
data: Data
|
|
39
|
+
data: Data<BaseDataEntry>;
|
|
40
40
|
labelPosition: number;
|
|
41
41
|
lengthAngle: number;
|
|
42
42
|
lineWidth: number;
|
|
@@ -45,21 +45,5 @@ declare const defaultProps: {
|
|
|
45
45
|
startAngle: number;
|
|
46
46
|
viewBoxSize: [number, number];
|
|
47
47
|
};
|
|
48
|
-
export declare type PropsWithDefaults = Props & typeof defaultProps;
|
|
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 {};
|
|
48
|
+
export declare type PropsWithDefaults<DataEntry extends BaseDataEntry> = Props<DataEntry> & typeof defaultProps;
|
|
49
|
+
export declare function ReactMinimalPieChart<DataEntry extends BaseDataEntry>(originalProps: Props<DataEntry>): 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
|
/// <reference types="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>): JSX.Element[] | undefined;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
import type { ExtendedData } from '../commonTypes';
|
|
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): JSX.Element[];
|
package/types/Label.d.ts
CHANGED
|
@@ -1,15 +1,16 @@
|
|
|
1
|
-
import type { CSSProperties
|
|
2
|
-
import type {
|
|
3
|
-
export declare type LabelRenderProps = {
|
|
1
|
+
import type { CSSProperties } from 'react';
|
|
2
|
+
import type { ExtendedData, BaseDataEntry, LabelRenderFunction } from './commonTypes';
|
|
3
|
+
export declare type LabelRenderProps<DataEntry extends BaseDataEntry> = {
|
|
4
4
|
x: number;
|
|
5
5
|
y: number;
|
|
6
6
|
dx: number;
|
|
7
7
|
dy: number;
|
|
8
8
|
textAnchor: string;
|
|
9
|
-
dataEntry:
|
|
9
|
+
dataEntry: ExtendedData<DataEntry>[number];
|
|
10
10
|
dataIndex: number;
|
|
11
11
|
style?: CSSProperties;
|
|
12
12
|
};
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
13
|
+
export default function ReactMinimalPieChartLabel<DataEntry extends BaseDataEntry>({ renderLabel, labelProps, }: {
|
|
14
|
+
renderLabel: LabelRenderFunction<DataEntry>;
|
|
15
|
+
labelProps: LabelRenderProps<DataEntry>;
|
|
16
|
+
}): JSX.Element | null;
|
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 declare type
|
|
4
|
-
export declare type
|
|
5
|
-
export declare type DataEntry = {
|
|
3
|
+
export declare type LabelRenderFunction<DataEntry extends BaseDataEntry> = (labelRenderProps: LabelRenderProps<DataEntry>) => ReactNode;
|
|
4
|
+
export declare 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
|
+
declare type BaseExtendedDataEntry<DataEntry extends BaseDataEntry = BaseDataEntry> = DataEntry & {
|
|
13
11
|
degrees: number;
|
|
14
12
|
startAngle: number;
|
|
15
13
|
percentage: number;
|
|
16
14
|
};
|
|
17
|
-
export declare type Data = DataEntry[];
|
|
18
|
-
export declare type ExtendedData =
|
|
15
|
+
export declare type Data<DataEntry extends BaseDataEntry = BaseDataEntry> = DataEntry[];
|
|
16
|
+
export declare 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
|
@@ -8,3 +8,4 @@ export declare function shiftVectorAlongAngle(angle: number, distance: number):
|
|
|
8
8
|
};
|
|
9
9
|
export declare function isNumber(value: unknown): value is number;
|
|
10
10
|
export declare function functionProp<Prop, Payload>(prop: Prop, payload?: Payload): Prop extends (...args: any) => any ? ReturnType<Prop> : Prop;
|
|
11
|
+
export declare function makePropsWithDefaults<Result extends Object>(props: Partial<Result>, defaultProps: Result): Result;
|