@mantine/charts 9.2.2 → 9.3.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.
Files changed (53) hide show
  1. package/cjs/AreaChart/AreaChart.cjs +0 -1
  2. package/cjs/AreaChart/AreaChart.cjs.map +1 -1
  3. package/cjs/AreaChart/AreaGradient.cjs +0 -1
  4. package/cjs/AreaChart/AreaGradient.cjs.map +1 -1
  5. package/cjs/AreaChart/AreaSplit.cjs +0 -1
  6. package/cjs/AreaChart/AreaSplit.cjs.map +1 -1
  7. package/cjs/BarsList/BarsList.cjs +0 -1
  8. package/cjs/BarsList/BarsList.cjs.map +1 -1
  9. package/cjs/BubbleChart/BubbleChart.cjs +0 -1
  10. package/cjs/BubbleChart/BubbleChart.cjs.map +1 -1
  11. package/cjs/ChartLegend/ChartLegend.cjs +0 -1
  12. package/cjs/ChartLegend/ChartLegend.cjs.map +1 -1
  13. package/cjs/ChartTooltip/ChartTooltip.cjs +0 -1
  14. package/cjs/ChartTooltip/ChartTooltip.cjs.map +1 -1
  15. package/cjs/CompositeChart/CompositeChart.cjs +0 -1
  16. package/cjs/CompositeChart/CompositeChart.cjs.map +1 -1
  17. package/cjs/DonutChart/DonutChart.cjs +4 -4
  18. package/cjs/DonutChart/DonutChart.cjs.map +1 -1
  19. package/cjs/DonutChart/DonutChart.module.cjs.map +1 -1
  20. package/cjs/FunnelChart/FunnelChart.cjs +0 -1
  21. package/cjs/FunnelChart/FunnelChart.cjs.map +1 -1
  22. package/cjs/Heatmap/Heatmap.cjs +0 -1
  23. package/cjs/Heatmap/Heatmap.cjs.map +1 -1
  24. package/cjs/Heatmap/HeatmapSplitWeeks.cjs +0 -1
  25. package/cjs/Heatmap/HeatmapSplitWeeks.cjs.map +1 -1
  26. package/cjs/Heatmap/HeatmapWeeks.cjs +0 -1
  27. package/cjs/Heatmap/HeatmapWeeks.cjs.map +1 -1
  28. package/cjs/LineChart/LineChart.cjs +0 -1
  29. package/cjs/LineChart/LineChart.cjs.map +1 -1
  30. package/cjs/PieChart/PieChart.cjs +6 -6
  31. package/cjs/PieChart/PieChart.cjs.map +1 -1
  32. package/cjs/PieChart/PieChart.module.cjs.map +1 -1
  33. package/cjs/PointLabel/PointLabel.cjs +0 -1
  34. package/cjs/PointLabel/PointLabel.cjs.map +1 -1
  35. package/cjs/RadarChart/RadarChart.cjs +0 -1
  36. package/cjs/RadarChart/RadarChart.cjs.map +1 -1
  37. package/cjs/RadialBarChart/RadialBarChart.cjs +0 -1
  38. package/cjs/RadialBarChart/RadialBarChart.cjs.map +1 -1
  39. package/cjs/ScatterChart/ScatterChart.cjs +0 -1
  40. package/cjs/ScatterChart/ScatterChart.cjs.map +1 -1
  41. package/cjs/Sparkline/Sparkline.cjs +0 -1
  42. package/cjs/Sparkline/Sparkline.cjs.map +1 -1
  43. package/esm/DonutChart/DonutChart.mjs +4 -3
  44. package/esm/DonutChart/DonutChart.mjs.map +1 -1
  45. package/esm/DonutChart/DonutChart.module.mjs.map +1 -1
  46. package/esm/PieChart/PieChart.mjs +6 -5
  47. package/esm/PieChart/PieChart.mjs.map +1 -1
  48. package/esm/PieChart/PieChart.module.mjs.map +1 -1
  49. package/lib/DonutChart/DonutChart.d.ts +1 -1
  50. package/lib/PieChart/PieChart.d.ts +1 -1
  51. package/package.json +3 -3
  52. package/styles.css +8 -0
  53. package/styles.layer.css +8 -0
@@ -1 +1 @@
1
- {"version":3,"file":"ScatterChart.cjs","names":["ReferenceLine","Scatter","LabelList","Box","ResponsiveContainer","ReChartsScatterChart","CartesianGrid","XAxis","Label","YAxis","Tooltip","ChartTooltip","Legend","ChartLegend","classes"],"sources":["../../src/ScatterChart/ScatterChart.tsx"],"sourcesContent":["import { useState } from 'react';\nimport {\n CartesianGrid,\n Label,\n LabelList,\n Legend,\n ScatterChart as ReChartsScatterChart,\n ReferenceLine,\n ResponsiveContainer,\n Scatter,\n ScatterProps,\n Tooltip,\n XAxis,\n YAxis,\n} from 'recharts';\nimport {\n Box,\n BoxProps,\n createVarsResolver,\n ElementProps,\n factory,\n Factory,\n getThemeColor,\n MantineColor,\n StylesApiProps,\n useMantineTheme,\n useProps,\n useResolvedStylesApi,\n useStyles,\n} from '@mantine/core';\nimport { ChartLegend, ChartLegendStylesNames } from '../ChartLegend';\nimport { ChartTooltip, ChartTooltipStylesNames } from '../ChartTooltip';\nimport { BaseChartStylesNames, GridChartBaseProps } from '../types';\nimport classes from '../grid-chart.module.css';\n\nexport interface ScatterChartSeries {\n color: MantineColor;\n name: string;\n data: Record<string, number>[];\n}\n\nexport type ScatterChartStylesNames =\n | 'scatter'\n | BaseChartStylesNames\n | ChartLegendStylesNames\n | ChartTooltipStylesNames;\n\nexport type ScatterChartCssVariables = {\n root: '--chart-text-color' | '--chart-grid-color';\n};\n\nexport interface ScatterChartProps\n extends\n Omit<GridChartBaseProps, 'dataKey' | 'data' | 'unit' | 'valueFormatter'>,\n BoxProps,\n StylesApiProps<ScatterChartFactory>,\n ElementProps<'div'> {\n /** Keys that should be used to retrieve data from the data array on x and y axis */\n dataKey: { x: string; y: string };\n\n /** Data that is used to build the chart */\n data: ScatterChartSeries[];\n\n /** Units displayed after value on axis and inside the tooltip */\n unit?: { x?: string; y?: string };\n\n /** Labels that should be used instead of keys names in the tooltip */\n labels?: { x?: string; y?: string };\n\n /** A function to format values on x/y axis and in the tooltip */\n valueFormatter?:\n | GridChartBaseProps['valueFormatter']\n | { x?: GridChartBaseProps['valueFormatter']; y?: GridChartBaseProps['valueFormatter'] };\n\n /** Props passed down to recharts `ScatterChart` component */\n scatterChartProps?: React.ComponentProps<typeof ReChartsScatterChart>;\n\n /** Props passed down to recharts `Scatter` component */\n scatterProps?: Partial<Omit<ScatterProps, 'ref'>>;\n\n /** If set, displays labels next to points for the given axis */\n pointLabels?: 'x' | 'y';\n}\n\nfunction getAxis(key: string, dataKey: { x: string; y: string }) {\n return key === dataKey.x ? 'x' : 'y';\n}\n\nexport type ScatterChartFactory = Factory<{\n props: ScatterChartProps;\n ref: HTMLDivElement;\n stylesNames: ScatterChartStylesNames;\n vars: ScatterChartCssVariables;\n}>;\n\nconst defaultProps = {\n withXAxis: true,\n withYAxis: true,\n withTooltip: true,\n tooltipAnimationDuration: 0,\n tickLine: 'y',\n strokeDasharray: '5 5',\n gridAxis: 'x',\n} satisfies Partial<ScatterChartProps>;\n\nconst varsResolver = createVarsResolver<ScatterChartFactory>((theme, { textColor, gridColor }) => ({\n root: {\n '--chart-text-color': textColor ? getThemeColor(textColor, theme) : undefined,\n '--chart-grid-color': gridColor ? getThemeColor(gridColor, theme) : undefined,\n },\n}));\n\nexport const ScatterChart = factory<ScatterChartFactory>((_props) => {\n const props = useProps('ScatterChart', defaultProps, _props);\n const {\n classNames,\n className,\n style,\n styles,\n unstyled,\n vars,\n referenceLines,\n dir,\n withLegend,\n withTooltip,\n withXAxis,\n withYAxis,\n xAxisProps,\n yAxisProps,\n orientation,\n scatterChartProps,\n legendProps,\n data,\n gridAxis,\n tickLine,\n strokeDasharray,\n gridProps,\n tooltipAnimationDuration,\n tooltipProps,\n children,\n onMouseLeave,\n dataKey,\n textColor,\n gridColor,\n xAxisLabel,\n yAxisLabel,\n unit,\n labels,\n valueFormatter,\n scatterProps,\n pointLabels,\n attributes,\n ...others\n } = props;\n\n const getFormatter = (axis: 'x' | 'y') =>\n typeof valueFormatter === 'function' ? valueFormatter : valueFormatter?.[axis];\n const xFormatter = getFormatter('x');\n const yFormatter = getFormatter('y');\n\n const theme = useMantineTheme();\n\n const mappedData = data.map((item) => ({\n ...item,\n data: item.data.map((point) => ({ ...point, name: item.name })),\n }));\n\n const { resolvedClassNames, resolvedStyles } = useResolvedStylesApi<ScatterChartFactory>({\n classNames,\n styles,\n props,\n });\n\n const getStyles = useStyles<ScatterChartFactory>({\n name: 'ScatterChart',\n classes,\n props,\n className,\n style,\n classNames,\n styles,\n unstyled,\n attributes,\n vars,\n varsResolver,\n });\n\n const withXTickLine = gridAxis !== 'none' && (tickLine === 'x' || tickLine === 'xy');\n const withYTickLine = gridAxis !== 'none' && (tickLine === 'y' || tickLine === 'xy');\n const [highlightedArea, setHighlightedArea] = useState<string | null>(null);\n const shouldHighlight = highlightedArea !== null;\n const handleMouseLeave = (event: React.MouseEvent<HTMLDivElement>) => {\n setHighlightedArea(null);\n onMouseLeave?.(event);\n };\n\n const referenceLinesItems = referenceLines?.map((line, index) => {\n const color = getThemeColor(line.color, theme);\n return (\n <ReferenceLine\n key={index}\n stroke={line.color ? color : 'var(--chart-grid-color)'}\n strokeWidth={1}\n {...line}\n label={{\n fill: line.color ? color : 'currentColor',\n fontSize: 12,\n position: line.labelPosition ?? 'insideBottomLeft',\n ...(typeof line.label === 'object' ? line.label : { value: line.label }),\n }}\n {...getStyles('referenceLine')}\n />\n );\n });\n\n const scatters = mappedData.map((item, index) => {\n const dimmed = shouldHighlight && highlightedArea !== item.name;\n return (\n <Scatter\n data={item.data}\n fill={getThemeColor(item.color, theme)}\n key={index}\n isAnimationActive={false}\n fillOpacity={dimmed ? 0.1 : 1}\n {...scatterProps}\n >\n {pointLabels && <LabelList dataKey={dataKey[pointLabels]} fontSize={8} dy={10} />}\n {scatterProps?.children}\n </Scatter>\n );\n });\n\n return (\n <Box {...getStyles('root')} onMouseLeave={handleMouseLeave} dir={dir || 'ltr'} {...others}>\n <ResponsiveContainer {...getStyles('container')}>\n <ReChartsScatterChart\n margin={{\n bottom: xAxisLabel ? 30 : undefined,\n left: yAxisLabel ? 10 : undefined,\n right: yAxisLabel ? 5 : undefined,\n }}\n {...scatterChartProps}\n >\n <CartesianGrid\n strokeDasharray={strokeDasharray as string}\n vertical={gridAxis === 'y' || gridAxis === 'xy'}\n horizontal={gridAxis === 'x' || gridAxis === 'xy'}\n {...getStyles('grid')}\n {...gridProps}\n />\n <XAxis\n type=\"number\"\n hide={!withXAxis}\n dataKey={dataKey.x}\n tick={{ transform: 'translate(0, 10)', fontSize: 12, fill: 'currentColor' }}\n stroke=\"\"\n interval=\"preserveStartEnd\"\n tickLine={withXTickLine ? { stroke: 'currentColor' } : false}\n minTickGap={5}\n unit={unit?.x}\n tickFormatter={xFormatter}\n {...getStyles('axis')}\n {...xAxisProps}\n >\n {xAxisLabel && (\n <Label position=\"insideBottom\" offset={-20} fontSize={12} {...getStyles('axisLabel')}>\n {xAxisLabel}\n </Label>\n )}\n {xAxisProps?.children}\n </XAxis>\n <YAxis\n type=\"number\"\n hide={!withYAxis}\n axisLine={false}\n dataKey={dataKey.y}\n tickLine={withYTickLine ? { stroke: 'currentColor' } : false}\n tick={{ transform: 'translate(-10, 0)', fontSize: 12, fill: 'currentColor' }}\n allowDecimals\n unit={unit?.y}\n tickFormatter={yFormatter}\n {...getStyles('axis')}\n {...yAxisProps}\n >\n {yAxisLabel && (\n <Label\n position=\"insideLeft\"\n angle={-90}\n textAnchor=\"middle\"\n fontSize={12}\n offset={-5}\n {...getStyles('axisLabel')}\n >\n {yAxisLabel}\n </Label>\n )}\n {yAxisProps?.children}\n </YAxis>\n\n {withTooltip && (\n <Tooltip\n animationDuration={tooltipAnimationDuration}\n isAnimationActive={tooltipAnimationDuration !== 0}\n position={{ y: 0 }}\n cursor={{\n stroke: 'var(--chart-grid-color)',\n strokeWidth: 1,\n strokeDasharray,\n }}\n content={({ label, payload, labelFormatter }) => (\n <ChartTooltip\n type=\"scatter\"\n label={labelFormatter && payload ? labelFormatter(label, payload) : label}\n payload={\n labels\n ? payload?.map((item) => ({\n ...item,\n name: labels[getAxis(item.name as string, dataKey)] || item.name,\n value:\n getFormatter(getAxis(item.name as string, dataKey))?.(\n item.value as number\n ) ?? item.value,\n }))\n : payload?.map((item) => ({\n ...item,\n value:\n getFormatter(getAxis(item.name as string, dataKey))?.(\n item.value as number\n ) ?? item.value,\n }))\n }\n classNames={resolvedClassNames}\n styles={resolvedStyles}\n series={data}\n attributes={attributes}\n />\n )}\n {...tooltipProps}\n />\n )}\n\n {withLegend && (\n <Legend\n verticalAlign=\"top\"\n content={(payload) => (\n <ChartLegend\n payload={payload.payload?.map((item, index) => ({\n ...item,\n dataKey: data[index].name,\n }))}\n onHighlight={setHighlightedArea}\n legendPosition={legendProps?.verticalAlign || 'top'}\n classNames={resolvedClassNames}\n styles={resolvedStyles}\n series={data}\n attributes={attributes}\n />\n )}\n height={44}\n {...legendProps}\n />\n )}\n\n {referenceLinesItems}\n {scatters}\n </ReChartsScatterChart>\n </ResponsiveContainer>\n </Box>\n );\n});\n\nScatterChart.displayName = '@mantine/charts/ScatterChart';\nScatterChart.classes = classes;\nScatterChart.varsResolver = varsResolver;\n\nexport namespace ScatterChart {\n export type Props = ScatterChartProps;\n export type StylesNames = ScatterChartStylesNames;\n export type CssVariables = ScatterChartCssVariables;\n export type Factory = ScatterChartFactory;\n export type Series = ScatterChartSeries;\n}\n"],"mappings":";;;;;;;;;;AAoFA,SAAS,QAAQ,KAAa,SAAmC;CAC/D,OAAO,QAAQ,QAAQ,IAAI,MAAM;AACnC;AASA,MAAM,eAAe;CACnB,WAAW;CACX,WAAW;CACX,aAAa;CACb,0BAA0B;CAC1B,UAAU;CACV,iBAAiB;CACjB,UAAU;AACZ;AAEA,MAAM,gBAAA,GAAA,cAAA,qBAAwD,OAAO,EAAE,WAAW,iBAAiB,EACjG,MAAM;CACJ,sBAAsB,aAAA,GAAA,cAAA,eAA0B,WAAW,KAAK,IAAI,KAAA;CACpE,sBAAsB,aAAA,GAAA,cAAA,eAA0B,WAAW,KAAK,IAAI,KAAA;AACtE,EACF,EAAE;AAEF,MAAa,gBAAA,GAAA,cAAA,UAA6C,WAAW;CACnE,MAAM,SAAA,GAAA,cAAA,UAAiB,gBAAgB,cAAc,MAAM;CAC3D,MAAM,EACJ,YACA,WACA,OACA,QACA,UACA,MACA,gBACA,KACA,YACA,aACA,WACA,WACA,YACA,YACA,aACA,mBACA,aACA,MACA,UACA,UACA,iBACA,WACA,0BACA,cACA,UACA,cACA,SACA,WACA,WACA,YACA,YACA,MACA,QACA,gBACA,cACA,aACA,YACA,GAAG,WACD;CAEJ,MAAM,gBA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KAGF,cACC,iBAAA,GAAA,kBAAA,KAACC,SAAAA,QAAD;MACE,eAAc;MACd,UAAU,YACR,iBAAA,GAAA,kBAAA,KAACC,oBAAAA,aAAD;OACE,SAAS,QAAQ,SAAS,KAAK,MAAM,WAAW;QAC9C,GAAG;QACH,SAAS,KAAK,OAAO;OACvB,EAAE;OACF,aAAa;OACb,gBAAgB,aAAa,iBAAiB;OAC9C,YAAY;OACZ,QAAQ;OACR,QAAQ;OACI;MACb,CAAA;MAEH,QAAQ;MACR,GAAI;KACL,CAAA;KAGF;KACA;IACmB;;EACH,CAAA;CAClB,CAAA;AAET,CAAC;AAED,aAAa,cAAc;AAC3B,aAAa,UAAUC,0BAAAA;AACvB,aAAa,eAAe"}
1
+ {"version":3,"file":"ScatterChart.cjs","names":["ReferenceLine","Scatter","LabelList","Box","ResponsiveContainer","ReChartsScatterChart","CartesianGrid","XAxis","Label","YAxis","Tooltip","ChartTooltip","Legend","ChartLegend","classes"],"sources":["../../src/ScatterChart/ScatterChart.tsx"],"sourcesContent":["import { useState } from 'react';\nimport {\n CartesianGrid,\n Label,\n LabelList,\n Legend,\n ScatterChart as ReChartsScatterChart,\n ReferenceLine,\n ResponsiveContainer,\n Scatter,\n ScatterProps,\n Tooltip,\n XAxis,\n YAxis,\n} from 'recharts';\nimport {\n Box,\n BoxProps,\n createVarsResolver,\n ElementProps,\n factory,\n Factory,\n getThemeColor,\n MantineColor,\n StylesApiProps,\n useMantineTheme,\n useProps,\n useResolvedStylesApi,\n useStyles,\n} from '@mantine/core';\nimport { ChartLegend, ChartLegendStylesNames } from '../ChartLegend';\nimport { ChartTooltip, ChartTooltipStylesNames } from '../ChartTooltip';\nimport { BaseChartStylesNames, GridChartBaseProps } from '../types';\nimport classes from '../grid-chart.module.css';\n\nexport interface ScatterChartSeries {\n color: MantineColor;\n name: string;\n data: Record<string, number>[];\n}\n\nexport type ScatterChartStylesNames =\n | 'scatter'\n | BaseChartStylesNames\n | ChartLegendStylesNames\n | ChartTooltipStylesNames;\n\nexport type ScatterChartCssVariables = {\n root: '--chart-text-color' | '--chart-grid-color';\n};\n\nexport interface ScatterChartProps\n extends\n Omit<GridChartBaseProps, 'dataKey' | 'data' | 'unit' | 'valueFormatter'>,\n BoxProps,\n StylesApiProps<ScatterChartFactory>,\n ElementProps<'div'> {\n /** Keys that should be used to retrieve data from the data array on x and y axis */\n dataKey: { x: string; y: string };\n\n /** Data that is used to build the chart */\n data: ScatterChartSeries[];\n\n /** Units displayed after value on axis and inside the tooltip */\n unit?: { x?: string; y?: string };\n\n /** Labels that should be used instead of keys names in the tooltip */\n labels?: { x?: string; y?: string };\n\n /** A function to format values on x/y axis and in the tooltip */\n valueFormatter?:\n | GridChartBaseProps['valueFormatter']\n | { x?: GridChartBaseProps['valueFormatter']; y?: GridChartBaseProps['valueFormatter'] };\n\n /** Props passed down to recharts `ScatterChart` component */\n scatterChartProps?: React.ComponentProps<typeof ReChartsScatterChart>;\n\n /** Props passed down to recharts `Scatter` component */\n scatterProps?: Partial<Omit<ScatterProps, 'ref'>>;\n\n /** If set, displays labels next to points for the given axis */\n pointLabels?: 'x' | 'y';\n}\n\nfunction getAxis(key: string, dataKey: { x: string; y: string }) {\n return key === dataKey.x ? 'x' : 'y';\n}\n\nexport type ScatterChartFactory = Factory<{\n props: ScatterChartProps;\n ref: HTMLDivElement;\n stylesNames: ScatterChartStylesNames;\n vars: ScatterChartCssVariables;\n}>;\n\nconst defaultProps = {\n withXAxis: true,\n withYAxis: true,\n withTooltip: true,\n tooltipAnimationDuration: 0,\n tickLine: 'y',\n strokeDasharray: '5 5',\n gridAxis: 'x',\n} satisfies Partial<ScatterChartProps>;\n\nconst varsResolver = createVarsResolver<ScatterChartFactory>((theme, { textColor, gridColor }) => ({\n root: {\n '--chart-text-color': textColor ? getThemeColor(textColor, theme) : undefined,\n '--chart-grid-color': gridColor ? getThemeColor(gridColor, theme) : undefined,\n },\n}));\n\nexport const ScatterChart = factory<ScatterChartFactory>((_props) => {\n const props = useProps('ScatterChart', defaultProps, _props);\n const {\n classNames,\n className,\n style,\n styles,\n unstyled,\n vars,\n referenceLines,\n dir,\n withLegend,\n withTooltip,\n withXAxis,\n withYAxis,\n xAxisProps,\n yAxisProps,\n orientation,\n scatterChartProps,\n legendProps,\n data,\n gridAxis,\n tickLine,\n strokeDasharray,\n gridProps,\n tooltipAnimationDuration,\n tooltipProps,\n children,\n onMouseLeave,\n dataKey,\n textColor,\n gridColor,\n xAxisLabel,\n yAxisLabel,\n unit,\n labels,\n valueFormatter,\n scatterProps,\n pointLabels,\n attributes,\n ...others\n } = props;\n\n const getFormatter = (axis: 'x' | 'y') =>\n typeof valueFormatter === 'function' ? valueFormatter : valueFormatter?.[axis];\n const xFormatter = getFormatter('x');\n const yFormatter = getFormatter('y');\n\n const theme = useMantineTheme();\n\n const mappedData = data.map((item) => ({\n ...item,\n data: item.data.map((point) => ({ ...point, name: item.name })),\n }));\n\n const { resolvedClassNames, resolvedStyles } = useResolvedStylesApi<ScatterChartFactory>({\n classNames,\n styles,\n props,\n });\n\n const getStyles = useStyles<ScatterChartFactory>({\n name: 'ScatterChart',\n classes,\n props,\n className,\n style,\n classNames,\n styles,\n unstyled,\n attributes,\n vars,\n varsResolver,\n });\n\n const withXTickLine = gridAxis !== 'none' && (tickLine === 'x' || tickLine === 'xy');\n const withYTickLine = gridAxis !== 'none' && (tickLine === 'y' || tickLine === 'xy');\n const [highlightedArea, setHighlightedArea] = useState<string | null>(null);\n const shouldHighlight = highlightedArea !== null;\n const handleMouseLeave = (event: React.MouseEvent<HTMLDivElement>) => {\n setHighlightedArea(null);\n onMouseLeave?.(event);\n };\n\n const referenceLinesItems = referenceLines?.map((line, index) => {\n const color = getThemeColor(line.color, theme);\n return (\n <ReferenceLine\n key={index}\n stroke={line.color ? color : 'var(--chart-grid-color)'}\n strokeWidth={1}\n {...line}\n label={{\n fill: line.color ? color : 'currentColor',\n fontSize: 12,\n position: line.labelPosition ?? 'insideBottomLeft',\n ...(typeof line.label === 'object' ? line.label : { value: line.label }),\n }}\n {...getStyles('referenceLine')}\n />\n );\n });\n\n const scatters = mappedData.map((item, index) => {\n const dimmed = shouldHighlight && highlightedArea !== item.name;\n return (\n <Scatter\n data={item.data}\n fill={getThemeColor(item.color, theme)}\n key={index}\n isAnimationActive={false}\n fillOpacity={dimmed ? 0.1 : 1}\n {...scatterProps}\n >\n {pointLabels && <LabelList dataKey={dataKey[pointLabels]} fontSize={8} dy={10} />}\n {scatterProps?.children}\n </Scatter>\n );\n });\n\n return (\n <Box {...getStyles('root')} onMouseLeave={handleMouseLeave} dir={dir || 'ltr'} {...others}>\n <ResponsiveContainer {...getStyles('container')}>\n <ReChartsScatterChart\n margin={{\n bottom: xAxisLabel ? 30 : undefined,\n left: yAxisLabel ? 10 : undefined,\n right: yAxisLabel ? 5 : undefined,\n }}\n {...scatterChartProps}\n >\n <CartesianGrid\n strokeDasharray={strokeDasharray as string}\n vertical={gridAxis === 'y' || gridAxis === 'xy'}\n horizontal={gridAxis === 'x' || gridAxis === 'xy'}\n {...getStyles('grid')}\n {...gridProps}\n />\n <XAxis\n type=\"number\"\n hide={!withXAxis}\n dataKey={dataKey.x}\n tick={{ transform: 'translate(0, 10)', fontSize: 12, fill: 'currentColor' }}\n stroke=\"\"\n interval=\"preserveStartEnd\"\n tickLine={withXTickLine ? { stroke: 'currentColor' } : false}\n minTickGap={5}\n unit={unit?.x}\n tickFormatter={xFormatter}\n {...getStyles('axis')}\n {...xAxisProps}\n >\n {xAxisLabel && (\n <Label position=\"insideBottom\" offset={-20} fontSize={12} {...getStyles('axisLabel')}>\n {xAxisLabel}\n </Label>\n )}\n {xAxisProps?.children}\n </XAxis>\n <YAxis\n type=\"number\"\n hide={!withYAxis}\n axisLine={false}\n dataKey={dataKey.y}\n tickLine={withYTickLine ? { stroke: 'currentColor' } : false}\n tick={{ transform: 'translate(-10, 0)', fontSize: 12, fill: 'currentColor' }}\n allowDecimals\n unit={unit?.y}\n tickFormatter={yFormatter}\n {...getStyles('axis')}\n {...yAxisProps}\n >\n {yAxisLabel && (\n <Label\n position=\"insideLeft\"\n angle={-90}\n textAnchor=\"middle\"\n fontSize={12}\n offset={-5}\n {...getStyles('axisLabel')}\n >\n {yAxisLabel}\n </Label>\n )}\n {yAxisProps?.children}\n </YAxis>\n\n {withTooltip && (\n <Tooltip\n animationDuration={tooltipAnimationDuration}\n isAnimationActive={tooltipAnimationDuration !== 0}\n position={{ y: 0 }}\n cursor={{\n stroke: 'var(--chart-grid-color)',\n strokeWidth: 1,\n strokeDasharray,\n }}\n content={({ label, payload, labelFormatter }) => (\n <ChartTooltip\n type=\"scatter\"\n label={labelFormatter && payload ? labelFormatter(label, payload) : label}\n payload={\n labels\n ? payload?.map((item) => ({\n ...item,\n name: labels[getAxis(item.name as string, dataKey)] || item.name,\n value:\n getFormatter(getAxis(item.name as string, dataKey))?.(\n item.value as number\n ) ?? item.value,\n }))\n : payload?.map((item) => ({\n ...item,\n value:\n getFormatter(getAxis(item.name as string, dataKey))?.(\n item.value as number\n ) ?? item.value,\n }))\n }\n classNames={resolvedClassNames}\n styles={resolvedStyles}\n series={data}\n attributes={attributes}\n />\n )}\n {...tooltipProps}\n />\n )}\n\n {withLegend && (\n <Legend\n verticalAlign=\"top\"\n content={(payload) => (\n <ChartLegend\n payload={payload.payload?.map((item, index) => ({\n ...item,\n dataKey: data[index].name,\n }))}\n onHighlight={setHighlightedArea}\n legendPosition={legendProps?.verticalAlign || 'top'}\n classNames={resolvedClassNames}\n styles={resolvedStyles}\n series={data}\n attributes={attributes}\n />\n )}\n height={44}\n {...legendProps}\n />\n )}\n\n {referenceLinesItems}\n {scatters}\n </ReChartsScatterChart>\n </ResponsiveContainer>\n </Box>\n );\n});\n\nScatterChart.displayName = '@mantine/charts/ScatterChart';\nScatterChart.classes = classes;\nScatterChart.varsResolver = varsResolver;\n\nexport namespace ScatterChart {\n export type Props = ScatterChartProps;\n export type StylesNames = ScatterChartStylesNames;\n export type CssVariables = ScatterChartCssVariables;\n export type Factory = ScatterChartFactory;\n export type Series = ScatterChartSeries;\n}\n"],"mappings":";;;;;;;;;AAoFA,SAAS,QAAQ,KAAa,SAAmC;CAC/D,OAAO,QAAQ,QAAQ,IAAI,MAAM;AACnC;AASA,MAAM,eAAe;CACnB,WAAW;CACX,WAAW;CACX,aAAa;CACb,0BAA0B;CAC1B,UAAU;CACV,iBAAiB;CACjB,UAAU;AACZ;AAEA,MAAM,gBAAA,GAAA,cAAA,qBAAwD,OAAO,EAAE,WAAW,iBAAiB,EACjG,MAAM;CACJ,sBAAsB,aAAA,GAAA,cAAA,eAA0B,WAAW,KAAK,IAAI,KAAA;CACpE,sBAAsB,aAAA,GAAA,cAAA,eAA0B,WAAW,KAAK,IAAI,KAAA;AACtE,EACF,EAAE;AAEF,MAAa,gBAAA,GAAA,cAAA,UAA6C,WAAW;CACnE,MAAM,SAAA,GAAA,cAAA,UAAiB,gBAAgB,cAAc,MAAM;CAC3D,MAAM,EACJ,YACA,WACA,OACA,QACA,UACA,MACA,gBACA,KACA,YACA,aACA,WACA,WACA,YACA,YACA,aACA,mBACA,aACA,MACA,UACA,UACA,iBACA,WACA,0BACA,cACA,UACA,cACA,SACA,WACA,WACA,YACA,YACA,MACA,QACA,gBACA,cACA,aACA,YACA,GAAG,WACD;CAEJ,MAAM,gBAAgB,SACpB,OAAO,mBAAmB,aAAa,iBAAiB,iBAAiB;CAC3E,MAAM,aAAa,aAAa,GAAG;CACnC,MAAM,aAAa,aAAa,GAAG;CAEnC,MAAM,SAAA,GAAA,cAAA,iBAAwB;CAE9B,MAAM,aAAa,KAAK,KAAK,UAAU;EACrC,GAAG;EACH,MAAM,KAAK,KAAK,KAAK,WAAW;GAAE,GAAG;GAAO,MAAM,KAAK;EAAK,EAAE;CAChE,EAAE;CAEF,MAAM,EAAE,oBAAoB,oBAAA,GAAA,cAAA,sBAA6D;EACvF;EACA;EACA;CACF,CAAC;CAED,MAAM,aAAA,GAAA,cAAA,WAA2C;EAC/C,MAAM;EACN,SAA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BAAAA;AACvB,aAAa,eAAe"}
@@ -1,5 +1,4 @@
1
1
  "use client";
2
- require("../_virtual/_rolldown/runtime.cjs");
3
2
  const require_AreaGradient = require("../AreaChart/AreaGradient.cjs");
4
3
  const require_Sparkline_module = require("./Sparkline.module.cjs");
5
4
  let _mantine_core = require("@mantine/core");
@@ -1 +1 @@
1
- {"version":3,"file":"Sparkline.cjs","names":["Box","ResponsiveContainer","ReChartsAreaChart","Area","AreaGradient","classes"],"sources":["../../src/Sparkline/Sparkline.tsx"],"sourcesContent":["import { useId, useMemo } from 'react';\nimport { Area, AreaProps, AreaChart as ReChartsAreaChart, ResponsiveContainer } from 'recharts';\nimport {\n Box,\n BoxProps,\n createVarsResolver,\n ElementProps,\n factory,\n Factory,\n getThemeColor,\n MantineColor,\n StylesApiProps,\n useProps,\n useStyles,\n} from '@mantine/core';\nimport { AreaChartCurveType, AreaGradient } from '../AreaChart';\nimport classes from './Sparkline.module.css';\n\nexport interface SparklineTrendColors {\n positive: MantineColor;\n negative: MantineColor;\n neutral?: MantineColor;\n}\n\nexport type SparklineStylesNames = 'root';\nexport type SparklineCssVariables = {\n root: '--chart-color';\n};\n\nexport interface SparklineProps\n extends BoxProps, StylesApiProps<SparklineFactory>, ElementProps<'div'> {\n /** Data used to render the chart */\n data: (number | null)[];\n\n /** Key of `theme.colors` or any valid CSS color @default theme.primaryColor */\n color?: MantineColor;\n\n /** Determines whether the chart fill should be a gradient @default true */\n withGradient?: boolean;\n\n /** Controls fill opacity of the area @default 0.6 */\n fillOpacity?: number;\n\n /** Type of the curve @default 'linear' */\n curveType?: AreaChartCurveType;\n\n /** Area stroke width @default 2 */\n strokeWidth?: number;\n\n /** If set, `color` prop is ignored and chart color is determined by the difference between first and last value. */\n trendColors?: SparklineTrendColors;\n\n /** Determines whether null values should be connected with other values @default true */\n connectNulls?: boolean;\n\n /** Props passed down to the underlying recharts `Area` component */\n areaProps?: Omit<AreaProps<any, any>, 'data' | 'dataKey' | 'ref'>;\n}\n\nexport type SparklineFactory = Factory<{\n props: SparklineProps;\n ref: HTMLDivElement;\n stylesNames: SparklineStylesNames;\n vars: SparklineCssVariables;\n}>;\n\nconst defaultProps = {\n withGradient: true,\n connectNulls: true,\n fillOpacity: 0.6,\n strokeWidth: 2,\n curveType: 'linear',\n} satisfies Partial<SparklineProps>;\n\nfunction getTrendColor(data: (number | null)[], trendColors: SparklineTrendColors) {\n const first = data[0];\n const last = data[data.length - 1];\n\n if (first === null || last === null) {\n return trendColors.neutral || trendColors.positive;\n }\n\n if (first < last) {\n return trendColors.positive;\n }\n\n if (first > last) {\n return trendColors.negative;\n }\n\n return trendColors.neutral || trendColors.positive;\n}\n\nconst varsResolver = createVarsResolver<SparklineFactory>(\n (theme, { color, data, trendColors }) => ({\n root: {\n '--chart-color': trendColors\n ? getThemeColor(getTrendColor(data, trendColors), theme)\n : color\n ? getThemeColor(color, theme)\n : undefined,\n },\n })\n);\n\nexport const Sparkline = factory<SparklineFactory>((_props) => {\n const props = useProps('Sparkline', defaultProps, _props);\n const {\n classNames,\n className,\n style,\n styles,\n unstyled,\n vars,\n data,\n withGradient,\n fillOpacity,\n curveType,\n strokeWidth,\n trendColors,\n connectNulls,\n areaProps,\n attributes,\n ...others\n } = props;\n\n const getStyles = useStyles<SparklineFactory>({\n name: 'Sparkline',\n classes,\n props,\n className,\n style,\n classNames,\n styles,\n unstyled,\n attributes,\n vars,\n varsResolver,\n });\n\n const id = useId();\n const mappedData = useMemo(() => data.map((value, index) => ({ value, index })), [data]);\n\n return (\n <Box {...getStyles('root')} {...others} dir=\"ltr\">\n <ResponsiveContainer>\n <ReChartsAreaChart data={mappedData}>\n <Area\n dataKey=\"value\"\n type={curveType}\n fill={`url(#${id})`}\n stroke=\"var(--chart-color, var(--mantine-color-blue-filled))\"\n isAnimationActive={false}\n connectNulls={connectNulls}\n strokeWidth={strokeWidth}\n fillOpacity={1}\n activeDot={false}\n {...areaProps}\n />\n\n <defs>\n <AreaGradient\n id={id}\n color=\"var(--chart-color, var(--mantine-color-blue-filled))\"\n fillOpacity={fillOpacity}\n withGradient={withGradient}\n />\n </defs>\n </ReChartsAreaChart>\n </ResponsiveContainer>\n </Box>\n );\n});\n\nSparkline.displayName = '@mantine/charts/Sparkline';\nSparkline.classes = classes;\nSparkline.varsResolver = varsResolver;\n\nexport namespace Sparkline {\n export type Props = SparklineProps;\n export type StylesNames = SparklineStylesNames;\n export type CssVariables = SparklineCssVariables;\n export type Factory = SparklineFactory;\n}\n"],"mappings":";;;;;;;;;AAkEA,MAAM,eAAe;CACnB,cAAc;CACd,cAAc;CACd,aAAa;CACb,aAAa;CACb,WAAW;AACb;AAEA,SAAS,cAAc,MAAyB,aAAmC;CACjF,MAAM,QAAQ,KAAK;CACnB,MAAM,OAAO,KAAK,KAAK,SAAS;CAEhC,IAAI,UAAU,QAAQ,SAAS,MAC7B,OAAO,YAAY,WAAW,YAAY;CAG5C,IAAI,QAAQ,MACV,OAAO,YAAY;CAGrB,IAAI,QAAQ,MACV,OAAO,YAAY;CAGrB,OAAO,YAAY,WAAW,YAAY;AAC5C;AAEA,MAAM,gBAAA,GAAA,cAAA,qBACH,OAAO,EAAE,OAAO,MAAM,mBAAmB,EACxC,MAAM,EACJ,iBAAiB,eAAA,GAAA,cAAA,eACC,cAAc,MAAM,WAAW,GAAG,KAAK,IACrD,SAAA,GAAA,cAAA,eACgB,OAAO,KAAK,IAC1B,KAAA,EACR,EACF,EACF;AAEA,MAAa,aAAA,GAAA,cAAA,UAAuC,WAAW;CAC7D,MAAM,SAAA,GAAA,cAAA,UAAiB,aAAa,cAAc,MAAM;CACxD,MAAM,EACJ,YACA,WACA,OACA,QACA,UACA,MACA,MACA,cACA,aACA,WACA,aACA,aACA,cACA,WACA,YACA,GAAG,WACD;CAEJ,MAAM,aAAA,GAAA,cAAA,WAAwC;EAC5C,MAAM;EACN,SAAA,yBAAA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;CACF,CAAC;CAED,MAAM,MAAA,GAAA,MAAA,OAAW;CACjB,MAAM,cAAA,GAAA,MAAA,eAA2B,KAAK,KAAK,OAAO,WAAW;EAAE;EAAO;CAAM,EAAE,GAAG,CAAC,IAAI,CAAC;CAEvF,OACE,iBAAA,GAAA,kBAAA,KAACA,cAAAA,KAAD;EAAK,GAAI,UAAU,MAAM;EAAG,GAAI;EAAQ,KAAI;YAC1C,iBAAA,GAAA,kBAAA,KAACC,SAAAA,qBAAD,EAAA,UACE,iBAAA,GAAA,kBAAA,MAACC,SAAAA,WAAD;GAAmB,MAAM;aAAzB,CACE,iBAAA,GAAA,kBAAA,KAACC,SAAAA,MAAD;IACE,SAAQ;IACR,MAAM;IACN,MAAM,QAAQ,GAAG;IACjB,QAAO;IACP,mBAAmB;IACL;IACD;IACb,aAAa;IACb,WAAW;IACX,GAAI;GACL,CAAA,GAED,iBAAA,GAAA,kBAAA,KAAC,QAAD,EAAA,UACE,iBAAA,GAAA,kBAAA,KAACC,qBAAAA,cAAD;IACM;IACJ,OAAM;IACO;IACC;GACf,CAAA,EACG,CAAA,CACW;KACA,CAAA;CAClB,CAAA;AAET,CAAC;AAED,UAAU,cAAc;AACxB,UAAU,UAAUC,yBAAAA;AACpB,UAAU,eAAe"}
1
+ {"version":3,"file":"Sparkline.cjs","names":["Box","ResponsiveContainer","ReChartsAreaChart","Area","AreaGradient","classes"],"sources":["../../src/Sparkline/Sparkline.tsx"],"sourcesContent":["import { useId, useMemo } from 'react';\nimport { Area, AreaProps, AreaChart as ReChartsAreaChart, ResponsiveContainer } from 'recharts';\nimport {\n Box,\n BoxProps,\n createVarsResolver,\n ElementProps,\n factory,\n Factory,\n getThemeColor,\n MantineColor,\n StylesApiProps,\n useProps,\n useStyles,\n} from '@mantine/core';\nimport { AreaChartCurveType, AreaGradient } from '../AreaChart';\nimport classes from './Sparkline.module.css';\n\nexport interface SparklineTrendColors {\n positive: MantineColor;\n negative: MantineColor;\n neutral?: MantineColor;\n}\n\nexport type SparklineStylesNames = 'root';\nexport type SparklineCssVariables = {\n root: '--chart-color';\n};\n\nexport interface SparklineProps\n extends BoxProps, StylesApiProps<SparklineFactory>, ElementProps<'div'> {\n /** Data used to render the chart */\n data: (number | null)[];\n\n /** Key of `theme.colors` or any valid CSS color @default theme.primaryColor */\n color?: MantineColor;\n\n /** Determines whether the chart fill should be a gradient @default true */\n withGradient?: boolean;\n\n /** Controls fill opacity of the area @default 0.6 */\n fillOpacity?: number;\n\n /** Type of the curve @default 'linear' */\n curveType?: AreaChartCurveType;\n\n /** Area stroke width @default 2 */\n strokeWidth?: number;\n\n /** If set, `color` prop is ignored and chart color is determined by the difference between first and last value. */\n trendColors?: SparklineTrendColors;\n\n /** Determines whether null values should be connected with other values @default true */\n connectNulls?: boolean;\n\n /** Props passed down to the underlying recharts `Area` component */\n areaProps?: Omit<AreaProps<any, any>, 'data' | 'dataKey' | 'ref'>;\n}\n\nexport type SparklineFactory = Factory<{\n props: SparklineProps;\n ref: HTMLDivElement;\n stylesNames: SparklineStylesNames;\n vars: SparklineCssVariables;\n}>;\n\nconst defaultProps = {\n withGradient: true,\n connectNulls: true,\n fillOpacity: 0.6,\n strokeWidth: 2,\n curveType: 'linear',\n} satisfies Partial<SparklineProps>;\n\nfunction getTrendColor(data: (number | null)[], trendColors: SparklineTrendColors) {\n const first = data[0];\n const last = data[data.length - 1];\n\n if (first === null || last === null) {\n return trendColors.neutral || trendColors.positive;\n }\n\n if (first < last) {\n return trendColors.positive;\n }\n\n if (first > last) {\n return trendColors.negative;\n }\n\n return trendColors.neutral || trendColors.positive;\n}\n\nconst varsResolver = createVarsResolver<SparklineFactory>(\n (theme, { color, data, trendColors }) => ({\n root: {\n '--chart-color': trendColors\n ? getThemeColor(getTrendColor(data, trendColors), theme)\n : color\n ? getThemeColor(color, theme)\n : undefined,\n },\n })\n);\n\nexport const Sparkline = factory<SparklineFactory>((_props) => {\n const props = useProps('Sparkline', defaultProps, _props);\n const {\n classNames,\n className,\n style,\n styles,\n unstyled,\n vars,\n data,\n withGradient,\n fillOpacity,\n curveType,\n strokeWidth,\n trendColors,\n connectNulls,\n areaProps,\n attributes,\n ...others\n } = props;\n\n const getStyles = useStyles<SparklineFactory>({\n name: 'Sparkline',\n classes,\n props,\n className,\n style,\n classNames,\n styles,\n unstyled,\n attributes,\n vars,\n varsResolver,\n });\n\n const id = useId();\n const mappedData = useMemo(() => data.map((value, index) => ({ value, index })), [data]);\n\n return (\n <Box {...getStyles('root')} {...others} dir=\"ltr\">\n <ResponsiveContainer>\n <ReChartsAreaChart data={mappedData}>\n <Area\n dataKey=\"value\"\n type={curveType}\n fill={`url(#${id})`}\n stroke=\"var(--chart-color, var(--mantine-color-blue-filled))\"\n isAnimationActive={false}\n connectNulls={connectNulls}\n strokeWidth={strokeWidth}\n fillOpacity={1}\n activeDot={false}\n {...areaProps}\n />\n\n <defs>\n <AreaGradient\n id={id}\n color=\"var(--chart-color, var(--mantine-color-blue-filled))\"\n fillOpacity={fillOpacity}\n withGradient={withGradient}\n />\n </defs>\n </ReChartsAreaChart>\n </ResponsiveContainer>\n </Box>\n );\n});\n\nSparkline.displayName = '@mantine/charts/Sparkline';\nSparkline.classes = classes;\nSparkline.varsResolver = varsResolver;\n\nexport namespace Sparkline {\n export type Props = SparklineProps;\n export type StylesNames = SparklineStylesNames;\n export type CssVariables = SparklineCssVariables;\n export type Factory = SparklineFactory;\n}\n"],"mappings":";;;;;;;;AAkEA,MAAM,eAAe;CACnB,cAAc;CACd,cAAc;CACd,aAAa;CACb,aAAa;CACb,WAAW;AACb;AAEA,SAAS,cAAc,MAAyB,aAAmC;CACjF,MAAM,QAAQ,KAAK;CACnB,MAAM,OAAO,KAAK,KAAK,SAAS;CAEhC,IAAI,UAAU,QAAQ,SAAS,MAC7B,OAAO,YAAY,WAAW,YAAY;CAG5C,IAAI,QAAQ,MACV,OAAO,YAAY;CAGrB,IAAI,QAAQ,MACV,OAAO,YAAY;CAGrB,OAAO,YAAY,WAAW,YAAY;AAC5C;AAEA,MAAM,gBAAA,GAAA,c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UAAU,cAAc;AACxB,UAAU,UAAUC,yBAAAA;AACpB,UAAU,eAAe"}
@@ -22,12 +22,13 @@ const varsResolver = createVarsResolver((theme, { strokeColor, labelColor, withL
22
22
  "--chart-labels-color": labelColor ? getThemeColor(labelColor, theme) : void 0,
23
23
  "--chart-size": withLabels ? rem(size + 80) : rem(size)
24
24
  } }));
25
- const getLabelValue = (labelsType, value, percent, valueFormatter) => {
25
+ const getLabelValue = (labelsType, value, percent, name, valueFormatter) => {
26
+ if (labelsType === "name") return name;
26
27
  if (labelsType === "percent") return `${((percent || 0) * 100).toFixed(0)}%`;
27
28
  if (typeof valueFormatter === "function") return valueFormatter(value || 0);
28
29
  return value;
29
30
  };
30
- const getLabel = (labelsType, valueFormatter) => ({ x, y, cx, cy, percent, value }) => /* @__PURE__ */ jsx("text", {
31
+ const getLabel = (labelsType, valueFormatter) => ({ x, y, cx, cy, percent, value, name }) => /* @__PURE__ */ jsx("text", {
31
32
  x,
32
33
  y,
33
34
  cx,
@@ -38,7 +39,7 @@ const getLabel = (labelsType, valueFormatter) => ({ x, y, cx, cy, percent, value
38
39
  fontSize: 12,
39
40
  children: /* @__PURE__ */ jsx("tspan", {
40
41
  x,
41
- children: getLabelValue(labelsType, Number(value), Number(percent), valueFormatter)
42
+ children: getLabelValue(labelsType, Number(value), Number(percent), name, valueFormatter)
42
43
  })
43
44
  });
44
45
  const DonutChart = factory((_props) => {
@@ -1 +1 @@
1
- {"version":3,"file":"DonutChart.mjs","names":["ReChartsPieChart","Tooltip","classes"],"sources":["../../src/DonutChart/DonutChart.tsx"],"sourcesContent":["import {\n Pie,\n PieLabel,\n PieProps,\n PieChart as ReChartsPieChart,\n ResponsiveContainer,\n Tooltip,\n TooltipProps,\n} from 'recharts';\nimport {\n Box,\n BoxProps,\n createVarsResolver,\n ElementProps,\n factory,\n Factory,\n getThemeColor,\n MantineColor,\n rem,\n StylesApiProps,\n useMantineTheme,\n useProps,\n useResolvedStylesApi,\n useStyles,\n} from '@mantine/core';\nimport { ChartTooltip, ChartTooltipStylesNames } from '../ChartTooltip/ChartTooltip';\nimport classes from './DonutChart.module.css';\n\nexport interface DonutChartCell {\n name: string;\n value: number;\n color: MantineColor;\n}\n\nexport type DonutChartStylesNames = 'root' | 'label' | ChartTooltipStylesNames;\nexport type DonutChartCssVariables = {\n root: '--chart-stroke-color' | '--chart-labels-color' | '--chart-size';\n};\n\nexport interface DonutChartProps\n extends BoxProps, StylesApiProps<DonutChartFactory>, ElementProps<'div'> {\n /** Data used to render chart */\n data: DonutChartCell[];\n\n /** Determines whether the tooltip should be displayed when one of the section is hovered @default true */\n withTooltip?: boolean;\n\n /** Tooltip animation duration in ms @default 0 */\n tooltipAnimationDuration?: number;\n\n /** Props passed down to `Tooltip` recharts component */\n tooltipProps?: Omit<TooltipProps<any, any>, 'ref'>;\n\n /** Props passed down to recharts `Pie` component */\n pieProps?: Partial<Omit<PieProps, 'ref'>>;\n\n /** Controls color of the segments stroke, by default depends on color scheme */\n strokeColor?: MantineColor;\n\n /** Controls text color of all labels, by default depends on color scheme */\n labelColor?: MantineColor;\n\n /** Controls padding between segments @default 0 */\n paddingAngle?: number;\n\n /** Determines whether each segment should have associated label @default false */\n withLabels?: boolean;\n\n /** Determines whether segments labels should have lines that connect the segment with the label @default true */\n withLabelsLine?: boolean;\n\n /** Controls thickness of the chart segments @default 20 */\n thickness?: number;\n\n /** Controls chart width and height, height is increased by 40 if `withLabels` prop is set. Cannot be less than `thickness`. @default 80 */\n size?: number;\n\n /** Controls width of segments stroke @default 1 */\n strokeWidth?: number;\n\n /** Controls angle at which chart starts. Set to `180` to render the chart as semicircle. @default 0 */\n startAngle?: number;\n\n /** Controls angle at which charts ends. Set to `0` to render the chart as semicircle. @default 360 */\n endAngle?: number;\n\n /** Determines which data is displayed in the tooltip. `'all'` – display all values, `'segment'` – display only hovered segment. @default 'all' */\n tooltipDataSource?: 'segment' | 'all';\n\n /** Chart label, displayed in the center of the chart */\n chartLabel?: string | number;\n\n /** Additional elements rendered inside `PieChart` component */\n children?: React.ReactNode;\n\n /** Props passed down to recharts `PieChart` component */\n pieChartProps?: React.ComponentProps<typeof ReChartsPieChart>;\n\n /** Type of labels to display, `'value'` by default */\n labelsType?: 'value' | 'percent';\n\n /** A function to format values inside the tooltip */\n valueFormatter?: (value: number) => string;\n\n /** Props passed down to each segment of the chart */\n cellProps?:\n | ((series: DonutChartCell) => Partial<Omit<React.SVGProps<SVGElement>, 'ref'>>)\n | Partial<Omit<React.SVGProps<SVGElement>, 'ref'>>;\n}\n\nexport type DonutChartFactory = Factory<{\n props: DonutChartProps;\n ref: HTMLDivElement;\n stylesNames: DonutChartStylesNames;\n vars: DonutChartCssVariables;\n}>;\n\nconst defaultProps = {\n withTooltip: true,\n withLabelsLine: true,\n paddingAngle: 0,\n thickness: 20,\n size: 160,\n strokeWidth: 1,\n startAngle: 0,\n endAngle: 360,\n labelsType: 'value',\n tooltipDataSource: 'all',\n} satisfies Partial<DonutChartProps>;\n\nconst varsResolver = createVarsResolver<DonutChartFactory>(\n (theme, { strokeColor, labelColor, withLabels, size }) => ({\n root: {\n '--chart-stroke-color': strokeColor ? getThemeColor(strokeColor, theme) : undefined,\n '--chart-labels-color': labelColor ? getThemeColor(labelColor, theme) : undefined,\n '--chart-size': withLabels ? rem(size! + 80) : rem(size),\n },\n })\n);\n\nconst getLabelValue = (\n labelsType: DonutChartProps['labelsType'],\n value: number | undefined,\n percent: number | undefined,\n valueFormatter?: DonutChartProps['valueFormatter']\n) => {\n if (labelsType === 'percent') {\n return `${((percent || 0) * 100).toFixed(0)}%`;\n }\n\n if (typeof valueFormatter === 'function') {\n return valueFormatter(value || 0);\n }\n\n return value;\n};\n\nconst getLabel =\n (labelsType: 'value' | 'percent', valueFormatter?: DonutChartProps['valueFormatter']): PieLabel =>\n ({ x, y, cx, cy, percent, value }) => (\n <text\n x={x}\n y={y}\n cx={cx}\n cy={cy}\n textAnchor={x > Number(cx) ? 'start' : 'end'}\n fill=\"var(--chart-labels-color, var(--mantine-color-dimmed))\"\n fontFamily=\"var(--mantine-font-family)\"\n fontSize={12}\n >\n <tspan x={x}>\n {getLabelValue(labelsType, Number(value), Number(percent), valueFormatter)}\n </tspan>\n </text>\n );\n\nexport const DonutChart = factory<DonutChartFactory>((_props) => {\n const props = useProps('DonutChart', defaultProps, _props);\n const {\n classNames,\n className,\n style,\n styles,\n unstyled,\n vars,\n data,\n withTooltip,\n tooltipAnimationDuration,\n tooltipProps,\n pieProps,\n paddingAngle,\n withLabels,\n withLabelsLine,\n size,\n thickness,\n strokeWidth,\n startAngle,\n endAngle,\n tooltipDataSource,\n chartLabel,\n children,\n pieChartProps,\n valueFormatter,\n strokeColor,\n labelsType,\n attributes,\n cellProps,\n ...others\n } = props;\n\n const theme = useMantineTheme();\n\n const getStyles = useStyles<DonutChartFactory>({\n name: 'DonutChart',\n classes,\n props,\n className,\n style,\n classNames,\n styles,\n unstyled,\n attributes,\n vars,\n varsResolver,\n });\n\n const { resolvedClassNames, resolvedStyles } = useResolvedStylesApi<DonutChartFactory>({\n classNames,\n styles,\n props,\n });\n\n const pieData = data.map((item) => ({\n ...item,\n fill: getThemeColor(item.color, theme),\n stroke: 'var(--chart-stroke-color, var(--mantine-color-body))',\n strokeWidth,\n ...(typeof cellProps === 'function' ? cellProps(item) : cellProps),\n }));\n\n return (\n <Box size={size} {...getStyles('root')} {...others}>\n <ResponsiveContainer>\n <ReChartsPieChart {...pieChartProps}>\n <Pie\n data={pieData as any}\n innerRadius={size / 2 - thickness}\n outerRadius={size / 2}\n dataKey=\"value\"\n isAnimationActive={false}\n paddingAngle={paddingAngle}\n startAngle={startAngle}\n endAngle={endAngle}\n label={withLabels ? getLabel(labelsType || 'value', valueFormatter) : false}\n labelLine={\n withLabelsLine\n ? {\n stroke: 'var(--chart-label-color, var(--mantine-color-dimmed))',\n strokeWidth: 1,\n }\n : false\n }\n {...pieProps}\n />\n\n {chartLabel && (\n <text\n x=\"50%\"\n y=\"50%\"\n textAnchor=\"middle\"\n dominantBaseline=\"middle\"\n {...getStyles('label')}\n >\n {chartLabel}\n </text>\n )}\n\n {withTooltip && (\n <Tooltip\n animationDuration={tooltipAnimationDuration}\n isAnimationActive={false}\n content={({ payload }) => (\n <ChartTooltip\n payload={data}\n classNames={resolvedClassNames}\n styles={resolvedStyles}\n type=\"radial\"\n segmentId={\n tooltipDataSource === 'segment' ? (payload?.[0]?.name as string) : undefined\n }\n valueFormatter={valueFormatter}\n attributes={attributes}\n />\n )}\n {...tooltipProps}\n />\n )}\n\n {children}\n </ReChartsPieChart>\n </ResponsiveContainer>\n </Box>\n );\n});\n\nDonutChart.displayName = '@mantine/charts/DonutChart';\nDonutChart.classes = classes;\nDonutChart.varsResolver = varsResolver;\n\nexport namespace DonutChart {\n export type Props = DonutChartProps;\n export type StylesNames = DonutChartStylesNames;\n export type Factory = DonutChartFactory;\n export type CssVariables = DonutChartCssVariables;\n export type Cell = DonutChartCell;\n}\n"],"mappings":";;;;;;;AAqHA,MAAM,eAAe;CACnB,aAAa;CACb,gBAAgB;CAChB,cAAc;CACd,WAAW;CACX,MAAM;CACN,aAAa;CACb,YAAY;CACZ,UAAU;CACV,YAAY;CACZ,mBAAmB;AACrB;AAEA,MAAM,eAAe,oBAClB,OAAO,EAAE,aAAa,YAAY,YAAY,YAAY,EACzD,MAAM;CACJ,wBAAwB,cAAc,cAAc,aAAa,KAAK,IAAI,KAAA;CAC1E,wBAAwB,aAAa,cAAc,YAAY,KAAK,IAAI,KAAA;CACxE,gBAAgB,aAAa,IAAI,OAAQ,EAAE,IAAI,IAAI,IAAI;AACzD,EACF,EACF;AAEA,MAAM,iBACJ,YACA,OACA,SACA,mBACG;CACH,IAAI,eAAe,WACjB,OAAO,KAAK,WAAW,KAAK,KAAK,QAAQ,CAAC,EAAE;CAG9C,IAAI,OAAO,mBAAmB,YAC5B,OAAO,eAAe,SAAS,CAAC;CAGlC,OAAO;AACT;AAEA,MAAM,YACH,YAAiC,oBACjC,EAAE,GAAG,GAAG,IAAI,I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AE;KACF,GAAE;KACF,YAAW;KACX,kBAAiB;KACjB,GAAI,UAAU,OAAO;eAEpB;IACG,CAAA;IAGP,eACC,oBAACC,WAAD;KACE,mBAAmB;KACnB,mBAAmB;KACnB,UAAU,EAAE,cACV,oBAAC,cAAD;MACE,SAAS;MACT,YAAY;MACZ,QAAQ;MACR,MAAK;MACL,WACE,sBAAsB,YAAa,UAAU,IAAI,OAAkB,KAAA;MAErD;MACJ;KACb,CAAA;KAEH,GAAI;IACL,CAAA;IAGF;GACe;KACC,CAAA;CAClB,CAAA;AAET,CAAC;AAED,WAAW,cAAc;AACzB,WAAW,UAAUC;AACrB,WAAW,eAAe"}
1
+ {"version":3,"file":"DonutChart.mjs","names":["ReChartsPieChart","Tooltip","classes"],"sources":["../../src/DonutChart/DonutChart.tsx"],"sourcesContent":["import {\n Pie,\n PieLabel,\n PieProps,\n PieChart as ReChartsPieChart,\n ResponsiveContainer,\n Tooltip,\n TooltipProps,\n} from 'recharts';\nimport {\n Box,\n BoxProps,\n createVarsResolver,\n ElementProps,\n factory,\n Factory,\n getThemeColor,\n MantineColor,\n rem,\n StylesApiProps,\n useMantineTheme,\n useProps,\n useResolvedStylesApi,\n useStyles,\n} from '@mantine/core';\nimport { ChartTooltip, ChartTooltipStylesNames } from '../ChartTooltip/ChartTooltip';\nimport classes from './DonutChart.module.css';\n\nexport interface DonutChartCell {\n name: string;\n value: number;\n color: MantineColor;\n}\n\nexport type DonutChartStylesNames = 'root' | 'label' | ChartTooltipStylesNames;\nexport type DonutChartCssVariables = {\n root: '--chart-stroke-color' | '--chart-labels-color' | '--chart-size';\n};\n\nexport interface DonutChartProps\n extends BoxProps, StylesApiProps<DonutChartFactory>, ElementProps<'div'> {\n /** Data used to render chart */\n data: DonutChartCell[];\n\n /** Determines whether the tooltip should be displayed when one of the section is hovered @default true */\n withTooltip?: boolean;\n\n /** Tooltip animation duration in ms @default 0 */\n tooltipAnimationDuration?: number;\n\n /** Props passed down to `Tooltip` recharts component */\n tooltipProps?: Omit<TooltipProps<any, any>, 'ref'>;\n\n /** Props passed down to recharts `Pie` component */\n pieProps?: Partial<Omit<PieProps, 'ref'>>;\n\n /** Controls color of the segments stroke, by default depends on color scheme */\n strokeColor?: MantineColor;\n\n /** Controls text color of all labels, by default depends on color scheme */\n labelColor?: MantineColor;\n\n /** Controls padding between segments @default 0 */\n paddingAngle?: number;\n\n /** Determines whether each segment should have associated label @default false */\n withLabels?: boolean;\n\n /** Determines whether segments labels should have lines that connect the segment with the label @default true */\n withLabelsLine?: boolean;\n\n /** Controls thickness of the chart segments @default 20 */\n thickness?: number;\n\n /** Controls chart width and height, height is increased by 40 if `withLabels` prop is set. Cannot be less than `thickness`. @default 80 */\n size?: number;\n\n /** Controls width of segments stroke @default 1 */\n strokeWidth?: number;\n\n /** Controls angle at which chart starts. Set to `180` to render the chart as semicircle. @default 0 */\n startAngle?: number;\n\n /** Controls angle at which charts ends. Set to `0` to render the chart as semicircle. @default 360 */\n endAngle?: number;\n\n /** Determines which data is displayed in the tooltip. `'all'` – display all values, `'segment'` – display only hovered segment. @default 'all' */\n tooltipDataSource?: 'segment' | 'all';\n\n /** Chart label, displayed in the center of the chart */\n chartLabel?: string | number;\n\n /** Additional elements rendered inside `PieChart` component */\n children?: React.ReactNode;\n\n /** Props passed down to recharts `PieChart` component */\n pieChartProps?: React.ComponentProps<typeof ReChartsPieChart>;\n\n /** Type of labels to display, `'value'` by default */\n labelsType?: 'value' | 'percent' | 'name';\n\n /** A function to format values inside the tooltip */\n valueFormatter?: (value: number) => string;\n\n /** Props passed down to each segment of the chart */\n cellProps?:\n | ((series: DonutChartCell) => Partial<Omit<React.SVGProps<SVGElement>, 'ref'>>)\n | Partial<Omit<React.SVGProps<SVGElement>, 'ref'>>;\n}\n\nexport type DonutChartFactory = Factory<{\n props: DonutChartProps;\n ref: HTMLDivElement;\n stylesNames: DonutChartStylesNames;\n vars: DonutChartCssVariables;\n}>;\n\nconst defaultProps = {\n withTooltip: true,\n withLabelsLine: true,\n paddingAngle: 0,\n thickness: 20,\n size: 160,\n strokeWidth: 1,\n startAngle: 0,\n endAngle: 360,\n labelsType: 'value',\n tooltipDataSource: 'all',\n} satisfies Partial<DonutChartProps>;\n\nconst varsResolver = createVarsResolver<DonutChartFactory>(\n (theme, { strokeColor, labelColor, withLabels, size }) => ({\n root: {\n '--chart-stroke-color': strokeColor ? getThemeColor(strokeColor, theme) : undefined,\n '--chart-labels-color': labelColor ? getThemeColor(labelColor, theme) : undefined,\n '--chart-size': withLabels ? rem(size! + 80) : rem(size),\n },\n })\n);\n\nconst getLabelValue = (\n labelsType: DonutChartProps['labelsType'],\n value: number | undefined,\n percent: number | undefined,\n name: string | undefined,\n valueFormatter?: DonutChartProps['valueFormatter']\n) => {\n if (labelsType === 'name') {\n return name;\n }\n\n if (labelsType === 'percent') {\n return `${((percent || 0) * 100).toFixed(0)}%`;\n }\n\n if (typeof valueFormatter === 'function') {\n return valueFormatter(value || 0);\n }\n\n return value;\n};\n\nconst getLabel =\n (\n labelsType: 'value' | 'percent' | 'name',\n valueFormatter?: DonutChartProps['valueFormatter']\n ): PieLabel =>\n ({ x, y, cx, cy, percent, value, name }) => (\n <text\n x={x}\n y={y}\n cx={cx}\n cy={cy}\n textAnchor={x > Number(cx) ? 'start' : 'end'}\n fill=\"var(--chart-labels-color, var(--mantine-color-dimmed))\"\n fontFamily=\"var(--mantine-font-family)\"\n fontSize={12}\n >\n <tspan x={x}>\n {getLabelValue(labelsType, Number(value), Number(percent), name as string, valueFormatter)}\n </tspan>\n </text>\n );\n\nexport const DonutChart = factory<DonutChartFactory>((_props) => {\n const props = useProps('DonutChart', defaultProps, _props);\n const {\n classNames,\n className,\n style,\n styles,\n unstyled,\n vars,\n data,\n withTooltip,\n tooltipAnimationDuration,\n tooltipProps,\n pieProps,\n paddingAngle,\n withLabels,\n withLabelsLine,\n size,\n thickness,\n strokeWidth,\n startAngle,\n endAngle,\n tooltipDataSource,\n chartLabel,\n children,\n pieChartProps,\n valueFormatter,\n strokeColor,\n labelsType,\n attributes,\n cellProps,\n ...others\n } = props;\n\n const theme = useMantineTheme();\n\n const getStyles = useStyles<DonutChartFactory>({\n name: 'DonutChart',\n classes,\n props,\n className,\n style,\n classNames,\n styles,\n unstyled,\n attributes,\n vars,\n varsResolver,\n });\n\n const { resolvedClassNames, resolvedStyles } = useResolvedStylesApi<DonutChartFactory>({\n classNames,\n styles,\n props,\n });\n\n const pieData = data.map((item) => ({\n ...item,\n fill: getThemeColor(item.color, theme),\n stroke: 'var(--chart-stroke-color, var(--mantine-color-body))',\n strokeWidth,\n ...(typeof cellProps === 'function' ? cellProps(item) : cellProps),\n }));\n\n return (\n <Box size={size} {...getStyles('root')} {...others}>\n <ResponsiveContainer>\n <ReChartsPieChart {...pieChartProps}>\n <Pie\n data={pieData as any}\n innerRadius={size / 2 - thickness}\n outerRadius={size / 2}\n dataKey=\"value\"\n isAnimationActive={false}\n paddingAngle={paddingAngle}\n startAngle={startAngle}\n endAngle={endAngle}\n label={withLabels ? getLabel(labelsType || 'value', valueFormatter) : false}\n labelLine={\n withLabelsLine\n ? {\n stroke: 'var(--chart-label-color, var(--mantine-color-dimmed))',\n strokeWidth: 1,\n }\n : false\n }\n {...pieProps}\n />\n\n {chartLabel && (\n <text\n x=\"50%\"\n y=\"50%\"\n textAnchor=\"middle\"\n dominantBaseline=\"middle\"\n {...getStyles('label')}\n >\n {chartLabel}\n </text>\n )}\n\n {withTooltip && (\n <Tooltip\n animationDuration={tooltipAnimationDuration}\n isAnimationActive={false}\n content={({ payload }) => (\n <ChartTooltip\n payload={data}\n classNames={resolvedClassNames}\n styles={resolvedStyles}\n type=\"radial\"\n segmentId={\n tooltipDataSource === 'segment' ? (payload?.[0]?.name as string) : undefined\n }\n valueFormatter={valueFormatter}\n attributes={attributes}\n />\n )}\n {...tooltipProps}\n />\n )}\n\n {children}\n </ReChartsPieChart>\n </ResponsiveContainer>\n </Box>\n );\n});\n\nDonutChart.displayName = '@mantine/charts/DonutChart';\nDonutChart.classes = classes;\nDonutChart.varsResolver = varsResolver;\n\nexport namespace DonutChart {\n export type Props = DonutChartProps;\n export type StylesNames = DonutChartStylesNames;\n export type Factory = DonutChartFactory;\n export type CssVariables = DonutChartCssVariables;\n export type Cell = DonutChartCell;\n}\n"],"mappings":";;;;;;;AAqHA,MAAM,eAAe;CACnB,aAAa;CACb,gBAAgB;CAChB,cAAc;CACd,WAAW;CACX,MAAM;CACN,aAAa;CACb,YAAY;CACZ,UAAU;CACV,YAAY;CACZ,mBAAmB;AACrB;AAEA,MAAM,eAAe,oBAClB,OAAO,EAAE,aAAa,YAAY,YAAY,YAAY,EACzD,MAAM;CACJ,wBAAwB,cAAc,cAAc,aAAa,KAAK,IAAI,KAAA;CAC1E,wBAAwB,aAAa,cAAc,YAAY,KAAK,IAAI,KAAA;CACxE,gBAAgB,aAAa,IAAI,OAAQ,EAAE,IAAI,IAAI,IAAI;AACzD,EACF,EACF;AAEA,MAAM,iBACJ,YACA,OACA,SACA,MACA,mBACG;CACH,IAAI,eAAe,QACjB,OAAO;CAGT,IAAI,eAAe,WACjB,OAAO,KAAK,WAAW,KAAK,KAAK,QAAQ,CAAC,EAAE;CAG9C,IAAI,OAAO,mBAAmB,YAC5B,OAAO,eAAe,SAAS,CAAC;CAGlC,OAAO;AACT;AAEA,MAAM,YAEF,YACA,oBAED,EAAE,GAAG,GAAG,IAAI,IAAI,SAAS,OAAO,WAC/B,oBAAC,QAAD;CACK;CACA;CACC;CACA;CACJ,YAAY,IAAI,OAAO,EAAE,IAAI,UAAU;CACvC,MAAK;CACL,YAAW;CACX,UAAU;WAEV,oBAAC,SAAD;EAAU;YACP,cAAc,YAAY,OAAO,KAAK,GAAG,OAAO,OAAO,GAAG,MAAgB,cAAc;CACpF,CAAA;AACH,CAAA;AAGV,MAAa,aAAa,SAA4B,WAAW;CAC/D,MAAM,QAAQ,SAAS,cAAc,cAAc,MAAM;CACzD,MAAM,EACJ,YACA,WACA,OACA,QACA,UACA,MACA,MACA,a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AW,cAAc;AACzB,WAAW,UAAUC;AACrB,WAAW,eAAe"}
@@ -1 +1 @@
1
- {"version":3,"file":"DonutChart.module.mjs","names":[],"sources":["../../src/DonutChart/DonutChart.module.css"],"sourcesContent":[".root {\n min-height: var(--chart-size, auto);\n height: var(--chart-size, auto);\n width: var(--chart-size, auto);\n min-width: var(--chart-size, auto);\n\n & :where(*) {\n outline: 0;\n }\n}\n\n.label {\n fill: var(--mantine-color-text);\n font-size: var(--mantine-font-size-sm);\n}\n"],"mappings":""}
1
+ {"version":3,"file":"DonutChart.module.mjs","names":[],"sources":["../../src/DonutChart/DonutChart.module.css"],"sourcesContent":[".root {\n min-height: var(--chart-size, auto);\n height: var(--chart-size, auto);\n width: var(--chart-size, auto);\n min-width: var(--chart-size, auto);\n\n & :where(*) {\n outline: 0;\n }\n\n & :where(:global(.recharts-surface)) {\n overflow: visible;\n }\n}\n\n.label {\n fill: var(--mantine-color-text);\n font-size: var(--mantine-font-size-sm);\n}\n"],"mappings":""}
@@ -22,12 +22,13 @@ const varsResolver = createVarsResolver((theme, { strokeColor, labelColor, withL
22
22
  "--chart-labels-color": labelColor ? getThemeColor(labelColor, theme) : void 0,
23
23
  "--chart-size": withLabels && labelsPosition === "outside" ? rem(size + 80) : rem(size)
24
24
  } }));
25
- const getLabelValue = (labelsType, value, percent, valueFormatter) => {
25
+ const getLabelValue = (labelsType, value, percent, name, valueFormatter) => {
26
+ if (labelsType === "name") return name;
26
27
  if (labelsType === "percent" && typeof percent === "number") return `${(percent * 100).toFixed(0)}%`;
27
28
  if (typeof valueFormatter === "function" && typeof value === "number") return valueFormatter(value);
28
29
  return value;
29
30
  };
30
- const getInsideLabel = (labelsType, valueFormatter) => ({ cx, cy, midAngle, innerRadius, outerRadius, value, percent }) => {
31
+ const getInsideLabel = (labelsType, valueFormatter) => ({ cx, cy, midAngle, innerRadius, outerRadius, value, percent, name }) => {
31
32
  const RADIAN = Math.PI / 180;
32
33
  const radius = Number(innerRadius) + (Number(outerRadius) - Number(innerRadius)) * .5;
33
34
  const x = Number(cx) + radius * Math.cos(-(midAngle || 0) * RADIAN);
@@ -37,10 +38,10 @@ const getInsideLabel = (labelsType, valueFormatter) => ({ cx, cy, midAngle, inne
37
38
  textAnchor: x > Number(cx) ? "start" : "end",
38
39
  dominantBaseline: "central",
39
40
  className: PieChart_module_default.label,
40
- children: getLabelValue(labelsType, Number(value), Number(percent), valueFormatter)
41
+ children: getLabelValue(labelsType, Number(value), Number(percent), name, valueFormatter)
41
42
  });
42
43
  };
43
- const getOutsideLabel = (labelsType, valueFormatter) => ({ x, y, cx, cy, percent, value }) => /* @__PURE__ */ jsx("text", {
44
+ const getOutsideLabel = (labelsType, valueFormatter) => ({ x, y, cx, cy, percent, value, name }) => /* @__PURE__ */ jsx("text", {
44
45
  x,
45
46
  y,
46
47
  cx,
@@ -51,7 +52,7 @@ const getOutsideLabel = (labelsType, valueFormatter) => ({ x, y, cx, cy, percent
51
52
  fontSize: 12,
52
53
  children: /* @__PURE__ */ jsx("tspan", {
53
54
  x,
54
- children: getLabelValue(labelsType, Number(value), Number(percent), valueFormatter)
55
+ children: getLabelValue(labelsType, Number(value), Number(percent), name, valueFormatter)
55
56
  })
56
57
  });
57
58
  const PieChart$1 = factory((_props) => {
@@ -1 +1 @@
1
- {"version":3,"file":"PieChart.mjs","names":["classes","PieChart","ReChartsPieChart","Tooltip"],"sources":["../../src/PieChart/PieChart.tsx"],"sourcesContent":["import {\n Pie,\n PieLabel,\n PieProps,\n PieChart as ReChartsPieChart,\n ResponsiveContainer,\n Tooltip,\n TooltipProps,\n} from 'recharts';\nimport {\n Box,\n BoxProps,\n createVarsResolver,\n ElementProps,\n factory,\n Factory,\n getThemeColor,\n MantineColor,\n rem,\n StylesApiProps,\n useMantineTheme,\n useProps,\n useResolvedStylesApi,\n useStyles,\n} from '@mantine/core';\nimport { ChartTooltip, ChartTooltipStylesNames } from '../ChartTooltip/ChartTooltip';\nimport classes from './PieChart.module.css';\n\nexport interface PieChartCell {\n key?: string | number;\n name: string;\n value: number;\n color: MantineColor;\n}\n\nexport type PieChartStylesNames = 'root' | ChartTooltipStylesNames;\nexport type PieChartCssVariables = {\n root: '--chart-stroke-color' | '--chart-labels-color' | '--chart-size';\n};\n\nexport interface PieChartProps\n extends BoxProps, StylesApiProps<PieChartFactory>, ElementProps<'div'> {\n /** Data used to render chart */\n data: PieChartCell[];\n\n /** Determines whether the tooltip should be displayed when one of the section is hovered @default true */\n withTooltip?: boolean;\n\n /** Tooltip animation duration in ms @default 0 */\n tooltipAnimationDuration?: number;\n\n /** Props passed down to `Tooltip` recharts component */\n tooltipProps?: Omit<TooltipProps<any, any>, 'ref'>;\n\n /** Props passed down to recharts `Pie` component */\n pieProps?: Partial<Omit<PieProps, 'ref'>>;\n\n /** Controls color of the segments stroke, by default depends on color scheme */\n strokeColor?: MantineColor;\n\n /** Controls text color of all labels, white by default */\n labelColor?: MantineColor;\n\n /** Controls padding between segments @default 0 */\n paddingAngle?: number;\n\n /** Determines whether each segment should have associated label @default false */\n withLabels?: boolean;\n\n /** Determines whether segments labels should have lines that connect the segment with the label @default true */\n withLabelsLine?: boolean;\n\n /** Controls chart width and height, height is increased by 40 if `withLabels` prop is set. Cannot be less than `thickness`. @default 80 */\n size?: number;\n\n /** Controls width of segments stroke @default 1 */\n strokeWidth?: number;\n\n /** Controls angle at which chart starts. Set to `180` to render the chart as semicircle. @default 0 */\n startAngle?: number;\n\n /** Controls angle at which charts ends. Set to `0` to render the chart as semicircle. @default 360 */\n endAngle?: number;\n\n /** Determines which data is displayed in the tooltip. `'all'` – display all values, `'segment'` – display only hovered segment. @default 'all' */\n tooltipDataSource?: 'segment' | 'all';\n\n /** Additional elements rendered inside `PieChart` component */\n children?: React.ReactNode;\n\n /** Props passed down to recharts `PieChart` component */\n pieChartProps?: React.ComponentProps<typeof ReChartsPieChart>;\n\n /** Controls labels position relative to the segment @default 'outside' */\n labelsPosition?: 'inside' | 'outside';\n\n /** Type of labels to display @default 'value' */\n labelsType?: 'value' | 'percent';\n\n /** A function to format values inside the tooltip */\n valueFormatter?: (value: number) => string;\n\n /** Props passed down to each segment of the chart */\n cellProps?:\n | ((series: PieChartCell) => Partial<Omit<React.SVGProps<SVGElement>, 'ref'>>)\n | Partial<Omit<React.SVGProps<SVGElement>, 'ref'>>;\n}\n\nexport type PieChartFactory = Factory<{\n props: PieChartProps;\n ref: HTMLDivElement;\n stylesNames: PieChartStylesNames;\n vars: PieChartCssVariables;\n}>;\n\nconst defaultProps = {\n withTooltip: false,\n withLabelsLine: true,\n paddingAngle: 0,\n size: 160,\n strokeWidth: 1,\n startAngle: 0,\n endAngle: 360,\n tooltipDataSource: 'all',\n labelsPosition: 'outside',\n labelsType: 'value',\n} satisfies Partial<PieChartProps>;\n\nconst varsResolver = createVarsResolver<PieChartFactory>(\n (theme, { strokeColor, labelColor, withLabels, size, labelsPosition }) => ({\n root: {\n '--chart-stroke-color': strokeColor ? getThemeColor(strokeColor, theme) : undefined,\n '--chart-labels-color': labelColor ? getThemeColor(labelColor, theme) : undefined,\n '--chart-size': withLabels && labelsPosition === 'outside' ? rem(size! + 80) : rem(size),\n },\n })\n);\n\nconst getLabelValue = (\n labelsType: PieChartProps['labelsType'],\n value: number | undefined,\n percent: number | undefined,\n valueFormatter?: PieChartProps['valueFormatter']\n) => {\n if (labelsType === 'percent' && typeof percent === 'number') {\n return `${(percent * 100).toFixed(0)}%`;\n }\n\n if (typeof valueFormatter === 'function' && typeof value === 'number') {\n return valueFormatter(value);\n }\n\n return value;\n};\n\nconst getInsideLabel =\n (labelsType: 'value' | 'percent', valueFormatter?: PieChartProps['valueFormatter']): PieLabel =>\n ({ cx, cy, midAngle, innerRadius, outerRadius, value, percent }) => {\n const RADIAN = Math.PI / 180;\n const radius = Number(innerRadius) + (Number(outerRadius) - Number(innerRadius)) * 0.5;\n const x = Number(cx) + radius * Math.cos(-(midAngle || 0) * RADIAN);\n const y = Number(cy) + radius * Math.sin(-(midAngle || 0) * RADIAN);\n\n return (\n <text\n x={x}\n y={y}\n textAnchor={x > Number(cx) ? 'start' : 'end'}\n dominantBaseline=\"central\"\n className={classes.label}\n >\n {getLabelValue(labelsType, Number(value), Number(percent), valueFormatter)}\n </text>\n );\n };\n\nconst getOutsideLabel =\n (labelsType: 'value' | 'percent', valueFormatter?: PieChartProps['valueFormatter']): PieLabel =>\n ({ x, y, cx, cy, percent, value }) => (\n <text\n x={x}\n y={y}\n cx={cx}\n cy={cy}\n textAnchor={x > Number(cx) ? 'start' : 'end'}\n fill=\"var(--chart-labels-color, var(--mantine-color-dimmed))\"\n fontFamily=\"var(--mantine-font-family)\"\n fontSize={12}\n >\n <tspan x={x}>\n {getLabelValue(labelsType, Number(value), Number(percent), valueFormatter)}\n </tspan>\n </text>\n );\n\nexport const PieChart = factory<PieChartFactory>((_props) => {\n const props = useProps('PieChart', defaultProps, _props);\n const {\n classNames,\n className,\n style,\n styles,\n unstyled,\n vars,\n data,\n withTooltip,\n tooltipAnimationDuration,\n tooltipProps,\n pieProps,\n paddingAngle,\n withLabels,\n withLabelsLine,\n size,\n strokeWidth,\n startAngle,\n endAngle,\n tooltipDataSource,\n children,\n pieChartProps,\n labelsPosition,\n valueFormatter,\n labelsType,\n strokeColor,\n attributes,\n cellProps,\n ...others\n } = props;\n\n const theme = useMantineTheme();\n\n const getStyles = useStyles<PieChartFactory>({\n name: 'PieChart',\n classes,\n props,\n className,\n style,\n classNames,\n styles,\n unstyled,\n attributes,\n vars,\n varsResolver,\n });\n\n const { resolvedClassNames, resolvedStyles } = useResolvedStylesApi<PieChartFactory>({\n classNames,\n styles,\n props,\n });\n\n const pieData = data.map((item) => ({\n ...item,\n fill: getThemeColor(item.color, theme),\n stroke: 'var(--chart-stroke-color, var(--mantine-color-body))',\n strokeWidth,\n ...(typeof cellProps === 'function' ? cellProps(item) : cellProps),\n }));\n\n return (\n <Box size={size} {...getStyles('root')} {...others}>\n <ResponsiveContainer>\n <ReChartsPieChart {...pieChartProps}>\n <Pie\n data={pieData as any}\n innerRadius={0}\n outerRadius={size / 2}\n dataKey=\"value\"\n isAnimationActive={false}\n paddingAngle={paddingAngle}\n startAngle={startAngle}\n endAngle={endAngle}\n label={\n withLabels\n ? labelsPosition === 'inside'\n ? getInsideLabel(labelsType || 'value', valueFormatter)\n : getOutsideLabel(labelsType || 'value', valueFormatter)\n : false\n }\n labelLine={\n withLabelsLine && labelsPosition === 'outside'\n ? {\n stroke: 'var(--chart-label-color, var(--mantine-color-dimmed))',\n strokeWidth: 1,\n }\n : false\n }\n {...pieProps}\n />\n\n {withTooltip && (\n <Tooltip\n animationDuration={tooltipAnimationDuration}\n isAnimationActive={false}\n content={({ payload }) => (\n <ChartTooltip\n payload={data}\n classNames={resolvedClassNames}\n styles={resolvedStyles}\n type=\"radial\"\n segmentId={\n tooltipDataSource === 'segment' ? (payload?.[0]?.name as string) : undefined\n }\n valueFormatter={valueFormatter}\n attributes={attributes}\n />\n )}\n {...tooltipProps}\n />\n )}\n\n {children}\n </ReChartsPieChart>\n </ResponsiveContainer>\n </Box>\n );\n});\n\nPieChart.displayName = '@mantine/charts/PieChart';\nPieChart.classes = classes;\nPieChart.varsResolver = varsResolver;\n\nexport namespace PieChart {\n export type Props = PieChartProps;\n export type StylesNames = PieChartStylesNames;\n export type CssVariables = PieChartCssVariables;\n export type Factory = PieChartFactory;\n export type Cell = PieChartCell;\n}\n"],"mappings":";;;;;;;AAmHA,MAAM,eAAe;CACnB,aAAa;CACb,gBAAgB;CAChB,cAAc;CACd,MAAM;CACN,aAAa;CACb,YAAY;CACZ,UAAU;CACV,mBAAmB;CACnB,gBAAgB;CAChB,YAAY;AACd;AAEA,MAAM,eAAe,oBAClB,OAAO,EAAE,aAAa,YAAY,YAAY,MAAM,sBAAsB,EACzE,MAAM;CACJ,wBAAwB,cAAc,cAAc,aAAa,KAAK,IAAI,KAAA;CAC1E,wBAAwB,aAAa,cAAc,YAAY,KAAK,IAAI,KAAA;CACxE,gBAAgB,cAAc,mBAAmB,YAAY,IAAI,O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MACA,aACA,YACA,UACA,mBACA,UACA,eACA,gBACA,gBACA,YACA,aACA,YACA,WACA,GAAG,WACD;CAEJ,MAAM,QAAQ,gBAAgB;CAE9B,MAAM,YAAY,UAA2B;EAC3C,MAAM;EACN,SAAA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;CACF,CAAC;CAED,MAAM,EAAE,oBAAoB,mBAAmB,qBAAsC;EACnF;EACA;EACA;CACF,CAAC;CAED,MAAM,UAAU,KAAK,KAAK,UAAU;EAClC,GAAG;EACH,MAAM,cAAc,KAAK,OAAO,KAAK;EACrC,QAAQ;EACR;EACA,GAAI,OAAO,cAAc,aAAa,UAAU,IAAI,IAAI;CAC1D,EAAE;CAEF,OACE,oBAAC,KAAD;EAAW;EAAM,GAAI,UAAU,MAAM;EAAG,GAAI;YAC1C,oBAAC,qBAAD,EAAA,UACE,qBAACC,UAAD;GAAkB,GAAI;aAAtB;IACE,oBAAC,KAAD;KACE,MAAM;KACN,aAAa;KACb,aAAa,OAAO;KACpB,SAAQ;KACR,mBAAmB;KACL;KACF;KACF;KACV,OACE,aACI,mBAAmB,WACjB,eAAe,cAAc,SAAS,cAAc,IACpD,gBAAgB,cAAc,SAAS,cAAc,IACvD;KAEN,WACE,kBAAkB,mBAAmB,YACjC;MACE,QAAQ;MACR,aAAa;KACf,IACA;KAEN,GAAI;IACL,CAAA;IAEA,eACC,oBAACC,WAAD;KACE,mBAAmB;KACnB,mBAAmB;KACnB,UAAU,EAAE,cACV,oBAAC,cAAD;MACE,SAAS;MACT,YAAY;MACZ,QAAQ;MACR,MAAK;MACL,WACE,sBAAsB,YAAa,UAAU,IAAI,OAAkB,KAAA;MAErD;MACJ;KACb,CAAA;KAEH,GAAI;IACL,CAAA;IAGF;GACe;KACC,CAAA;CAClB,CAAA;AAET,CAAC;AAED,WAAS,cAAc;AACvB,WAAS,UAAUH;AACnB,WAAS,eAAe"}
1
+ {"version":3,"file":"PieChart.mjs","names":["classes","PieChart","ReChartsPieChart","Tooltip"],"sources":["../../src/PieChart/PieChart.tsx"],"sourcesContent":["import {\n Pie,\n PieLabel,\n PieProps,\n PieChart as ReChartsPieChart,\n ResponsiveContainer,\n Tooltip,\n TooltipProps,\n} from 'recharts';\nimport {\n Box,\n BoxProps,\n createVarsResolver,\n ElementProps,\n factory,\n Factory,\n getThemeColor,\n MantineColor,\n rem,\n StylesApiProps,\n useMantineTheme,\n useProps,\n useResolvedStylesApi,\n useStyles,\n} from '@mantine/core';\nimport { ChartTooltip, ChartTooltipStylesNames } from '../ChartTooltip/ChartTooltip';\nimport classes from './PieChart.module.css';\n\nexport interface PieChartCell {\n key?: string | number;\n name: string;\n value: number;\n color: MantineColor;\n}\n\nexport type PieChartStylesNames = 'root' | ChartTooltipStylesNames;\nexport type PieChartCssVariables = {\n root: '--chart-stroke-color' | '--chart-labels-color' | '--chart-size';\n};\n\nexport interface PieChartProps\n extends BoxProps, StylesApiProps<PieChartFactory>, ElementProps<'div'> {\n /** Data used to render chart */\n data: PieChartCell[];\n\n /** Determines whether the tooltip should be displayed when one of the section is hovered @default true */\n withTooltip?: boolean;\n\n /** Tooltip animation duration in ms @default 0 */\n tooltipAnimationDuration?: number;\n\n /** Props passed down to `Tooltip` recharts component */\n tooltipProps?: Omit<TooltipProps<any, any>, 'ref'>;\n\n /** Props passed down to recharts `Pie` component */\n pieProps?: Partial<Omit<PieProps, 'ref'>>;\n\n /** Controls color of the segments stroke, by default depends on color scheme */\n strokeColor?: MantineColor;\n\n /** Controls text color of all labels, white by default */\n labelColor?: MantineColor;\n\n /** Controls padding between segments @default 0 */\n paddingAngle?: number;\n\n /** Determines whether each segment should have associated label @default false */\n withLabels?: boolean;\n\n /** Determines whether segments labels should have lines that connect the segment with the label @default true */\n withLabelsLine?: boolean;\n\n /** Controls chart width and height, height is increased by 40 if `withLabels` prop is set. Cannot be less than `thickness`. @default 80 */\n size?: number;\n\n /** Controls width of segments stroke @default 1 */\n strokeWidth?: number;\n\n /** Controls angle at which chart starts. Set to `180` to render the chart as semicircle. @default 0 */\n startAngle?: number;\n\n /** Controls angle at which charts ends. Set to `0` to render the chart as semicircle. @default 360 */\n endAngle?: number;\n\n /** Determines which data is displayed in the tooltip. `'all'` – display all values, `'segment'` – display only hovered segment. @default 'all' */\n tooltipDataSource?: 'segment' | 'all';\n\n /** Additional elements rendered inside `PieChart` component */\n children?: React.ReactNode;\n\n /** Props passed down to recharts `PieChart` component */\n pieChartProps?: React.ComponentProps<typeof ReChartsPieChart>;\n\n /** Controls labels position relative to the segment @default 'outside' */\n labelsPosition?: 'inside' | 'outside';\n\n /** Type of labels to display @default 'value' */\n labelsType?: 'value' | 'percent' | 'name';\n\n /** A function to format values inside the tooltip */\n valueFormatter?: (value: number) => string;\n\n /** Props passed down to each segment of the chart */\n cellProps?:\n | ((series: PieChartCell) => Partial<Omit<React.SVGProps<SVGElement>, 'ref'>>)\n | Partial<Omit<React.SVGProps<SVGElement>, 'ref'>>;\n}\n\nexport type PieChartFactory = Factory<{\n props: PieChartProps;\n ref: HTMLDivElement;\n stylesNames: PieChartStylesNames;\n vars: PieChartCssVariables;\n}>;\n\nconst defaultProps = {\n withTooltip: false,\n withLabelsLine: true,\n paddingAngle: 0,\n size: 160,\n strokeWidth: 1,\n startAngle: 0,\n endAngle: 360,\n tooltipDataSource: 'all',\n labelsPosition: 'outside',\n labelsType: 'value',\n} satisfies Partial<PieChartProps>;\n\nconst varsResolver = createVarsResolver<PieChartFactory>(\n (theme, { strokeColor, labelColor, withLabels, size, labelsPosition }) => ({\n root: {\n '--chart-stroke-color': strokeColor ? getThemeColor(strokeColor, theme) : undefined,\n '--chart-labels-color': labelColor ? getThemeColor(labelColor, theme) : undefined,\n '--chart-size': withLabels && labelsPosition === 'outside' ? rem(size! + 80) : rem(size),\n },\n })\n);\n\nconst getLabelValue = (\n labelsType: PieChartProps['labelsType'],\n value: number | undefined,\n percent: number | undefined,\n name: string | undefined,\n valueFormatter?: PieChartProps['valueFormatter']\n) => {\n if (labelsType === 'name') {\n return name;\n }\n\n if (labelsType === 'percent' && typeof percent === 'number') {\n return `${(percent * 100).toFixed(0)}%`;\n }\n\n if (typeof valueFormatter === 'function' && typeof value === 'number') {\n return valueFormatter(value);\n }\n\n return value;\n};\n\nconst getInsideLabel =\n (\n labelsType: 'value' | 'percent' | 'name',\n valueFormatter?: PieChartProps['valueFormatter']\n ): PieLabel =>\n ({ cx, cy, midAngle, innerRadius, outerRadius, value, percent, name }) => {\n const RADIAN = Math.PI / 180;\n const radius = Number(innerRadius) + (Number(outerRadius) - Number(innerRadius)) * 0.5;\n const x = Number(cx) + radius * Math.cos(-(midAngle || 0) * RADIAN);\n const y = Number(cy) + radius * Math.sin(-(midAngle || 0) * RADIAN);\n\n return (\n <text\n x={x}\n y={y}\n textAnchor={x > Number(cx) ? 'start' : 'end'}\n dominantBaseline=\"central\"\n className={classes.label}\n >\n {getLabelValue(labelsType, Number(value), Number(percent), name as string, valueFormatter)}\n </text>\n );\n };\n\nconst getOutsideLabel =\n (\n labelsType: 'value' | 'percent' | 'name',\n valueFormatter?: PieChartProps['valueFormatter']\n ): PieLabel =>\n ({ x, y, cx, cy, percent, value, name }) => (\n <text\n x={x}\n y={y}\n cx={cx}\n cy={cy}\n textAnchor={x > Number(cx) ? 'start' : 'end'}\n fill=\"var(--chart-labels-color, var(--mantine-color-dimmed))\"\n fontFamily=\"var(--mantine-font-family)\"\n fontSize={12}\n >\n <tspan x={x}>\n {getLabelValue(labelsType, Number(value), Number(percent), name as string, valueFormatter)}\n </tspan>\n </text>\n );\n\nexport const PieChart = factory<PieChartFactory>((_props) => {\n const props = useProps('PieChart', defaultProps, _props);\n const {\n classNames,\n className,\n style,\n styles,\n unstyled,\n vars,\n data,\n withTooltip,\n tooltipAnimationDuration,\n tooltipProps,\n pieProps,\n paddingAngle,\n withLabels,\n withLabelsLine,\n size,\n strokeWidth,\n startAngle,\n endAngle,\n tooltipDataSource,\n children,\n pieChartProps,\n labelsPosition,\n valueFormatter,\n labelsType,\n strokeColor,\n attributes,\n cellProps,\n ...others\n } = props;\n\n const theme = useMantineTheme();\n\n const getStyles = useStyles<PieChartFactory>({\n name: 'PieChart',\n classes,\n props,\n className,\n style,\n classNames,\n styles,\n unstyled,\n attributes,\n vars,\n varsResolver,\n });\n\n const { resolvedClassNames, resolvedStyles } = useResolvedStylesApi<PieChartFactory>({\n classNames,\n styles,\n props,\n });\n\n const pieData = data.map((item) => ({\n ...item,\n fill: getThemeColor(item.color, theme),\n stroke: 'var(--chart-stroke-color, var(--mantine-color-body))',\n strokeWidth,\n ...(typeof cellProps === 'function' ? cellProps(item) : cellProps),\n }));\n\n return (\n <Box size={size} {...getStyles('root')} {...others}>\n <ResponsiveContainer>\n <ReChartsPieChart {...pieChartProps}>\n <Pie\n data={pieData as any}\n innerRadius={0}\n outerRadius={size / 2}\n dataKey=\"value\"\n isAnimationActive={false}\n paddingAngle={paddingAngle}\n startAngle={startAngle}\n endAngle={endAngle}\n label={\n withLabels\n ? labelsPosition === 'inside'\n ? getInsideLabel(labelsType || 'value', valueFormatter)\n : getOutsideLabel(labelsType || 'value', valueFormatter)\n : false\n }\n labelLine={\n withLabelsLine && labelsPosition === 'outside'\n ? {\n stroke: 'var(--chart-label-color, var(--mantine-color-dimmed))',\n strokeWidth: 1,\n }\n : false\n }\n {...pieProps}\n />\n\n {withTooltip && (\n <Tooltip\n animationDuration={tooltipAnimationDuration}\n isAnimationActive={false}\n content={({ payload }) => (\n <ChartTooltip\n payload={data}\n classNames={resolvedClassNames}\n styles={resolvedStyles}\n type=\"radial\"\n segmentId={\n tooltipDataSource === 'segment' ? (payload?.[0]?.name as string) : undefined\n }\n valueFormatter={valueFormatter}\n attributes={attributes}\n />\n )}\n {...tooltipProps}\n />\n )}\n\n {children}\n </ReChartsPieChart>\n </ResponsiveContainer>\n </Box>\n );\n});\n\nPieChart.displayName = '@mantine/charts/PieChart';\nPieChart.classes = classes;\nPieChart.varsResolver = varsResolver;\n\nexport namespace PieChart {\n export type Props = PieChartProps;\n export type StylesNames = PieChartStylesNames;\n export type CssVariables = PieChartCssVariables;\n export type Factory = PieChartFactory;\n export type Cell = PieChartCell;\n}\n"],"mappings":";;;;;;;AAmHA,MAAM,eAAe;CACnB,aAAa;CACb,gBAAgB;CAChB,cAAc;CACd,MAAM;CACN,aAAa;CACb,YAAY;CACZ,UAAU;CACV,mBAAmB;CACnB,gBAAgB;CAChB,YAAY;AACd;AAEA,MAAM,eAAe,oBAClB,OAAO,EAAE,aAAa,YAAY,YAAY,MAAM,sBAAsB,EACzE,MAAM;CACJ,wBAAwB,cAAc,cAAc,aAAa,KAAK,IAAI,KAAA;CAC1E,wBAAwB,aAAa,cAAc,YAAY,KAAK,IAAI,KAAA;CACxE,gBAAgB,cAAc,mBAAmB,YAAY,IAAI,OAAQ,EAAE,IAAI,IAAI,IAAI;AACzF,EACF,EACF;AAEA,MAAM,iBACJ,YACA,OACA,SACA,MACA,mBACG;CACH,IAAI,eAAe,QACjB,OAAO;CAGT,IAAI,eAAe,aAAa,OAAO,YAAY,UACjD,OAAO,IAAI,UAAU,KAAK,QAAQ,CAAC,EAAE;CAGvC,IAAI,OAAO,mBAAmB,cAAc,OAAO,UAAU,UAC3D,OAAO,eAAe,KAAK;CAG7B,OAAO;AACT;AAEA,MAAM,kBAEF,YACA,oBAED,EAAE,IAAI,IAAI,UAAU,aAAa,aAAa,OAAO,SAAS,WAAW;CACxE,MAAM,SAAS,KAAK,KAAK;CACzB,MAAM,SAAS,OAAO,WAAW,KAAK,OAAO,WAAW,IAAI,OAAO,WAAW,KAAK;CACnF,MAAM,IAAI,OAAO,EAAE,IAAI,SAAS,KAAK,IAAI,EAAE,YAAY,KAAK,MAAM;CAGlE,OACE,oBAAC,QAAD;EACK;EACH,GALM,OAAO,EAAE,IAAI,SAAS,KAAK,IAAI,EAAE,YAAY,KAAK,MAAM;EAM9D,YAAY,IAAI,OAAO,EAAE,IAAI,UAAU;EACvC,kBAAiB;EACjB,WAAWA,wBAAQ;YAElB,cAAc,YAAY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,eAAe,cAAc,SAAS,cAAc,IACpD,gBAAgB,cAAc,SAAS,cAAc,IACvD;KAEN,WACE,kBAAkB,mBAAmB,YACjC;MACE,QAAQ;MACR,aAAa;KACf,IACA;KAEN,GAAI;IACL,CAAA;IAEA,eACC,oBAACC,WAAD;KACE,mBAAmB;KACnB,mBAAmB;KACnB,UAAU,EAAE,cACV,oBAAC,cAAD;MACE,SAAS;MACT,YAAY;MACZ,QAAQ;MACR,MAAK;MACL,WACE,sBAAsB,YAAa,UAAU,IAAI,OAAkB,KAAA;MAErD;MACJ;KACb,CAAA;KAEH,GAAI;IACL,CAAA;IAGF;GACe;KACC,CAAA;CAClB,CAAA;AAET,CAAC;AAED,WAAS,cAAc;AACvB,WAAS,UAAUH;AACnB,WAAS,eAAe"}
@@ -1 +1 @@
1
- {"version":3,"file":"PieChart.module.mjs","names":[],"sources":["../../src/PieChart/PieChart.module.css"],"sourcesContent":[".root {\n min-height: var(--chart-size, auto);\n height: var(--chart-size, auto);\n width: var(--chart-size, auto);\n min-width: var(--chart-size, auto);\n\n & :where(*) {\n outline: 0;\n }\n}\n"],"mappings":""}
1
+ {"version":3,"file":"PieChart.module.mjs","names":[],"sources":["../../src/PieChart/PieChart.module.css"],"sourcesContent":[".root {\n min-height: var(--chart-size, auto);\n height: var(--chart-size, auto);\n width: var(--chart-size, auto);\n min-width: var(--chart-size, auto);\n\n & :where(*) {\n outline: 0;\n }\n\n & :where(:global(.recharts-surface)) {\n overflow: visible;\n }\n}\n"],"mappings":""}
@@ -50,7 +50,7 @@ export interface DonutChartProps extends BoxProps, StylesApiProps<DonutChartFact
50
50
  /** Props passed down to recharts `PieChart` component */
51
51
  pieChartProps?: React.ComponentProps<typeof ReChartsPieChart>;
52
52
  /** Type of labels to display, `'value'` by default */
53
- labelsType?: 'value' | 'percent';
53
+ labelsType?: 'value' | 'percent' | 'name';
54
54
  /** A function to format values inside the tooltip */
55
55
  valueFormatter?: (value: number) => string;
56
56
  /** Props passed down to each segment of the chart */
@@ -49,7 +49,7 @@ export interface PieChartProps extends BoxProps, StylesApiProps<PieChartFactory>
49
49
  /** Controls labels position relative to the segment @default 'outside' */
50
50
  labelsPosition?: 'inside' | 'outside';
51
51
  /** Type of labels to display @default 'value' */
52
- labelsType?: 'value' | 'percent';
52
+ labelsType?: 'value' | 'percent' | 'name';
53
53
  /** A function to format values inside the tooltip */
54
54
  valueFormatter?: (value: number) => string;
55
55
  /** Props passed down to each segment of the chart */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mantine/charts",
3
- "version": "9.2.2",
3
+ "version": "9.3.1",
4
4
  "description": "Charts components built with recharts and Mantine",
5
5
  "homepage": "https://mantine.dev/",
6
6
  "license": "MIT",
@@ -35,8 +35,8 @@
35
35
  "directory": "packages/@mantine/charts"
36
36
  },
37
37
  "peerDependencies": {
38
- "@mantine/core": "9.2.2",
39
- "@mantine/hooks": "9.2.2",
38
+ "@mantine/core": "9.3.1",
39
+ "@mantine/hooks": "9.3.1",
40
40
  "react": "^19.2.0",
41
41
  "react-dom": "^19.2.0",
42
42
  "recharts": ">=3.2.1"
package/styles.css CHANGED
@@ -201,6 +201,10 @@
201
201
  outline: 0;
202
202
  }
203
203
 
204
+ .m_a410e613 :where(.recharts-surface) {
205
+ overflow: visible;
206
+ }
207
+
204
208
  .m_ddb0bfe3 {
205
209
  fill: var(--mantine-color-text);
206
210
  font-size: var(--mantine-font-size-sm);
@@ -217,6 +221,10 @@
217
221
  outline: 0;
218
222
  }
219
223
 
224
+ .m_cd8943fd :where(.recharts-surface) {
225
+ overflow: visible;
226
+ }
227
+
220
228
  :where([data-mantine-color-scheme='light']) .m_1f271cf7 {
221
229
  --chart-grid-color: rgba(173, 181, 189, 0.6);
222
230
  --chart-text-color: var(--mantine-color-gray-7);
package/styles.layer.css CHANGED
@@ -201,6 +201,10 @@
201
201
  outline: 0;
202
202
  }
203
203
 
204
+ .m_a410e613 :where(.recharts-surface) {
205
+ overflow: visible;
206
+ }
207
+
204
208
  .m_ddb0bfe3 {
205
209
  fill: var(--mantine-color-text);
206
210
  font-size: var(--mantine-font-size-sm);
@@ -217,6 +221,10 @@
217
221
  outline: 0;
218
222
  }
219
223
 
224
+ .m_cd8943fd :where(.recharts-surface) {
225
+ overflow: visible;
226
+ }
227
+
220
228
  :where([data-mantine-color-scheme='light']) .m_1f271cf7 {
221
229
  --chart-grid-color: rgba(173, 181, 189, 0.6);
222
230
  --chart-text-color: var(--mantine-color-gray-7);