echarts多对多关系图

let dataInfo = [{
    name: "蔚来汽车",
    category: 0, // 层级关系
    symbolSize: 50,
    draggable: true,
    fixed: true,
    value: [0, 150],
    // symbol: `image://${bubble1}`  自定义背景图
}, {
    name: "威马汽车",
    category: 0,
    symbolSize: 80,
    draggable: true,
    fixed: true,
    value: [600, 150]
}, {
    name: "小鹏汽车",
    category: 0,
    value: [200, 200],
    draggable: true,
    fixed: true,
    symbolSize: 50
}, {
    name: "比亚迪",
    category: 0,
    value: [150, 140],
    draggable: true,
    fixed: true,
    symbolSize: 50
}, {
    name: "江淮汽车",
    category: 0,
    value: [200, 100],
    draggable: false,
    symbolSize: 50
}, {
    name: "北汽新能源",
    category: 0,
    symbolSize: 50,
    draggable: false,
    value: [300, 200]
}]
let dataLink = [{
    source: "蔚来汽车",
    value: " ",
    target: "比亚迪",
    lineStyle: {
        width: 1
    }
},{
    source: "比亚迪",
    value: " ",
    target: "蔚来汽车",
    lineStyle: {
        width: 3
    }
},{
    source: "蔚来汽车",
    value: " ",
    target: "威马汽车",
}, {
    source: "蔚来汽车",
    value: " ",
    target: "小鹏汽车",
}, {
    source: "威马汽车",
    value: " ",
    target: "小鹏汽车",
}, {
    source: "比亚迪",
    value: " ",
    target: "小鹏汽车",
}, {
    source: "比亚迪",
    value: " ",
    target: "威马汽车",
}, {
    source: "北汽新能源",
    value: " ",
    target: "比亚迪",
}, {
    source: "北汽新能源",
    value: " ",
    target: "蔚来汽车",
}, {
    source: "北汽新能源",
    value: " ",
    target: "江淮汽车",
}, {
    source: "江淮汽车",
    value: " ",
    target: "蔚来汽车",
}, {
    source: "江淮汽车",
    value: " ",
    target: "比亚迪",
    lineStyle: {
        width: 3
    }
}, {
    source: "江淮汽车",
    value: " ",
    target: "威马汽车",
}, {
    source: "威马汽车",
    value: " ",
    target: "北汽新能源",
}, {
    source: "小鹏汽车",
    value: " ",
    target: "北汽新能源",
    lineStyle: {
        width: 5
    }
}, {
    source: "小鹏汽车",
    value: " ",
    target: "江淮汽车",
}]
option = {
    title: {
        text: "实体属性关系图",
        top: "top",
        left: "center"
    },
    itemStyle: {
        normal: {
            color: '#000',
        },
        shadowBlur: 10
    },
    animationDuration: 1500,
    animationEasingUpdate: 'quinticInOut',
    xAxis: {
        show: false,
        type: 'value'
    },
    yAxis: {
        show: false,
        type: 'value'
    },
    series: [{
        type: 'graph',
        coordinateSystem: 'cartesian2d',
        legendHoverLink: false,
        hoverAnimation: true,
        nodeScaleRatio: false,
        // 是否要箭头
        edgeSymbol: ['circle', 'none'],
        edgeSymbolSize: [2, 15],
        edgeLabel: {
            show: false,
            normal: {
                show: true,
                position: 'middle',
                textStyle: {
                    fontSize: 12
                },
                formatter: "{c}"
            }
        },
        focusNodeAdjacency: true,
        roam: true,
        categories: [{
            name: '一级关系',
            itemStyle: { // 可配置颜色
                normal: {
                    color: new echarts.graphic.LinearGradient(
                  0, 0, 0, 1,
                  [
                    {offset: 0.1, color: '#A1C3D6'},
                    {offset: 0.6, color: '#186C9B'},
                    {offset: 0.95, color: '#A1C3D6'},
                  ]),
                }
            }
        }],
        //圆形上面的文字
        label: {
            normal: {
                position: "inside",
                show: true,
                textStyle: {
                    color: '#fff',
                    fontSize: 12
                },
            }
        },
        force: {
            repulsion: 1000,
        },
        itemStyle: {
            normal: {
                color: new echarts.graphic.LinearGradient(0, 0, 1, 1, [{
                    offset: 0,
                    color: '#000eff'
                }, {
                    offset: 1,
                    color: '#35c2ff'
                }]),
            },
            shadowBlur: 10
        },
        lineStyle: {
            normal: {
                width: 1,
                shadowColor: 'none',
                color: '#000'
            },
        },
        data: dataInfo,
        links: dataLink
    }]
}

 

  • 0
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
很抱歉,作为一个文本AI模型,我无法直接显示片。但是,你可以通过以下步骤来获取Echarts关系片: 1. 首先,你需要安装Echarts库。你可以在Echarts的官方网站(https://www.echartsjs.com/zh/index.html)上找到安装和使用文档。 2. 使用Echarts创建你想要的关系,并将其保存为片。你可以使用Echarts提供的API和配置选项来定义表的样式和数据。 3. 保存关系片。Echarts提供了`echarts.convertToImage`方法,可以将关系转换为片,并可以选择下载或保存。 以下是一个简单的示例代码,展示了如何使用Echarts创建一个关系并保存为片: ```javascript // 引入Echarts库 import echarts from 'echarts'; // 创建一个关系实例 const chart = echarts.init(document.getElementById('chart-container')); // 配置关系的样式和数据 const option = { // 配置选项... series: [{ type: 'graph', // 数据... }] }; // 设置关系的配置项 chart.setOption(option); // 将关系转换为片 chart.convertToImage({ type: 'png', // 片类型 pixelRatio: 1, // 分辨率 backgroundColor: '#fff', // 背景颜色 }); // 保存关系片 chart.saveAsImage('relation_chart.png'); ``` 请确保你已经正确安装了Echarts库,并在HTML文件中添加了一个具有唯一id的div元素(例如`<div id="chart-container"></div>`)作为关系的容器。 希望这能帮到你!如果你有任何其他问题,请随时提问。

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值