diff --git a/src/components/chart-elements/DonutChart/DonutChart.tsx b/src/components/chart-elements/DonutChart/DonutChart.tsx index a3e0de11..3c15b43e 100644 --- a/src/components/chart-elements/DonutChart/DonutChart.tsx +++ b/src/components/chart-elements/DonutChart/DonutChart.tsx @@ -18,6 +18,7 @@ import { parseData, parseLabelInput } from "./inputParser"; import type { EventProps } from "components/chart-elements/common"; import { CustomTooltipProps } from "components/chart-elements/common/CustomTooltipProps"; import type BaseAnimationTimingProps from "../common/BaseAnimationTimingProps"; +import { PieLabel } from "recharts/types/polar/Pie"; type DonutChartVariant = "donut" | "pie"; @@ -36,6 +37,7 @@ export interface DonutChartProps extends BaseAnimationTimingProps { className?: string; onValueChange?: (value: EventProps) => void; customTooltip?: React.ComponentType; + renderLabel?: PieLabel; } const renderInactiveShape = (props: any) => { @@ -89,6 +91,7 @@ const DonutChart = React.forwardRef((props, ref noDataText, onValueChange, customTooltip, + renderLabel, className, ...other } = props; @@ -177,6 +180,7 @@ const DonutChart = React.forwardRef((props, ref activeIndex={activeIndex} inactiveShape={renderInactiveShape} style={{ outline: "none" }} + label={renderLabel} /> {/* {showTooltip ? ( { + const radius = innerRadius + 10 + (outerRadius - innerRadius) * 0.6; + const x = cx + radius * Math.cos(-midAngle * RADIAN); + const y = cy + radius * Math.sin(-midAngle * RADIAN); + + return ( + cx ? "start" : "end"} + dominantBaseline="auto" + > + {`${(percent * 100).toFixed(0)}%`} + + ); +}; + +export const DataLabelsFunction: Story = { + args: { + renderLabel: renderCustomizedLabel, + variant: "pie", + }, +};