@antv/hierarchy
layout algorithms for visualizing hierarchical data
Last updated 2 years ago by kopiluwaky .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ gnpm install @antv/hierarchy 
SYNC missed versions from official npm registry.

hierarchy

layout algorithms for visualizing hierarchical data.

API

example

const Hierarchy = require('@antv/hierarchy');

// your tree data
const root = {
  isRoot: true,
  id: 'Root',
  children: [
    {
      id: 'SubTreeNode1',
      children: [
        {
          id: 'SubTreeNode1.1'
        },
        {
          id: 'SubTreeNode1.2'
        }
      ]
    },
    {
      id: 'SubTreeNode2'
    }
  ]
};

// apply layout
const NODE_SIZE = 16;
const PEM = 5;
const ctx = document.getElementById('id-of-canvas-element').getContext('2d');
const rootNode = Hierarchy.compactBox(root, {
  direction: 'H', // H / V / LR / RL / TB / BT
  getId(d) {
    return d.id;
  },
  getHeight(d) {
    if (d.isRoot) {
      return NODE_SIZE * 2;
    }
    return NODE_SIZE;
  },
  getWidth(d) {
    if (d.isRoot) {
      return ctx.measureText(d.id).width * 2 + PEM * 1.6;
    }
    return ctx.measureText(d.id).width + PEM * 1.6;
  },
  getHGap(d) {
    if (d.isRoot) {
      return PEM * 2;
    }
    return PEM;
  },
  getVGap(d) {
    if (d.isRoot) {
      return PEM * 2;
    }
    return PEM;
  },
  getSubTreeSep(d) {
    if (!d.children || !d.children.length) {
      return 0;
    }
    return PEM;
  }
});

layout types

Hierarchy[type]

compactBox

this layout differs from d3-hierarcy.tree, it is a compact box tidy layout that is tidy in both horizontal and vertical directions.

demos

LR RL H
LR RL H
TB BT V
TB BT V

dendrogram

demos

LR RL H
LR RL H
TB BT V
TB BT V

indented

demos

LR RL H
LR RL H

mindmap

this layout is inspired by XMind.

demos

mindmap

Current Tags

  • 0.1.0-beta.4                                ...           beta (6 years ago)
  • 0.6.11                                ...           latest (2 years ago)

39 Versions

  • 0.1.0-beta.3                                ...           6 years ago
  • 0.6.11                                ...           2 years ago
  • 0.6.10                                ...           2 years ago
  • 0.6.9                                ...           2 years ago
  • 0.6.8                                ...           3 years ago
  • 0.6.7                                ...           4 years ago
  • 0.6.6                                ...           4 years ago
  • 0.6.5                                ...           4 years ago
  • 0.6.4                                ...           4 years ago
  • 0.6.3                                ...           5 years ago
  • 0.6.2                                ...           5 years ago
  • 0.6.1                                ...           5 years ago
  • 0.6.0                                ...           5 years ago
  • 0.5.0                                ...           5 years ago
  • 0.4.0                                ...           6 years ago
  • 0.3.15                                ...           6 years ago
  • 0.3.14                                ...           6 years ago
  • 0.3.13                                ...           6 years ago
  • 0.3.12                                ...           6 years ago
  • 0.3.11                                ...           6 years ago
  • 0.3.10                                ...           6 years ago
  • 0.3.9                                ...           6 years ago
  • 0.3.8                                ...           6 years ago
  • 0.3.7                                ...           6 years ago
  • 0.3.6                                ...           6 years ago
  • 0.3.5                                ...           6 years ago
  • 0.3.4                                ...           6 years ago
  • 0.3.3                                ...           6 years ago
  • 0.3.2                                ...           6 years ago
  • 0.3.1                                ...           6 years ago
  • 0.3.0                                ...           6 years ago
  • 0.2.1                                ...           6 years ago
  • 0.2.0                                ...           6 years ago
  • 0.1.2                                ...           6 years ago
  • 0.1.1                                ...           6 years ago
  • 0.1.0                                ...           6 years ago
  • 0.1.0-beta.4                                ...           6 years ago
  • 0.1.0-beta.2                                ...           6 years ago
  • 0.1.0-beta.1                                ...           6 years ago

Copyright 2013 - present © cnpmjs.org | Home |