1.注册自定义节点
// 注册自定义节点
G6.registerNode(
'flow-rect', // 节点名称,后续使用时用此名称
{
drawShape: function drawShape(cfg, group) {
const rectConfig = {
height: 110,
lineWidth: 1,
fontSize: 12,
fill: '#fff',
radius: 4,
stroke: cfg.status ? '#EB2F96' : '#1890FF',
opacity: 1,
};
// 节点添加方形
const rect = group.addShape('rect', {
attrs: {
...rectConfig,
},
});
const { name = '', time, percent } = cfg;
// 节点添加文本
group.addShape('text', {
attrs: {
text: name, // 文本内容
x: 0, // 横向坐标
y: 0, // 纵向坐标
textAlign: 'left',
textBaseline: 'middle',
fontSize: 16,
fontWeight: 500,
fill: '#666',
},
});
...
...
.