Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: 修复配置了多行文本但实际渲染的文本未换行时, 单元格高度也会自适应调整的问题 #2705

Merged
merged 4 commits into from
May 11, 2024

Conversation

lijinke666
Copy link
Member

@lijinke666 lijinke666 commented May 9, 2024

👀 PR includes

🐛 Bugfix

  • Solve the issue and close #0

📝 Description

public drawTextShape() {
// G 遵循浏览器的规范, 空间不足以展示省略号时, 会裁剪文字, 而不是展示省略号 https://developer.mozilla.org/en-US/docs/Web/CSS/text-overflow#ellipsis
const maxTextWidth = Math.max(this.getMaxTextWidth(), 0);
const textStyle = this.getTextStyle();
// 在坐标计算 (getTextPosition) 之前, 预渲染一次, 提前生成 textShape, 获得文字宽度, 用于计算 icon 绘制坐标
this.renderTextShape({
...textStyle,
x: 0,
y: 0,
text: this.getFieldValue(),
wordWrapWidth: maxTextWidth,
});
if (this.isShallowRender()) {
return;
}
this.updateTextPosition();
}

在布局时, 会先计算叶子节点的宽度, 然后反向计算父级节点, 父级节点由于先渲染, 计算多行文本的高度时, 由于依赖 maxTextWidth 为 0, 会导致 G 将一行文本计算出来多行, 比如 "成都市" => ['成','都', '市'], 然后 S2 按 3行去自适应高度

image

image

  1. 重构布局计算流程, 优先计算所有节点的宽度, 保证后续多行文本高度能正常计算.
  2. 修复透视表行列头/明细表列头自适应高度的 bug.

🖼️ Screenshot

Before After
image image

🔗 Related issue link

🔍 Self-Check before the merge

  • Add or update relevant docs.
  • Add or update relevant demos.
  • Add or update test case.
  • Add or update relevant TypeScript definitions.

Copy link

vercel bot commented May 9, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
antvis-s2 ❌ Failed (Inspect) May 10, 2024 7:31am

@github-actions github-actions bot added the pr(fix) bug fix label May 9, 2024
@github-actions github-actions bot added the next 2.0-next 版本的问题 label May 9, 2024
Copy link
Contributor

github-actions bot commented May 9, 2024

Size Change: +107 B (+0.03%)

Total Size: 319 kB

Filename Size Change
./packages/s2-core/dist/index.min.js 223 kB +107 B (+0.05%)
ℹ️ View Unchanged
Filename Size
./packages/s2-core/dist/style.min.css 402 B
./packages/s2-react/dist/index.min.js 69.4 kB
./packages/s2-react/dist/style.min.css 3.92 kB
./packages/s2-vue/dist/index.min.js 21 kB
./packages/s2-vue/dist/style.min.css 1.99 kB

compressed-size-action

Copy link
Contributor

github-actions bot commented May 9, 2024

你好, @lijinke666 CI 执行失败, 请点击 [Details] 按钮查看, 并根据日志修复。

Hello, @lijinke666 CI run failed, please click the [Details] button for detailed log information and fix it.

@github-actions github-actions bot added the 🚨 test failed 单元测试挂了 label May 9, 2024
@codecov-commenter
Copy link

codecov-commenter commented May 10, 2024

Codecov Report

Attention: Patch coverage is 76.19048% with 20 lines in your changes are missing coverage. Please review.

Project coverage is 80.08%. Comparing base (ecdc9c8) to head (7e648d8).
Report is 344 commits behind head on next.

Files Patch % Lines
packages/s2-core/src/facet/pivot-facet.ts 73.43% 2 Missing and 15 partials ⚠️
packages/s2-core/src/facet/table-facet.ts 82.35% 0 Missing and 3 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             next    #2705      +/-   ##
==========================================
+ Coverage   75.77%   80.08%   +4.31%     
==========================================
  Files         257      176      -81     
  Lines       11994    10096    -1898     
  Branches     2464     2311     -153     
==========================================
- Hits         9088     8085    -1003     
+ Misses       1398      614     -784     
+ Partials     1508     1397     -111     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@github-actions github-actions bot added the 🚨 test failed 单元测试挂了 label May 10, 2024
@github-actions github-actions bot removed the 🚨 test failed 单元测试挂了 label May 10, 2024
@lijinke666 lijinke666 merged commit 5d19e62 into next May 11, 2024
8 of 9 checks passed
@lijinke666 lijinke666 deleted the fix-multi-text branch May 11, 2024 02:09
@lijinke666
Copy link
Member Author

🎉 This PR is included in version @antv/s2-v2.0.0-next.20 🎉

The release is available on:

Your semantic-release bot 📦🚀

@lijinke666
Copy link
Member Author

🎉 This PR is included in version @antv/s2-react-v2.0.0-next.19 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
next 2.0-next 版本的问题 pr(fix) bug fix released on @next
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants