refactor(ui): convert entity usage and usage page charts to shadcn/recharts - #32729
Conversation
…charts Swap the tremor BarChart/DonutChart render sites in EntityUsage, SpendByProvider, TopKeyView, TopModelView, KeyModelUsageView and UsagePageView to the shared shadcn/recharts wrappers. Convert the two sole-chart Daily Spend cards and the KeyModelUsageView card to the shadcn Card primitives. Close the donut parity gap with strictly additive optional DonutChart props: showLabel/label render a center total (tremor showed valueFormatter(sum) by default) and startAngle/endAngle forward to the Pie so both provider donuts keep tremor's clockwise-from-12 layout. Defaults preserve the previous wrapper behavior. DailyData and two site-local row types move from interface to type alias so they satisfy the wrappers' Record<string, unknown> constraint; interfaces lack implicit index signatures. Tests now assert on real recharts output: bar/sector counts, cyan fills, axis labels, donut center totals, and the TopKeyView bar-click drill-down into the key info modal. The dead tremor chart mocks in UsagePageView.test.tsx are removed and lint metrics/suppressions are regenerated for the dropped tremor imports.
Greptile SummaryThis PR is the second stage of the shadcn/recharts migration for the usage pages, converting 9 tremor chart render sites across 6 files to the shared wrappers established in the foundation PR (#32668). The
Confidence Score: 5/5Safe to merge — this is a well-scoped chart library swap with no changes to data flow, API calls, or business logic. Every changed file is a UI-layer refactor: import swaps, card primitive upgrades, and three strictly additive props on DonutChart whose defaults keep existing callers rendering identically. The interface-to-type-alias conversions are structurally equivalent and required for the wrappers' generic constraint. New tests exercise real recharts SVG output and the previously flagged concerns have both been addressed with regression tests. No files require special attention.
|
| Filename | Overview |
|---|---|
| ui/litellm-dashboard/src/components/shared/charts/donut_chart.tsx | Adds showLabel/label and startAngle/endAngle props; formattedCategoryTotal helper is correctly guarded inside the showCenterLabel branch so valueFormatter is never called when the label is hidden. |
| ui/litellm-dashboard/src/components/UsagePage/components/EntityUsage/EntityUsage.tsx | Swaps tremor BarChart/DonutChart imports for shared wrappers, migrates the Daily Spend card to shadcn primitives, and threads showLabel/startAngle/endAngle into the provider donut; no functional changes to data or tooltips. |
| ui/litellm-dashboard/src/components/UsagePage/components/KeyModelUsageView.tsx | Full card migrated from tremor Card/Title to shadcn primitives with CardAction hosting the Table/Chart toggle; BarChart import swapped. |
| ui/litellm-dashboard/src/components/UsagePage/components/UsagePageView.tsx | Daily Spend card migrated to shadcn primitives; BarChart import swapped; tremor Card/Title for that card removed. |
| ui/litellm-dashboard/src/components/shared/charts/donut_chart.test.tsx | Adds tests for hidden label default, formatter-not-called guard, explicit label override, empty data guard, and 3 o'clock vs 12 o'clock startAngle geometry. |
Reviews (2): Last reviewed commit: "fix(ui): compute donut center label only..." | Re-trigger Greptile
…itellm_shadcn_charts_entity_usage # Conflicts: # ui/litellm-dashboard/eslint-metrics.json
…Usage renders as a card title
|
@greptileai re review. Both P2s addressed: the donut center label total is now computed by a helper invoked only inside the showCenterLabel render branch, with a regression test asserting the valueFormatter is never called when the label is hidden; the Model Usage assertion now checks the text renders inside a [data-slot="card-title"] element instead of a bare getByText. Also merged latest litellm_internal_staging (picked up the eslint-metrics.json removal and the merged sibling chart PRs) |
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
0710cf2
into
litellm_internal_staging
Relevant issues
Linear ticket
Pre-Submission checklist
Please complete all items before asking a LiteLLM maintainer to review your PR
@greptileaito re-request a review after pushing changes)Delays in PR merge?
If you're seeing a delay in your PR being merged, ping the LiteLLM Team on Slack (#pr-review).
Screenshots / Proof of Fix
QA against live dev servers, comparing each chart side by side with the pre-change UI (screenshots to follow in a comment):
python litellm/proxy/proxy_cli.py --config litellm/proxy/dev_config.yaml) and the dashboard dev server (npm run devin ui/litellm-dashboard)for i in 1 2 3; do curl -s http://localhost:4000/v1/chat/completions -H "Authorization: Bearer sk-..." -H "Content-Type: application/json" -d '{"model": "gpt-5.2", "messages": [{"role": "user", "content": "hi"}]}'; doneType
🧹 Refactoring
Changes
Stage PR in the charts track of the shadcn migration (foundation: #32668). Converts the entity usage cluster, 9 tremor chart render sites across 6 files, to the shared shadcn/recharts wrappers: EntityUsage (Daily Spend bars, Spend Per Entity vertical bars, Provider Usage donut), SpendByProvider (donut), TopKeyView (the app's only interactive chart; its onValueChange drill-down into the key info modal keeps working and is now covered by a test), TopModelView, KeyModelUsageView and UsagePageView (Daily Spend and Top Models bars). Each site is the mechanical import swap the foundation was built for; data, props, heights, colors and the inline custom tooltips are unchanged. The two sole-chart Daily Spend cards and the KeyModelUsageView card also move from tremor Card/Title to the shadcn Card primitives, while everything else on these pages stays tremor until its own stage
The shared DonutChart gains strictly additive optional props to close a known parity gap: tremor donuts default to a center label showing valueFormatter(sum of the category) and draw from startAngle 90 to endAngle -270, and both donuts on these pages show a center dollar total today. New
showLabel/labelandstartAngle/endAngleprops forward that behavior to recharts; the defaults (label off, 0/360) preserve the wrapper's previous rendering so sibling stage PRs branching from the same base are unaffected. Both provider donuts passshowLabel startAngle={90} endAngle={-270}DailyData and two site-local row types change from interface to type alias. Interfaces carry no implicit index signature, so they fail the wrappers'
Record<string, unknown>data constraint while structurally identical type aliases satisfy itTests assert on real recharts SVG through the foundation's jsdom ResizeObserver setup: bar and sector counts, cyan fills, axis labels, donut center totals, slice angle geometry in the wrapper test, and a click on a TopKeyView bar fetching key info and opening the modal. UsagePageView.test.tsx drops its now-dead tremor BarChart/DonutChart mocks so the real wrappers render, a few assertions move to getAllByText where chart axis labels now legitimately duplicate table text, eslint-suppressions.json loses the stale no-restricted-imports entries for the files that no longer import tremor, and eslint-metrics.json is regenerated