Layout for a hierarchical tree. A stack tree layout. Output is x, y, x2, y2 coordinates for .qp.rect.

Useful for weighted trees (trace timelines, etc). When used in polar coordinates, becomes a Sunburst Chart.


  • [`expand] expand children to take entire width of the parent.
  • [`filldepth] depth at which children are assigned a colour (default 4).
  • [`colours] a list of 0xrrggbb colours to use when filling.


Name Type Description
t table table of a tree - should contain a scalar id column and a nested child column pointing to other ids
id symbol id column
children symbol children column
weight symbol weight (numeric) column
o dict | null options


Name Type Description
<returns> dict Node and edges layout table
<returns>.nodes table
<returns>.edges table

Example: Basic layout

      t: .gg.cheat.i.assemble[];
      t: update w:count each children from t;

      rr: .qp.treestack.layout[t;`id;`children;`w;``expand!(::;1b)];



Example: Adding a fill and alpha scale

     .qp.theme[.gg.theme.blank , ``legend_use!(::;0b)]
         .qp.s.geom[``colour!(::;0xffffff)] ,
         .qp.s.aes[`fill`alpha; `id`d__] ,
         .qp.s.scale[`fill; rr[`id]!rr`fill__]


Example: Sunburst chart

         .qp.s.geom[``colour!(::;0xffffff)] ,
         .qp.s.aes[`fill`alpha; `id`d__] ,
         .qp.s.scale[`fill; rr[`id]!rr`fill__] ,