Name: deep-partition-layout
Owner: NodeSource
Description: A fork of d3's partition layout which includes the values of inner nodes in its final sums
Created: 2015-09-28 08:02:13.0
Updated: 2016-08-26 07:32:08.0
Pushed: 2016-03-16 21:24:14.0
Homepage: null
Size: 4
Language: JavaScript
GitHub Committers
User | Most Recent Commit | # Commits |
---|
Other Committers
User | Most Recent Commit | # Commits |
---|
A fork of d3's partition layout which includes the values of inner nodes in its final sums.
partition = Partition()
Creates a new partition layout instance.
partition.children([children])
If children is specified, sets the specified children accessor function. If children is not specified, returns the current children accessor function, which by default assumes that the input data is an object with a children array:
tion children(d) {
turn d.children
partition.value([value])
If value is specified, sets the value accessor to the specified function. If value is not specified, returns the current value accessor, which assumes that the input data is an object with a numeric value attribute:
tion value(d) {
turn d.value
Note: multiple calls to partition.nodes
on the same root node will result in re-accummulating each node's values. It's wise to have your value
accessor set to something other than the default to avoid unexpected results.
partition.sort([comparator])
If comparator is specified, sets the sort order of sibling nodes for the layout using the specified comparator function. If comparator is not specified, returns the current group sort order, which defaults to descending order by the associated input data's numeric value attribute:
tion comparator(a, b) {
turn b.value - a.value
partition.size([size])
If size is specified, sets the available layout size to the specified two-element array of numbers representing x and y.
rt Partition from 'deep-partition-layout'
t width = 320
t height = 240
t partition = Partition()
ize([width, height])
partition.nodes(root)
Runs the partition layout, returning the array of nodes associated with the specified root node. In the process of doing so, the following properties will be added to each node in your tree:
parent
: the parent node, or null for the root.children
: the array of child nodes, or null for leaf nodes.value
: the node value, as returned by the value accessor.depth
: the depth of the node, starting at 0 for the root.x
: the minimum x-coordinate of the node position.y
: the minimum y-coordinate of the node position.dx
: the x-extent of the node position.dy
: the y-extent of the node position.Hugh Kennedy | GitHub/hughsk | Twitter/@hughskennedy |
---|
Contributions are welcomed from anyone wanting to improve this project!
deep-partition-layout is Copyright (c) 2015 NodeSource and licensed under the MIT license. All rights not explicitly granted in the MIT license are reserved. See the included LICENSE.md file for more details.