(seriesModel: TreeSeriesModel, api: ExtensionAPI)
| 43 | } |
| 44 | |
| 45 | function commonLayout(seriesModel: TreeSeriesModel, api: ExtensionAPI) { |
| 46 | const refContainer = createBoxLayoutReference(seriesModel, api).refContainer; |
| 47 | const layoutInfo = getLayoutRect(seriesModel.getBoxLayoutParams(), refContainer); |
| 48 | seriesModel.layoutInfo = layoutInfo; |
| 49 | const layout = seriesModel.get('layout'); |
| 50 | let width = 0; |
| 51 | let height = 0; |
| 52 | let separation = null; |
| 53 | |
| 54 | if (layout === 'radial') { |
| 55 | width = 2 * Math.PI; |
| 56 | height = Math.min(layoutInfo.height, layoutInfo.width) / 2; |
| 57 | separation = sep(function (node1, node2) { |
| 58 | return (node1.parentNode === node2.parentNode ? 1 : 2) / node1.depth; |
| 59 | }); |
| 60 | } |
| 61 | else { |
| 62 | width = layoutInfo.width; |
| 63 | height = layoutInfo.height; |
| 64 | separation = sep(); |
| 65 | } |
| 66 | |
| 67 | const virtualRoot = seriesModel.getData().tree.root as TreeLayoutNode; |
| 68 | const realRoot = virtualRoot.children[0]; |
| 69 | |
| 70 | if (realRoot) { |
| 71 | init(virtualRoot); |
| 72 | eachAfter(realRoot, firstWalk, separation); |
| 73 | virtualRoot.hierNode.modifier = -realRoot.hierNode.prelim; |
| 74 | eachBefore(realRoot, secondWalk); |
| 75 | |
| 76 | let left = realRoot; |
| 77 | let right = realRoot; |
| 78 | let bottom = realRoot; |
| 79 | eachBefore(realRoot, function (node: TreeLayoutNode) { |
| 80 | const x = node.getLayout().x; |
| 81 | if (x < left.getLayout().x) { |
| 82 | left = node; |
| 83 | } |
| 84 | if (x > right.getLayout().x) { |
| 85 | right = node; |
| 86 | } |
| 87 | if (node.depth > bottom.depth) { |
| 88 | bottom = node; |
| 89 | } |
| 90 | }); |
| 91 | |
| 92 | const delta = left === right ? 1 : separation(left, right) / 2; |
| 93 | const tx = delta - left.getLayout().x; |
| 94 | let kx = 0; |
| 95 | let ky = 0; |
| 96 | let coorX = 0; |
| 97 | let coorY = 0; |
| 98 | if (layout === 'radial') { |
| 99 | kx = width / (right.getLayout().x + delta + tx); |
| 100 | // here we use (node.depth - 1), bucause the real root's depth is 1 |
| 101 | ky = height / ((bottom.depth - 1) || 1); |
| 102 | eachBefore(realRoot, function (node) { |
no test coverage detected
searching dependent graphs…