NuclearDispersionSystem/ant-design-vue-jeecg/node_modules/@antv/hierarchy
2023-09-14 14:47:11 +08:00
..
.github 111 2023-09-14 14:47:11 +08:00
assets 111 2023-09-14 14:47:11 +08:00
bin 111 2023-09-14 14:47:11 +08:00
build 111 2023-09-14 14:47:11 +08:00
lib 111 2023-09-14 14:47:11 +08:00
node_modules/@antv/util 111 2023-09-14 14:47:11 +08:00
src 111 2023-09-14 14:47:11 +08:00
.babelrc 111 2023-09-14 14:47:11 +08:00
.editorconfig 111 2023-09-14 14:47:11 +08:00
.eslintignore 111 2023-09-14 14:47:11 +08:00
.eslintrc 111 2023-09-14 14:47:11 +08:00
.travis.yml 111 2023-09-14 14:47:11 +08:00
CHANGELOG.md 111 2023-09-14 14:47:11 +08:00
CONTRIBUTING.md 111 2023-09-14 14:47:11 +08:00
CONTRIBUTING.zh-CN.md 111 2023-09-14 14:47:11 +08:00
LICENSE 111 2023-09-14 14:47:11 +08:00
package.json 111 2023-09-14 14:47:11 +08:00
README.md 111 2023-09-14 14:47:11 +08:00

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