This commit is contained in:
duanhao 2025-08-11 15:35:45 +08:00
parent 5a35e6fd1a
commit a6b733df7e
3 changed files with 59 additions and 36 deletions

View File

@ -128,6 +128,8 @@ const registEvents = () => {
}
})
}
const runDiffForceLayout = (layoutConfig, layoutType, isAsync) => {
function handleLayoutSuccess() {
//
@ -204,7 +206,10 @@ const runDiffForceLayout = (layoutConfig, layoutType, isAsync) => {
}
)
}
graphVis.autoGroupLayout(graphVis.nodes)
// graphVis.autoGroupLayout(graphVis.nodes)
}
new Map([
@ -244,15 +249,20 @@ const clusterAnalyze = () => {
node.fillColor = color
node.color = color
})
if(storeId !== "anomalousGroup"){
graphVis.addNodesInGroup(nodes, {
shape: "circle", //circle|rect|polygon|bubbleset
color: color,
alpha: 0.2
})
}
})
graphVis.autoGroupLayout(graphVis.nodes)
// graphVis.autoGroupLayout(graphVis.nodes)
}
//
if (storeId === "anomalousGroup") {
watch(
@ -286,7 +296,12 @@ const initChart = () => {
createGraph()
graphVis.addGraph({ ...toRaw(graph.value) })
clusterAnalyze()
if(storeId === "anomalousGroup"){
runDiffForceLayout({ strength: -500, ajustCluster: true }, "simulation", true)
}else {
runDiffForceLayout({ strength: -500, ajustCluster: true }, "simulation", true)
}
}
//
@ -299,7 +314,11 @@ const updateChart = (newGraphData) => {
graphVis.addGraph({ ...toRaw(newGraphData) })
//
clusterAnalyze()
if(storeId === "anomalousGroup"){
runDiffForceLayout({ strength: -500, ajustCluster: true }, "simulation", true)
}else {
runDiffForceLayout({ strength: -500, ajustCluster: true }, "simulation", true)
}
}
let lastLength = 0 //

View File

@ -174,16 +174,6 @@ const initChart = async() => {
//
chartInstance.on('mouseover', function(params) {
if (!params.data) return;
/* const isBridgeNode = params.data.category === 0;
if (isBridgeNode) {
//
const nodeId = params.data.originalId;
//
activeNodeId.value = nodeId;
updateNodeImage(nodeId, true);
} */
if (params.dataType === 'node') {
//
chartInstance.dispatchAction({
@ -192,7 +182,7 @@ const initChart = async() => {
dataIndex: params.dataIndex
});
//
//
const isBridgeNode = params.data.category === 0;
if (isBridgeNode) {
const nodeId = params.data.originalId;
@ -203,7 +193,6 @@ const initChart = async() => {
//
chartInstance.dispatchAction({ type: 'unfocusNodeAdjacency', seriesIndex: SERIES_INDEX });
chartInstance.dispatchAction({ type: 'downplay', seriesIndex: SERIES_INDEX });
// tooltip formatter
}
});
@ -211,15 +200,6 @@ const initChart = async() => {
//
chartInstance.on('mouseout', function(params) {
if (!params.data) return;
/* const isBridgeNode = params.data.category === 0;
if (isBridgeNode) {
//
const nodeId = params.data.originalId;
if (activeNodeId.value === nodeId) {
activeNodeId.value = null;
updateNodeImage(nodeId, false);
}
} */
if (params.dataType === 'node') {
//
chartInstance.dispatchAction({

View File

@ -51,6 +51,24 @@ const initChart = async () => {
//
chart = echarts.init(document.getElementById("container"))
const SERIES_INDEX = 0;
//
chart.on('mouseover', function(params) {
if (!params.data) return;
if (params.dataType === 'node') {
//
chart.dispatchAction({
type: 'focusNodeAdjacency',
seriesIndex: SERIES_INDEX,
dataIndex: params.dataIndex
});
} else if (params.dataType === 'edge') {
//
chart.dispatchAction({ type: 'unfocusNodeAdjacency', seriesIndex: SERIES_INDEX });
chart.dispatchAction({ type: 'downplay', seriesIndex: SERIES_INDEX });
}
});
//data
//key: id value:
//id
@ -267,12 +285,18 @@ const initChart = async () => {
width: 1
},
emphasis: {
//
focus: "adjacency", //
lineStyle: {
// 线
width: 5 // 线(10)
}
focus: 'adjacency', // blur
blurScope: 'series', //
scale: false, //
lineStyle: { opacity: 1 },
itemStyle: { opacity: 1 },
label: { opacity: 1 }
},
blur: {
// /
lineStyle: { opacity: 0.05 },
itemStyle: { opacity: 0.1 },
label: { opacity: 0 }
}
}
]