{"id":13831990,"url":"https://github.com/nikolaydubina/treemap","last_synced_at":"2025-04-09T23:14:00.535Z","repository":{"id":40737066,"uuid":"434580767","full_name":"nikolaydubina/treemap","owner":"nikolaydubina","description":"🍬 Pretty Treemaps","archived":false,"fork":false,"pushed_at":"2025-03-04T13:05:21.000Z","size":6168,"stargazers_count":158,"open_issues_count":11,"forks_count":3,"subscribers_count":6,"default_branch":"main","last_synced_at":"2025-04-09T23:13:54.314Z","etag":null,"topics":["command-line-tool","data-visualization","graph","heatmap","tree"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/nikolaydubina.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":"CITATION.cff","codeowners":".github/CODEOWNERS","security":"SECURITY.md","support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"github":"nikolaydubina"}},"created_at":"2021-12-03T12:01:16.000Z","updated_at":"2025-03-28T08:36:33.000Z","dependencies_parsed_at":"2024-01-15T15:44:25.915Z","dependency_job_id":"11530000-13d6-445d-93c5-69bed8976838","html_url":"https://github.com/nikolaydubina/treemap","commit_stats":null,"previous_names":[],"tags_count":11,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nikolaydubina%2Ftreemap","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nikolaydubina%2Ftreemap/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nikolaydubina%2Ftreemap/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nikolaydubina%2Ftreemap/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/nikolaydubina","download_url":"https://codeload.github.com/nikolaydubina/treemap/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248125589,"owners_count":21051770,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["command-line-tool","data-visualization","graph","heatmap","tree"],"created_at":"2024-08-04T10:01:46.821Z","updated_at":"2025-04-09T23:14:00.515Z","avatar_url":"https://github.com/nikolaydubina.png","language":"Go","funding_links":["https://github.com/sponsors/nikolaydubina"],"categories":["Go"],"sub_categories":[],"readme":"# 🍬 Pretty Treemaps\n\n\u003e _Looking to run this for Go coverage? Check https://github.com/nikolaydubina/go-cover-treemap_\n\n[![Go Reference](https://pkg.go.dev/badge/github.com/nikolaydubina/treemap.svg)](https://pkg.go.dev/github.com/nikolaydubina/treemap)\n[![codecov](https://codecov.io/gh/nikolaydubina/treemap/branch/main/graph/badge.svg?token=h3S894POFO)](https://codecov.io/gh/nikolaydubina/treemap)\n[![Go Report Card](https://goreportcard.com/badge/github.com/nikolaydubina/treemap)](https://goreportcard.com/report/github.com/nikolaydubina/treemap)\n[![OpenSSF Scorecard](https://api.securityscorecards.dev/projects/github.com/nikolaydubina/treemap/badge)](https://securityscorecards.dev/viewer/?uri=github.com/nikolaydubina/treemap)\n\nUses \"Squarified Treemaps\" (Mark Bruls, Kees Huizing, and Jarke J. van Wijk., 2000) algorithm.\n\n```bash\n$ go install github.com/nikolaydubina/treemap/cmd/treemap@latest\n$ echo '\nAfrica/Algeria,33333216,72\nAfrica/Angola,12420476,42\nAfrica/Benin,8078314,56\n...\n' | treemap \u003e out.svg\n```\n![example](./docs/gapminder-2007-population-life.svg)\n\nAdjusting size\n```bash\n$ ... | treemap -w 1080 -h 360 \u003e out.svg\n```\n![example-narrow](./docs/gapminder-2007-population-life-1080x360.svg)\n\n```bash\n$ ... | treemap -w 1080 -h 1080 \u003e out.svg\n```\n![example-square](./docs/gapminder-2007-population-life-1080x1080.svg)\n\nImputing heat\n```bash\n$ ... | treemap -impute-heat \u003e out.svg\n```\n![example-narrow](./docs/gapminder-2007-population-life-impute-heat.svg)\n\nDifferent colorscheme\n```bash\n$ ... | treemap -color RdYlGn \u003e out.svg\n```\n![example-RdYlGn](./docs/gapminder-2007-population-life-RdYlGn.svg)\n\n\nTree-Hue coloring when there is no heat\n```\n$ ... | treemap -color balanced \u003e out.svg\n```\n![example-balanced](./docs/gapminder-2007-population-life-balanced.svg)\n\nWithout color\n```bash\n$ ... | treemap -color none \u003e out.svg\n```\n![example-no-color](./docs/gapminder-2007-population-life-nocolor.svg)\n\n## Format\n\nSize and heat is optional.\n\n```\n\u003c/ delimitered path\u003e,\u003csize\u003e,\u003cheat\u003e\n```\n\n## Algorithms\n\n* `Squarified` algorithm for treemap layout problem. This is very common algorithm used in Plotly and most of visualization packages. _\"Squarified Treemaps\", Mark Bruls, Kees Huizing, and Jarke J. van Wijk, 2000_\n* `Tree-Hue Color` algorithm for generating colors for nodes in treemap. The idea is to represent hierarchical structure by recursively painting similar hue to subtrees. _Nikolay Dubina, 2021_\n\n\n## Contributions\n\nWelcomed!\n\n## References\n\n* Plotly treemaps: https://plotly.com/python/treemaps/\n* go-colorful: https://github.com/lucasb-eyer/go-colorful\n* D3 treemap is using Squerified: https://github.com/d3/d3-hierarchy\n* Interactive treemap: https://github.com/vasturiano/treemap-chart\n* Squerified in Rust: https://github.com/bacongobbler/treemap-rs\n* Squerified in JavaScript: https://github.com/clementbat/treemap\n* Squerified in Python: https://github.com/laserson/squarify\n* Treemap Go tool: https://github.com/willpoint/treemap\n* Plotly color scales: https://plotly.com/python/builtin-colorscales\n* Plotly color scales source: https://github.com/plotly/plotly.py/blob/master/packages/python/plotly/_plotly_utils/colors/colorbrewer.py\n* Colorbrewer project, that is used in Plotly: http://colorbrewer2.org\n\n## Appendix A: Long Roots\n\nWhen roots have one child multiple times it takes extra vertical space, which is very useful for narrow final dimensions.\n\n![example-long-roots](./docs/long-roots-long-roots.svg)\n\nCan collapse them into one node\n![example-long-roots-collapse](./docs/long-roots.svg)\n\nLong roots without collapsing somewhere deep inside\n\n![](./docs/hugo-binsize-nocolor-large-long-roots.svg)\n\nLong roots with collapsing somewhere deep inside\n\n![](./docs/hugo-binsize-nocolor-large.svg)\n\n## Appendix B: Less Illustrative Examples\n\nLarge dimensions and large tree (e.g. `github.com/golang/go`)\n```bash\n$ ... | treemap -w 4096 -h 4096 \u003e out.svg\n```\n![example-large](./docs/find-src-go-dir.svg)\n\n## Appendix C: Known Issues\n\n### The entire treemap is a black box when viewed from Jenkins\n\nIt's convenient to create treemap svg reports in a Jenkins jobs, because you can\nbrowse the job's \"artifacts\" from your browser.  However, out of the box, Jenkin's\n[Content Security Policy](https://www.jenkins.io/doc/book/security/configuring-content-security-policy/)\nprevents inline styles from being applied. Instead of your treemap, you'll see\na giant black rectangle.\n\nIf you look at the javascript console in the developer tools, you will see:\n```\nRefused to apply inline style because it violates the following\nContent Security Policy directive: \"style-src 'self'\".\n```\n\nYou can relax Jenkin's CSP rules by following the examples at:\n* [Jenkins error - Blocked script execution in \u003cURL\u003e. because the document's frame is sandboxed and the 'allow-scripts' permission is not set](https://stackoverflow.com/questions/34315723/jenkins-error-blocked-script-execution-in-url-because-the-documents-frame)\n* [https://stackoverflow.com/questions/35783964/jenkins-html-publisher-plugin-no-css-is-displayed-when-report-is-viewed-in-j](https://stackoverflow.com/questions/35783964/jenkins-html-publisher-plugin-no-css-is-displayed-when-report-is-viewed-in-j)\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnikolaydubina%2Ftreemap","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnikolaydubina%2Ftreemap","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnikolaydubina%2Ftreemap/lists"}