antvis/G2


The issue has been closed
registerShape,多次addShape后return shape,渲染是没有问题的,但是使用legend过滤之后,会残留部分shape #3765
PiDazhong posted onGitHub
G2 Version: ^4.1.30
Platform: react
Mini Showcase(like screenshots):
CodePen Link:
registerShape('point', 'maxOrMinPoint', { draw(cfg, group) { const color = 'red'; const showMinPoint = _.get(cfg, 'data.isMin', false); const showMaxPoint = _.get(cfg, 'data.isMax', false); const cfgX = cfg.x as number; const cfgY = cfg.y as number; let resultShape = group.addShape('circle', { attrs: { x: cfg.x as number, y: cfg.y as number, }, }); if (showMaxPoint || showMinPoint) { resultShape = group.addShape('circle', { attrs: { x: cfgX, y: cfgY, r: 3, lineWidth: 2, stroke: color, fill: '#fff', }, name: 'maxCircle', }); resultShape = group.addShape('path', { attrs: { path: `M${cfgX} ${cfgY - 4} L${cfgX + 4} ${cfgY - 8} L${cfgX - 4} ${cfgY - 8} Z`, lineWidth: 2, stroke: color, fill: color, }, name: 'maxPath', }); resultShape = group.addShape('rect', { attrs: { x: cfgX - 20, // 矩形起始点为左上角 y: cfgY - 32, width: 40, height: 24, radius: 4, stroke: color, fill: color, }, name: 'maxPath', }); resultShape = group.addShape('text', { attrs: { x: cfgX, y: cfgY - 14, fontSize: 12, lineWidth: 1, shadowBlur: 0, text: showMaxPoint ? 'Max' : 'Min', fontStyle: 'normal', textAlign: 'center', stroke: '#fff', fill: '#fff', fontWeight: 'lighter', }, name: showMaxPoint ? 'maxCircleText' : 'minCircleText', }); return resultShape; } return resultShape; }, });