console
G6.registerNode(
'inner-animate',
{
afterDraw(cfg, group) {
const image = group.addShape('rect', {
attrs: {
x: 150,
y: 200,
style: {
fill: 'green'
},
width: cfg.size[0],
height: cfg.size[1]
}
// must be assigned in G6 3.3 and later versions. it can be any value you want
})
}
},
'rect'
)
const data = {
nodes: [
{
id: 'node1',
x: 50,
y: 100,
type: 'inner-animate',
size: [50, 50],
style: {
fill: 'red'
}
} // 最简单的
]
}
const graph = new G6.Graph({
container: 'container',
width: 500,
height: 500,
// renderer: 'svg',
modes: {
default: [
'drag-canvas',
'zoom-canvas'
]
}
})
graph.data(data)
graph.render()
<script src="https://gw.alipayobjects.com/os/lib/antv/g6/4.1.4/dist/g6.min.js"></script>
<div id="container" />