企业图谱

一,需要的插件,charts ,jquery

    <script type="text/javascript" src="jquery/jquery-1.9.1.min.js"></script>
    <script type="text/javascript" src="echarts/echarts.js"></script>

二,设置参数

 (1)节点 ,_node

数据格式 

{
   name: '张东',
   itemStyle: {
              normal: {
              color: 'green',                                
                       }
               }
 }

参数  symbolSize  图表的点的大小

(2)链路

数据格式

{
           source: '马云',
           target: '阿里巴巴',
           name: '高管',                         
           des: 'XXXX',
           lineStyle: {
                          normal: {                                  
                                       color: '#000',
                                  }
                              
            }
 }

参数 source  边的源节点名称的字符串,也支持使用数字表示源节点的索引。

         target  边的目标节点名称的字符串,也支持使用数字表示源节点的索引。

         value 边的数值,可以在力引导布局中用于映射到边的长度。

         lineStyle 线条风格

三,series 设置

                    type: 'graph',
                    layout: 'force',
                    symbolSize: 80,
                    roam: true,
                    edgeSymbol: ['circle', 'arrow'],
                    edgeSymbolSize: [4, 10],
                    edgeLabel: {
                        normal: {
                            textStyle: {
                                fontSize: 20
                            }
                        }
                    },
                    force: {
                        repulsion: 2500,
                        edgeLength: [10, 50]
                    },
                    draggable: true,
                    itemStyle: {
                        normal: {
                            color: '#4b565b'
                        }
                    },
                    lineStyle: {
                        normal: {
                            width: 2,
                            color: '#4b565b'

                        }
                    },
                    edgeLabel: {
                        normal: {
                            show: true,
                            formatter: function (x) {
                                return x.data.name;
                            }
                        }
                    },
                    label: {
                        normal: {
                            show: true,
                            textStyle: {
                            }
                        }
                    },
                    data: _node,
                    links:_links 
                }                   

参数 (1)roam 是否开启鼠标缩放和平移漫游。默认不开启。如果只想要开启缩放或者平移,可以设置成 'scale' 或者 'move'。设置成 true 为都开启

         (2)layout    'none' 不采用任何布局,使用节点中提供的 x, y 作为节点的位置。

            'circular' 采用环形布局,见示例 Les Miserables,布局相关的配置项见 graph.circular

            'force' 采用力引导布局,见示例 Force,布局相关的配置项见 graph.force

         (3) edgeSymbol

               边两端的标记类型,可以是一个数组分别指定两端,也可以是单个统一指定。默认不显示标记,常见的可以设置为箭头,如下:

edgeSymbol: ['circle', 'arrow']

     (4) series[i]-graph.draggable boolean

             [ default: false ]

            节点是否可拖拽,只在使用力引导布局的时候有用

 其他参数可以查看 http://echarts.baidu.com/option.html#series-graph.edgeSymbol

源码


<html>
<head>
    <meta name="viewport" content="width=device-width" />
    <title>ECharts 关系图谱</title>
   
    <script type="text/javascript" src="jquery/jquery-1.9.1.min.js"></script>
    <script type="text/javascript" src="echarts/echarts.js"></script>
    <style type="text/css">
        html, body, #main { height: 100%; width: 100%; margin: 0; padding: 0 }
    </style>
</head>
<body>
    <div id="main" style=""></div>
    <script type="text/javascript">
        var myChart = echarts.init(document.getElementById('main'));
        var _node=[
                        {
                            name: '张东',
                            itemStyle: {
                                normal: {
                                    color: 'green',
                                  
                                }
                            }
                        },
                        {
                            name: '高育良'
                        },
                         {
                            name: '高育良1'
                        },
                         {
                            name: '高育良2'
                        },
                        {
                            name: '阿里巴巴',
                            itemStyle: {
                                normal: {
                                    color: 'blue',
                                  
                                }
                            }
                        }
                        
                        , {
                            name: '陕西西部资信',
                            symbolSize:100,
                            itemStyle: {
                                normal: {
                                    color: 'red',
                                  
                                }
                            }
                        }
                    ]
        var _links=[    
                        {
                            source: '高育良',
                            target: '陕西西部资信',
                            name: '高管',
                         
                            des: '陕西西部资信是高育良的得意门生',
                            lineStyle: {
                                normal: {
                                  
                                    color: '#000',
                                    
                                }
                              
                            }
                        },
                          {
                            source: '高育良1',
                            target: '陕西西部资信',
                            name: '高管',
                         
                            des: '陕西西部资信是高育良的得意门生',
                            lineStyle: {
                                normal: {
                                   
                                    color: '#000',
                                    
                                }
                              
                            }
                        },
                          {
                            source: '高育良2',
                            target: '陕西西部资信',
                            name: '高管',
                         
                            des: '陕西西部资信是高育良的得意门生',
                            lineStyle: {
                                normal: {
                                   
                                    color: '#000',
                                    
                                }
                              
                            }
                        },
                          {
                            source: '张东',
                            target: '陕西西部资信',
                            name: '股东',
                         
                            des: '陕西西部资信是高育良的得意门生',
                            lineStyle: {
                                normal: {
                                 
                                    color: '#000',
                                    
                                }
                              
                            }
                        },
                          {
                            source: '张东',
                            target: '阿里巴巴',
                            name: '任职',
                         
                            des: '陕西西部资信是高育良的得意门生',
                            lineStyle: {
                                normal: {
                                   
                                    color: '#000',
                                    
                                }
                              
                            }
                        },
                        {
                            source: '张东',
                            target: '陕西西部资信',
                            name: '任职',
                         
                            des: '陕西西部资信',
                            lineStyle: {
                                normal: {
                                    
                                    color: '#000',
                                    
                                }
                              
                            }
                        }]
        option = {
            title: { text: '企业关系' },
            tooltip: {
                formatter: function (x) {
                    return x.data.des;
                }
            },
            series: [
                {
                    type: 'graph',
                    layout: 'force',
                    symbolSize: 80,
                    roam: true,
                    edgeSymbol: ['circle', 'arrow'],
                    edgeSymbolSize: [4, 10],
                    edgeLabel: {
                        normal: {
                            textStyle: {
                                fontSize: 20
                            }
                        }
                    },
                    force: {
                        repulsion: 2500,
                        edgeLength: [10, 50]
                    },
                    draggable: true,
                    itemStyle: {
                        normal: {
                            color: '#4b565b'
                        }
                    },
                    lineStyle: {
                        normal: {
                            width: 2,
                            color: '#4b565b'

                        }
                    },
                    edgeLabel: {
                        normal: {
                            show: true,
                            formatter: function (x) {
                                return x.data.name;
                            }
                        }
                    },
                    label: {
                        normal: {
                            show: true,
                            textStyle: {
                            }
                        }
                    },
                    data: _node,
                    links:_links 
                }
            ]
        };
        myChart.setOption(option);
    </script>
</body>
</html>

 

 

 

 

 

 

 

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值