All Projects → David-Desmaisons → Vue.d3.tree

David-Desmaisons / Vue.d3.tree

Licence: mit
Vue component to display tree based on D3.js layout.

Projects that are alternatives of or similar to Vue.d3.tree

Bandersnatch
💻 Interactive Black Mirror: Bandersnatch Paths Website 🎥
Stars: ✭ 169 (-76.72%)
Mutual labels:  tree, d3js
React Virtualized Tree
A virtualized tree view component making use of react
Stars: ✭ 328 (-54.82%)
Mutual labels:  tree, component
Vue Treeselect
A multi-select component with nested options support for Vue.js
Stars: ✭ 2,347 (+223.28%)
Mutual labels:  tree, component
Vue Element Loading
⏳ Loading inside a container or full screen for Vue.js
Stars: ✭ 234 (-67.77%)
Mutual labels:  component, vuejs2
Vue Json Tree View
A JSON Tree View Component for Vue.js
Stars: ✭ 418 (-42.42%)
Mutual labels:  tree, vuejs2
Vue Form Json Schema
Create forms using JSON schema. Bring your components!
Stars: ✭ 253 (-65.15%)
Mutual labels:  component, vuejs2
Ngx Treeview
An Angular treeview component with checkbox
Stars: ✭ 312 (-57.02%)
Mutual labels:  tree, component
V Chart Plugin
Easily bind a chart to the data stored in your Vue.js components.
Stars: ✭ 188 (-74.1%)
Mutual labels:  component, d3js
React Sortable Tree
Drag-and-drop sortable component for nested data and hierarchies
Stars: ✭ 4,348 (+498.9%)
Mutual labels:  tree, component
Vue Tagsinput
A simple tags input with typeahead (autocomplete) built with Vue.js 2.
Stars: ✭ 375 (-48.35%)
Mutual labels:  component, vuejs2
Vue Marquee Text Component
[CSS GPU Animation] Marquee Text for vuejs
Stars: ✭ 226 (-68.87%)
Mutual labels:  component, vuejs2
Ngx Ui
🚀 Style and Component Library for Angular
Stars: ✭ 534 (-26.45%)
Mutual labels:  tree, component
V Bar
The virtual responsive crossbrowser scrollbar component for VueJS 2x
Stars: ✭ 216 (-70.25%)
Mutual labels:  component, vuejs2
Vue Ui For Pc
基于Vue2.x的一套PC端UI组件,包括了Carousel 跑马灯、Cascader 级联、Checkbox 多选框、Collapse 折叠面板、DatePicker 日期选择、Dialog 对话框、Form 表单、Input 输入框、InputNumber 数字输入框、Layer 弹窗层、Loading 加载、Menu 菜单、Page 分页、Progress 进度条、Radio 单选框、SelectDropDown 仿select、Switch 开关、Table 表格、Tabs 标签页、Textarea 文本框、Tooltip 文字提示、BackTop 返回顶部、steps 步骤条、Transfer 穿梭框、Tree 树形、Upload 文件上传、Lazy 图片懒加载、Loading 加载、Pagination 分页等等
Stars: ✭ 156 (-78.51%)
Mutual labels:  tree, vuejs2
Vue Easytable
🍉 Table Component/ Data Grid / Data Table.Support Virtual Scroll,Column Fixed,Header Fixed,Header Grouping,Filter,Sort,Cell Ellipsis,Row Expand,Row Checkbox ...
Stars: ✭ 2,501 (+244.49%)
Mutual labels:  component, vuejs2
Vuejs Tree
A highly customizable and blazing fast Vue tree component ⚡🌲
Stars: ✭ 211 (-70.94%)
Mutual labels:  tree, component
Vue Notifyjs
Minimalist 1kb Notification component
Stars: ✭ 160 (-77.96%)
Mutual labels:  component, vuejs2
Vue Draggable Resizable
Vue2 Component for draggable and resizable elements.
Stars: ✭ 2,431 (+234.85%)
Mutual labels:  component, vuejs2
Liquor Tree
Tree component based on Vue.js
Stars: ✭ 348 (-52.07%)
Mutual labels:  tree, component
Vue Swatches
🎨 Help the user picking beautiful colors!
Stars: ✭ 456 (-37.19%)
Mutual labels:  component, vuejs2

Vue.D3.tree

GitHub open issues Npm version npm download vue2 MIT License

Vue components to display graphics based on D3.js layout.

Tree

demo

Live demo

https://david-desmaisons.github.io/Vue.D3.tree/tree

Usage

<tree :data="tree" node-text="name" layoutType="circular">
</tree>
import {tree} from 'vued3tree'

export default {
  components: {
    tree
  },
  data() {
    return {
      tree: {
        name: "father",
        children:[{
          name: "son1",
          children:[ {name: "grandson"}, {name: "grandson2"}]
        },{
          name: "son2",
          children:[ {name: "grandson3"}, {name: "grandson4"}]
        }]
      }
    }
  }
}
  //...

Props

Name Required Type/Value Default Description
data no Object null Data representing tree structure, children nodes are represented by children property
duration no Number 750 Animation duration in milliseconds
layoutType no 'circular' 'vertical' or 'horizontal' 'horizontal' Circular, vertical or horizontal layout
leafTextMargin no Number 6 margin in pixel for leaf node text
linkLayout no 'bezier' or 'orthogonal' bezier' Define the link layout
identifier no Function () => i++ Function that receives a data and returns its identity that can be a number or a string, useful when dynamically updating the tree
marginX no Number 20 margin for X axis in pixel
marginY no Number 20 margin for Y axis in pixel
maxZoom no Number 0.8 minimal zoom value
minZoom no Number 9 maximum zoom value
nodeText no String 'name' name of the property of the node to be used as a display name
nodeTextDisplay no 'all' 'leaves' or 'extremities' 'all' Determine wether all node texts are displayed or only leaf nodes or leaves and root node respectively.
nodeTextMargin no Number 6 margin in pixel for node text
popUpPlacement no String 'bottom-start' Pop-up position as defined by popper.js
radius no Number 3 node circle radius in pixel
selected no Object null The selected node -on which a selected class is applied-. It can be bound using a v-model directive. By default, click on text to select a node but this behavior can be customized using the behavior slot.
strokeWidth no Number 1.5 The path stroke-width in pixel.
type no 'tree' or 'cluster' 'tree' kind of layout: tree or cluster
zoomable no Boolean false If true tree can be zoomed in using mouse wheel and drag-and-drop

Slots

node

Use this slot to customize the rendering of individual node.

Note that the mark-up will be rendered inside a svg element, so only svg elements are allowed here

Slot-scope:

Name Type Description
actions Object Value: {collapse, collapseAll, expand, expandAll, setSelected, show, toggleExpandCollapse} where each property is a component method (see below for detailed description)
data Object node data as provided by the data props
isRetracted Bool true if the node has hidden children -retracted state-
isSelected Bool true if the node is selected
node D3.js node D3.js node to be displayed
radius Number tree radius props value

Example:

<template #node="{data, node: {depth}, radius, isRetracted}">
  <template v-if="data.children && data.children.length">
    <path :fill="isRetracted? 'red' : 'blue'" d="M190.5..">
      <title>{{data.text}} {{depth}}</title>
    </path>
  </template>
  <template v-else>
    <circle r="6" :stroke="blue? 'blue' : 'yellow'">
      <title>{{data.text}} {{depth}}</title>
    </circle>
  </template>
</template>

popUp

Use this slot to create a pop-up, tooltip or context menu for nodes. The position of the pop-up relative to its target is defined by the popUpPlacement prop.

By default, pop-up will open when clicking on node text. This behavior can be overridden using behavioral slot. For example by using the PopUpOnTextHover component provides opening of pop-up when hovering the node test. See below for example.

Slot-scope:

Name Type Description
data Object node data as provided by the data props
close Function function to close the pop-up
node D3.js node D3.js node to be displayed

Example:

<template #popUp="{data,node}">
  <div class="btn-group-vertical">
    <button @click="addFor(data)">
      <i class="fa fa-plus" aria-hidden="true"></i>
    </button>
    <button @click="remove(data, node)">
      <i class="fa fa-trash" aria-hidden="true"></i>
    </button>
  </div>
</template>

behavior

Behavior slots provide an elegant way to customize the tree behavior by receiving as slot-scope both node information (including clicked node, hovered node, ...) and actions to alter the graph accordingly.

The concept of this slot is to react to changes in node information by calling an action

By design this slot is renderless.

For more about this pattern, you can check here.

Slot-scope:

Name Type Description
on Function Value: $on method of the tree component, exposing all events
actions Object Value: {collapse, collapseAll, expand, expandAll, setSelected, show, toggleExpandCollapse} where each property is a component method (see below for detailed description)

By default tree component use standardBehavior as component which provides toggle retract on node click and select the node on clicking on its text.

Example:

<tree>
  <template #behavior="{on, actions}">
    <CollapseOnClick v-bind="{on, actions}"/>
  </template>
</tree>

With CollapseOnClick component:

export default {
  props: ['on', 'actions'],

  render: () => null,

  created () {
    const {on, actions: {toggleExpandCollapse}} = this;

    on('clickedNode', ({element}) => {
      toggleExpandCollapse(element);
    })
  }
}

To display pop-up on hover, use the built-in popUpOnHoverText:

<tree>
  <template #behavior="{on, actions}">
    <popUpOnHoverText v-bind="{on, actions}"/>
  </template>
</tree>
import {tree, popUpOnHoverText} from 'vued3tree'

export default {
  components: {
    tree,
    popUpOnHoverText
  },
  //...

Events

change

  • Argument : node raw data.
  • Sent when the node is selected

clickedNode

  • Argument : {element, data, target} where element represents the node build by D3.js, data is the node raw data and target the target DOM element.
  • Sent when the node is clicked

clickOutside

  • Argument: none
  • Sent when mouse is clicked outside any geometry or text of the tree

clickedText

  • Argument: same as mouseNodeOver
  • Sent when the node text is clicked

expand

  • Argument : same as clicked.
  • Sent when the node is clicked and the node children are expanded

mouseOverText

  • Argument: same as mouseNodeOver
  • Sent when mouse hovers the node text

onNodeTextLeave

  • Argument: same as mouseNodeOver
  • Sent when mouse leaves the node text

retract

  • Argument : same as clicked.
  • Sent when the node is clicked and the node children are retracted

For all these events, the argument passed is {element, data} .

zoom

Methods

Name Argument return Description
expand D3.js node a promise which resolve when animation is over Expand the given node.
expandAll D3.js node a promise which resolve when animation is over Expand the given node and all its children.
collapse D3.js node a promise which resolve when animation is over Collapse the given node.
collapseAll D3.js node a promise which resolve when animation is over Collapse the given node and all its children.
resetZoom - a promise which resolve when animation is over Set zoom matrix to identity
resetPopUp - undefined close pop-up
setPopUp {target, node} undefined Open pop-up for the corresponding node, using the target DOM element as reference. Designed to be called with event argument.
setSelected Object: node data undefined Select the given node by sending a change event. Should be used with a v-model binding
show D3.js node a promise which resolve when animation is over Expand nodes if needed in order to show the given node.
showOnly D3.js node a promise which resolve when animation is over Retract all node that are not in the path of the given node.
toggleExpandCollapse D3.js node a promise which resolve when animation is over Retract or collapse the given node depending on its current state.

Gotchas

This component is responsive and will adjust to resizing. In order for this to work properly, you must define for this component or its parent wether:

  • a height or a max-height
  • or a width or a max-width.

Failing to do so may result in a component whose size that will keep increasing.

Hierarchical Edge Bundling

demo

Live demo

https://david-desmaisons.github.io/Vue.D3.tree/hierarchicalEdgeBundling

Usage

<hierarchical-edge-bundling identifier="id" :data="tree" :links="links" node-text="name"/>
import {hierarchicalEdgeBundling} from 'vued3tree'

export default {
  components: {
    hierarchicalEdgeBundling
  },
  data() {
    return {
      tree: {
        name: "father",
        children:[{
          name: "son1",
          children:[ {name: "grandson", id: 1}, {name: "grandson2", id: 2}]
        },{
          name: "son2",
          children:[ {name: "grandson3", id: 3}, {name: "grandson4", id: 4}]
        }]
      },
      links: [
        {source: 3, target: 1, type: 1},
        {source: 3, target: 4, type: 2}
      ],
      linkTypes: [
        {id: 1, name: 'depends', symmetric: true},
        {id: 2, name: 'implement', inName: 'implements', outName: 'is implemented by'},
        {id: 3, name: 'uses', inName: 'uses', outName: 'is used by'},
      ]
    }
  }
}
  //...

Props

Name Required Type/Value Default Description
data no Object null Data representing tree structure, children nodes are represented by children property
duration no Number 750 Animation duration in milliseconds
links no Array null Data representing links between the nodes, having source and target properties referencing node identifiers
identifier yes String or Function - name of the property of the node to be used as a identifier or function taking a node and returning its identifier
marginX no Number 20 margin for X axis in pixel
marginY no Number 20 margin for Y axis in pixel
maxTextWidth no Number -1 Max node text width (in pixel) to be displayed, if -1 text is not truncated.
nodeClass no String 'graph' class to be applied to the root div. Useful when custom CSS rules have to be applied.
nodeText yes String - name of the property of the node to be used as a display name

Events

mouseNodeOver

  • Argument: {element, data} where element represents the node build by D3.js and data is the node raw data.
  • Sent when the node name is hovered by mouse

mouseNodeOut

  • Argument: same as mouseNodeOver
  • Sent when mouse leaves the node name

clickOutsideGraph

  • Argument: none
  • Sent when mouse is clicked outside any geometry or text of the hierarchical edge bundling

nodesComputed

highlightedNodeChanged

  • Argument: none
  • Sent when highlighted node has changed.

Data

highlightedNode

Highlighted node: when set to a node data, the corresponding node and its related links will be highlighted. If null standard display is showing.

Gotchas

This component is responsive and will adjust to resizing. In order for this to work properly, you must define for this component or its parent wether:

  • a height or a max-height
  • or a width or a max-width.

Failing to do so may result in a component whose size that will keep increasing.

Installation

  • Available through:
 npm install vued3tree

Build Setup

# install dependencies
npm install

# serve with hot reload at localhost:8080
npm run dev

# build for production with minification
npm run build
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].