Skip to content

Commit a26dc06

Browse files
committed
fixed axis label styling for cost
1 parent 663d76a commit a26dc06

2 files changed

Lines changed: 15 additions & 3 deletions

File tree

src/components/CompareModal.tsx

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -260,6 +260,17 @@ useEffect(() => {
260260
const spiderChartDomain: [number, number] =
261261
activeMetric === 'cost' ? spiderValueDomain : [0, 100];
262262

263+
const formatSpiderTick = useCallback(
264+
(value: number) => {
265+
if (activeMetric === 'cost') {
266+
if (!Number.isFinite(value)) return '$0.000000';
267+
return `$${value.toFixed(6)}`;
268+
}
269+
return value.toFixed(0);
270+
},
271+
[activeMetric]
272+
);
273+
263274
useEffect(() => {
264275
if (activeBarAxis && !currentAxes.includes(activeBarAxis)) {
265276
setActiveBarAxis('');
@@ -730,7 +741,7 @@ useEffect(() => {
730741
</text>
731742
)}
732743
/>
733-
<PolarRadiusAxis domain={spiderValueDomain} tickCount={5} />
744+
<PolarRadiusAxis domain={spiderValueDomain} tickCount={5} tickFormatter={formatSpiderTick} />
734745
{routerIds.map((id, index) => (
735746
<Radar
736747
key={id}

src/components/DifficultyBarPanel.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,9 +95,10 @@ const DifficultyBarPanel: React.FC<DifficultyBarPanelProps> = ({
9595
position="right"
9696
formatter={(value: number) => {
9797
if (metricKey === 'cost') {
98-
return value.toFixed(5);
98+
const safeValue = Number.isFinite(value) ? value : 0;
99+
return `$${safeValue.toFixed(5)}`;
99100
}
100-
return value.toFixed(1);
101+
return Number.isFinite(value) ? value.toFixed(1) : '0.0';
101102
}}
102103
fill="#0f172a"
103104
fontSize={12}

0 commit comments

Comments
 (0)