当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript d3-hierarchy.hierarchy函数代码示例

本文整理汇总了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)
}
开发者ID:Ptival,项目名称:PeaCoq,代码行数:29,代码来源:utils.ts

示例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);		

	}
开发者ID:Ao21,项目名称:rollup-test,代码行数:20,代码来源:index.ts

示例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);
  }
开发者ID:gems-uff,项目名称:noworkflow,代码行数:24,代码来源:graph.ts

示例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 ------------------------------------------------------
开发者ID:HawkHouseIntegration,项目名称:DefinitelyTyped,代码行数:30,代码来源:d3-hierarchy-tests.ts

示例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 ------------------------------------------------------
开发者ID:BernieSumption,项目名称:DefinitelyTyped,代码行数:30,代码来源:d3-hierarchy-tests.ts


注:本文中的d3-hierarchy.hierarchy函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。