feat: add ExtensionMarkSyncStatePlugin for vchart-extension#4551
Open
kitee0325 wants to merge 2 commits intoVisActor:developfrom
Open
feat: add ExtensionMarkSyncStatePlugin for vchart-extension#4551kitee0325 wants to merge 2 commits intoVisActor:developfrom
kitee0325 wants to merge 2 commits intoVisActor:developfrom
Conversation
…xtensionMark interactive states
xuefei1313
reviewed
Apr 10, 2026
| } | ||
|
|
||
| // 建立新监听 | ||
| const handler = () => { |
Contributor
There was a problem hiding this comment.
我看逻辑入口是chart 层的 'afterRender' ,那这里的状态更新监听其实没有必要,因为 afterRender 在每次完成状态更新后都会触发。
Author
There was a problem hiding this comment.
感谢指出,目前已经做了以下修改:
移除了单个 graphic 上的 afterStateUpdate 事件监听,改为在 afterRender 回调中直接读取 mainGraphic.currentStates 并同步到 extensionMark graphic。
具体变更:
- 移除 _bindHandlers 数组及所有 afterStateUpdate 事件绑定/解绑逻辑
- 移除 graphic 上的去重标记位(_syncStateBindKey、_syncStateBindTarget、_syncStateHandler)
- afterRender 回调中直接遍历 extensionMark graphics,按 context.key 配对主 graphic,同步 currentStates
- 补充了 clearStates() 处理主图元无状态时清除 extensionMark 状态的场景
- Remove afterStateUpdate event binding on individual graphics - Sync states directly in afterRender callback - Remove _bindHandlers, dedup markers - Add clearStates() for empty state scenario - Improve type safety with IMarkGraphic - Fix test page debug log
xuefei1313
approved these changes
Apr 11, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
[中文版模板 / Chinese template]
🤔 This is a ...
🔗 Related issue link
🔗 Related PR link
🐞 Bugserver case id
💡 Background and solution
When using
extensionMarkto draw custom graphics on a series, those graphics do not follow the interactive states (hover, select, etc.) of the primary mark by default. This creates a visual inconsistency when users interact with the chart.Solution: Add a new
ExtensionMarkSyncStatePluginto@visactor/vchart-extension. When anextensionMarkis configured withsyncState: true, the plugin automatically synchronizes the primary mark's interactive states (highlight, blur, selected, etc.) to the corresponding extension mark graphics, matched bycontext.key(data dimension identifier).API:
📝 Changelog
ExtensionMarkSyncStatePluginin@visactor/vchart-extension— enablesextensionMarkto automatically synchronize interactive states (hover/select/blur) from the corresponding primary mark viasyncState: trueconfig@visactor/vchart-extension中新增ExtensionMarkSyncStatePlugin—— 通过syncState: true配置,让 extensionMark 自动同步主图元的交互状态(hover/select/blur)☑️ Self-Check before Merge
🚀 Summary
copilot:summary
🔍 Walkthrough
copilot:walkthrough