Skip to content

Feature/make area - #3949

Open
eleliauk wants to merge 2 commits into
VisActor:developfrom
eleliauk:Feature/makeArea
Open

eleliauk wants to merge 2 commits into
VisActor:developfrom
eleliauk:Feature/makeArea

Conversation

@eleliauk

@eleliauk eleliauk commented May 9, 2025

Copy link
Copy Markdown

[中文版模板 / Chinese template]

🤔 This is a New Feature

  • New feature
  • Bug fix
  • TypeScript definition update
  • Bundle size optimization
  • Performance optimization
  • Enhancement feature
  • Refactoring
  • Update dependency
  • Code style optimization
  • Test Case
  • Branch merge
  • Release
  • Site / documentation update
  • Demo update
  • Workflow
  • Other (about what?)

🔗 Related issue link

🔗 Related PR link

🐞 Bugserver case id

💡 Background and solution

这面函数的data类型 我直接写的data看看类型能否精细化一些

📝 Changelog

Language Changelog
🇺🇸 English
🇨🇳 Chinese

☑️ Self-Check before Merge

⚠️ Please check all items below before requesting a reviewing. ⚠️

  • Doc is updated/provided or not needed
  • Demo is updated/provided or not needed
  • TypeScript definition is updated/provided or not needed
  • Changelog is provided or not needed

🚀 Summary

copilot:summary

🔍 Walkthrough

copilot:walkthrough

@xile611 xile611 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@eleliauk 感谢你为 #3225 补充 markArea 标签的动态偏移支持。这个需求很明确:图表 resize 后能够重新计算标签位置。本次在 develop 0461971e2367 上叠加当前提交 d6a454e4f862 验证,markArea 的 resize、数据更新、多标签和极坐标场景都能正常工作。

合并前还需要修正一个公共类型与运行时实现不一致的问题,具体复现和建议已附在行内评论中:共享标签接口允许 markLine、markPoint 使用函数形式的 dx/dy,但这两个组件并没有执行回调,实际会产生无效的标签变换坐标。建议按本次需求范围,仅在 markArea 的标签类型中扩展函数支持。

另外,麻烦一并整理以下内容:

  • 补充回归测试:保留数值偏移场景,覆盖 markArea 的首次渲染、resize、updateDataSync、多标签和极坐标。若将函数类型限制在 markArea,也请确保 markLine、markPoint 不会通过公共类型接受尚不支持的函数配置。
  • 统一文档docs/assets/option/zh/component/mark-area.md 新增了 dx/dy(number|function),但文件末尾引入的 component-marker-label 模板仍包含 dx/dy(number),同一字段会有重复且不一致的说明。请收敛为一份与实际支持范围一致的说明。回调参数类型也可以沿用现有 formatMethodDatum[] 定义。
  • 拆分无关改动:词云的动画配置处理和 maxFontSize 传递与 #3225 无关,建议从本 PR 移出,另行说明需求并补充验证后评审。

本地验证结果为 17 项通过、2 项失败:10 项现有 marker/word-cloud 测试通过,5 项 markArea 补充用例和 2 项 markLine/markPoint 数值偏移对照通过;失败的 2 项均是行内评论所述的函数偏移契约问题。这些补充用例是评审时在隔离副本中运行的,目前不包含在 PR 中。

本次先提交 Request changes,请优先修正上述支持范围问题。感谢你的贡献,调整后可以继续复核合并。

* 水平方向的偏移,可以是具体的像素值或返回偏移量的函数
*/
dx?: number;
dx?: number | ((data: any[], seriesData: any[]) => number);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

[P2] 请让函数偏移的公共类型与实际支持范围保持一致

这里修改的是共享的 IMarkerLabelWithoutRefSpec,会同时扩大 IMarkLineSpec.labelIMarkPointSpec.itemContent.text 的类型范围;但本 PR 只在 BaseMarkArea._markerLayout() 中解析 dx/dy 回调。markLine、markPoint 仍把函数对象直接传给 VRender 标签。

在包含 { x: 'A', y: 20 }{ x: 'B', y: 60 }{ x: 'C', y: 40 } 数据的普通折线图中,以下两种配置都能通过修改后的 TypeScript 类型检查:

const markLine: IMarkLineSpec = {
  y: 30,
  label: { text: 'threshold', dx: () => 12, dy: () => -8 }
};

const markPoint: IMarkPointSpec = {
  x: 'B',
  y: 30,
  itemContent: {
    text: { text: 'point', dx: () => 12, dy: () => -8 }
  }
};

实测两者的 dx/dy 回调调用次数都是 0,标签属性仍为函数对象,globalTransMatrix.e/f 出现非有限值;将同一配置改成数值 dx: 12, dy: -8 后,标签坐标正常。

麻烦按 #3225 的范围,把共享接口的 dx/dy 保持为 number,仅在 IMarkAreaLabel 中扩展函数类型(可以通过 Omit 后重新声明这两个属性,避免与原数值类型交叉)。如果本次希望同时支持其他 marker,则需要统一补齐它们在布局阶段的回调解析及回归测试。

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.

[Feature] markArea中label的dx和dy支持函数

2 participants