Skip to content

Commit 72e7640

Browse files
clstaudtcursoragent
andcommitted
fix(dashboard): polish revenue chart issues found in UI smoke
Three fixes from screenshotting the chart in every granularity: - Sub-thousand bar labels showed a pointless decimal (€903.6) and crowded their neighbours; compact notation has no suffix to shorten below a thousand, so drop the fraction digits there. - Year view shaded alternating bars, because every bucket is its own year there — skip the year banding entirely in that view. - Cap bar width so the three-bar year view doesn't draw slabs, and don't repeat the year on both ends of a single-year window label. Co-authored-by: Cursor <cursoragent@cursor.com>
1 parent 10416ce commit 72e7640

1 file changed

Lines changed: 11 additions & 3 deletions

File tree

ui/src/components/dashboard/RevenueChart.tsx

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -93,9 +93,12 @@ export function RevenueChart() {
9393
}
9494

9595
const currency = data?.currency || "EUR";
96+
// Below a thousand there is no compact suffix to shorten the number, so a
97+
// decimal there is just noise: €904, not €903.6.
9698
const fmtCompact = useCallback(
9799
(v: number) => new Intl.NumberFormat(undefined, {
98-
style: "currency", currency, notation: "compact", maximumFractionDigits: 1,
100+
style: "currency", currency, notation: "compact",
101+
maximumFractionDigits: Math.abs(v) < 1000 ? 0 : 1,
99102
}).format(v),
100103
[currency],
101104
);
@@ -133,20 +136,24 @@ export function RevenueChart() {
133136
return indices;
134137
}, [rows]);
135138

139+
// Grouping buckets by year is only meaningful when a year spans several of
140+
// them — in year view every bucket is its own year.
136141
const yearBands = useMemo(() => {
142+
if (granularity === "year") return [];
137143
const bands: { year: number; count: number }[] = [];
138144
for (const row of rows) {
139145
const last = bands[bands.length - 1];
140146
if (last && last.year === row.year) last.count += 1;
141147
else bands.push({ year: row.year, count: 1 });
142148
}
143149
return bands;
144-
}, [rows]);
150+
}, [rows, granularity]);
145151

146152
const windowLabel = useMemo(() => {
147153
if (!rows.length) return "";
148154
const first = rows[0], last = rows[rows.length - 1];
149155
if (granularity === "year") return first.year === last.year ? first.label : `${first.label}${last.label}`;
156+
if (first.year === last.year) return `${first.label}${last.label} ${first.year}`;
150157
return `${first.label} ${first.year}${last.label} ${last.year}`;
151158
}, [rows, granularity]);
152159

@@ -254,6 +261,7 @@ export function RevenueChart() {
254261
fill={s.color}
255262
fillOpacity={s.opacity}
256263
radius={isTop ? [3, 3, 0, 0] : [0, 0, 0, 0]}
264+
maxBarSize={72}
257265
isAnimationActive={false}
258266
>
259267
{isTop && (
@@ -276,7 +284,7 @@ export function RevenueChart() {
276284
<div
277285
key={`${band.year}-${i}`}
278286
style={{ flexGrow: band.count }}
279-
className={`text-[11px] text-tertiary text-center ${i > 0 ? "border-l border-border" : ""}`}
287+
className={`text-[11px] text-secondary text-center ${i > 0 ? "border-l border-border" : ""}`}
280288
>
281289
{band.year}
282290
</div>

0 commit comments

Comments
 (0)