All Projects → PierreCapo → Treeviz

PierreCapo / Treeviz

Licence: bsd-3-clause
Tree diagrams with JavaScript 🌲 📈

Programming Languages

javascript
184084 projects - #8 most used programming language
typescript
32286 projects

Projects that are alternatives of or similar to Treeviz

Graphview
Flutter GraphView is used to display data in graph structures. It can display Tree layout, Directed and Layered graph. Useful for Family Tree, Hierarchy View.
Stars: ✭ 152 (+60%)
Mutual labels:  tree, hierarchy
Smart Array To Tree
Convert large amounts of data array to tree fastly
Stars: ✭ 91 (-4.21%)
Mutual labels:  tree, big-data
Hierarchy
Layout algorithms for visualizing hierarchical data.
Stars: ✭ 110 (+15.79%)
Mutual labels:  tree, hierarchy
Overvue
Prototyping Tool For Vue Devs 适用于Vue的原型工具
Stars: ✭ 2,108 (+2118.95%)
Mutual labels:  tree, hierarchy
react
Basic Primitives Diagrams for React. Data visualization components library that implements organizational chart and multi-parent dependency diagrams.
Stars: ✭ 15 (-84.21%)
Mutual labels:  tree, hierarchy
Angular2 Tree Diagram
Angular Hierarchical UI module
Stars: ✭ 50 (-47.37%)
Mutual labels:  tree, hierarchy
React D3 Tree
🌳 React component to create interactive D3 tree graphs
Stars: ✭ 543 (+471.58%)
Mutual labels:  tree, hierarchy
Vue Finder
📁 A Vue.js component to display hierarchical data (like the MacOS X finder)
Stars: ✭ 87 (-8.42%)
Mutual labels:  tree, hierarchy
Redmine issues tree
Provides a tree view of the Redmine issues list
Stars: ✭ 79 (-16.84%)
Mutual labels:  tree
Behavior Tree
🌲 Manage React state with Behavior Trees
Stars: ✭ 85 (-10.53%)
Mutual labels:  tree
Attic Predictionio Template Recommender
PredictionIO Recommendation Engine Template (Scala-based parallelized engine)
Stars: ✭ 78 (-17.89%)
Mutual labels:  big-data
Iotdb
Apache IoTDB
Stars: ✭ 1,221 (+1185.26%)
Mutual labels:  big-data
Dataengineeringproject
Example end to end data engineering project.
Stars: ✭ 82 (-13.68%)
Mutual labels:  big-data
Setl
A simple Spark-powered ETL framework that just works 🍺
Stars: ✭ 79 (-16.84%)
Mutual labels:  big-data
Spark Website
Apache Spark Website
Stars: ✭ 75 (-21.05%)
Mutual labels:  big-data
Pidtree
🚸 Cross platform children list of a PID.
Stars: ✭ 76 (-20%)
Mutual labels:  tree
Hazelcast Python Client
Hazelcast IMDG Python Client
Stars: ✭ 92 (-3.16%)
Mutual labels:  big-data
Astq
Abstract Syntax Tree (AST) Query Engine
Stars: ✭ 89 (-6.32%)
Mutual labels:  tree
Swordtooffer
经典常考必备面试算法,包括但不仅限于《剑指Offer》,《程序员面试金典》中的题目,持续更新中...
Stars: ✭ 81 (-14.74%)
Mutual labels:  tree
Hands On Algorithmic Problem Solving
A middle-to-high level algorithm book designed with coding interview at heart!
Stars: ✭ 1,227 (+1191.58%)
Mutual labels:  tree

Treeviz

Known Vulnerabilities David license

This javascript module aims at providing an easy interface in order to represent tree diagrams on screen with the ability to handle dynamic data flows. The data format must be JSON.

💅 Come play with the Treeviz storybook! 💅

Installation

With npm : npm install treeviz

and then you can use it with : import * as Treeviz from 'treeviz';

Or download this repository and link the dist/index.js file in your page directly : <script src="./dist/index.js><script> Also, but not recommended, you can use : <script src="https://rawgit.com/PierreCapo/treeviz/master/dist/index.js"></script>

Usage

React

Check the treeviz wrapper for react: treeviz-react

Vanilla JavaScript

// Define a tree element where dimensions are mandatory
<div id="tree" style="height:700px; width:900px"></div>

<script>
// Define a dataset
var data = [
  { id: 1, text_1: "Father", father: null },
  { id: 2, text_1: "Child A", father: 1 },
  { id: 3, text_1: "Child B", father: 1 },
  { id: 4, text_1: "Subchild C", father: 2 }
];

// Define and configure a tree object
var myTree = Treeviz.create({
  htmlId: "tree",
  idKey: "id",
  hasFlatData: true,
  nodeColor: (nodeData) => "grey",
  relationnalField: "father",
});

// Display the tree based on the data
myTree.refresh(data);
</script>

To update the tree visually you will just have to pass new data to the refresh method like this :

myTree.refresh(data);
myTree.refresh(data_update1);
myTree.refresh(data_update2);

The tree will be clever enough to updates only the part of the trees that have been added or removed in the dataset, and so it won't redraw the entire tree.

Treeviz Example

Hierarchical data case :

var hierarchical_data_example = {
  name: "Mom",
  qty: 10,
  children: [
    { name: "Son A", qty: 3 },
    { name: "Son B", qty: 7 },
  ],
};

var myTree = Treeviz.create({
  htmlId: "tree",
  idKey: "name",
  hasFlatData: false,
  relationnalField: "children",
});

myTree.refresh(hierarchical_data_example);

API

The big part of the API is configuring the tree before passing data to it :

Treeviz.create(config);

The table below lists all the avalaible key that the config object can have

Key Type Default Definition
htmlId string (Required) The HTML id tag on the page where the tree should be drawn. It must have a width and an height specified
idKey string "id" The key in a data item representing the unique identifier of a node
relationnalField string "father" In case of flat dataset, usually the relationnal field between each node is the field representing the father of the node, linking it to the id of the field. (See example below).
hasFlatData boolean true Specify whether the data passed to the tree is flat or already hierarchical
hasPan boolean false Toggle the ability to pan the tree
hasZoom boolean false Toggle the ability to zoom the tree
nodeWidth number 160 Width of a node in px
nodeHeight number 100 Height of a node in px
linkColor function (nodeData) => "#ffcc80" Color of the link
linkWidth function (nodeData) => 10 Width of the link
linkShape "quadraticBeziers" | "orthogonal" | "curve" "quadraticBeziers" Shape of the link
renderNode function (nodeData) => null HTML template for every node
isHorizontal boolean true Direction of the tree. If true, the tree expands from left to right. If false, it goes from top to bottom
onNodeClick function (nodeData) => null Function handling the event when someone click on it
onNodeMouseEnter function (nodeData) => null Function handling the event when someone hover a node
onNodeMouseLeave function (nodeData) => null Function handling the event when the mouse pointer leaves a node
mainAxisNodeSpacing number or "auto" 300 Set the distance in pixels between two depths in the tree. If the value is auto it will automatically display the tree to fit the size of the container.
secondaryAxisNodeSpacing number 1.25 Set the distance between nodes in the same level as a coefficient of node dimensions. Recommended to have the value superior to 1
marginTop number 1.25 Set the margin between the SVG element and the tree
marginBottom number 1.25 Set the margin between the SVG element and the tree
marginLeft number 1.25 Set the margin between the SVG element and the tree
marginRight number 1.25 Set the margin between the SVG element and the tree
duration number 600 The duration of the animation transition between layouts

Credits

This module is based on d3 library, credit to all the contributors of this project.

License

BSD

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].