Refactor treegroup= and chart=tree features.

treegroup= is now split into three separate transforms: treegroup,
finishtree, and cracktree.

The new treegroup just does exactly the same thing as group=, except it
always produces exactly one output column, _tree, which is formed by
join('|') of all the key columns.  The resulting string is essentially the
pathname of the object inside the tree.  Because of this change, you can now
provide your own trees more easily, just by producing data with | separators
in it.  You can also combine two or more such columns (if you're careful!)
using treegroup.

finishtree takes a key list where the last element is expected to be a
treegroup column.  It fills in any missing points in the hierarchy.  So if
the treegroup has rows 'x|y|z' and 'p|q|r', it adds new rows 'x|y', 'x',
'p|q', 'p', and ''.

cracktree splits the _tree column into two columns, _id and _parent, which
is the format expected by chart=tree.  It also makes sure only one object
points directly at the root (an arbitrary rule enforced by gviz.TreeChart)
by renaming all references to '' into 'ALL' and then pointing 'ALL' at ''.

Finally, chart=tree now auto-runs finishtree and cracktree if the first
column is named _tree.  This means queries that use
treegroup=whatever&chart=tree will continue to work.
1 file changed