antvis/G6

icon的部分style在调用updateNodeData方法更新后不能生效 #6116

abc3660170 posted onGitHub

Describe the bug / 问题描述

假设我使用的是 iconfont字体图标作为我的icon,style: { iconText: '\u103' } , updateNodeData([ { id:xxx, style: { iconText: '\u104' } }]), 很显然我想通过updateNodeData 将我的icon图标(\u103)更新为其他图标(\u104),这样是无法生效的,如果我更新的是key的fill ,就可以正常更新

No response

Steps to Reproduce the Bug or Issue / 重现步骤

No response

G6 Version / G6 版本

🆕 5.x

Operating System / 操作系统

Windows

Browser / 浏览器

Chrome

Additional context / 补充说明

No response


我猜你可能 node.style 是这样配置的 iconText: '\ue602' 改成下面这样即可:

iconText: d => d.style.iconText || '\ue602',

因为 node.style 的优先级会高于数据中的配置

posted by Aarebecca 9 months ago

确实,配置按照你说的这样调整就可以了

posted by abc3660170 9 months ago

Fund this Issue

$0.00
Funded

Pull requests