@vis-tree/core

main logic of vis-tree

Usage no npm install needed!

<script type="module">
  import visTreeCore from 'https://cdn.skypack.dev/@vis-tree/core';
</script>

README

@vis-tree/core

download npm types license

@vis-tree/core contains the main logic of tree data visualization, the layout strategy follows the idea of A Node-Positioning Algorithm for General Trees.

Features

  • Support users to use custom components to render nodes and connecting lines
  • Support multiple layout methods
  • Support dynamic insertion/removal of nodes
  • Support virtual rendering, saving performance overhead
  • Support animation, virtual rendering will also be used during animation

Related NPM library

For React, you can use @vis-tree/react.

For Vue, you can use @vis-tree/vue.

Write your own component

@vis-tree/core is written in pure typescript, based on it, you can encapsulate a tree-data visualization component with any fontend framework. But you should maintain the following DOM structure:

<div class="tree-canvas">
  <div class="tree-anchor">
    <div class="tree-node-wrapper">
      <div class="tree-node-content" />
      <div class="tree-node-head-line" />
      <div class="tree-node-tail-line" />
    </div>

    <div class="tree-junction-line" />

    <div class="tree-custom-line" />
  </div>
</div>
.tree-canvas {
  position: relative;
  overflow: hidden;
  cursor: move;
}

.tree-anchor {
  position: absolute;
  top: 0;
  left: 0;
}

.tree-node-wrapper {
  position: absolute;
  cursor: auto;
}

.tree-node-content {
  position: absolute;
  width: 100%;
  height: 100%;
  top: 0;
  left: 0;
  z-index: 1;
}

.tree-node-head-line,
.tree-node-tail-line,
.tree-junction-line,
.tree-custom-line {
  position: absolute;
  cursor: auto;
}