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

chore: export some useful utils func #6648

Merged
merged 1 commit into from
Mar 14, 2025
Merged

chore: export some useful utils func #6648

merged 1 commit into from
Mar 14, 2025

Conversation

moayuisuda
Copy link
Collaborator

Checklist
  • npm test passes
  • commit message follows commit guidelines
Description of change
  1. 导出一些常用的工具方法,调整了工具函数的目录结构
  2. 简化 dataOf 函数,支持直接传入 element 得到原始数据
import { dataOf } from '@antv/g2'
...
chart.on('plot:click', e => {
  console.log(dataOf(e.target)) // do something with original data
})

Copy link

Walkthrough

本次PR主要导出了一些常用的工具函数,并调整了工具函数的目录结构。此外,简化了dataOf函数,使其支持直接传入元素以获取原始数据。

Changes

文件 概要
tests/unit/utils/helper.test.ts 添加了groupNameOfdataOf函数的单元测试。
src/api/runtime.ts 添加了关于取消渲染的注释。
src/exports.ts 导出了dataOfgroupNameOf函数。
src/interaction/event.ts 标记dataOf函数为已弃用,建议使用新的实现。
src/interaction/tooltip.ts 移除了groupNameOf函数的旧实现,改为从utils/helper导入。
src/utils/helper.ts 添加了getViewFromElementdataOfgroupNameOf函数。

@coveralls
Copy link

coveralls commented Mar 12, 2025

Pull Request Test Coverage Report for Build 13854422832

Warning: This coverage report may be inaccurate.

This pull request's base commit is no longer the HEAD commit of its target branch. This means it includes changes from outside the original pull request, including, potentially, unrelated coverage changes.

Details

  • 39 of 42 (92.86%) changed or added relevant lines in 4 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage increased (+0.007%) to 86.697%

Changes Missing Coverage Covered Lines Changed/Added Lines %
src/utils/helper.ts 34 37 91.89%
Totals Coverage Status
Change from base Build 13853281457: 0.007%
Covered Lines: 10630
Relevant Lines: 11886

💛 - Coveralls

@hustcc
Copy link
Member

hustcc commented Mar 12, 2025

另外一起看看,这类 api,文档上怎么透出。

@moayuisuda
Copy link
Collaborator Author

另外一起看看,这类 api,文档上怎么透出。

可以像自定义 legend 那样写一个自定义 tooltip 的例子,实际场景里说明下怎么用这些 utils

@moayuisuda moayuisuda requested a review from hustcc March 13, 2025 08:44
@moayuisuda moayuisuda merged commit 649ec99 into v5 Mar 14, 2025
2 checks passed
@moayuisuda moayuisuda deleted the feat/export-helper branch March 14, 2025 10:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants