fix(ui): usage charts clip Y-axis labels at large token/request counts - #27464
Conversation
…abels aren't clipped
The Total Tokens Over Time and Total Requests Over Time AreaCharts on the
Usage page used Tremor's default yAxisWidth (~56 px), which is too narrow
once totals pass the hundred-million mark — leading digits of labels like
"100.00M" / "4500.00M" got clipped against the chart edge. The requests
chart was worse: it formatted with toLocaleString(), so billion-scale
request counts produced "1,000,000,000" (13 chars) and overflowed
immediately.
Fix in two places so neither alone has to carry the whole margin:
- activity_metrics.tsx: add yAxisWidth={80} to both AreaCharts, and
switch the requests chart to the shared valueFormatter so it uses the
same compact k/M/B suffixes as the tokens chart.
- value_formatters.tsx: add a >= 1e9 branch to valueFormatter /
valueFormatterSpend that emits a "B" suffix (4.50B, $4.50B), keeping
every formatted label at most 7 chars.
Co-Authored-By: Claude Opus 4 (1M context) <noreply@anthropic.com>
Greptile SummaryThis PR fixes Y-axis label clipping on the Usage page's Total Tokens Over Time and Total Requests Over Time AreaCharts by widening the gutter (
Confidence Score: 5/5Safe to merge — changes are scoped to two UI formatter/chart files with no logic regressions. Both changes are purely presentational: widening the Y-axis gutter and capping formatter output length. The formatter logic is straightforward and only affects how numbers are displayed in charts, so the blast radius of any mistake is limited to visual rendering with no data or API impact. No files require special attention.
|
| Filename | Overview |
|---|---|
| ui/litellm-dashboard/src/components/UsagePage/utils/value_formatters.tsx | Adds a billion (B) suffix branch to both valueFormatter and valueFormatterSpend, and applies toFixed(2) to the million branch of valueFormatterSpend; kilo branch in valueFormatterSpend still omits toFixed, producing variable-length output. |
| ui/litellm-dashboard/src/components/activity_metrics.tsx | Adds yAxisWidth={80} to the Total Tokens and Total Requests AreaCharts, and switches the requests chart from toLocaleString() to the shared valueFormatter for compact suffixed output. |
Reviews (2): Last reviewed commit: "Update ui/litellm-dashboard/src/componen..." | Re-trigger Greptile
…atters.tsx Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com>
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
|
@krrish-berri-2 @Sameerlite Could you take a look at this PR when you get a chance? |
|
@yassin-berriai @mateo-berri @Sameerlite gentle nudge on this one. On the Usage page, the Total Tokens Over Time and Total Requests Over Time charts clip their Y-axis labels once the counts get large; the gutter is too narrow and big numbers overflow, so the axis becomes unreadable at exactly the scale where the chart matters most. This widens the gutter and shortens the labels so they stay legible. It's been open since early May with no maintainer eyes yet. Could you take a look? |
PR: fix(ui): usage charts clip Y-axis labels at large token/request counts
Relevant issues
Pre-Submission checklist
@greptileaiand get Confidence Score ≥ 4/5 before requesting maintainer reviewType
🐛 Bug Fix
Changes
Root cause
On the Usage page, the Total Tokens Over Time and Total Requests Over
Time AreaCharts in
activity_metrics.tsxrely on Tremor's defaultyAxisWidth(≈ 56 px). At realistic production scale the formatted labelsare wider than that gutter, so the leading digits get clipped:
valueFormatterreturns strings like"4500.00M"(8 chars) once totalspass the billion mark — the leading
4is hidden."100.00M"(7 chars) the leading1is already cut off in thereporter's screenshot.
number.toLocaleString(), which produces"1,000,000,000"(13 chars) forbillion-scale request counts and overflows the gutter immediately.
For comparison, every other chart in the same file (e.g. lines 86–94, 764–772)
already sets an explicit
yAxisWidth={72}/{80}. These two AreaCharts werethe only ones missing it.
Reproduce:
tokens (or seed test data above ~1 × 10⁸).
the left-hand digit of each Y-axis tick (
100.00M,4500.00M, …) isclipped against the chart edge.
Fix
Two complementary changes — widen the gutter and keep the label string
short — so neither alone has to carry the whole margin:
activity_metrics.tsx— addyAxisWidth={80}to both AreaCharts, andswitch the requests chart from
toLocaleString()to the sharedvalueFormatterso request counts also use compactk/M/Bsuffixes.
value_formatters.tsx— extendvalueFormatterandvalueFormatterSpendwith a>= 1_000_000_000branch that emits aBsuffix.
4_500_000_000now formats as"4.50B"(5 chars) instead of"4500.00M"(8 chars), which is shorter and more conventional.<AreaChart ... categories={["metrics.prompt_tokens", "metrics.completion_tokens", "metrics.total_tokens"]} valueFormatter={valueFormatter} + yAxisWidth={80} /> <AreaChart ... categories={["metrics.successful_requests", "metrics.failed_requests"]} - valueFormatter={(number: number) => number.toLocaleString()} + valueFormatter={valueFormatter} + yAxisWidth={80} />export function valueFormatter(number: number) { + if (number >= 1_000_000_000) { + return (number / 1_000_000_000).toFixed(2) + "B"; + } if (number >= 1_000_000) { return (number / 1_000_000).toFixed(2) + "M"; } ... }After the fix the longest label
valueFormattercan produce is 7 chars(
999.99k,999.99M,999.99B), well under the new 80 px gutter.Files changed
ui/litellm-dashboard/src/components/activity_metrics.tsxyAxisWidth={80}to both Usage-page AreaCharts; switch the requests chart to the sharedvalueFormatter.ui/litellm-dashboard/src/components/UsagePage/utils/value_formatters.tsxB(billion) suffix branch tovalueFormatterandvalueFormatterSpend.