Skip to content
commit-766c8d6756a1

Interactive treemap

Weighted hierarchies shown as nested areas for broad branch-size comparison.

Purpose
Explore weighted hierarchies with area for leaves and branch totals.
Use when
Relative size within a recursive structure is more important than precise comparison.
Avoid when
Deep nesting or exact values must be compared; use a tree and table.
Equivalent data
An adjacent table preserves node paths, parents, totals, leaf values, and classes.
Exact hierarchy and values
PathParentValueClass
d1 / f1d11000file
d11000directory
d2 / f1d2100file
d2 / f2d2300file
d2 / f3d2200file
d2600directory
d3 / f0d38file
d3 / f1d35file
d3 / f2d312file
d3 / f3d39file
d3 / f4d36file
d3 / f5d313file
d3 / f6d310file
d3 / f7d37file
d3 / f8d314file
d3 / f9d311file
d3 / f10d38file
d3 / f11d35file
d3 / f12d312file
d3 / f13d39file
d3 / f14d36file
d3 / f15d313file
d3 / f16d310file
d3 / f17d37file
d3 / f18d314file
d3 / f19d311file
d3 / f20d38file
d3 / f21d35file
d3 / f22d312file
d3 / f23d39file
d3 / f24d36file
d3 / f25d313file
d3 / f26d310file
d3 / f27d37file
d3 / f28d314file
d3 / f29d311file
d3 / f30d38file
d3 / f31d35file
d3 / f32d312file
d3 / f33d39file
d3 / f34d36file
d3 / f35d313file
d3 / f36d310file
d3 / f37d37file
d3 / f38d314file
d3 / f39d311file
d3380directory
f1450file
Usage Example
@interactivetreemap.Treemap(interactivetreemap.Config{
  Label: "Basic treemap example",
  Caption: "File system usage in KB. Select a directory; use the breadcrumb to return.",
  Nodes: []*interactivetreemap.Node{
    {Name: "d1", Class: "directory", Children: []*interactivetreemap.Node{
      {Name: "f1", Value: 1000, Class: "file"},
    }},
    {Name: "d2", Class: "directory", Children: []*interactivetreemap.Node{
      {Name: "f1", Value: 100}, {Name: "f2", Value: 300}, {Name: "f3", Value: 200},
    }},
    {Name: "d3", Class: "directory", Children: deterministicFiles},
    {Name: "f1", Value: 450, Class: "file"},
  },
  Navigation: interactivetreemap.NavigationDrillDown,
  Roam: interactivetreemap.RoamEnabled,
  LabelOptions: &chart.LabelOptions{Show: chart.Bool(true), Position: "inside"},
  UpperLabel: &chart.LabelOptions{Show: chart.Bool(true)},
  Breadcrumb: &interactivetreemap.Breadcrumb{Show: chart.Bool(true)},
  NodeStyle: interactivetreemap.NodeStyle{BorderWidth: 1, GapWidth: 1},
  LeafDepth: chart.Int(1),
  Width: "100%",
  Height: "500px",
})

Hierarchy values

Leaf values determine branch area. Use the table for exact totals and paths; drill-down is only a visual exploration aid.

Go API

v0.0.1

The examples above cover behavior and composition. pkg.go.dev is the canonical reference for exported types, functions, methods, and Go documentation.

github.com/araihu/goshtoso-charts/components/interactive/treemap

Enabled, disabled, hidden, and omitted wrapper behavior, controls, export, and client transitions are shared by every chart. Review chart controls, then compare static/vector and interactive capabilities.

Open v0.0.1 API