Treemap, sunburst, icicle, slice-and-dice, and flame graph layouts for hierarchical data. Pure logic, no GUI dependency.
Project description
┌──────────────────────┬───────────────┬─────────┐
│ codechu-treeviz │ ┌─────────┐ │ ┌───┐ │
│ ┌────────┬───────┐ │ │ photos │ │ │ . │ │
│ │ videos │ music │ │ ├────┬────┤ │ └───┘ │
│ ├────────┴───────┤ │ │ .. │ .. │ │ cache │
│ │ documents │ │ └────┴────┘ │ │
│ └────────────────┘ │ pictures │ logs │
└──────────────────────┴───────────────┴─────────┘
Squarified treemap + sunburst layouts — rectangles and arcs, you render.
codechu-treeviz
Squarified treemap + sunburst layout algorithms for hierarchical data. Pure Python, no GUI dependency — gives you rectangles and arcs; you render them with whatever toolkit (Cairo, SVG, Matplotlib, browser canvas).
pip install codechu-treeviz
What it gives you
- Squarified treemap layout — Bruls/Huijsen/van Wijk algorithm, aspect-ratio optimized
- Sunburst layout — circular hierarchical chart with concentric rings
- TreeNode builder — turn a
(path, size)list into a hierarchical tree - Hit testing — given (x, y), find the node at that position
- "Other" bundling — small slivers grouped into a single "(N items)" bucket
- Color palette — perceptually balanced fill colors
- Pure stdlib + Python
math, zero deps
Example
from codechu_treeviz import build_tree, TreemapStrategy
# 1. Walk a directory into a TreeNode
root = build_tree("~/Pictures")
# 2. Lay it out — writes (x, y, w, h) onto every node.rect
strategy = TreemapStrategy(min_frac=0.005)
strategy.layout(root, w=800, h=600)
# 3. Render however you like (Cairo, SVG, browser canvas, …)
for child in root.children:
if child.rect is not None:
x, y, w, h = child.rect
print(child.path, (x, y, w, h))
# 4. Hit test for hover/click
node = strategy.hit_test(root, x=120, y=80)
Swap TreemapStrategy() for SunburstStrategy() and the same code
renders a radial chart (rects become 7-tuples — see the API docs).
Documentation
- docs/API.md — full API reference (TreeNode, SizeProvider, VizStrategy, layout functions, hit-test, colors)
- docs/RECIPES.md — patterns: disk-usage
treemap, sunburst from a directory tree, custom
SizeProvider, subclassingVizStrategy, hit-test plumbing
Design
- No rendering — algorithms produce geometry; rendering is your job (Cairo, SVG, PNG via Pillow, browser canvas via JSON over HTTP, etc.)
- No GUI dependency —
import codechu_treevizworks without GTK/Qt/Tk - Cancel + progress support in
build_treefor long inputs - Bounded depth (
TREEMAP_MAX_DEPTH = 40) protects against pathological nesting
Use cases
- Disk usage visualizer (the original)
- Source-code size / dependency tree explorer
- Package size analyzer (npm, PyPI, Cargo)
- Time-tracking dashboard (project / task / subtask hierarchy)
- Any "where did the bytes / hours / records go?" question
License
MIT — see LICENSE.
Part of Codechu.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file codechu_treeviz-0.2.0.tar.gz.
File metadata
- Download URL: codechu_treeviz-0.2.0.tar.gz
- Upload date:
- Size: 20.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
fe87894b1fd7a10311974568be244fcc93d0e3b6e5ae0dac7cb3711a1876379f
|
|
| MD5 |
50278b3d82273a1937f2d820710b785e
|
|
| BLAKE2b-256 |
c7f84660d283c825e0523f3476ae12afb05b8c42d5c2031e261dfbb855ac5032
|
Provenance
The following attestation bundles were made for codechu_treeviz-0.2.0.tar.gz:
Publisher:
release.yml on codechu/treeviz-py
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
codechu_treeviz-0.2.0.tar.gz -
Subject digest:
fe87894b1fd7a10311974568be244fcc93d0e3b6e5ae0dac7cb3711a1876379f - Sigstore transparency entry: 1582034514
- Sigstore integration time:
-
Permalink:
codechu/treeviz-py@f661dfc0c02daba77f233c12ecb75d2b1ca42b7e -
Branch / Tag:
refs/tags/v0.2.0 - Owner: https://github.com/codechu
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@f661dfc0c02daba77f233c12ecb75d2b1ca42b7e -
Trigger Event:
push
-
Statement type:
File details
Details for the file codechu_treeviz-0.2.0-py3-none-any.whl.
File metadata
- Download URL: codechu_treeviz-0.2.0-py3-none-any.whl
- Upload date:
- Size: 19.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3c6931cdb2567c25e6f6dd36482f0ba52b7e75764f3e9e15300c739170440b6c
|
|
| MD5 |
dbd64d18d48058533f40db2bfdfe47b3
|
|
| BLAKE2b-256 |
7f8fbb3c56d32bf8faf9c7f700f70f9c3022ee85606aff4e580e6663ea89cf4a
|
Provenance
The following attestation bundles were made for codechu_treeviz-0.2.0-py3-none-any.whl:
Publisher:
release.yml on codechu/treeviz-py
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
codechu_treeviz-0.2.0-py3-none-any.whl -
Subject digest:
3c6931cdb2567c25e6f6dd36482f0ba52b7e75764f3e9e15300c739170440b6c - Sigstore transparency entry: 1582034581
- Sigstore integration time:
-
Permalink:
codechu/treeviz-py@f661dfc0c02daba77f233c12ecb75d2b1ca42b7e -
Branch / Tag:
refs/tags/v0.2.0 - Owner: https://github.com/codechu
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@f661dfc0c02daba77f233c12ecb75d2b1ca42b7e -
Trigger Event:
push
-
Statement type: