behavior/highlight-element/activate-relations
Example page
import { Graph } from '@antv/g6';
const format = (data) => {
const { nodes, edges } = data;
return {
nodes: nodes.map(({ id, ...node }) => ({ id, data: node })),
edges: edges.map(({ id, source, target, ...edge }) => ({ id, source, target, data: edge })),
};
};
fetch('https://gw.alipayobjects.com/os/antvdemo/assets/data/xiaomi.json')
.then((res) => res.json())
.then((data) => {
const graph = new Graph({
container: 'container',
autoFit: 'view',
data: format(data),
behaviors: [
{
type: 'hover-activate',
degree: 1, // 👈🏻 Activate relations.
},
],
layout: {
type: 'force',
preventOverlap: true,
nodeSize: 24,
},
animation: false,
});
graph.render();
});