d3-sankey/src/align.js
raw| 1 | import {min} from "d3-array"; |
| 2 | |
| 3 | function targetDepth(d) { |
| 4 | return d.target.depth; |
| 5 | } |
| 6 | |
| 7 | export function left(node) { |
| 8 | return node.depth; |
| 9 | } |
| 10 | |
| 11 | export function right(node, n) { |
| 12 | return n - 1 - node.height; |
| 13 | } |
| 14 | |
| 15 | export function justify(node, n) { |
| 16 | return node.sourceLinks.length ? node.depth : n - 1; |
| 17 | } |
| 18 | |
| 19 | export function center(node) { |
| 20 | return node.targetLinks.length ? node.depth |
| 21 | : node.sourceLinks.length ? min(node.sourceLinks, targetDepth) - 1 |
| 22 | : 0; |
| 23 | } |