Tree
Tree
A tree diagram.
Usage
from dataviz_mojo import tree
from dataviz_mojo.plot import save
def main() raises:
var ids: List[String] = [
"CEO", "Engineering", "Sales", "Backend", "Frontend", "Enterprise", "SMB",
]
var parent_ids: List[String] = ["", "CEO", "CEO", "Engineering", "Engineering", "Sales", "Sales"]
var values: List[Float64] = [0.0, 0.0, 0.0, 1.0, 1.0, 1.0, 1.0]
var c = tree(ids, parent_ids, values)
save(c, "docs/src/examples/out_tree.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 magnitude (unused bytree()’s own layout, but still validated non-negative – seePlot. encode_hierarchy()’s docstring).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.