┌──────────────────────┬───────────────┬─────────┐
│ 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.
Metadata
Release files for codechu-treeviz 0.2.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| codechu_treeviz-0.2.0.tar.gz | 20.1 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| codechu_treeviz-0.2.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 39.8 kB
Release files / codechu_treeviz-0.2.0.tar.gz
| Download URL | codechu_treeviz-0.2.0.tar.gz |
|---|---|
| Size | 20.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
fe87894b1fd7a10311974568be244fcc93d0e3b6e5ae0dac7cb3711a1876379f
|
|
BLAKE2b-256 checksum How to use checksums |
c7f84660d283c825e0523f3476ae12afb05b8c42d5c2031e261dfbb855ac5032
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.12
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on May 20, 2026.
Transparency logRelease files / codechu_treeviz-0.2.0-py3-none-any.whl
| Download URL | codechu_treeviz-0.2.0-py3-none-any.whl |
|---|---|
| Size | 19.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
3c6931cdb2567c25e6f6dd36482f0ba52b7e75764f3e9e15300c739170440b6c
|
|
BLAKE2b-256 checksum How to use checksums |
7f8fbb3c56d32bf8faf9c7f700f70f9c3022ee85606aff4e580e6663ea89cf4a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.12
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on May 20, 2026.
Transparency log