How to Use the Top Languages Card with Different Layouts (Donut, Pie) in GitHub Readme Stats
You can switch the visual style of your top languages card by adding &layout=<name> to the API URL, choosing from normal, compact, donut, donut-vertical, or pie.
The top languages card in the anuraghazra/github-readme-stats repository renders your most-used programming languages as an SVG image. By default, it displays a vertical list with progress bars, but the underlying renderer supports five distinct visual layouts. This guide explains how to invoke each layout and how the rendering pipeline processes your selection.
Available Top Languages Card Layouts
The API recognizes five layout values, each handled by a dedicated renderer in src/cards/top-languages.js:
normal(default) – Vertical list with language names, colored dots, and horizontal progress bars.compact– Dense vertical list without progress bars; defaults to showing 6 languages.donut– Circular donut chart with a legend positioned to the right.donut-vertical– Larger donut chart with the legend stacked underneath.pie– Classic pie chart with angular slices representing language proportions.
Each layout automatically calculates its own SVG height via dedicated helpers such as calculateDonutLayoutHeight and calculatePieLayoutHeight.
How to Change the Layout
Pass the layout query parameter to the /api/top-langs endpoint. The validation logic in api/top-langs.js (lines 81‑84) ensures only the five supported values are accepted.
Markdown Examples for Each Layout
<!-- Normal (default) -->

<!-- Compact -->

<!-- Donut -->

<!-- Donut-vertical -->

<!-- Pie -->

You can combine layout with other parameters such as theme, langs_count, or hide:

Technical Implementation Details
The layout selection flows through three main stages:
-
Parameter validation (
api/top-langs.js) – The incominglayoutvalue is checked against the allowed array["compact", "normal", "donut", "donut-vertical", "pie"]. -
Default language count (
src/cards/top-languages.js) – The functiongetDefaultLanguagesCountByLayoutassigns different defaults per layout (e.g., 6 forcompact, 5 fordonut) to ensure optimal visual balance. -
Rendering branch (
src/cards/top-languages.js, lines 390‑426) – TherenderTopLanguagesfunction switches to the appropriate renderer:renderPieLayout– Uses polar-to-cartesian math (polarToCartesian,cartesianToPolar) to generate SVG path data for pie slices.renderDonutLayout/renderDonutVerticalLayout– InvokecreateDonutPathsto build the circular chart and position legends horizontally or vertically.renderCompactLayout– Omits progress bars and compresses row height.renderNormalLayout– Full list with progress bars.
Each layout calculates its own height via specific helpers (e.g., calculatePieLayoutHeight) to prevent clipping.
Customizing Layout Behavior
Overriding Default Language Counts
While getDefaultLanguagesCountByLayout sets sensible defaults (e.g., 5 languages for donut charts), you can override this with langs_count:

Hiding Progress Bars
Setting hide_progress=true forces the renderer to use renderCompactLayout regardless of the specified layout, because progress bars only render in the normal layout.
Displaying Raw Bytes
Add stats_format=bytes to show absolute byte counts instead of percentages. This works across all layouts including pie and donut.
Summary
- The top languages card supports five layouts:
normal,compact,donut,donut-vertical, andpie. - Specify your choice via the
layoutquery parameter; validation occurs inapi/top-langs.js. - Each layout has dedicated rendering functions in
src/cards/top-languages.js(e.g.,renderPieLayout,renderDonutLayout). - Default language counts vary by layout to optimize visual presentation, but you can override with
langs_count. - Combine
layoutwiththeme,hide, orstats_formatfor further customization.
Frequently Asked Questions
What layouts are available for the top languages card?
The API supports five layouts: normal (default list with progress bars), compact (dense list without bars), donut (circular chart with side legend), donut-vertical (larger donut with bottom legend), and pie (classic pie chart with angular slices). Each layout is rendered by a specific function in src/cards/top-languages.js.
How do I switch to the donut or pie layout?
Append &layout=donut or &layout=pie to your API URL. For example:

The validation logic in api/top-langs.js ensures only supported layout values are processed, and renderTopLanguages routes the request to renderDonutLayout or renderPieLayout accordingly.
Why does my compact layout show fewer languages by default?
The getDefaultLanguagesCountByLayout function assigns different defaults per layout to optimize visual balance. The compact layout defaults to 6 languages, while donut defaults to 5. You can override this behavior by adding langs_count=10 (or any number) to your query string.
Can I combine layout options with themes and other parameters?
Yes. The layout parameter works independently of theme, hide, langs_count, and stats_format. For example, to render a radical-themed donut chart showing 8 languages with raw byte stats:

Have a question about this repo?
These articles cover the highlights, but your codebase questions are specific. Give your agent direct access to the source. Share this with your agent to get started:
curl -s "https://instagit.com/install.md" Maintain an open-source project? Get it listed too →