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

  • 1
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
以下是一个基本的echarts 3D柱状demo: ```html <!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>ECharts 3D Bar Chart Example</title> <script src="https://cdn.jsdelivr.net/npm/echarts@5.2.1/dist/echarts.min.js"></script> </head> <body> <div id="chart" style="width: 600px;height:400px;"></div> <script> var myChart = echarts.init(document.getElementById('chart')); var data = [ [0, 0, 0, 2], [0, 1, 0, 3], [0, 2, 0, 4], [1, 0, 0, 5], [1, 1, 0, 6], [1, 2, 0, 7], [2, 0, 0, 8], [2, 1, 0, 9], [2, 2, 0, 10] ]; myChart.setOption({ tooltip: {}, visualMap: { max: 10, inRange: { color: ['#e0ffff', '#006edd'] } }, xAxis3D: { type: 'category', data: ['A', 'B', 'C'] }, yAxis3D: { type: 'category', data: ['X', 'Y', 'Z'] }, zAxis3D: { type: 'value' }, grid3D: { boxWidth: 200, boxDepth: 80, viewControl: { // projection: 'orthographic' }, light: { main: { intensity: 1.2, shadow: true }, ambient: { intensity: 0.3 } } }, series: [{ type: 'bar3D', data: data.map(function (item) { return { value: [item[1], item[0], item[2], item[3]] } }), shading: 'lambert', label: { textStyle: { fontSize: 16, borderWidth: 1 }, formatter: function (param) { return param.value[3]; } }, itemStyle: { opacity: 0.8 }, emphasis: { label: { textStyle: { fontSize: 20, color: '#900' } }, itemStyle: { color: '#900' } } }] }); </script> </body> </html> ``` 在这个demo中,我们使用了echarts 5.2.1版本,定义了一个3D柱状,并设置了x、y、z轴的数据和光照等参数。你可以根据需要自定义数据和样式。

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

打赏作者

木子李0531

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

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

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

打赏作者

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

抵扣说明:

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

余额充值