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

feat: 新增treeLineShow配置和usePolyline,给树形表头扩展配置线性功能 #2995

Closed
wants to merge 6 commits into from

Conversation

gb853940223
Copy link
Contributor

👀 PR includes

✨ Feature

  • New feature

📝 Description

改动点:给树形结构的表头,添加线性配置,类似于Ant Design的TreeSelect组件

解决问题:面对复杂的树形结构,在视觉上可以增加层次感。

🖼️ Screenshot

改动前:
image

改动后:
image
image

🔗 Related issue link

#2987

🔍 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 Nov 28, 2024

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

Name Status Preview Comments Updated (UTC)
antvis-s2 ❌ Failed (Inspect) Dec 10, 2024 3:29am

@lijinke666
Copy link
Member

感谢贡献, 近期有点忙, 预计下周 review 代码

@lijinke666 lijinke666 added the 🙏 need test cases or docs 需要单元测试或者补充文档 label Nov 28, 2024
Copy link
Contributor

你好 @gb853940223,感谢你的贡献, 为了让代码更健壮, 请根据 贡献指南 补充相应单元测试, 如果有 API 改动, 请修改 相应的文档

Hello, @gb853940223, Thanks for your contribution. In order to make the code more robust, please add the corresponding unit tests, and update the docs if there are API changes.

@gb853940223
Copy link
Contributor Author

@lijinke666 十分感谢

@@ -0,0 +1,166 @@
import { Polyline } from '@antv/g';
Copy link
Member

Choose a reason for hiding this comment

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

线的逻辑为什么是做在 react 这一层, 而不是 s2-core 里? 不太合理

/**
* 是否配置线性样式,默认不配置
*/
treeLineShow?: boolean;
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
treeLineShow?: boolean;
showTreeLine?: boolean;

另外连接线属于行头的能力, 建议放在 s2Options.style.rowCell.showTreeLine

@lijinke666
Copy link
Member

  1. 需要增加一个单测, 测试一下相关功能 (如线的坐标, 数量是否正确, 折叠展开后是否渲染正确), 可以放在 packages/s2-core/tests/spreadsheet/spread-sheet-tree-mode-spec.ts
  2. 需要增加 api 文档 s2-site/docs/common/style.zh.md


const dottedLine = canvas.appendChild(
new Polyline({
style: {
Copy link
Member

Choose a reason for hiding this comment

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

建议主题里面增加相关配置能力, 满足个性化诉求: packages/s2-core/src/theme/index.ts
类似:

resizeArea: {
size: 3,
background: basicColors[7],
backgroundOpacity: 0,
guideLineColor: basicColors[7],
guideLineDisableColor: 'rgba(0,0,0,0.25)',
guideLineDash: [3, 3],

/**
* 获取列头的高度
*/
const getColHeaderHeight = (chart: SpreadSheet | TableSheet | PivotSheet) => {
Copy link
Member

Choose a reason for hiding this comment

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

下同

Suggested change
const getColHeaderHeight = (chart: SpreadSheet | TableSheet | PivotSheet) => {
const getColHeaderHeight = (s2: SpreadSheet) => {

points.push([x2, y2 - offsetHeight]);
}

const dottedLine = canvas.appendChild(
Copy link
Member

Choose a reason for hiding this comment

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

相关绘制逻辑建议放在 RowHeader (packages/s2-core/src/facet/header/row.ts) 或者 PivotFacet (packages/s2-core/src/facet/pivot-facet.ts) 里, 而不是直接在 canvas 上添加

Copy link
Contributor Author

Choose a reason for hiding this comment

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

之所以在canvas添加,是因为只有表格绘制完成之后,即S2Event.LAYOUT_AFTER_RENDER,才能更好的根据整个树形图的位置、层级、宽高等因素来计算绘制polyLine,而且在处理展开、收起、滚动操作时,polyLine的计算也更加准确和方便。

@gb853940223
Copy link
Contributor Author

@lijinke666 感谢大佬专业的意见,修改之后,下周再PR一版

@lijinke666
Copy link
Member

#3022

@lijinke666 lijinke666 closed this Dec 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🙏 need test cases or docs 需要单元测试或者补充文档 next 2.0-next 版本的问题 pr(feature) new feature
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants