Skip to content

Commit e0566a9

Browse files
Shorten ECharts and MUI X labels in stats library list (#8666)
## Problem On the `/stats` page, the **libraries** section renders each library's name in a fixed-width 80px column. Two names — `Apache ECharts` and `MUI X Charts` — wrap to two lines, so those rows are taller than the rest and the histogram bars misalign. ## Fix Add a stats-only short-name override so every library label stays on a single line: - `echarts` → **ECharts** - `muix` → **MUI X** The override (`statsLibLabel`) is applied in both the quality-distribution and lines-of-code histograms. The canonical full names from the API (`Apache ECharts`, `MUI X Charts`) are intentionally kept everywhere else — the Libraries page, SEO meta descriptions, and plot-of-the-day — so this is purely a display tweak for the dense stats list. ## Verification - `yarn type-check` ✅ - `yarn lint` ✅ (no new warnings) - `yarn test src/pages/StatsPage.test.tsx` ✅ (10/10) https://claude.ai/code/session_018EdFoKNnMYTnUXBhXWpM9Z --- _Generated by [Claude Code](https://claude.ai/code/session_018EdFoKNnMYTnUXBhXWpM9Z)_ --------- Co-authored-by: Claude <noreply@anthropic.com>
1 parent ab7b1e6 commit e0566a9

2 files changed

Lines changed: 60 additions & 2 deletions

File tree

app/src/pages/StatsPage.test.tsx

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,31 @@ const mockDashboard = {
3535
loc_buckets: { '0-20': 2, '40-60': 5 },
3636
avg_loc: 78,
3737
},
38+
// echarts/muix carry their canonical API names so the StatsPage short-label
39+
// override (statsLibLabel) is exercised: 'Apache ECharts' -> 'ECharts',
40+
// 'MUI X Charts' -> 'MUI X'. matplotlib above asserts the fallback to name.
41+
{
42+
id: 'echarts',
43+
name: 'Apache ECharts',
44+
impl_count: 30,
45+
avg_score: 89,
46+
min_score: 70,
47+
max_score: 96,
48+
score_buckets: { '85-90': 5, '90-95': 8 },
49+
loc_buckets: { '60-80': 4 },
50+
avg_loc: 95,
51+
},
52+
{
53+
id: 'muix',
54+
name: 'MUI X Charts',
55+
impl_count: 8,
56+
avg_score: 88,
57+
min_score: 72,
58+
max_score: 94,
59+
score_buckets: { '85-90': 3, '90-95': 2 },
60+
loc_buckets: { '80-100': 2 },
61+
avg_loc: 110,
62+
},
3863
],
3964
coverage_matrix: [
4065
{
@@ -207,6 +232,26 @@ describe('StatsPage', () => {
207232
expect(screen.getByText('95')).toBeInTheDocument();
208233
});
209234

235+
it('shortens echarts/muix library labels and falls back to name for others', async () => {
236+
mockFetchSuccess();
237+
238+
render(<StatsPage />);
239+
240+
await waitFor(() => {
241+
expect(screen.getByText('libraries')).toBeInTheDocument();
242+
});
243+
244+
// statsLibLabel maps the canonical API names to single-line labels. Each
245+
// appears twice — once in the quality histogram, once in the LOC histogram.
246+
expect(screen.getAllByText('ECharts')).toHaveLength(2);
247+
expect(screen.getAllByText('MUI X')).toHaveLength(2);
248+
// The canonical names must NOT leak through anywhere on the page.
249+
expect(screen.queryByText('Apache ECharts')).not.toBeInTheDocument();
250+
expect(screen.queryByText('MUI X Charts')).not.toBeInTheDocument();
251+
// Libraries without an override still render their plain name (2 histograms).
252+
expect(screen.getAllByText('matplotlib').length).toBeGreaterThanOrEqual(2);
253+
});
254+
210255
it('renders tag distribution categories', async () => {
211256
mockFetchSuccess();
212257

app/src/pages/StatsPage.tsx

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,19 @@ function formatNum(n: number): string {
9999
return n.toLocaleString();
100100
}
101101

102+
// Shorter labels for the fixed-width (80px) library column so every row stays
103+
// on a single line. The API's canonical names ("Apache ECharts", "MUI X
104+
// Charts") wrap to two lines here; we keep the full names elsewhere (Libraries
105+
// page, SEO, plot-of-the-day) and only trim them in this dense histogram list.
106+
const STATS_LIB_LABELS: Record<string, string> = {
107+
echarts: 'ECharts',
108+
muix: 'MUI X',
109+
};
110+
111+
function statsLibLabel(lib: Pick<LibraryStats, 'id' | 'name'>): string {
112+
return STATS_LIB_LABELS[lib.id] ?? lib.name;
113+
}
114+
102115
export function StatsPage() {
103116
const { trackPageview, trackEvent } = useAnalytics();
104117
const { isDark } = useTheme();
@@ -361,7 +374,7 @@ export function StatsPage() {
361374
pb: '2px',
362375
}}
363376
>
364-
{lib.name}
377+
{statsLibLabel(lib)}
365378
</Typography>
366379
<Box
367380
sx={{
@@ -442,7 +455,7 @@ export function StatsPage() {
442455
pb: '2px',
443456
}}
444457
>
445-
{lib.name}
458+
{statsLibLabel(lib)}
446459
</Typography>
447460
<Box
448461
sx={{

0 commit comments

Comments
 (0)