diff --git a/.changeset/config.json b/.changeset/config.json
index f38b47ab5..d71842701 100644
--- a/.changeset/config.json
+++ b/.changeset/config.json
@@ -5,7 +5,7 @@
"fixed": [],
"linked": [],
"access": "restricted",
- "baseBranch": "main",
+ "baseBranch": "master",
"updateInternalDependencies": "patch",
"ignore": []
}
diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml
index 5ca524058..142939199 100644
--- a/.github/workflows/lint.yml
+++ b/.github/workflows/lint.yml
@@ -7,7 +7,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
- node-version: [14.x]
+ node-version: [latest]
steps:
- uses: actions/checkout@v3
- name: Use Node.js ${{ matrix.node-version }}
diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml
new file mode 100644
index 000000000..1c8b3960b
--- /dev/null
+++ b/.github/workflows/publish.yml
@@ -0,0 +1,36 @@
+# 当具有 publish 标签的 PR 被合并时,自动发布新版本
+# Automatically publish a new version when a PR with the publish label is merged
+name: Auto Publish
+on:
+ pull_request:
+ types: [closed]
+ branches:
+ - v2
+
+jobs:
+ publish:
+ runs-on: ubuntu-latest
+ if: contains(github.event.pull_request.labels.*.name, 'publish') && github.event.pull_request.merged == true
+
+ steps:
+ - uses: actions/checkout@v3
+
+ - name: Install Node.js
+ uses: actions/setup-node@v3
+ with:
+ node-version: 18
+
+ - name: Install pnpm and dependencies
+ uses: pnpm/action-setup@v4
+ with:
+ version: 9
+ run_install: true
+
+ - name: Build
+ run: npm run build
+
+ - name: Publish
+ env:
+ GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
+ NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
+ run: pnpm config set //registry.npmjs.org/:_authToken ${NPM_TOKEN} & pnpm run publish
diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml
new file mode 100644
index 000000000..893f15e6d
--- /dev/null
+++ b/.github/workflows/release.yml
@@ -0,0 +1,51 @@
+name: Changesets
+on:
+ push:
+ branches:
+ - master
+env:
+ CI: true
+ PNPM_CACHE_FOLDER: .pnpm-store
+
+jobs:
+ version:
+ timeout-minutes: 15
+ runs-on: ubuntu-latest
+ strategy:
+ matrix:
+ node-version: [latest]
+ steps:
+ - name: checkout code repository
+ uses: actions/checkout@v3
+ with:
+ fetch-depth: 0
+ - name: Use Node.js ${{ matrix.node-version }}
+ uses: actions/setup-node@v3
+ with:
+ node-version: ${{ matrix.node-version }}
+ - name: install pnpm
+ run: npm i pnpm@latest -g
+ - name: Setup npmrc
+ run: |
+ cat << EOF > "$HOME/.npmrc"
+ email=${NPM_EMAIL}
+ //registry.npmjs.org/:_authToken=$NPM_TOKEN
+ EOF
+ env:
+ NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
+ NPM_EMAIL: ${{ secrets.NPM_EMAIL }}
+ - name: setup pnpm config
+ run: pnpm config set store-dir $PNPM_CACHE_FOLDER
+ - name: install dependencies
+ run: pnpm install
+ - name: create publish versions
+ uses: changesets/action@v1
+ with:
+ version: pnpm ci:version
+ commit: 'chore: release versions'
+ title: 'chore: release versions'
+ env:
+ GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
+ NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
+ - name: publish to npm
+ run: pnpm run release
diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml
index 898a5b684..35df7d3ff 100644
--- a/.github/workflows/test.yml
+++ b/.github/workflows/test.yml
@@ -12,7 +12,7 @@ jobs:
timeout-minutes: 15
strategy:
matrix:
- node-version: [14.x]
+ node-version: [latest]
steps:
- name: checkout code repository
uses: actions/checkout@v3
@@ -30,6 +30,16 @@ jobs:
run: pnpm install
- name: test
run: pnpm test
+ - name: Run Playwright tests
+ run: |
+ pnpm exec playwright install chromium
+ pnpm exec playwright test --workers=10
+ - uses: actions/upload-artifact@v4
+ if: ${{ !cancelled() }}
+ with:
+ name: playwright-report
+ path: playwright-report/
+ retention-days: 30
# - name: Coveralls
# uses: coverallsapp/github-action@master
# with:
diff --git a/.github/workflows/v2-site.yml b/.github/workflows/v2-site.yml
new file mode 100644
index 000000000..364204f63
--- /dev/null
+++ b/.github/workflows/v2-site.yml
@@ -0,0 +1,69 @@
+name: V2 Site
+
+on:
+ pull_request:
+ branches:
+ - v2 # default branch
+env:
+ CI: true
+ PNPM_STORE: .pnpm-store
+
+jobs:
+ deploy:
+ runs-on: ubuntu-latest
+ timeout-minutes: 15
+ strategy:
+ matrix:
+ node-version: [latest]
+ steps:
+ - name: checkout code repository
+ uses: actions/checkout@v3
+ with:
+ fetch-depth: 0
+ - name: Switch to site branch
+ run: git checkout -b gh-pages
+ - name: Use Node.js ${{ matrix.node-version }}
+ uses: actions/setup-node@v3
+ with:
+ node-version: ${{ matrix.node-version }}
+ - name: install pnpm
+ run: npm i pnpm@latest -g
+ - name: Setup npmrc
+ run: |
+ cat << EOF > "$HOME/.npmrc"
+ email=${NPM_EMAIL}
+ //registry.npmjs.org/:_authToken=$NPM_TOKEN
+ EOF
+ env:
+ NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
+ NPM_EMAIL: ${{ secrets.NPM_EMAIL }}
+ - name: setup pnpm config
+ run: pnpm config set store-dir $PNPM_STORE
+ - name: install dependencies
+ run: pnpm install
+ - name: build site
+ run: |
+ pnpm run build:lib
+ pnpm run build:site
+ - name: copy and delete files
+ run: |
+ find . -maxdepth 1 -type f -exec rm -f {} \;
+ cp -r site/dist/* ./
+ rm -rf site
+ rm -rf node_modules
+ rm -rf packages
+ rm -rf scripts
+ rm -rf public
+ rm -rf config
+ rm -rf template
+ rm -rf .changeset
+ rm -rf .github
+ rm -rf $PNPM_STORE
+ - name: commit changes
+ run: |
+ git config --local user.email "954055752@qq.com"
+ git config --local user.name "lxfu1"
+ git add .
+ git commit -m "chore: update site"
+ - name: push to gh-pages branch
+ run: git push origin gh-pages -f
diff --git a/.gitignore b/.gitignore
index 33f664b2b..602f421bd 100644
--- a/.gitignore
+++ b/.gitignore
@@ -5,7 +5,7 @@ node_modules
/npm-debug.log*
/yarn-error.log
/yarn.lock
-/pnpm-lock.yaml
+pnpm-lock.yaml
/package-lock.json
/pnpm-debug.log
/**/pnpm-debug.log
@@ -31,6 +31,12 @@ logs
#ide
.idea/
.eslintcache
+.vscode/**
# temp
temp-gallery.md
+
+# Tools
+/test-results/
+/playwright-report/
+/playwright/.cache/
diff --git a/.npmrc b/.npmrc
index 62b8985c7..00e134fbe 100644
--- a/.npmrc
+++ b/.npmrc
@@ -4,4 +4,5 @@ public-hoist-pattern[]=d3-*
public-hoist-pattern[]=@types/react
public-hoist-pattern[]=@types/react-dom
public-hoist-pattern[]=npm-run-all
-public-hoist-pattern[]=rimraf
\ No newline at end of file
+public-hoist-pattern[]=rimraf
+public-hoist-pattern[]=@antv/*
\ No newline at end of file
diff --git a/.prettierignore b/.prettierignore
index 8af90c5d6..58db32539 100644
--- a/.prettierignore
+++ b/.prettierignore
@@ -1,6 +1,5 @@
**/*.svg
**/*.html
-*.md
package.json
.umi
.umi-production
@@ -11,4 +10,4 @@ dist
node_modules
*.ejs
gatsby-browser.js
-*.min.js
\ No newline at end of file
+*.min.js
diff --git a/.prettierrc.js b/.prettierrc.js
index f30f82663..305cdad3a 100644
--- a/.prettierrc.js
+++ b/.prettierrc.js
@@ -3,4 +3,5 @@ const fabric = require('@umijs/fabric');
module.exports = {
...fabric.prettier,
printWidth: 120,
+ plugins: [require.resolve('prettier-plugin-organize-imports'), require.resolve('prettier-plugin-packagejson')],
};
diff --git a/CHANGELOG.md b/CHANGELOG.md
index ec2f7b59c..bdbc24379 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,393 +1,3 @@
-## 1.4.2
+## 2.0.0-alpah.0
-`2022-07-19`
-
-- 🐞 [Critical security vulnerabilities immer and minimist](https://github.com/ant-design/ant-design-charts/issues/1289)
-## 1.4.1
-
-`2022-07-13`
-
-- 🐞 修复 umd 不可用
-
-## 1.4.0
-
-`2022-07-12`
-
-- 🔥 文件目录命名风格统一
-- `@ant-design/maps` Heatmap 重命名为 GeographicHeatmap
-- 支持自定义 anchor
-- 🆕 OrganizationGraph 支持自定义 anchor
-- 🐞 修复 scaleToolbarPanelProps 为空时出错
-- 🐞 修复流程图保存数据失败
-
-## 1.3.6
-
-`2022-03-22`
-
-- 🆕 Flowchart 阅读态完善,支持取消键盘事件和画布事件
-- 🆕 Graph 支持自定义布局
-- 🐞 修复 TS 类型错误
-## 1.3.5
-
-`2022-01-25`
-
-- 🐞 修复 umd 命名错误问题 [1120](https://github.com/ant-design/ant-design-charts/issues/1120)
-- 🐞 修复流程图无法异步加载数据 [1117](https://github.com/ant-design/ant-design-charts/issues/1117)
-- 🐞 修复关系图 tooltipCfg.container 配置报错
-
-## 1.3.4
-
-`2022-01-07`
-
-- 🆕 官网示例更新
-- 🐞 修复 interaction tooltip 导致页面崩溃
-- 🐞 修复 OrganizationGraph 接口和实现不一致
-## 1.3.3
-
-`2021-12-24`
-
-- 🆕 新增 Venn 图
-- 🆕 主包导出 flowchart 样式文件
-- 🆕 新增 PR 巡检
-- 🐞 修复官网示例
-
-## 1.3.2
-
-`2021-12-07`
-
-- 🐞 修复 peerDependencies
-
-## 1.3.1
-
-`2021-11-26`
-
-- 🆕 CDN 引入变量重命名
- - window.charts -> window.Charts
- - window.plots -> window.Plots
- - window.maps -> window.Maps
- - window.graphs -> window.Graphs
-
-## 1.3.0
-
-`2021-11-25`
-
-- 🆕 新增流程图 [Flowchart](https://charts.ant.design/zh/examples/flowchart/basic#basic)
-
-流程图除 `react`、`react-dom` 外,还依赖 `antd`、`@ant-design/icons`、`lodash`,使用时确保已经安装,同时记得引入样式文件 `import "@ant-design/flowchart/dist/index.css";`
-
-```ts
-"peerDependencies": {
- "@ant-design/icons": "^4.6.0",
- "antd": "^4.6.3",
- "lodash": "^4.17.20",
- "react": ">=16.8.4",
- "react-dom": ">=16.8.4"
- }
-```
-
-```tsx
-import { Flowchart } from '@ant-design/charts';
-import "@ant-design/flowchart/dist/index.css";
-```
-
-- 🆕 新增地理可视化 [Maps](https://charts.ant.design/zh/examples/map-area/division#chinese-provinces)
-- 🆕 新增 CirclePacking
-- 🆕 Ant Design Charts 完成拆包,推荐使用子包
- - 统计图表:@ant-design/plots
- - 流程图:@ant-design/flowchart
- - 地理可视化:@ant-design/maps
- - 关系图:@ant-design/graphs
-
-
-## 1.2.4
-
-`2021-07-27`
-
-- 🆕 DagreGraph 新增 card 类型。
-- 🐞 修复 FlowAnalysisGraph 类型错误。
-- 🐞 修复 autoFit 布局偏移。
-
-## 1.2.3
-
-`2021-07-20`
-
-### New Features
-
-- 新增资金流向图(FundFlowGraph): 支持节自定义;展开收起;边、节点格式化配置等。
-
-- FlowAnalysisGraph 、DecompositionTreeGraph 新增 badge 配置
-
-- 关系图支持默认节点类型
-
-- `indicator-card` 新增 `LR` 布局
-
-### Bug fixes
-
-- 修复 FlowAnalysisGraph 、DecompositionTreeGraph 空数据报错
-
-## 1.2.2
-
-`2021-07-20`
-
-- 🐞 旧 Graph 节点注册
-- 🐞 修复 FlowAnalysisGraph 空数据异常
-
-## 1.2.1
-
-`2021-07-20`
-
-- 🆕 FlowAnalysisGraph layout 新增 `follow`
-- 🆕 Graphs ArrowCfg 新增 size
-- 🆕 Graphs 默认值&文档优化
-
-## 1.2.0
-
-> 图组件全新 API ,新增&优化多个图组件,新增交互、节点自定义等。调整目录结构,类型引入定义更简单。
-
-### 新功能
-
-> 新增节点、边交互状态,来源去向图、组织架构图、指标拆解树支持自定义节点,节点、边个性化设置,更灵活。
-
-#### 来源去向图
-
-> FlowAnalysisGraph
-
-| ![image.png](https://cdn.nlark.com/yuque/0/2021/png/278352/1626337308273-1869606d-da26-470b-99ac-7dce4a324eb6.png#clientId=uc4615b79-7491-4&from=paste&height=396&id=ufe21e8a7&margin=%5Bobject%20Object%5D&name=image.png&originHeight=396&originWidth=754&originalType=binary&ratio=1&size=103139&status=done&style=none&taskId=u8c9cb519-5085-4006-a5cc-7a15448f60a&width=754) | ![image.png](https://cdn.nlark.com/yuque/0/2021/png/278352/1626335599778-010ac67d-982c-4fca-b240-d53ef55ef35a.png#clientId=ua9a3d129-b5b7-4&from=paste&height=448&id=u2b24628b&margin=%5Bobject%20Object%5D&name=image.png&originHeight=448&originWidth=931&originalType=binary&ratio=1&size=89087&status=done&style=none&taskId=uc41711ad-8b1a-45d9-bacc-acab2f49541&width=931) |
-| --- | --- |
-
-#### 组织架构图
-
-> OrganizationGraph
-
-| ![image.png](https://cdn.nlark.com/yuque/0/2021/png/278352/1626336025336-fe4de176-5cf4-490a-b222-dac7039bf628.png#clientId=ua9a3d129-b5b7-4&from=paste&height=506&id=u3f49c5ea&margin=%5Bobject%20Object%5D&name=image.png&originHeight=506&originWidth=923&originalType=binary&ratio=1&size=125664&status=done&style=none&taskId=uee2b4d05-5a34-41ab-824a-bd0b2af281f&width=923) | ![image.png](https://cdn.nlark.com/yuque/0/2021/png/278352/1626336047983-fe2acb21-072f-486f-b0d8-3bb1498d52f1.png#clientId=ua9a3d129-b5b7-4&from=paste&height=372&id=u2cda8a8f&margin=%5Bobject%20Object%5D&name=image.png&originHeight=372&originWidth=866&originalType=binary&ratio=1&size=92687&status=done&style=none&taskId=u6ab558b7-7d5a-43c3-b025-819b815da49&width=866) |
-| --- | --- |
-
-
-
-#### 指标拆解树
-
-> DecompositionTreeGraph
-
-| ![image.png](https://cdn.nlark.com/yuque/0/2021/png/278352/1626336487396-701f2b89-4d96-4b43-aa2c-0a98e4ead468.png#clientId=ua9a3d129-b5b7-4&from=paste&height=340&id=ue6de2099&margin=%5Bobject%20Object%5D&name=image.png&originHeight=340&originWidth=721&originalType=binary&ratio=1&size=95783&status=done&style=none&taskId=u0babaee1-4b72-4114-8a53-5643b8d543c&width=721) | ![image.png](https://cdn.nlark.com/yuque/0/2021/png/278352/1626336513538-be5d3195-b73f-4ed8-87d1-4e68834d7e71.png#clientId=ua9a3d129-b5b7-4&from=paste&height=361&id=u651a2cae&margin=%5Bobject%20Object%5D&name=image.png&originHeight=361&originWidth=692&originalType=binary&ratio=1&size=74657&status=done&style=none&taskId=ua5a066c3-d3d8-4f01-bf7c-a2bc4c30f0a&width=692) |
-| --- | --- |
-
-#### 辐射树图
-
-> RadialTreeGraph
-
-| ![image.png](https://cdn.nlark.com/yuque/0/2021/png/278352/1626336586223-5d573bc5-01da-43d8-b9cc-250e56cbe79f.png#clientId=ua9a3d129-b5b7-4&from=paste&height=213&id=ub106f57d&margin=%5Bobject%20Object%5D&name=image.png&originHeight=525&originWidth=620&originalType=binary&ratio=1&size=157766&status=done&style=none&taskId=ufcc3ccab-ea60-42b4-98ba-10b0ca74d6c&width=252) | ![image.png](https://cdn.nlark.com/yuque/0/2021/png/278352/1626336604503-8982ef00-7d01-4a60-8132-4c78f2ffdb0a.png#clientId=ua9a3d129-b5b7-4&from=paste&height=225&id=u4541d37d&margin=%5Bobject%20Object%5D&name=image.png&originHeight=513&originWidth=547&originalType=binary&ratio=1&size=133385&status=done&style=none&taskId=u468c94a6-439f-4b6b-b83d-78287c4251a&width=240) |
-| --- | --- |
-
-
-
-### 不兼容改动
-
-> 调整目录结构带来不兼容
-
-#### 类型引入
-
-旧:
-
-```typescript
-import { Line } from '@ant-design/charts';
-import { LineConfig } from '@ant-design/charts/es/line';
-```
-
-新:
-
-```typescript
-import { Line, LineConfig } from '@ant-design/charts';
-```
-
-#### 按需引入
-
-旧:
-
-```typescript
-import Line from '@ant-design/charts/es/line';
-```
-
-新:
-
-```typescript
-import Line from '@ant-design/charts/es/plots/line';
-```
-
-#### 官网示例少了
-
-由于目前 API 做了升级,还没来得及升级的图表暂时不在官网透出,但任然可以正常使用,也可以在官网访问。
只需手动输入网址即可。
-
-```typescript
-// 组件名为中划线格式
-https://charts.ant.design/zh-CN/demos/ + 组件名
-// OrganizationalGraph
-https://charts.ant.design/zh-CN/demos/organizational-graph
-```
-
-## 1.1.20
-
-`2021-06-29`
-
-- 🐞 修复 useGraph props 丢失,导致更新失败。
-
-## 1.1.19
-
-`2021-06-28`
-
-- 🆕 OrganizationalGraph 新增 [Title](https://charts.ant.design/demos/organizational-graph#set-title)。
-
-## 1.1.18
-
-`2021-06-24`
-
-- 🐞 修复 onReady & onEvent 类型错误。
-- ContainerOptions 统一为 ContainerConfig,并从 src/hooks/useChart 动到 src/interface 。
-
-## 1.1.17
-
-`2021-06-17`
-
-- 🐞 修复 graph autoFit 不生效。
-- 🆕 新增 Violin 文档。
-
-## 1.1.16
-
-`2021-06-15`
-
-- 🆕 新增 [Facet](https://charts.ant.design/demos/facet)。
-- 🆕 新增 Violin 组件,文档暂未透出。
-
-## 1.1.15
-
-`2021-06-14`
-
-- 🐞 所有图表 ts 类型统一。
- - ContainerProps to ContainerConfig.
- - RelationGraph to CommonConfig.
- - IndentedTreeProps to IndentedTreeGraphConfig.
- - OrganizationTreeProps to OrganizationalGraphConfig.
-
-## 1.1.14
-
-`2021-06-14`
-
-- 🆕 新增 [RadialGraph](https://charts.ant.design/demos/radial-graph#base)。
-- 🆕 IndentedTreeGraph 新增 markerPosition 功能,配合布局使用。
-- 🐞 修复 OrganizationalGraph 不支持线文本配置。
-
-## 1.1.13
-
-`2021-06-11`
-
-- 🆕 新增 OrganizationalGraph。OrganizationTreeGraph 的升级版,OrganizationTreeGraph 后续不在官网透出。
-- 🐞 修复 OrganizationTreeGraph changeData 布局出错。
-
-## 1.1.12
-
-`2021-06-10`
-
-- 🐞 大小写问题
-
-## 1.1.11
-
-`2021-06-09`
-
-- 🐞 合理化文件路径。
-- 🆕 IndentedTreeGraph 新增 animate 配置。
-
-## 1.1.10
-
-`2021-06-07`
-
-- 💄 CDN 使用方式 charts_g6 改名为 graphs
-
-## 1.1.9
-
-`2021-06-04`
-
-- 🐞 修复引用类型,数据不更新。
-
-## 1.1.8
-
-`2021-06-04`
-
-- 🐞 修复 IndentedTreeGraph ts 类型出错。
-
-## 1.1.5
-
-`2021-06-01`
-
-- 🆕 新增 IndentedTreeGraph, 功能类似 IndentedTree ,IndentedTree 不再官网继续透出,功能保留。
-- 🆕 关系图内置 `grahpId` , 默认支持一个页面使用多个关系图。
-- 🆕 关系图新增 `loading`、`onReady`、`loadingTemplate` 等 props.
-
-## 1.1.4
-
-`2021-05-14`
-
-- 🔥 已经废弃 MultiView ,更名为 Mix ,MultiView 继续保留,但不在文档透出。
-
-## 1.1.3
-
-`2021-04-28`
-
-- 🔥 默认支持按需加载 [#475](https://github.com/ant-design/ant-design-charts/issues/475)
-
-## 1.1.2
-
-`2021-04-12`
-
-- 🐞 修复更新逻辑,config immutable 避免底层修改 config 后出现重复更新。
-
-## 1.1.1
-
-- remname: history -> CHANGELOG
-- fix: graph layout and changeData error
-
-## 1.1.0
-
-- 文档更新 [#545](https://github.com/ant-design/ant-design-charts/pull/545)
-- feat: 新增弦图(Chord) [#545](https://github.com/ant-design/ant-design-charts/pull/545)
-- fix: fund flow graph with large slope edges [#540](https://github.com/ant-design/ant-design-charts/pull/540)
-- fix: 兼容 React17 [#542](https://github.com/ant-design/ant-design-charts/pull/542)
-- 导出 G2Plot 相关 function [#545](https://github.com/ant-design/ant-design-charts/pull/545)
- - flow
- - measureTextWidth
- - adaptors
-
-## 1.0.1
-
-- 新增瀑布图
-
-## 1.0.0
-
-- 底层依赖架构全新升级
-- 新增全量 API
-- 持续迭代
-
-## 0.9.6
-
-- 新增 onlyChangeData props 用于控制 changeData 。
-
-## 0.9.5
-
-- tooltip 添加 ReactNode 支持。
-- 提供额外 API : downloadImage()、toDataURL() 。
-- 新增 memoData props 用于控制 rerender 。
-
-## 0.9.4
-
-新增图表
-
-- column-line
-- dual-line
-- groupedColumn-line
-- stackedColumn-line
-
-删除图表
-
-- OverlappedComboPlot
-
-## 0.9.2
-
-修改 props 属性名,chartStyle => style。
+`2023-08-31`
diff --git a/CONTRIBUTING.zh-CN.md b/CONTRIBUTING.zh-CN.md
index 79ddeb3e5..c997ea148 100644
--- a/CONTRIBUTING.zh-CN.md
+++ b/CONTRIBUTING.zh-CN.md
@@ -10,12 +10,17 @@
```bash
# clone 代码
-$ git clone https://github.com/ant-design/ant-design-charts.git
+$ git clone -b v2 https://github.com/ant-design/ant-design-charts.git
$ cd ./ant-design-charts
# 依赖安装,由于项目使用了 pnpm 做多包管理,如果没有安装 pnpm,请先[安装pnpm](https://pnpm.io/installation#using-npm),并配置对应的 [store-dir](https://pnpm.io/configuring)
$ pnpm i
# 先创建开发分支开发,分支名应该有含义,避免使用 update、tmp 之类的
$ git checkout -b branch-name
+# 启动本地官网
+$ pnpm build:lib & pnpm start
+# 监听要改动的包,eg plots
+$ cd ./packages/plots
+$ pnpm start
# 开发完成后跑下测试是否通过,必要时需要新增或修改测试用例
$ pnpm test
# 测试通过后,提交代码,message 见下面的规范
@@ -40,55 +45,10 @@ $ git push origin branch-name
```ts
- packages
- charts
- - flowchart
- - graphs
- - maps
- plots
+ - util
```
-以 graphs 为例,`cd ./packages/graphs`, 修改 scripts 里面的 `test:live` 文件路径修改为对应的测试文件, 并执行 `pnpm test:live` 即可,由于 afterEach 会移除对应的 DOM,测试时记得注释掉。
-
-```tsx
-import React from 'react';
-import { act } from 'react-dom/test-utils';
-import { render } from '../../src/utils';
-import { FileTreeGraph } from '../../src';
-import { FileData } from '../data';
-
-describe('File Tree', () => {
- let container;
- beforeEach(() => {
- container = document.createElement('div');
- document.body.appendChild(container);
- });
- afterEach(() => {
- // document.body.removeChild(container);
- // container = null;
- });
- it('render', () => {
- let chartRef = undefined;
- const chartProps = {
- data: FileData,
- onReady: (graph) => {
- chartRef = graph;
- },
- };
- act(() => {
- render(
- Website • - Quick Start • - Gallery • - FAQ • - Blog + Website • + Quick Start • + Examples • + FAQ •
- Website • - Quick Start • - Gallery • - FAQ • - Blog -
- -{ - console.log(ev); - }} - > - click -
- > - ); - }, - }; - - act(() => { - ReactDOM.render( -- Website • - Quick Start • - Gallery • - FAQ • - Blog -
- -- Website • - Quick Start • - Gallery • - FAQ • - Blog -
- -();
- const plotConfig = useRef = ((plot: P) => void) | React.MutableRefObject ;
-
-export interface ContainerConfig {
- containerStyle?: React.CSSProperties;
- className?: string;
- loading?: boolean;
- loadingTemplate?: React.ReactElement;
- errorTemplate?: (e: Error) => React.ReactNode;
-}
diff --git a/packages/maps/src/util/config.ts b/packages/maps/src/util/config.ts
deleted file mode 100644
index d716a3afd..000000000
--- a/packages/maps/src/util/config.ts
+++ /dev/null
@@ -1,13 +0,0 @@
-import { PlotOptions } from '@antv/l7plot';
-import { deepClone } from '../util';
-
-/**
- * 深克隆配置项
- * @param config 要深克隆的配置
- */
-export const deepCloneMapConfig = (chartRef: PlotRef | undefined, chart: P) => {
- if (!chartRef) {
- return;
- }
- if (isFunction(chartRef)) {
- chartRef(chart);
- } else {
- chartRef.current = chart;
- }
-};
diff --git a/packages/maps/src/util/index.ts b/packages/maps/src/util/index.ts
deleted file mode 100644
index c055fa9e2..000000000
--- a/packages/maps/src/util/index.ts
+++ /dev/null
@@ -1,4 +0,0 @@
-export * from './getChart';
-export * from './config';
-export * from './utils';
-export { render, unmount } from './render';
diff --git a/packages/maps/src/util/render.ts b/packages/maps/src/util/render.ts
deleted file mode 100644
index db0eecbf6..000000000
--- a/packages/maps/src/util/render.ts
+++ /dev/null
@@ -1,105 +0,0 @@
-import type * as React from 'react';
-import * as ReactDOM from 'react-dom';
-import type { Root } from 'react-dom/client';
-
-// Let compiler not to search module usage
-const fullClone = {
- ...ReactDOM,
-} as typeof ReactDOM & {
- __SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED?: {
- usingClientEntryPoint?: boolean;
- };
- createRoot?: CreateRoot;
-};
-
-type CreateRoot = (container: ContainerType) => Root;
-
-const { version, render: reactRender, unmountComponentAtNode } = fullClone;
-
-let createRoot: CreateRoot;
-try {
- const mainVersion = Number((version || '').split('.')[0]);
- if (mainVersion >= 18) {
- ({ createRoot } = fullClone);
- }
-} catch (e) {
- // Do nothing;
-}
-
-function toggleWarning(skip: boolean) {
- const { __SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED } = fullClone;
-
- if (
- __SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED &&
- typeof __SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED === 'object'
- ) {
- __SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.usingClientEntryPoint = skip;
- }
-}
-
-const MARK = '__rc_react_root__';
-
-// ========================== Render ==========================
-type ContainerType = (Element | DocumentFragment) & {
- [MARK]?: Root;
-};
-
-function modernRender(node: React.ReactNode, container: ContainerType) {
- toggleWarning(true);
- const root = container[MARK] || createRoot(container);
- toggleWarning(false);
-
- root.render(node);
-
- container[MARK] = root;
-}
-
-function legacyRender(node: React.ReactElement, container: ContainerType) {
- reactRender(node, container);
-}
-
-/** @private Test usage. Not work in prod */
-export function _r(node: React.ReactElement, container: ContainerType) {
- if (process.env.NODE_ENV !== 'production') {
- return legacyRender(node, container);
- }
-}
-
-export function render(node: React.ReactElement, container: ContainerType) {
- if (createRoot) {
- modernRender(node, container);
- return;
- }
-
- legacyRender(node, container);
-}
-
-// ========================= Unmount ==========================
-async function modernUnmount(container: ContainerType) {
- // Delay to unmount to avoid React 18 sync warning
- return Promise.resolve().then(() => {
- container[MARK]?.unmount();
-
- delete container[MARK];
- });
-}
-
-function legacyUnmount(container: ContainerType) {
- unmountComponentAtNode(container);
-}
-
-/** @private Test usage. Not work in prod */
-export function _u(container: ContainerType) {
- if (process.env.NODE_ENV !== 'production') {
- return legacyUnmount(container);
- }
-}
-
-export async function unmount(container: ContainerType) {
- if (createRoot !== undefined) {
- // Delay to unmount to avoid React 18 sync warning
- return modernUnmount(container);
- }
-
- legacyUnmount(container);
-}
diff --git a/packages/maps/src/util/utils.ts b/packages/maps/src/util/utils.ts
deleted file mode 100644
index 8b4d8cf6b..000000000
--- a/packages/maps/src/util/utils.ts
+++ /dev/null
@@ -1,43 +0,0 @@
-// 类型检测
-export const isType = (value: any, type: string): boolean => {
- const { toString } = {};
- return toString.call(value) === `[object ${type}]`;
-};
-
-export const getType = (n: Object) => {
- return Object.prototype.toString.call(n).slice(8, -1);
-};
-
-/**
- * 深克隆
- * @param source 要深克隆的目标对象
- */
-export const deepClone = (source: Object | undefined) => {
- if (!source || typeof source !== 'object') {
- return source;
- }
-
- let target;
- if (Array.isArray(source)) {
- target = source.map((item) => deepClone(item));
- } else {
- target = {};
- Object.keys(source).forEach((key) => {
- return (target[key] = deepClone(source[key]));
- });
- }
-
- return target;
-};
-
-export const clone = (source: Object) => {
- if (!source) {
- return source;
- }
- const target = {};
- // eslint-disable-next-line guard-for-in
- for (const k in source) {
- target[k] = source[k];
- }
- return target;
-};
diff --git a/packages/maps/tests/maps/heat-map.test.tsx b/packages/maps/tests/maps/heat-map.test.tsx
deleted file mode 100644
index 155eed9cb..000000000
--- a/packages/maps/tests/maps/heat-map.test.tsx
+++ /dev/null
@@ -1,65 +0,0 @@
-// @ts-nocheck
-import React from 'react';
-import { act } from 'react-dom/test-utils';
-import GeographicHeatmap from '../../src/components/geographic-heatmap';
-import { render } from '../../src/util';
-
-describe('Heat Map', () => {
- let container;
- beforeEach(() => {
- container = document.createElement('div');
- document.body.appendChild(container);
- });
- afterEach(() => {
- document.body.removeChild(container);
- container = null;
- });
- const data = [
- {
- w: 21.5458,
- t: 22.2,
- s: '广东',
- l: 11,
- m: '电白',
- j: 110.9886,
- h: '59664',
- },
- {
- w: 22.9661,
- t: 21.9,
- s: '广东',
- l: 12,
- m: '东莞',
- j: 113.7389,
- h: '59289',
- },
- ];
- it('初始化以及销毁', () => {
- let chartRef = undefined;
- const props = {
- className: 'container',
- chartRef: (ref) => {
- chartRef = ref;
- },
- };
- const config = {
- map: { type: 'amap' },
- source: {
- data,
- parser: {
- type: 'json',
- x: 'j',
- y: 'w',
- },
- },
- size: {
- field: 't',
- value: [0, 1],
- },
- };
- act(() => {
- render(