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/pack

10 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.pack configuration

Pack layout configuration methods: pack.radius (set radius accessor), pack.size (set layout size), pack.padding (set padding).

d3.packSiblings and packEnclose

Circle packing functions: d3.packSiblings (pack array of circles with siblings), d3.packEnclose (enclose array of circles).

pack() creates a new pack layout

pack() creates a new pack layout with default settings. The default size is [1, 1], the default radius accessor is null, and the default padding accessor is zero.

pack(root) lays out hierarchy and assigns x, y, r properties

pack(root) lays out the specified root hierarchy and assigns the following properties on root and its descendants: node.x is the x-coordinate of the circle's center, node.y is the y-coordinate of the circle's center, and node.r is the radius of the circle. You must call root.sum before passing the hierarchy to the pack layout, and you should call root.sort to order the hierarchy before computing the layout.

pack.radius() accessor for circle radius

pack.radius(radius) sets or gets the pack layout's radius accessor. If radius is specified, it sets the radius accessor to the specified function and returns the pack layout. If radius is not specified, it returns the current radius accessor, which defaults to null. When the radius accessor is null, the radius of each leaf circle is derived from the leaf node.value and scaled proportionally to fit the layout size. When the radius accessor is not null, the radius of each leaf circle is specified exactly by the function.

pack.size() sets layout dimensions

pack.size(size) sets or gets the pack layout's size. If size is specified, it sets the size to a two-element array [width, height] and returns the pack layout. If size is not specified, it returns the current size, which defaults to [1, 1].

pack.padding() accessor for circle separation

pack.padding(padding) sets or gets the pack layout's padding accessor. If padding is specified, it sets the padding accessor to the specified number or function and returns the pack layout. If padding is not specified, it returns the current padding accessor, which defaults to zero. When siblings are packed, tangent siblings are separated by approximately the specified padding, and the enclosing parent circle is also separated from its children by approximately the specified padding. If an explicit radius is not specified, the padding is approximate because a two-pass algorithm is used: circles are first packed without padding, a scaling factor is computed and applied to the specified padding, and then circles are re-packed with padding.

packSiblings(circles) packs array of circles

packSiblings(circles) packs the specified array of circles using the front-chain packing algorithm by Wang et al. Each circle must have a circle.r property specifying the circle's radius. The function assigns circle.x (the x-coordinate of the circle's center) and circle.y (the y-coordinate of the circle's center) properties to each circle.

packEnclose(circles) computes smallest enclosing circle

packEnclose(circles) computes the smallest circle that encloses the specified array of circles using the Matoušek-Sharir-Welzl algorithm. Each circle must have a circle.r property specifying the circle's radius, and circle.x and circle.y properties specifying the circle's center.

Circle packing vs treemap space efficiency tradeoff

Circle packing does not use space as efficiently as a treemap, but the wasted space more prominently reveals the hierarchical structure. Only leaf nodes can be accurately compared by size because enclosing circles show approximate cumulative size of each subtree with some distortion.

Give your agent this brain