Skip to content

Commit 584ae5c

Browse files
CopilotBoshen
andcommitted
Fix Recharts v3 LabelList formatter compatibility issues
Co-authored-by: Boshen <1430279+Boshen@users.noreply.github.com>
1 parent 2e0b0ed commit 584ae5c

2 files changed

Lines changed: 5 additions & 4 deletions

File tree

apps/dashboard/src/MinificationBenchmarks.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ function MinificationBenchmarks({}: MinificationBenchmarksProps) {
115115
<LabelList
116116
dataKey='value'
117117
position='top'
118-
formatter={(value: number) => `${value}ms`}
118+
formatter={(label: React.ReactNode) => `${label}ms`}
119119
style={{ fontSize: '12px', fill: '#374151' }}
120120
/>
121121
</Bar>
@@ -160,7 +160,7 @@ function MinificationBenchmarks({}: MinificationBenchmarksProps) {
160160
<LabelList
161161
dataKey='value'
162162
position='top'
163-
formatter={(value: number) => `${value}%`}
163+
formatter={(label: React.ReactNode) => `${label}%`}
164164
style={{ fontSize: '10px', fill: '#374151' }}
165165
/>
166166
</Bar>

apps/dashboard/src/RolldownStats.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,8 @@ function RolldownStats({ selectedMetric, setSelectedMetric }: RolldownStatsProps
169169
<LabelList
170170
dataKey='value'
171171
position='top'
172-
formatter={(value: number) => {
172+
formatter={(label: React.ReactNode) => {
173+
const value = typeof label === 'number' ? label : Number(label) || 0;
173174
if (value === 0) return 'baseline';
174175
return value >= 0 ? `+${formatNumberWithCommas(value)}` : formatNumberWithCommas(value);
175176
}}
@@ -219,7 +220,7 @@ function RolldownStats({ selectedMetric, setSelectedMetric }: RolldownStatsProps
219220
<LabelList
220221
dataKey='value'
221222
position='top'
222-
formatter={(value: number) => `${value}ms`}
223+
formatter={(label: React.ReactNode) => `${label}ms`}
223224
style={{ fontSize: '11px', fill: '#374151' }}
224225
/>
225226
</Bar>

0 commit comments

Comments
 (0)