Skip to content

Commit ef2941f

Browse files
committed
Track dollar formatting helper
1 parent 6cd9bce commit ef2941f

3 files changed

Lines changed: 12 additions & 2 deletions

File tree

app/src/components/ScatterPlot.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import {
99
ReferenceLine,
1010
} from "recharts";
1111
import type { BenchData } from "../App";
12-
import { formatDollars } from "../lib/format";
12+
import { formatDollars } from "../format";
1313
import { MODEL_COLORS, MODEL_LABELS, MODEL_ORDER } from "../modelMeta";
1414

1515
function CustomTooltip({ active, payload }: { active?: boolean; payload?: Array<{ payload: Record<string, unknown> }> }) {

app/src/components/ScenarioExplorer.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { useState, useMemo } from "react";
22
import type { BenchData } from "../App";
3-
import { formatDollars } from "../lib/format";
3+
import { formatDollars } from "../format";
44
import { MODEL_COLORS, MODEL_LABELS, MODEL_ORDER } from "../modelMeta";
55

66
type PromptByVariable = Record<string, { tool?: string; json?: string }>;

app/src/format.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
export function formatDollars(value: number): string {
2+
const rounded = Math.round(value);
3+
4+
if (Object.is(rounded, -0) || rounded === 0) {
5+
return "$0";
6+
}
7+
8+
const abs = Math.abs(rounded).toLocaleString();
9+
return rounded < 0 ? `-$${abs}` : `$${abs}`;
10+
}

0 commit comments

Comments
 (0)