You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

96 lines
2.2 KiB

3 years ago
export default function splitOption(dataNodes = [],dataEdges=[]) {
let nodes = [];
dataNodes.forEach(ele => {
let obj = {
x: ele.x,
y: ele.y,
id: ele.id,
name: ele.name,
value: ele.value,
symbolSize: ele.symbolSize,
itemStyle: {
color: ele.color
}
};
nodes.push(obj)
})
// let nodes = data.nodes.map(node => {
// return {
// x: node.x,
// y: node.y,
// id: node.id,
// name: node.name,
// value: node.value,
// symbolSize: node.symbolSize,
// itemStyle: {
// color: node.color
// }
// };
// });
let edges = [];
dataEdges.forEach(ele => {
let obj = {
source: ele.source,
target: ele.target
};
edges.push(obj);
})
// let edges = data.edges.map(edge => {
// return {
// source: edge.source,
// target: edge.target
// };
// })
return {
tooltip: {
trigger: "item",
color: "#333",
textStyle: {
color: "#333", //设置文字颜色
},
},
title: {
show: false,
text: 'NPM Dependencies'
},
animationDurationUpdate: 1500,
animationEasingUpdate: 'quinticInOut',
series: [
{
type: 'graph',
layout: 'none',
// progressiveThreshold: 700,
data: nodes,
links: edges,
emphasis: {
focus: 'adjacency',
label: {
position: 'right',
show: true
}
},
label: {
show: true,
color: '#fff',
position: 'right',
formatter: '{b}'
},
labelLayout: {
hideOverlap: true
},
scaleLimit: {
min: 0.4,
max: 2
},
roam: true,
lineStyle: {
color: 'source',
width: 0.5,
curveness: 0.3,
opacity: 0.7
}
}
]
}
}