Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
// Configure treemap layout generator ====================================
// tile() ----------------------------------------------------------------
treemapLayout = treemapLayout.tile(function (node, x0, y0, x1, y1) {
let n: number;
console.log('x0 coordinate of node: ', node.x0);
console.log('Node parent id: ', node.data.parentId); // type of node is HierarchyRectangularNode
num = x0; // number
num = y0; // number
num = x1; // number
num = y1; // number
// tile away
});
treemapLayout = treemapLayout.tile(d3Hierarchy.treemapDice);
let tilingFn: (node: d3Hierarchy.HierarchyRectangularNode, x0: number, y0: number, x1: number, y1: number) => void;
tilingFn = treemapLayout.tile();
// size() ----------------------------------------------------------------
treemapLayout = treemapLayout.size(null);
treemapLayout = treemapLayout.size([400, 200]);
size = treemapLayout.size();
// round() ------------------------------------------------------------
treemapLayout = treemapLayout.round(true);
let roundFlag: boolean = treemapLayout.round();
// Configure treemap layout generator ====================================
// tile() ----------------------------------------------------------------
treemapLayout = treemapLayout.tile(function (node, x0, y0, x1, y1) {
let n: number;
console.log('x0 coordinate of node: ', node.x0);
console.log('Node parent id: ', node.data.parentId); // type of node is HierarchyRectangularNode
num = x0; // number
num = y0; // number
num = x1; // number
num = y1; // number
// tile away
});
treemapLayout = treemapLayout.tile(d3Hierarchy.treemapDice);
let tilingFn: (node: d3Hierarchy.HierarchyRectangularNode, x0: number, y0: number, x1: number, y1: number) => void;
tilingFn = treemapLayout.tile();
// size() ----------------------------------------------------------------
treemapLayout = treemapLayout.size(null);
treemapLayout = treemapLayout.size([400, 200]);
size = treemapLayout.size();
// round() ------------------------------------------------------------
treemapLayout = treemapLayout.round(true);
let roundFlag: boolean = treemapLayout.round();
numberRectangularNodeAccessor = treemapLayout.paddingLeft();
// Use treemap layout generator ==========================================
let treemapRootNode: d3Hierarchy.HierarchyRectangularNode;
treemapRootNode = treemapLayout(stratifiedRootNode);
// Tiling functions ======================================================
tilingFn = d3Hierarchy.treemapBinary;
tilingFn = d3Hierarchy.treemapDice;
tilingFn = d3Hierarchy.treemapSlice;
tilingFn = d3Hierarchy.treemapSliceDice;
// Tiling Factory functions treemapSquarify() and treemapResquarify() ====
let tilingFactoryFn: d3Hierarchy.RatioSquarifyTilingFactory;
tilingFactoryFn = d3Hierarchy.treemapSquarify;
tilingFactoryFn = d3Hierarchy.treemapSquarify.ratio(2);
treemapLayout.tile(d3Hierarchy.treemapSquarify.ratio(2));
tilingFactoryFn = d3Hierarchy.treemapResquarify;
tilingFactoryFn = d3Hierarchy.treemapResquarify.ratio(2);
numberRectangularNodeAccessor = treemapLayout.paddingLeft();
// Use treemap layout generator ==========================================
let treemapRootNode: d3Hierarchy.HierarchyRectangularNode;
treemapRootNode = treemapLayout(stratifiedRootNode);
// Tiling functions ======================================================
tilingFn = d3Hierarchy.treemapBinary;
tilingFn = d3Hierarchy.treemapDice;
tilingFn = d3Hierarchy.treemapSlice;
tilingFn = d3Hierarchy.treemapSliceDice;
// Tiling Factory functions treemapSquarify() and treemapResquarify() ====
let tilingFactoryFn: d3Hierarchy.RatioSquarifyTilingFactory;
tilingFactoryFn = d3Hierarchy.treemapSquarify;
tilingFactoryFn = d3Hierarchy.treemapSquarify.ratio(2);
treemapLayout.tile(d3Hierarchy.treemapSquarify.ratio(2));
tilingFactoryFn = d3Hierarchy.treemapResquarify;
tilingFactoryFn = d3Hierarchy.treemapResquarify.ratio(2);
function getTilingMethod(key, squarifyratio) {
switch(key) {
case 'squarify':
return d3Hierarchy.treemapSquarify.ratio(squarifyratio);
case 'binary':
return d3Hierarchy.treemapBinary;
case 'dice':
return d3Hierarchy.treemapDice;
case 'slice':
return d3Hierarchy.treemapSlice;
default: // i.e. 'slice-dice' | 'dice-slice'
return d3Hierarchy.treemapSliceDice;
}
}