diff --git a/packages/@mantine/charts/src/AreaChart/AreaChart.tsx b/packages/@mantine/charts/src/AreaChart/AreaChart.tsx index 029b6e92987..c7332485a3e 100644 --- a/packages/@mantine/charts/src/AreaChart/AreaChart.tsx +++ b/packages/@mantine/charts/src/AreaChart/AreaChart.tsx @@ -299,7 +299,7 @@ export const AreaChart = factory((_props, ref) => { strokeOpacity={dimmed ? 0.5 : 1} strokeDasharray={item.strokeDasharray} yAxisId={item.yAxisId || 'left'} - label={withPointLabels ? : undefined} + label={withPointLabels ? : undefined} {...(typeof areaProps === 'function' ? areaProps(item) : areaProps)} /> diff --git a/packages/@mantine/charts/src/CompositeChart/CompositeChart.story.tsx b/packages/@mantine/charts/src/CompositeChart/CompositeChart.story.tsx index ea6dca69bf0..a7ab8822c46 100644 --- a/packages/@mantine/charts/src/CompositeChart/CompositeChart.story.tsx +++ b/packages/@mantine/charts/src/CompositeChart/CompositeChart.story.tsx @@ -55,6 +55,7 @@ export function Usage() { ]} withLegend withPointLabels + valueFormatter={(value) => `$ ${value}`} /> ); diff --git a/packages/@mantine/charts/src/CompositeChart/CompositeChart.tsx b/packages/@mantine/charts/src/CompositeChart/CompositeChart.tsx index 68a056724c5..f1e2b5ce73b 100644 --- a/packages/@mantine/charts/src/CompositeChart/CompositeChart.tsx +++ b/packages/@mantine/charts/src/CompositeChart/CompositeChart.tsx @@ -276,7 +276,7 @@ export const CompositeChart = factory((_props, ref) => { type={curveType} strokeDasharray={item.strokeDasharray} yAxisId={item.yAxisId || 'left'} - label={withPointLabels ? : undefined} + label={withPointLabels ? : undefined} {...(typeof lineProps === 'function' ? lineProps(item) : lineProps)} /> ); @@ -322,7 +322,7 @@ export const CompositeChart = factory((_props, ref) => { strokeOpacity={dimmed ? 0.5 : 1} strokeDasharray={item.strokeDasharray} yAxisId={item.yAxisId || 'left'} - label={withPointLabels ? : undefined} + label={withPointLabels ? : undefined} {...(typeof areaProps === 'function' ? areaProps(item) : areaProps)} /> ); diff --git a/packages/@mantine/charts/src/LineChart/LineChart.story.tsx b/packages/@mantine/charts/src/LineChart/LineChart.story.tsx index 203bd9ec24e..e00fc6c5b19 100644 --- a/packages/@mantine/charts/src/LineChart/LineChart.story.tsx +++ b/packages/@mantine/charts/src/LineChart/LineChart.story.tsx @@ -69,6 +69,7 @@ export function Usage() { { name: 'Oranges', color: 'blue.6' }, { name: 'Tomatoes', color: 'teal.6' }, ]} + valueFormatter={(value) => `$ ${value}`} withLegend withPointLabels /> diff --git a/packages/@mantine/charts/src/LineChart/LineChart.tsx b/packages/@mantine/charts/src/LineChart/LineChart.tsx index cb3374b105e..f87c941f669 100644 --- a/packages/@mantine/charts/src/LineChart/LineChart.tsx +++ b/packages/@mantine/charts/src/LineChart/LineChart.tsx @@ -282,7 +282,7 @@ export const LineChart = factory((_props, ref) => { type={curveType} strokeDasharray={item.strokeDasharray} yAxisId={item.yAxisId || 'left'} - label={withPointLabels ? : undefined} + label={withPointLabels ? : undefined} {...(typeof lineProps === 'function' ? lineProps(item) : lineProps)} /> ); diff --git a/packages/@mantine/charts/src/PointLabel/PointLabel.tsx b/packages/@mantine/charts/src/PointLabel/PointLabel.tsx index 7d1f9c6d4fa..295b5c716d6 100644 --- a/packages/@mantine/charts/src/PointLabel/PointLabel.tsx +++ b/packages/@mantine/charts/src/PointLabel/PointLabel.tsx @@ -2,9 +2,10 @@ interface PointLabelProps { x?: number; y?: number; value?: number; + valueFormatter?: (value: number) => string; } -export function PointLabel({ x, y, value }: PointLabelProps) { +export function PointLabel({ x, y, value, valueFormatter }: PointLabelProps) { return ( - {value} + {valueFormatter ? valueFormatter(value!) : value} );