Skip to content

fix: respect disabled label smart invert - #4637

Open
biubiukam wants to merge 1 commit into
VisActor:developfrom
biubiukam:fix/issue-4492-label-smart-invert
Open

fix: respect disabled label smart invert#4637
biubiukam wants to merge 1 commit into
VisActor:developfrom
biubiukam:fix/issue-4492-label-smart-invert

Conversation

@biubiukam

Copy link
Copy Markdown

🤔 这个分支是...

  • 新功能
  • Bug fix
  • Ts 类型更新
  • 打包优化
  • 性能优化
  • 功能增强
  • 重构
  • 依赖版本更新
  • 代码优化
  • 测试 case 更新
  • 分支合并
  • 发布
  • 网站/文档更新
  • demo 更新
  • Workflow
  • 其他 (具体是什么,请补充?)

🔗 相关 issue 链接

Fix #4492

🔗 相关的 PR 链接

N/A

🐞 Bugserver 用例 id

N/A

💡 问题的背景&解决方案

内部 bar 和 pie 标签会根据 position 自动开启 smartInvert,但现有归一化逻辑会覆盖显式配置的 smartInvert: false,bar 标签还会覆盖显式传入的 options 对象。

本次修改仅在 smartInvert 未配置时使用内部标签的自动反色默认值,从而保留显式的布尔值或 options 对象。同时补充单元测试,覆盖关闭自动反色、保留 options 对象以及未配置时维持原有默认行为。

📝 Changelog

Language Changelog
🇺🇸 English Respect explicit smart invert settings for bar and pie labels.
🇨🇳 Chinese 修复 bar 和 pie 标签显式 smartInvert 配置被自动默认值覆盖的问题。

☑️ 自测

⚠️ 在提交 PR 之前,请检查一下内容. ⚠️

  • 文档提供了,或者更新,或者不需要
  • Demo 提供了,或者更新,或者不需要
  • Ts 类型定义提供了,或者更新,或者不需要
  • Changelog 提供了,或者不需要

🚀 Summary

copilot:summary

🔍 Walkthrough

copilot:walkthrough

@biubiukam
biubiukam marked this pull request as ready for review August 4, 2026 15:43
@xuefei1313

Copy link
Copy Markdown
Contributor

🦞 Aime Bot Review

🔍 改动摘要

本次 PR 修复了 barLabelpieLabel 在显式配置 smartInvert: false 时失效的问题。主要改动包括:

  • packages/vchart/src/component/label/util.ts 中,使用空值合并运算符 (??) 替代了原本的布尔值判断,确保 false 配置能被正确识别。
  • 优化了变量声明,并补充了相关的单元测试。

📝 具体观察

  • 逻辑修复:通过 labelSpec.smartInvert ?? ... 正确处理了显式配置,避免了默认值对 false 的覆盖。
  • 测试覆盖:新增的测试用例覆盖了布尔值、对象配置以及未配置时的默认行为,逻辑闭环。
  • 代码质量:改动简洁,符合项目规范。

🚀 合并建议

代码逻辑正确,测试充分,建议合并。

@Issues-translate-bot

Copy link
Copy Markdown

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


🦞Aime Bot Review

🔍 Summary of changes

This PR fixes the issue where barLabel and pieLabel fail when smartInvert: false is explicitly configured. Major changes include:

  • In packages/vchart/src/component/label/util.ts, the null value merging operator (??) is used instead of the original Boolean value judgment to ensure that false configuration can be correctly recognized.
  • Optimized variable declaration and added related unit tests.

📝 Specific observations

  • Logic Fix: Correctly handle explicit configuration via labelSpec.smartInvert ?? ..., avoiding default value override of false.
  • Test Coverage: The new test cases cover Boolean values, object configuration and default behavior when not configured, and the logic is closed loop.
  • Code Quality: The changes are concise and in line with project specifications.

🚀 Merge suggestions

The code logic is correct and fully tested. It is recommended to merge.

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] label.smartInvert can not be closed

3 participants