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: 列头文字&icon无法正确对齐 #1515

Merged
merged 7 commits into from
Jul 5, 2022
Merged

Conversation

lcx-seima
Copy link
Contributor

@lcx-seima lcx-seima commented Jul 4, 2022

👀 PR includes

🐛 Bugfix

📝 Description

列头文字&icon 无法正确对齐,主要原因有:

  • measureText 中 canvas 没有渲染到 dom 树,无法继承 body 上的 css 样式,导致估计值与实际值有差距
  • 最早的列头 col.ts 绘制文字时,只有 center 样式,即提供给 g 文字中心点位置即可。后支持了 leftright 绘制,但是 getTextPosition 等依旧计算的是中心点,导致有偏移效果。

🖼️ Screenshot

textAlign=right 为例,以下 demo 分别为不带 icon 和带 icon

Before After
CleanShot 2022-07-04 at 11 11 17 CleanShot 2022-07-04 at 11 08 32
CleanShot 2022-07-04 at 11 12 27 CleanShot 2022-07-04 at 11 07 43

🔍 Self-Check before the merge

  • Add or update test case.

@github-actions
Copy link
Contributor

github-actions bot commented Jul 4, 2022

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

Hello, @lcx-seima 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 Jul 4, 2022
@github-actions
Copy link
Contributor

github-actions bot commented Jul 4, 2022

Size Change: -699 B (0%)

Total Size: 252 kB

Filename Size Change
./packages/s2-core/dist/index.min.js 163 kB +68 B (0%)
./packages/s2-react/dist/index.min.js 63.5 kB -603 B (-1%)
./packages/s2-react/dist/style.min.css 3.2 kB -164 B (-5%)
ℹ️ View Unchanged
Filename Size
./packages/s2-core/dist/style.min.css 389 B
./packages/s2-vue/dist/index.min.js 20.3 kB
./packages/s2-vue/dist/style.min.css 1.59 kB

compressed-size-action

@github-actions github-actions bot added 🚨 lint failed 静态检查失败 and removed 🚨 test failed 单元测试挂了 labels Jul 4, 2022
@codecov
Copy link

codecov bot commented Jul 4, 2022

Codecov Report

Merging #1515 (947f7c7) into master (89e22d3) will decrease coverage by 0.10%.
The diff coverage is 86.36%.

@@            Coverage Diff             @@
##           master    #1515      +/-   ##
==========================================
- Coverage   76.29%   76.18%   -0.11%     
==========================================
  Files         228      229       +1     
  Lines       10872    11020     +148     
  Branches     2249     2289      +40     
==========================================
+ Hits         8295     8396     +101     
- Misses       1314     1337      +23     
- Partials     1263     1287      +24     
Impacted Files Coverage Δ
packages/s2-core/src/theme/index.ts 100.00% <ø> (ø)
packages/s2-core/src/utils/text.ts 41.36% <50.00%> (ø)
packages/s2-core/src/cell/col-cell.ts 88.32% <86.95%> (+1.19%) ⬆️
packages/s2-core/src/utils/canvas.ts 87.50% <87.50%> (ø)
packages/s2-core/src/sheet-type/spread-sheet.ts 81.39% <100.00%> (+0.21%) ⬆️
packages/s2-core/src/utils/cell/cell.ts 74.77% <100.00%> (-0.68%) ⬇️
...act/src/components/sheets/strategy-sheet/index.tsx 25.92% <0.00%> (-4.44%) ⬇️
...ackages/s2-core/src/interaction/brush-selection.ts 82.53% <0.00%> (-0.35%) ⬇️
... and 6 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 89e22d3...947f7c7. Read the comment docs.

@lcx-seima lcx-seima changed the title [WIP] fix: 列头文字&icon无法正确对齐 fix: 列头文字&icon无法正确对齐 Jul 4, 2022
@github-actions github-actions bot added pr(fix) bug fix 🚨 test failed 单元测试挂了 and removed 🚨 lint failed 静态检查失败 labels Jul 4, 2022
@github-actions github-actions bot removed the 🚨 test failed 单元测试挂了 label Jul 5, 2022
@xingwanying xingwanying enabled auto-merge (squash) July 5, 2022 11:40
Copy link
Member

@xingwanying xingwanying left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LG

@xingwanying xingwanying merged commit 3457af9 into master Jul 5, 2022
@xingwanying xingwanying deleted the fix/col-cell-text-align branch July 5, 2022 11:46
@lijinke666
Copy link
Member

🎉 This PR is included in version @antv/s2-v1.23.0-alpha.3 🎉

The release is available on:

Your semantic-release bot 📦🚀

@lijinke666
Copy link
Member

🎉 This PR is included in version @antv/s2-v1.23.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

@lijinke666
Copy link
Member

🎉 This PR is included in version @antv/s2-v1.24.0-alpha.1 🎉

The release is available on:

Your semantic-release bot 📦🚀

@lijinke666
Copy link
Member

🎉 This PR is included in version @antv/s2-v1.26.0-alpha.1 🎉

The release is available on:

Your semantic-release bot 📦🚀

@lijinke666
Copy link
Member

🎉 This PR is included in version @antv/s2-v1.28.0-alpha.1 🎉

The release is available on:

Your semantic-release bot 📦🚀

@lijinke666
Copy link
Member

🎉 This PR is included in version @antv/s2-v1.30.0-alpha.1 🎉

The release is available on:

Your semantic-release bot 📦🚀

@lijinke666
Copy link
Member

🎉 This PR is included in version @antv/s2-v1.31.0-alpha.1 🎉

The release is available on:

Your semantic-release bot 📦🚀

@lijinke666
Copy link
Member

🎉 This PR is included in version @antv/s2-v1.33.0-alpha.1 🎉

The release is available on:

Your semantic-release bot 📦🚀

@lijinke666
Copy link
Member

🎉 This PR is included in version 1.0.0 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

@lijinke666
Copy link
Member

🎉 This PR is included in version @antv/s2-v1.37.0-alpha.1 🎉

The release is available on:

Your semantic-release bot 📦🚀

@lijinke666
Copy link
Member

🎉 This PR is included in version @antv/s2-v1.40.0-alpha.1 🎉

The release is available on:

Your semantic-release bot 📦🚀

wjgogogo pushed a commit that referenced this pull request Oct 25, 2023
* fix: body样式影响measureTextWidth测量结果

* refactor: 统一主题fontWeight为整数

* fix: 列头text未适配left/right对齐方式

* fix: import remove alias

* test: 更新theme测试参数

* test: 列头文字对齐单元测试

* test: 修复ellipsis文字测试
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.

🐛透视表自定义列头 设置对齐方式出现错位
3 participants