Treemap
Treemap
A treemap.
Usage
from dataviz_mojo import treemap
from dataviz_mojo.plot import save
def main() raises:
var ids: List[String] = ["root", "src", "docs", "main.py", "utils.py", "guide.md", "api.md"]
var parent_ids: List[String] = ["", "root", "root", "src", "src", "docs", "docs"]
var sizes: List[Float64] = [0.0, 0.0, 0.0, 45.0, 20.0, 12.0, 8.0]
var c = treemap(ids, parent_ids, sizes)
save(c, "docs/src/examples/out_treemap.svg")Args:
ids: Every node’s unique id, flattened (not nested), one entry per node.parent_ids: Each node’s parent id (must be a value present inids, or empty for the single root); paired withids[i].values: Each leaf node’s area; an internal node’s area is the sum of its descendants’ – seePlot.encode_hierarchy()’s docstring for the exact rule.theme: Full styling knobs beyond this function’s own parameters (colors, margins, fonts, gridlines, …) – seeTheme’s docstring.width: Pixel width of the returnedPlot(.size()).height: Pixel height of the returnedPlot(.size()).title: The chart’s title, shown above the plot.subtitle: A secondary line shown under the title.x_title: The x-axis caption.y_title: The y-axis caption.