new·The score now tells you which way it movedA brain's exam only ever grows: its own material writes questions, and so does every question a real caller asked and did not get answered. The score is a percentage over that growing set, so a brain that learned more could post a smaller number — and this week three did. One of them answered two MORE questions than the week before and showed eighteen points less. Printed as a single percentage, that reads as decline to a reader and as punishment to anyone who contributes material.all news →
mozg.beta
Sign in

D3 · all subjects

d3-hierarchy/stratify

8 notes, read out of this brain and free to use. Each one was extracted from a source and is re-checked against its exam.

d3.stratify configuration

Stratify operator configuration methods: stratify.id (set node id accessor), stratify.parentId (set parent node id accessor), stratify.path (set path accessor).

d3.stratify() constructor

Creates a new stratify operator with default settings. Use d3.stratify() to construct a new instance that can be configured and called on tabular data.

stratify(data) generates hierarchy from tabular data

The stratify operator is called with an array of data objects to generate a new hierarchy. It converts tabular relationships into a hierarchical structure suitable for hierarchical layouts like tree.

stratify.id(id) accessor for node identity

Sets or gets the id accessor function. The accessor is invoked for each data element with arguments (d, i) and must return a string to identify nodes. The id must be unique for non-leaf nodes. Null and empty string are treated as undefined. Defaults to function id(d) { return d.id; }

stratify.parentId(parentId) accessor for parent relationships

Sets or gets the parent id accessor function. The accessor is invoked for each data element with arguments (d, i) and must return a string identifying the parent node. The root node's parent id should be undefined; null and empty string are treated as undefined. There must be exactly one root node and no circular relationships. Defaults to function parentId(d) { return d.parentId; }

stratify.path(path) accessor for slash-delimited hierarchy

Sets or gets the path accessor function. When set, the id and parentId accessors are ignored. Instead, a unix-like hierarchy is computed from slash-delimited strings returned by the path accessor, automatically imputing parent nodes and ids as necessary. Defaults to undefined.

stratify example with id and parentId accessors

This example converts a tabular array of {name, parent} objects into a hierarchy: const root = d3.stratify() .id((d) => d.name) .parentId((d) => d.parent) (table);

stratify example with path accessor for file system hierarchy

This example creates a hierarchy from unix-like file paths: const paths = [ "axes.js", "channel.js", "legends/ramp.js", "marks/density.js", "scales/diverging.js" ]; const root = d3.stratify().path((d) => d)(paths);

Give your agent this brain