Commit 90fa582d authored by Remi  PLANEL's avatar Remi PLANEL

Add phylotree layout

parent 8e8c3089
Pipeline #12588 failed with stage
in 38 seconds
import { hierarchy, cluster } from "d3-hierarchy";
import { RawPhyloTreeNode, PhyloTreeNode } from "../types";
import { defaultSeparation } from "./phylotree";
export default function () {
let dx = 1;
let dy = 1;
let nodeSize: boolean | null = null;
let separation = defaultSeparation;
function cladogram(data: RawPhyloTreeNode) {
// Apply the layout hierarchy.
cluster()
.separation(separation)
(hierarchy(data))
return data;
}
// PUBLIC
cladogram.nodeSize = function (size: [number, number]) {
nodeSize = true;
dx = +size[0];
dy = +size[1];
return cladogram;
};
cladogram.size = function (size: [number, number]) {
dx = +size[0];
dy = +size[1];
return cladogram;
}
cladogram.separation = function <T>(
separationCb: (a: d3.HierarchyNode<T>, b:d3.HierarchyNode<T>) => number
) {
separation = separationCb;
}
return cladogram;
}
\ No newline at end of file
export function defaultSeparation<T>(
a: d3.HierarchyPointNode<T>, b: d3.HierarchyPointNode<T>
): number {
return 1;
// return (a && b && a.parent === b.parent) ? 1 : 2;
}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment