https://github.com/dhvcc/github-contribution-treemap-generator
GitHub contribution treemap SVG generator
https://github.com/dhvcc/github-contribution-treemap-generator
Last synced: 10 months ago
JSON representation
GitHub contribution treemap SVG generator
- Host: GitHub
- URL: https://github.com/dhvcc/github-contribution-treemap-generator
- Owner: dhvcc
- License: gpl-3.0
- Created: 2025-08-18T14:53:36.000Z (12 months ago)
- Default Branch: main
- Last Pushed: 2025-08-19T19:33:14.000Z (12 months ago)
- Last Synced: 2025-08-19T21:26:42.987Z (12 months ago)
- Language: TypeScript
- Homepage:
- Size: 73.2 KB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# GitHub Contribution Treemap Generator
GitHub contributions as an SVG treemap. Built with [d3](https://github.com/d3/d3)
It counts merged PRs you authored across repos, sizes by your contributions, and colors by repo stars.

[](https://github.com/dhvcc/rss-parser/blob/master/LICENSE)

## Install
```bash
npm i -g @dhvcc/github-contribution-treemap-generator
# for project install, use
npm i @dhvcc/github-contribution-treemap-generator
```
## Quick start (CLI)
```bash
export GITHUB_TOKEN=YOUR_TOKEN
github-contribution-treemap-generator -o treemap.svg
```
- Without `-o`, SVG goes to stdout
- If you don't pass `--username`, it auto-detects from the token
## Usage
```man
Usage: github-contribution-treemap-generator [options]
GitHub contribution treemap SVG generator
Options:
-V, --version output the version number
-t, --token GitHub personal access token (env: GITHUB_TOKEN)
-u, --username GitHub username (auto-detected if not provided) (env: GITHUB_USERNAME)
-o, --output Output file path (default: stdout)
-w, --width SVG width in pixels (default: 465, env: WIDTH)
--height SVG height in pixels (default: 165, env: HEIGHT)
--exclude-repos Comma-separated list of repos to exclude (default: none) (default: "", env: EXCLUDE_REPOS)
--exclude-owners Comma-separated list of owners to hide (default: none) (default: "", env: EXCLUDE_OWNERS)
--timeout GitHub API timeout in milliseconds (default: 15000, env: GITHUB_TIMEOUT_MS)
--github-base-url GitHub GraphQL API base URL (default: "https://api.github.com/graphql", env: GITHUB_BASE_URL)
-q, --quiet Suppress non-error logs
-h, --help display help for command
Environment variables:
GITHUB_TOKEN Required unless --token is provided
GITHUB_USERNAME Username, otherwise auto-detected from token
EXCLUDE_REPOS Comma-separated repos to exclude (default: none)
EXCLUDE_OWNERS Comma-separated owners to hide (default: none)
WIDTH SVG width in pixels (default 465)
HEIGHT SVG height in pixels (default 165)
GITHUB_TIMEOUT_MS GitHub API timeout in ms (default 15000)
GITHUB_BASE_URL GitHub GraphQL API base URL (default https://api.github.com/graphql)
QUIET=0 Suppress non-error logs
```
## Examples
```bash
# Save to file
github-contribution-treemap-generator -t $GITHUB_TOKEN -o treemap.svg
# Custom size
github-contribution-treemap-generator -t $GITHUB_TOKEN -w 800 --height 400 -o treemap.svg
# Hide my org and exclude a repo
github-contribution-treemap-generator -t $GITHUB_TOKEN -H my-org -e owner/repo,another-repo -o treemap.svg
# Print to stdout (pipe to file)
github-contribution-treemap-generator -t $GITHUB_TOKEN > treemap.svg
```
## Use as a library
```ts
import { generateContributionTreemap } from '@dhvcc/github-contribution-treemap-generator';
const svg = await generateContributionTreemap(process.env.GITHUB_TOKEN!, {
username: 'your-username',
width: 800,
height: 400,
excludeRepos: ['owner/repo', 'name-only'],
hideOwners: ['some-org'],
});
```
## Notes
- Public data only. A basic token is fine for public repos
- Uses GitHub GraphQL search for merged PRs you authored (`is:pr is:merged author:`)
## License
[GPLv3](./LICENSE)