echarts 人物关系图demo

<!DOCTYPE html>
<html style="height: 100%">
    <head>
        <meta charset="utf-8">
    </head>
    <body style="height: 100%; margin: 0">
        <div id="container" style="height: 100%"></div>
        <script type="text/javascript" src="https://cdn.jsdelivr.net/npm/echarts@5/dist/echarts.min.js"></script>
<script type="text/javascript">
var dom = document.getElementById("container");
var myChart = echarts.init(dom);
var app = {};

var option;

option = {
    title: {
        text: 'Graph 简单示例'
    },
    tooltip: {},
    animationDurationUpdate: 1500,
    animationEasingUpdate: 'quinticInOut',
    series: [
        {
            type: 'graph',
            layout: 'circular',
            symbolSize: 50,
            roam: true,
            label: {
                show: true
            },
            edgeSymbol: ['circle', 'arrow'],
            edgeSymbolSize: [3, 10],
            focusNodeAdjacency: true,
            edgeLabel: {
                 normal: {
                    show: true,
                    textStyle: {
                        fontSize: 20
                    },
                    formatter: "{c}"
                }
            },
            // layout:'',
            data: [{
                name: '人物1',
                // x: 300,
                // y: 300
            }, {
                name: '人物2',
                // x: 800,
                // y: 300
            }, {
                name: '人物3',
                // x: 550,
                // y: 100
            }, {
                name: '人物4',
                // x: 550,
                // y: 500
            },{
                name: '人物5',
                // x: 580,
                // y: 400
            }],
            // links: [],
            links: [{

                source:0,
                target: 2,
                value: '父亲',
                // symbolSize: [5, 20],
                // label: {
                //     show: true,
                // },
                lineStyle: {
                    color: 'red',
                    curveness: '-0.4'
                }
            },{

                source:2,
                target: 0,
                value: '儿子',
                // symbolSize: [5, 20],
                // label: {
                //     show: true,
                // },
                lineStyle: {
                    color: 'pink',
                    curveness: 0.4
                }
            }, {
                source: 2,
                target: 3,
                value: '情人',
                lineStyle: {
                    curveness: -0.2
                }
            }, {
                source: 4,
                target: 0,
                value: '夫妻',
                lineStyle: {
                    color:'blue',
                    curveness: 0.1
                }
            }, {
                source: 0,
                target: 4,
                value: '夫妻',
                lineStyle: {
                    color:'red',
                    curveness: '-0.1'
                }
            },{
                source: 1,
                target: 2,
                value: '朋友',
            }, {
                source: 1,
                target: 3,
                value: '朋友',
            }, {
                source: 0,
                target: 3,
                value: '情人',
            }],
            lineStyle: {
                opacity: 0.9,
                width: 2,
                curveness: 0
            }
        }
    ]
};

if (option && typeof option === 'object') {
    myChart.setOption(option);
}
</script>
</body>
</html>
    

 

具体参数说明参考官方文档:https://echarts.apache.org/zh/option.html#series-graph.type

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

木子李0531

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值