效果图:
代码块:
var nodes = [
{
x: 10,
y: 990,
nodeName: '秋藤',
svgPath: 'M512 512m-512 0a512 512 0 1 0 1024 0 512 512 0 1 0-1024 0Z',
symbolSize: 20
},
{
x: 200,
y: 990,
nodeName: '台积一',
svgPath: 'M512 512m-512 0a512 512 0 1 0 1024 0 512 512 0 1 0-1024 0Z',
symbolSize: 20
},
{
x: 10,
y: 750,
nodeName: '高旺',
svgPath: 'M512 512m-512 0a512 512 0 1 0 1024 0 512 512 0 1 0-1024 0Z',
symbolSize: 20
},
{
x: 150,
y: 800,
nodeName: '桥林',
svgPath: 'M512 512m-512 0a512 512 0 1 0 1024 0 512 512 0 1 0-1024 0Z',
symbolSize: 20
},
{
x: 10,
y: 550,
nodeName: '研创',
svgPath: 'M512 512m-512 0a512 512 0 1 0 1024 0 512 512 0 1 0-1024 0Z',
symbolSize: 20
},
{
x: 10,
y: 350,
nodeName: '城南河',
svgPath: 'M512 512m-512 0a512 512 0 1 0 1024 0 512 512 0 1 0-1024 0Z',
symbolSize: 20
},
{
x: 200,
y: 350,
nodeName: '山江',
svgPath: 'M512 512m-512 0a512 512 0 1 0 1024 0 512 512 0 1 0-1024 0Z',
symbolSize: 20
},
{
x: 110,
y: 150,
nodeName: '沿泰',
svgPath: 'M512 512m-512 0a512 512 0 1 0 1024 0 512 512 0 1 0-1024 0Z',
symbolSize: 20
},
{
x: 300,
y: 500,
nodeName: '东大',
svgPath: 'M512 512m-512 0a512 512 0 1 0 1024 0 512 512 0 1 0-1024 0Z',
symbolSize: 20
},
{
x: 500,
y: 900,
nodeName: '六合',
svgPath: 'M512 512m-512 0a512 512 0 1 0 1024 0 512 512 0 1 0-1024 0Z',
symbolSize: 20
},
{
x: 700,
y: 900,
nodeName: '熊州',
svgPath: 'M512 512m-512 0a512 512 0 1 0 1024 0 512 512 0 1 0-1024 0Z',
symbolSize: 20
},
{
x: 900,
y: 900,
nodeName: '宁北',
svgPath: 'M512 512m-512 0a512 512 0 1 0 1024 0 512 512 0 1 0-1024 0Z',
symbolSize: 20
},
{
x: 500,
y: 550,
nodeName: '三汊湾',
svgPath: 'M512 512m-512 0a512 512 0 1 0 1024 0 512 512 0 1 0-1024 0Z',
symbolSize: 20
},
{
x: 700,
y: 400,
nodeName: '槽坊',
svgPath: 'M512 512m-512 0a512 512 0 1 0 1024 0 512 512 0 1 0-1024 0Z',
symbolSize: 20
},
{
x: 700,
y: 150,
nodeName: '扬巴',
svgPath: 'M512 512m-512 0a512 512 0 1 0 1024 0 512 512 0 1 0-1024 0Z',
symbolSize: 20
},
{
x: 800,
y: 200,
nodeName: '扬石',
svgPath: 'M512 512m-512 0a512 512 0 1 0 1024 0 512 512 0 1 0-1024 0Z',
symbolSize: 20
},
{
x: 900,
y: 550,
nodeName: '黄巷',
svgPath: 'M512 512m-512 0a512 512 0 1 0 1024 0 512 512 0 1 0-1024 0Z',
symbolSize: 20
},
{
x: 1000,
y: 550,
nodeName: '宁化',
svgPath: 'M512 512m-512 0a512 512 0 1 0 1024 0 512 512 0 1 0-1024 0Z',
symbolSize: 20
},
{
x: 900,
y: 300,
nodeName: '杨石二',
svgPath: 'M512 512m-512 0a512 512 0 1 0 1024 0 512 512 0 1 0-1024 0Z',
symbolSize: 20
},
{
x: 980,
y: 300,
nodeName: '玉带',
svgPath: 'M512 512m-512 0a512 512 0 1 0 1024 0 512 512 0 1 0-1024 0Z',
symbolSize: 20
},
{
x: 500,
y: 150,
nodeName: '汊河',
svgPath: 'M512 512m-512 0a512 512 0 1 0 1024 0 512 512 0 1 0-1024 0Z',
symbolSize: 20
},
{
x: 400,
y: 250,
nodeName: '刚五',
svgPath: 'M512 512m-512 0a512 512 0 1 0 1024 0 512 512 0 1 0-1024 0Z',
symbolSize: 20
},
{
x: 300,
y: 200,
nodeName: '刚三',
svgPath: 'M512 512m-512 0a512 512 0 1 0 1024 0 512 512 0 1 0-1024 0Z',
symbolSize: 20
},
{
x: 300,
y: 50,
nodeName: '盘城',
svgPath: 'M512 512m-512 0a512 512 0 1 0 1024 0 512 512 0 1 0-1024 0Z',
symbolSize: 20
},
{
x: 500,
y: -50,
nodeName: '桃花',
svgPath: 'M512 512m-512 0a512 512 0 1 0 1024 0 512 512 0 1 0-1024 0Z',
symbolSize: 20
},
{
x: 650,
y: -50,
nodeName: '南热',
svgPath: 'M512 512m-512 0a512 512 0 1 0 1024 0 512 512 0 1 0-1024 0Z',
symbolSize: 20
}
];
var charts = {
nodes: [],
linesData: [
{
coords: [
//秋藤 -> 台积一
[10, 1000],
[200, 1000]
],
label: {
normal: {
show: true,
formatter: '1212',
color: '#ed46a2',
fontSize: 12,
fontWeight: 'normal'
}
},
},
{
coords: [
//秋藤 -> 桥林
[10, 970],
[80, 970],
[80, 800],
[150, 800]
]
},
{
coords: [
//秋藤 -> 高旺
[10, 1000],
[10, 750]
]
},
{
coords: [
//高旺 -> 研创
[10, 750],
[10, 550]
]
},
{
coords: [
//研创 -> 城南河
[10, 550],
[10, 350]
]
},
{
coords: [
//城南河 -> 山江
[10, 350],
[200, 350]
]
},
{
coords: [
//山江 -> 沿泰
[193, 350],
[192, 150],
[110, 150]
]
},
{
coords: [
//沿泰 -> 桃花
[110, 150],
[110, -60],
[500, -60]
]
},
{
coords: [
//山江 -> 桃花
[205, 350],
[205, -40],
[500, -40]
]
},
{
coords: [
//山江 -> 东大
[200, 360],
[395, 360],
[395, 490],
[300, 490]
]
},
{
coords: [
//山江 -> 三汊湾
[200, 340],
[405, 340],
[405, 540],
[500, 540]
]
},
{
//三汊湾 -> 六合
coords: [
[500, 550],
[500, 900]
]
},
{
//三汊湾 -> 槽坊
coords: [
[500, 540],
[695, 540],
[695, 400]
]
},
{
//三汊湾 -> 东大
coords: [
[500, 560],
[395, 560],
[395, 515],
[300, 515]
]
},
{
//六合 -> 熊州
coords: [
[500, 900],
[700, 900]
]
},
{
//熊州 -> 宁北
coords: [
[700, 900],
[900, 900]
]
},
{
//宁北 -> 黄巷
coords: [
[900, 900],
[900, 550]
]
},
{
//黄巷 -> 宁化
coords: [
[900, 550],
[1000, 550]
]
},
{
//黄巷 -> 槽坊
coords: [
[900, 540],
[705, 540],
[705, 400]
]
},
{
//黄巷 -> 杨石二
coords: [
[900, 550],
[900, 300]
]
},
{
//黄巷 -> 玉带
coords: [
[900, 550],
[980, 300]
]
},
{
//三汊湾 -> 黄巷
coords: [
[500, 560],
[900, 560]
]
},
{
//三汊湾 -> 汊河
coords: [
[500, 550],
[500, 150]
]
},
{
//糟坊 -> 扬巴
coords: [
[700, 400],
[700, 150]
]
},
{
//糟坊 -> 汊河
coords: [
[700, 400],
[600, 400],
[600, 150],
[500, 150]
]
},
{
//糟坊 -> 扬石
coords: [
[700, 400],
[800, 400],
[800, 200]
]
},
{
//汊河 -> 桃花
coords: [
[500, 150],
[500, -50]
]
},
{
//汊河 -> 刚五
coords: [
[500, 160],
[400, 160],
[400, 250]
]
},
{
//汊河 -> 盘城
coords: [
[500, 140],
[400, 140],
[400, 50],
[300, 50]
]
},
{
//盘城 -> 刚三
coords: [
[300, 50],
[300, 200]
]
},
{
//桃花 -> 南热
coords: [
[500, -50],
[650, -50]
]
}
]
};
for (var j = 0; j < nodes.length; j++) {
const { x, y, nodeName, svgPath, symbolSize } = nodes[j];
var node = {
nodeName,
value: [x, y],
symbolSize: symbolSize || 50,
symbol: 'path://' + svgPath,
itemStyle: {
color: 'orange'
}
};
charts.nodes.push(node);
}
option = {
backgroundColor: '#090E45',
grid: {
left: '3%',
top: '3%',
right: '3%'
},
xAxis: {
min: 0,
max: 1000,
show: false,
type: 'value'
},
yAxis: {
min: -70,
max: 1020,
show: false,
type: 'value'
},
series: [
{
type: 'graph',
coordinateSystem: 'cartesian2d',
label: {
show: true,
position: 'bottom',
color: 'orange',
formatter: function (item) {
return item.data.nodeName;
}
},
data: charts.nodes
},
{
type: 'lines',
polyline: true,
coordinateSystem: 'cartesian2d',
lineStyle: {
type: 'solid',
width: 1,
color: '#175064',
curveness: 1,
shadowBlur:1, //阴影
shadowColor:"#9AEFFF",
// shadowOffsetX:10,
// shadowOffsetY:10
},
effect: {
show: true,
trailLength: 0.1,
symbol: 'rect', //线特效的配置
color: 'orange',
symbolSize: [3,9]
},
data: charts.linesData
}
]
};