Skip to main content
   ┌──────────────────────┬───────────────┬─────────┐
   │  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, subclassing VizStrategy, 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 dependencyimport codechu_treeviz works without GTK/Qt/Tk
  • Cancel + progress support in build_tree for 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.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

codechu_treeviz-0.2.0.tar.gz (20.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

codechu_treeviz-0.2.0-py3-none-any.whl (19.6 kB view details)

Uploaded Python 3

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

Hashes for codechu_treeviz-0.2.0.tar.gz
Algorithm Hash digest
SHA256 fe87894b1fd7a10311974568be244fcc93d0e3b6e5ae0dac7cb3711a1876379f
MD5 50278b3d82273a1937f2d820710b785e
BLAKE2b-256 c7f84660d283c825e0523f3476ae12afb05b8c42d5c2031e261dfbb855ac5032

See more details on using hashes here.

Provenance

The following attestation bundles were made for codechu_treeviz-0.2.0.tar.gz:

Publisher: release.yml on codechu/treeviz-py

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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

Hashes for codechu_treeviz-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 3c6931cdb2567c25e6f6dd36482f0ba52b7e75764f3e9e15300c739170440b6c
MD5 dbd64d18d48058533f40db2bfdfe47b3
BLAKE2b-256 7f8fbb3c56d32bf8faf9c7f700f70f9c3022ee85606aff4e580e6663ea89cf4a

See more details on using hashes here.

Provenance

The following attestation bundles were made for codechu_treeviz-0.2.0-py3-none-any.whl:

Publisher: release.yml on codechu/treeviz-py

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Release history Release notifications | RSS feed

This release

0.2.0 This release

2 files

0.1.0

2 files

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page