fix(pictogram): respect SVG text anchors - #4685
Merged
Merged
Conversation
skie1997
approved these changes
Sep 15, 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.
🤔 这个分支是...
🐞 Bugserver 用例 id
674d2b8a435dab00bc007d5c💡 问题的背景&解决方案
Pictogram 将 SVG 的
text-anchor写入无效的textBaseLine字段,水平对齐始终回退为left。因此使用middle或end的文字向右偏移,并可能被 SVG 画布裁剪。在现有文字属性转换器中将
start / middle / end映射为left / center / right,保留显式textAlign的优先级,并删除错误的基线赋值。使用已有 SVG 属性继承和 VRender 默认基线,保持现有缩放、裁剪及 resize 路径。例如
<text x="170" text-anchor="middle">WWWW</text>应以 x=170 为中心;修复前实际文字中心为约 192.65,修复后为 170。原 network 用例使用相同源码基点、依赖及 500×500 容器进行修复前后对照:
📝 Changelog
已有使用
middle / end的 SVG 会出现符合锚点语义的文字位置变化;没有公共 API 或依赖变更。☑️ 自测
验证结果:
rush test --only tag:package通过:VChart 84 个测试文件、470 项测试通过,VUtils Extension 1 项测试通过;其余四个包未定义测试任务。tsc --noEmit、git diff --check通过。tsc --noEmit未通过:修改前后均为 901 条既有错误,主要由缺失@visactor/vchart/esm构建产物导致。去除源码行列号后逐项对比一致,无新增错误。🚀 Summary
copilot:summary
🔍 Walkthrough
copilot:walkthrough