0.0.2 • Published 3 years ago

antv-tree-graph v0.0.2

Weekly downloads
3
License
ISC
Repository
github
Last release
3 years ago
tree-graph 基于 G6 的开箱即用应用
安装

yarn add tree-graph --save --registry https://nexus.alltosea.com/repository/nhc-npm-group/

主要实现功能
  •  右键菜单
  •  节点 hover 效果
  • 数据驱动
  • 画布自适应
demo
 import TreeGraph from 'tree-graph';
 const data = {

    "id": "0",
    "level": 0,
    "collapsed": false,
    "dataType": "root",
    "name": "2020.03.12 13:03 hwx测试",
    "data": {},
    "children": [
      {
        "id": "1336529001644064",
        "fid": "0",
        "level": 1,
        "collapsed": true,
        "dataType": "",
        "name": "2020.03.12 13:03 申请资源名称2",
         "conextMenu": []
        "data": {
          "isImmediate": true,

        },
        "children": [
          {
            "id": "1336534944972832",
            "fid": "1336529001644064",
            "level": 2,
            "collapsed": true,
            "dataType": "",
            "name": "测试三",
            "data": {}
          }
        ]
      },
      {
        "id": "1336528909369376",
        "fid": "0",
        "level": 1,
        "collapsed": true,
        "dataType": "",
        "name": "2020.03.12 13:03 申请资源名称",
        "conextMenu": [
            {
              "name": "资源表:来穗人口调查",
              "data": {}
            },
            {
              "name": "附件",
              "data": {}
            }
          ]
        "data": {

        }
      },
      {
        "id": "1336532740866080",
        "fid": "0",
        "level": 1,
        "collapsed": true,
        "dataType": "",
        "name": "测试",
        "data": {}
      }
    ]

}
 const config = { data:data, container:'container'};
 console.log('config', config);
 const taskRelationshipDiagram = new TreeGraph(config);

API

data
参数说明类型默认值require
id节点唯一标识string-true
fid父节点 id(最顶层节点可不传) string-true
level节点层次number-false
collapsed是否展开booleanfalsefalse
name节点 titlestring-false
data模型数据object-false
conextMenu右键菜单array-false
children子节点object-false
disableExpandIcon隐藏展开收宿 iconbooleanfalsefalse
data.conextMenu
参数说明类型默认值require
name右键菜单列表 titlestring-true
data右键菜单列表数据  object-false
treeGraph.Graph

返回图表的载体,等同 G6.Graph 用  法可参考 https://g6.antv.vision/zh/docs/api/Graph

回调参数

treeGraph.conextMenuClick

右键菜单回调函数

名称类型描述
dataobjectconextMenu.data 数据
例:treeGraph.conextMenuClick(
  function(data) {}
)