本文整理匯總了TypeScript中d3-hierarchy.hierarchy函數的典型用法代碼示例。如果您正苦於以下問題:TypeScript hierarchy函數的具體用法?TypeScript hierarchy怎麽用?TypeScript hierarchy使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了hierarchy函數的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1: makeHierarchyTree
export function makeHierarchyTree(t : IProofTree) : d3Hierarchy.HierarchyPointNode<IProofTreeNode> {
const hierarchyRoot = d3Hierarchy.hierarchy(
t.rootNode,
(node : IProofTreeNode) => {
console.log('Computing some children')
// fake nodes are used to trick the layout engine into spacing
// childrenless nodes appropriately
if (node instanceof FakeNode) { return [] }
const viewChildren = node.getViewChildren()
// in order to trick d3 into displaying tactics better add fake
// children to tactic nodes that solve their goal
if (node instanceof TacticGroupNode && viewChildren.length === 0) {
return [new FakeNode(t, node)]
}
if (viewChildren === undefined) {
debugger
}
return viewChildren
}
)
return d3Hierarchy.tree<IProofTreeNode>()
.separation(d => {
// TODO: now that I put fake nodes, still need this?
// TODO: this just won't work, need invisible children
// for tactics without children
return 1 / (1 + Math.pow(d.depth, 3))
})
(hierarchyRoot)
}
示例2: prep
prep(initData) {
initData = initData.filter((d) => { return d.YEAR == 2016 });
let entries = nest()
.key((e: any) => { return e.CATEGORY; })
.key((e: any) => { return e.FUNDING_CATEGORY; })
.entries(initData);
let root = hierarchy({ values: entries }, (d) => {
return d.values;
}).sum((d) => {
if (d.TYPE === 'Total') {
return d.AMOUNT;
}
});
console.log(root);
}
示例3: init
init(data: TrialGraphData, t1: number, t2: number) {
this.t1 = t1;
this.t2 = t2;
this.minDuration = data.min_duration;
this.maxDuration = data.max_duration;
this.totalDuration = {};
this.totalDuration[t1] = this.maxDuration[t1] - this.minDuration[t1];
this.totalDuration[t2] = this.maxDuration[t2] - this.minDuration[t2];
this.maxTotalDuration = Math.max(
this.totalDuration[t1], this.totalDuration[t2]
);
this.colors = data.colors;
if (!data.root) return;
this.root = d3_hierarchy(data.root, function(d) { return d.children; }) as VisibleTrialNode;
this.root.x0 = 0;
this.root.y0 = (this.config.width) / 2;
this.alledges = data.edges;
this.update(this.root);
}
示例4: function
let hierarchyNode: d3Hierarchy.HierarchyNode<HierarchyDatum>;
let hierarchyPointNodeArray: Array<d3Hierarchy.HierarchyPointNode<HierarchyDatumWithParentId>>;
let hierarchyPointNode: d3Hierarchy.HierarchyPointNode<HierarchyDatumWithParentId>;
let hierarchyRectangularNodeArray: Array<d3Hierarchy.HierarchyRectangularNode<HierarchyDatumWithParentId>>;
let hierarchyRectangularNode: d3Hierarchy.HierarchyRectangularNode<HierarchyDatumWithParentId>;
let hierarchyCircularNodeArray: Array<d3Hierarchy.HierarchyCircularNode<HierarchyDatumWithParentId>>;
let hierarchyCircularNode: d3Hierarchy.HierarchyCircularNode<HierarchyDatumWithParentId>;
// Create Hierarchy Layout Root Node =====================================
let hierarchyRootNode: d3Hierarchy.HierarchyNode<HierarchyDatum>;
hierarchyRootNode = d3Hierarchy.hierarchy(hierarchyRootDatum);
hierarchyRootNode = d3Hierarchy.hierarchy(hierarchyRootDatum, function (d) {
return d.children || null;
});
// Use Hierarchy Node ====================================================
// data, depth, height ---------------------------------------------------
hierarchyRootDatum = hierarchyRootNode.data;
num = hierarchyRootNode.depth;
num = hierarchyRootNode.height;
// children, parent ------------------------------------------------------
示例5:
let hierarchyNode: d3Hierarchy.HierarchyNode<HierarchyDatum>;
let hierarchyPointNodeArray: Array<d3Hierarchy.HierarchyPointNode<HierarchyDatumWithParentId>>;
let hierarchyPointNode: d3Hierarchy.HierarchyPointNode<HierarchyDatumWithParentId>;
let hierarchyRectangularNodeArray: Array<d3Hierarchy.HierarchyRectangularNode<HierarchyDatumWithParentId>>;
let hierarchyRectangularNode: d3Hierarchy.HierarchyRectangularNode<HierarchyDatumWithParentId>;
let hierarchyCircularNodeArray: Array<d3Hierarchy.HierarchyCircularNode<HierarchyDatumWithParentId>>;
let hierarchyCircularNode: d3Hierarchy.HierarchyCircularNode<HierarchyDatumWithParentId>;
// Create Hierarchy Layout Root Node =====================================
let hierarchyRootNode: d3Hierarchy.HierarchyNode<HierarchyDatum>;
hierarchyRootNode = d3Hierarchy.hierarchy(hierarchyRootDatum);
hierarchyRootNode = d3Hierarchy.hierarchy(hierarchyRootDatum, (d) => {
return d.children || null;
});
// Use Hierarchy Node ====================================================
// data, depth, height ---------------------------------------------------
hierarchyRootDatum = hierarchyRootNode.data;
num = hierarchyRootNode.depth;
num = hierarchyRootNode.height;
// children, parent ------------------------------------------------------