Skip to content

fix: Fix the issue where map labels do not follow the map#4592

Open
rubbishmaker wants to merge 1 commit into
VisActor:developfrom
rubbishmaker:fix/map-label-scale@20260529
Open

fix: Fix the issue where map labels do not follow the map#4592
rubbishmaker wants to merge 1 commit into
VisActor:developfrom
rubbishmaker:fix/map-label-scale@20260529

Conversation

@rubbishmaker
Copy link
Copy Markdown

[中文版模板 / Chinese template]

🤔 This is a ...

  • New feature
  • Bug fix
  • TypeScript definition update
  • Bundle size optimization
  • Performance optimization
  • Enhancement feature
  • Refactoring
  • Update dependency
  • Code style optimization
  • Test Case
  • Branch merge
  • Release
  • Site / documentation update
  • Demo update
  • Workflow
  • Other (about what?)

🔗 Related issue link

#4585

🔗 Related PR link

🐞 Bugserver case id

💡 Background and solution

问题在于:

  1. renderInner() 仅触发 label 组件的重渲染,但 label 的 x/y 是缓存在编码器中的,且 projection 此时已经被 zoom() 累加了缩放——但 label 渲染并不会重新跑 dataToPosition ,所以 label 仍处于 旧位置 。
  2. 即使 label 编码会重算,path 是通过 postMatrix 在父 group 上做变换(不在 label 所在的 component 节点链上),label 与 path 处于不同的渲染父级, postMatrix 不会传播到 label graphic 。
    最终结果:path 视觉上被缩放/平移了,label 没有同步任何变换 → 错位。
    参考 ScatterSeries 的成熟方案: 给 label graphic 同步施加和 path 一致的 postMatrix 变换 ,并在 onLayoutEnd 中重置(与 GeoCoordinate.onLayoutEnd 重置 path 的 postMatrix 行为一致)。

📝 Changelog

Language Changelog
🇺🇸 English
🇨🇳 Chinese

☑️ Self-Check before Merge

⚠️ Please check all items below before requesting a reviewing. ⚠️

  • Doc is updated/provided or not needed
  • Demo is updated/provided or not needed
  • TypeScript definition is updated/provided or not needed
  • Changelog is provided or not needed

🚀 Summary

copilot:summary

🔍 Walkthrough

copilot:walkthrough

@xuefei1313
Copy link
Copy Markdown
Contributor

🦞 Aime Bot Review

本次改动的核心思路是将地图 roam 过程中施加在 pathGroup 上的 postMatrix 同步应用到 label graphic,并在 onLayoutEnd 时将 label 的 postMatrix 重置后再触发一次 renderInner(),这样可以让地图缩放/平移期间的 label 与区域 path 保持一致,同时避免重新布局后遗留上一次交互变换。整体方向和问题定位与 PR 描述是一致的。

代码层面看,packages/vchart/src/series/map/map.ts 中把原先仅触发 label.renderInner() 的处理改为直接对 label graphic 做 scale/translate,能够覆盖 label 与 path 不在同一渲染父级、父级 postMatrix 无法自然透传的场景;另外新增的单元测试和浏览器用例分别覆盖了 zoom、pan、连续交互以及 onLayoutEnd 重置行为,测试补充也比较完整。当前我没有看到明显的阻塞性问题。若后续还计划支持更多 map label 变体(例如特殊 label component / 自定义 label renderer),请确认它们同样走的是当前这条 graphic 变换链路。

合并建议:从当前改动和测试覆盖来看,我这边倾向于合并。

@Issues-translate-bot
Copy link
Copy Markdown

Bot detected the issue body's language is not English, translate it automatically. 👯👭🏻🧑‍🤝‍🧑👫🧑🏿‍🤝‍🧑🏻👩🏾‍🤝‍👨🏿👬🏿


🦞Aime Bot Review

The core idea of this change is to synchronously apply the postMatrix applied to the pathGroup during the map roam process to the label graphic, and reset the label's postMatrix during onLayoutEnd before triggering renderInner() again. This can keep the label consistent with the area path during map scaling/panning, and avoid leaving behind the last interactive transformation after re-layout. The overall direction and issue positioning are consistent with the PR description.

At the code level, packages/vchart/src/series/map/map.ts changed the processing that originally only triggered label.renderInner() to directly do scale/translate on the label graphic, which can cover the scenario where the label and path are not in the same rendering parent, and the parent postMatrix cannot be naturally transparently transmitted; in addition, the newly added unit tests and browser use cases cover zoom, pan, continuous interaction and onLayoutEnd resets the behavior, and the test supplement is also relatively complete. Currently I see no obvious blocking issues. If there are plans to support more map label variants (such as special label component/custom label renderer) in the future, please confirm that they also follow the current graphic transformation link.

Merger suggestion: Judging from the current changes and test coverage, I am inclined to merge.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants