本文整理汇总了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 ------------------------------------------------------