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

View File

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

View File

@ -51,6 +51,24 @@ const initChart = async () => {
// //
chart = echarts.init(document.getElementById("container")) 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 //data
//key: id value: //key: id value:
//id //id
@ -267,12 +285,18 @@ const initChart = async () => {
width: 1 width: 1
}, },
emphasis: { emphasis: {
// focus: 'adjacency', // blur
focus: "adjacency", // blurScope: 'series', //
lineStyle: { scale: false, //
// 线 lineStyle: { opacity: 1 },
width: 5 // 线(10) itemStyle: { opacity: 1 },
} label: { opacity: 1 }
},
blur: {
// /
lineStyle: { opacity: 0.05 },
itemStyle: { opacity: 0.1 },
label: { opacity: 0 }
} }
} }
] ]