How to use the d3-hierarchy.tree function in d3-hierarchy

To help you get started, we’ve selected a few d3-hierarchy examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github UXAspects / UXAspects / src / components / organization-chart / organization-chart.component.ts View on Github external
private getLayout(): HierarchyPointNode> {

        // create a hierarchical representation of the data - don't include collapsed nodes
        const treeHierarchy = hierarchy(this.dataset, node => Array.isArray(node.children) && node.expanded ? node.children : []);

        // create our layout
        const layout = tree>()
            .nodeSize([this.nodeWidth, this.nodeHeight])
            .separation(this.getNodeSpacing.bind(this));

        // process the data with the layout
        const treeLayout = layout(treeHierarchy);

        // calculate the vertical spacing
        const verticalSpacing = this.verticalSpacing === undefined ? this.nodeHeight : this.verticalSpacing;

        // set the vertical spacing
        treeLayout.each(data => data.y = data.depth * (this.nodeHeight + verticalSpacing));

        return treeLayout;
    }
github chanzuckerberg / idseq-web / app / assets / src / components / visualizations / TidyTree.js View on Github external
this.options.minHeight,
      this.options.leafNodeHeight * this.root.leaves().length
    );

    // if (!this.root.x0) {
    this.root.x0 = height / 2;
    this.root.y0 = 0;
    // }

    this.svg
      .transition()
      .duration(this.options.transitionDuration)
      .attr("width", width + this.margins.left + this.margins.right)
      .attr("height", height + this.margins.top + this.margins.bottom);

    d3Tree().size([height, width])(this.root);

    source = source || this.root;

    // compute scales for nodes
    let nodeScale = scaleLinear()
      .domain(this.range)
      .range([4, 20]);
    let linkScale = scaleLinear()
      .domain(this.range)
      .range([1, 20]);
    let fontScale = scaleLinear()
      .domain(this.range)
      .range([this.options.smallerFont, this.options.largerFont]);

    let link = this.pathContainer
      .selectAll(".link")
github mcnuttandrew / forum-explorer / src / layouts / time-embed-x.js View on Github external
layout: () => {
    const layout = tree().size([1, 1]);
    return input => {
      const root = layout(input);
      root.descendants().forEach(node => {
        const hold = node.x;
        node.x = node.y;
        node.y = hold;
      });
      return root;
    };
  },
  getXScale: ({width, margin}, root) => {
github StateOfJS / State-of-JS-2019 / src / modules_not_used / features / blocks / _FeaturesRadialClusterOverviewBlock.js View on Github external
() =>
            d3Tree()
                .size([2 * Math.PI, innerRadius])
                .separation((a, b) => (a.parent === b.parent ? 1 : 2.4) / a.depth),
        [innerRadius]
github ui-router / visualizer / src / statevis / renderers.tsx View on Github external
export function TREE_LAYOUT(rootNode: StateVisNode) {
  let root = hierarchy(rootNode);
  let tree = d3tree();
  return updateNodes(tree(root));
}
github onap / sdc / openecomp-ui / src / nfvo-components / tree / Tree.jsx View on Github external
renderTree() {
        let {
            width,
            nodes,
            name,
            allowScaleWidth,
            selectedNodeId,
            onRenderedBeyondWidth,
            toWiden
        } = this.props;
        if (nodes.length > 0) {
            let horizontalSpaceBetweenLeaves = toWiden
                ? WIDE_HORIZONTAL_SPACES
                : NARROW_HORIZONTAL_SPACES;
            const treeFn = tree().nodeSize([
                horizontalSpaceBetweenLeaves,
                verticalSpaceBetweenNodes
            ]); //.size([width - 50, height - 50])
            let root = stratifyFn(nodes).sort((a, b) =>
                a.data.name.localeCompare(b.data.name)
            );
            let svgHeight =
                verticalSpaceBetweenNodes * root.height + nodeRadius * 6;

            treeFn(root);

            let nodesXValue = root.descendants().map(node => node.x);
            let maxX = Math.max(...nodesXValue);
            let minX = Math.min(...nodesXValue);

            let svgTempWidth =
github hpcc-systems / Visualization / src / tree / Dendrogram.ts View on Github external
constructor() {
        super();
        ITree.call(this);
        Utility.SimpleSelectionMixin.call(this);

        this._drawStartPos = "origin";

        this._d3LayoutCluster = d3Cluster();
        this._d3LayoutTree = d3Tree();
    }