vue 使用echarts 实现关系图,效果如下:


说明: 关系图可以有两种,一种是指定坐标x,y。 另外一种就是通过设置series属性

layout: "force",
force: {repulsion: [-2, 100], //节点之间的斥力因子。支持数组表达斥力范围,值越大斥力越大。gravity: 0.03, //节点受到的向中心的引力因子。该值越大节点越往中心点靠拢。edgeLength: [20, 200], //边的两个节点之间的距离,这个距离也会受 repulsion:[10, 50]值越小则长度越长layoutAnimation: false,},

vue全部代码如下```javascript
<template><div class="uni-chart-container"><div class="uni-bar-charts" :id="id"></div></div>
</template><script>
import echarts from "echarts";
import resize from "../mixins/resize";
export default {name: "uniGraph",mixins: [resize],components: {},data() {return {options: {title: {text: "",},series: [],},barData: [],myChart: null,seriesName: "",};},props: {id: {type: String,require: true,},sortMethod: {type: String,default: "desc",},title: {type: String,},optionsSetup: {type: Object,default: () => {return {};},},isVertical: {type: Boolean,default: true,},chartsData: {type: Object,default: function () {return {nodes: [{name: "李志强",category: 0,symbolSize: 30,value: ["确诊"],color: "#F10F0F",},{name: "张亮",category: 2,symbolSize: 30,value: ["密接"],color: "#FFC001",},{name: "王飞",category: 1,symbolSize: 30,value: ["次密接"],color: "#1D84C6",},{name: "王丽",category: 2,symbolSize: 30,value: ["密接"],color: "#FFC001",},{name: "符华",category: 1,symbolSize: 30,value: ["次密接"],color: "#1D84C6",},{name: "钱峰",category: 1,symbolSize: 30,value: ["次密接"],color: "#1D84C6",},{name: "吴梦",category: 1,symbolSize: 30,color: "#1D84C6",value: ["次密接"],},{name: "杨月",category: 1,symbolSize: 30,color: "#1D84C6",value: ["次密接"],},],links: [{source: "李志强",target: "张亮",linkTip: "聚餐",},{source: "张亮",target: "王飞",linkTip: "出现在同一场所",},{source: "李志强",target: "王丽",linkTip: "出现在同一场所",},{source: "张亮",target: "钱峰",linkTip: "聚餐",},{source: "张亮",target: "符华",linkTip: "家庭聚集",},{source: "张亮",target: "杨月",linkTip: "出现在同一场所",},{source: "张亮",target: "吴梦",linkTip: "出现在同一场所",},],categories: [{name: "确诊",},{name: "次密接",},{name: "密接",},],};},},customColor: {type: Array,default: function () {return ["#1890FF"];},},// 展示前5条 可传5maxL: {default: "auto",},codeStatus: {type: Array,},},watch: {chartsData: {deep: true,immediate: true,handler: function (v) {let _this = this;this.$nextTick(function () {_this.init();});},},},beforeDestroy() {if (!this.myChart) {return;}this.myChart.dispose();this.myChart = null;},methods: {init() {//构建3d饼状图if (this.myChart) this.myChart.dispose();this.myChart = echarts.init(document.getElementById(this.id));this.editorOptions(this.chartsData);// 传入数据生成 optionthis.myChart.setOption(this.options);},editorOptions(val) {let series = this.getSeries(val);var options = {tooltip: {// formatter: (e) => {//   console.log(e);//   return e.name + e.data.value;// },},animationDuration: 1500,animationEasingUpdate: "quinticInOut",color: this.customColor,grid: this.setOptionsMargin(),series: series,};this.options = options;},getSeries(newData) {const series = [];series.push({name: "关系图谱",type: "graph",hoverAnimation: true,layout: "force",force: {repulsion: [-2, 100], //节点之间的斥力因子。支持数组表达斥力范围,值越大斥力越大。gravity: 0.03, //节点受到的向中心的引力因子。该值越大节点越往中心点靠拢。edgeLength: [20, 200], //边的两个节点之间的距离,这个距离也会受 repulsion:[10, 50]值越小则长度越长layoutAnimation: false,},nodeScaleRatio: 0.6,draggable: true,roam: false, //鼠标缩放和平移symbol: "circle",edgeSymbol: ["circle", "arrow"],data: newData.nodes,links: newData.links,categories: newData.categories,cursor: "pointer",focusNodeAdjacency: true,scaleLimit: {//所属组件的z分层,z值小的图形会被z值大的图形覆盖min: 0, //最小的缩放值max: 9, //最大的缩放值},edgeLabel: {//连接线上文字normal: {show: true,textStyle: {fontSize: 10,},formatter: (e) => {return e.name;},},},label: {normal: {show: true,},},lineStyle: {normal: {width: 1.5,curveness: 0,type: "solid",},},});return series;},// 边距设置setOptionsMargin() {const optionsSetup = this.optionsSetup;const grid = {left: optionsSetup.marginLeft,right: optionsSetup.marginRight,bottom: optionsSetup.marginBottom,top: optionsSetup.marginTop,containLabel: true,};return grid;},},
};
</script>
<style lang="scss">
.uni-chart-container,
.uni-bar-charts {width: 100%;height: 100%;
}
</style>

resize文件如下:debounce可以自行实现

import {debounce
} from "@/utils/utils.js";export default {data() {return {};},mounted() {this.initListener();},beforeDestroy() {this.destroyListener();},deactivated() {this.destroyListener();},methods: {initListener() {window.addEventListener("resize", debounce(this.resize, 100));},destroyListener() {window.removeEventListener("resize", this.resize);},resize() {const {myChart} = this;myChart && myChart.resize();},},
};

echarts关系图vue完整代码相关推荐

  1. echarts 关系图 option

    echarts 关系图 option <script type="text/javascript" src="plugins/echarts/echarts.min ...

  2. echarts关系图graph点击折叠

    首选参考别人的地址:echarts节点折叠实现_SongJingzhou的博客-CSDN博客 echarts下载: echarts下载 其次先看一下我改的效果图: 接下来分段解释一下需要的代码: 1. ...

  3. 用Bi-GRU语义解析,实现中文人物关系分析 | 附完整代码

    作者 | 李秋键 责编 | Carol 来源 | AI科技大本营(ID:rgznai100) 语义解析作为自然语言处理的重要方面,其主要作用如下:在词的层次上,语义分析的基本任务是进行词义消歧:在句子 ...

  4. 知识图谱---echarts关系图

    一:三级关系图知识图谱 最近写了个demo,主要功能是搜索实体,搜索结果显示与该实体相关的公司.子公司.设备.位置.状态.危害这六类,数据是通过我司的数据标注系统提供的.后端用到的技术栈是python ...

  5. echarts关系图demo

    实现效果: 代码: <!DOCTYPE html> <html lang="en"><head><meta charset="U ...

  6. ECharts关系图(详细示例——满满的注释)

    图表效果如下: 具体代码如下: <!DOCTYPE html> <html><head><meta charset="UTF-8"> ...

  7. echarts关系图配置详解

    title 图表标题样式 title: {text: "ECharts简单线形图表及其配置展示实例", //正标题link: "http://www.stepday.co ...

  8. echarts关系图配置,及超出范围处理 + a、b两个节点互相指向时线上的字重叠问题

    情景:由于人物关系复杂,可以有几个 --几十个(上百个),所以固定范围内(如:500高度)可能放不下,或者太空.所以可以根据node节点(也可根据其他判断条件)来动态修改 div / canvas高度 ...

  9. Echarts关系图的例子

    1.普通关系图 option = {title: {text: '数据图谱'},tooltip: {trigger: 'item',formatter: '{a} : {b}'// 如果用索引关联关系 ...

  10. Python实现图片转化为字符图(附完整代码)

    工作原理: 先将图片每个像素的hsv(色相,饱和度,明度)值转化为可读取对象,使用到PIL的Image方法: from PIL import Imageimg = Image.open('test.p ...

最新文章

  1. 属性与意图识别_解密宝能汽车智能驾舱的“未来属性”
  2. javaScript初学笔记(二)
  3. asp.net导出excel-一行代码实现excel、xml、pdf、word、html、csv等7种格式文件导出功能而且美观-SNF快速开发平台...
  4. cad设计院常用字体_趣谈 | 那些年我们看过的电气图纸(附CAD/EPLAN区别)
  5. linux中tags文件能删除吗,Git 详细介绍查看、删除、重命名远程分支和tag
  6. python2 python3 通信_python与USB通信
  7. 深度学习常用软件包和基本环境配置
  8. Markdown 语法手册全
  9. 网友在各自领域中所用到的芯片总结(转载赛亚人hanker的博客)
  10. 产品故事:一家服装厂的创新之路
  11. CSDN博客索引-2
  12. 索尼手机android怎么连,索尼SmartWatch 2 SW2 连接手机图文教程
  13. C++设计模式——组合模式(高屋建瓴)
  14. HTML_个人简历表
  15. 5.brackets 快捷键 有大用
  16. Ctrl+c和Ctrl+v永远的神
  17. android 耳机图标显示图标,一种耳机图标的显示方法及终端与流程
  18. C++——黑白棋(落子)
  19. 深度学习——CNN(卷积神经网络)(超详细)
  20. Linux——分布式存储Ceph

热门文章

  1. 1、结构化、面向对象程序设计差别、类基本概念
  2. 云刷工具q币android版,交流电app下载2021-交流电交友手机版v3.2.4最新版-游吧乐下载...
  3. tomcat-解决get请求中文乱码问题
  4. VC6.0 中文代码显示乱码的问题
  5. html背景图片被白色覆盖,html – CSS背景图片淡出白色
  6. 美团技术团队书单(通用能力篇)
  7. 大学计算机第一课知识点,大学计算机基础第一课
  8. 一位10年Java工作经验的架构师聊Java和工作经验
  9. 传统架构 vs 云原生架构,谈谈为什么我们需要云原生架构?
  10. 如何将PDF英文文档进行翻译?