Platform module tree

A module tree shows how code is organised into containing modules. That gives a developer a map of the codebase before they need the finer detail of individual dependencies. The screenshot is from Fission's chart gallery.

What the chart is for

Containment is not dependency. A presentation module can depend on a domain module without being its child. Keep this chart for module organisation and use a graph for cross-module calls or imports.

Data model

Each TreemapNode contains its child modules. The numeric values are structural placeholders here; they do not count lines of code or assign importance to a module. TreeSeries draws the parent-child relation supplied by those records.

Rust API

Setting
Type
Meaning
TreeSeries::data
Vec<TreemapNode>
Supplies the roots of the hierarchy.
TreemapNode::children
Vec<TreemapNode>
Supplies each node's next level.
TreemapNode::value
f32
Carries the numeric value associated with the node.
Chart::series
Vec<Series>
Presents the hierarchy without Cartesian axes.

Example

use fission::charts::{Chart, TreeSeries, TreemapNode};

let nodes = vec![TreemapNode {
    name: "Platform".into(),
    value: 2.0,
    children: vec![
        TreemapNode {
            name: "Domain".into(),
            value: 1.0,
            children: vec![],
        },
        TreemapNode {
            name: "Presentation".into(),
            value: 1.0,
            children: vec![],
        },
    ],
}];

let chart = Chart::new()
    .title("Platform module organisation")
    .series(vec![TreeSeries::new("Modules")
        .data(nodes)
        .radial(false)
        .into()]);

Authoring from a Fission component

The parent prepares the hierarchy and its loading or error state. The chart component only presents the records supplied to it.
use fission::prelude::*;
use fission::charts::{Chart, TreeSeries, TreemapNode};

// The parent resolves display labels from its translation bundles.
fission_component! {
    pub PlatformModuleTreeChart<()> {
        props {
            chart_title: String,
            series_label: String,
            nodes: Vec<TreemapNode>,
        }
    }
    view(hierarchy, _state, _cx) =>
        Chart(
            title: Some(hierarchy.chart_title.clone()),
            series: vec![TreeSeries::new(&hierarchy.series_label)
                .data(hierarchy.nodes.clone())
                .radial(false)
                .into()],
        )
}

Testing and accessibility

Check empty modules, deep nesting and repeated short names. Use qualified names when otherwise identical labels would prevent a developer from locating the module in source.
Tags: tree, platform.