前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >Echarts 关系图谱示例「建议收藏」

Echarts 关系图谱示例「建议收藏」

作者头像
全栈程序员站长
发布2022-09-07 15:59:17
1.5K0
发布2022-09-07 15:59:17
举报
文章被收录于专栏:全栈程序员必看

大家好,又见面了,我是你们的朋友全栈君。

在这里插入图片描述
在这里插入图片描述
代码语言:javascript
复制
<!DOCTYPE html>
<html>
<head>
    <meta name="viewport" content="width=device-width"/>
    <title>ECharts 关系图谱</title>
    <script src="jquery-1.10.2.min.js"></script>
    <script src="echarts.min.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')); 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: [ { 
      name: '张三', des: '退休', symbolSize: 100, itemStyle: { 
      normal: { 
      color: 'red' } } }, { 
      name: '李四', des: '自己创业', itemStyle: { 
      normal: { 
      color: 'red' } } }, { 
      name: '王五', des: '测试人员', symbolSize: 100 }, { 
      name: '天天', des: '程序员', itemStyle: { 
      normal: { 
      color: 'red' } } } ], links: [ { 
      source: '张三', target: '李四', name: '姐妹', des: '张三与户主【李四】关系为姐妹' }, { 
      source: '王五', target: '李四', name: '朋友' }, { 
      source: '天天', target: '王五', name: "同事" }, { 
      source: '李四', target: '天天', name: "父子" } ] } ] }; myChart.setOption(option); </script>
</body>
</html>

发布者:全栈程序员栈长,转载请注明出处:https://javaforall.cn/153298.html原文链接:https://javaforall.cn

本文参与 腾讯云自媒体同步曝光计划,分享自作者个人站点/博客。
原始发表:2022年6月2,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体同步曝光计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档