From 5f81d2a02a2944aa5923c571cd557d600b022540 Mon Sep 17 00:00:00 2001 From: lijinke666 Date: Tue, 26 Dec 2023 10:23:31 +0800 Subject: [PATCH 01/64] =?UTF-8?q?docs:=20=E5=AE=8C=E5=96=84=202.0=20?= =?UTF-8?q?=E7=89=88=E6=9C=AC=E6=96=87=E6=A1=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.en-US.md | 28 +- README.md | 50 ++- packages/s2-core/README.en-US.md | 28 +- packages/s2-core/README.md | 70 +-- .../s2-core/src/common/interface/tooltip.ts | 6 +- pnpm-lock.yaml | 172 +++++++- s2-site/.dumirc.ts | 7 + s2-site/docs/api/general/S2DataConfig.zh.md | 2 + s2-site/docs/common/browser.zh.md | 5 +- s2-site/docs/common/contact-us.zh.md | 9 +- s2-site/docs/common/development.zh.md | 6 +- s2-site/docs/common/mini-chart.zh.md | 4 +- s2-site/docs/manual/advanced/adaptive.zh.md | 27 +- ...stom-g2-chart.en.md => custom-chart.en.md} | 0 .../manual/advanced/custom/custom-chart.zh.md | 413 ++++++++++++++++++ .../advanced/custom/custom-g2-chart.zh.md | 175 -------- .../manual/advanced/interaction/custom.zh.md | 16 +- .../advanced/interaction/link-jump.zh.md | 4 +- .../advanced/interaction/merge-cell.zh.md | 2 +- .../manual/basic/analysis/copy-export.zh.md | 4 +- s2-site/docs/manual/basic/formatter.en.md | 4 + s2-site/docs/manual/basic/formatter.zh.md | 97 ++++ s2-site/docs/manual/basic/i18n.zh.md | 4 +- .../manual/basic/sheet-type/pivot-mode.zh.md | 3 +- .../manual/basic/sheet-type/table-mode.zh.md | 3 +- s2-site/docs/manual/basic/theme.zh.md | 15 +- s2-site/docs/manual/faq.zh.md | 14 +- s2-site/docs/manual/getting-started.zh.md | 4 +- s2-site/docs/manual/introduction.zh.md | 84 +++- .../analysis/conditions/demo/background.ts | 9 +- .../conditions/demo/bidirectional-interval.ts | 9 +- .../conditions/demo/gradient-interval.ts | 12 +- .../examples/analysis/conditions/demo/icon.ts | 9 +- .../conditions/demo/intelligent-background.ts | 8 +- .../analysis/conditions/demo/interval.ts | 9 +- .../conditions/demo/multi-background.ts | 26 +- .../conditions/demo/multi-conditions.ts | 17 +- .../analysis/conditions/demo/table-text.ts | 11 +- .../examples/analysis/conditions/demo/text.ts | 9 +- .../analysis/sort/demo/custom-list.ts | 11 +- .../analysis/sort/demo/custom-measure.ts | 11 +- .../analysis/sort/demo/custom-method.ts | 11 +- .../analysis/sort/demo/custom-sort-func.ts | 15 +- .../analysis/sort/demo/custom-totals.ts | 17 +- .../analysis/sort/demo/group-sort.tsx | 5 +- .../analysis/sort/demo/table-sort.tsx | 24 +- .../examples/analysis/totals/demo/basic.ts | 15 +- .../analysis/totals/demo/calculate.ts | 11 +- .../examples/analysis/totals/demo/custom.ts | 11 +- .../analysis/totals/demo/multiple-values.ts | 15 +- s2-site/examples/analysis/totals/demo/tree.ts | 11 +- s2-site/examples/basic/pivot/demo/grid.ts | 45 +- s2-site/examples/basic/pivot/demo/tree.ts | 4 +- s2-site/examples/basic/table/demo/table.ts | 4 +- s2-site/examples/case/art/demo/mosaic.tsx | 3 +- .../case/art/demo/time-spend-abstract.tsx | 13 +- .../comparison/demo/measure-comparison.tsx | 28 +- .../demo/multiple-people-comparison.tsx | 5 + .../case/comparison/demo/philosophers.tsx | 32 +- .../case/comparison/demo/time-spend.tsx | 8 +- .../examples/case/data-preview/demo/excel.tsx | 14 +- .../examples/case/data-preview/demo/house.tsx | 37 +- .../examples/case/data-preview/demo/index.tsx | 11 +- .../examples/case/kpi-strategy/demo/basic.tsx | 12 +- .../case/kpi-strategy/demo/covid-trend.tsx | 2 + .../case/performance-compare/demo/basic.tsx | 16 +- .../case/performance-compare/demo/pivot.tsx | 22 +- .../case/performance-compare/demo/table.tsx | 23 +- .../case/proportion/demo/group-drill-down.tsx | 14 +- .../custom/custom-cell/demo/col-cell.ts | 13 +- .../custom/custom-cell/demo/corner-cell.ts | 13 +- .../custom/custom-cell/demo/corner-header.ts | 17 +- .../custom-cell/demo/custom-merged-cell.ts | 16 +- .../custom-cell/demo/custom-specified-cell.ts | 19 +- .../custom/custom-cell/demo/data-cell.ts | 16 +- .../custom/custom-cell/demo/row-cell.ts | 13 +- .../custom-cell/demo/series-number-cell.ts | 21 +- .../custom/custom-cell/demo/totals-cell.ts | 20 +- .../custom-g2-chart/demo/custom-g2-chart.ts | 36 +- .../demo/custom-data-cell-icon.tsx | 9 +- .../custom-icon/demo/custom-svg-icon.ts | 13 +- .../custom-layout/demo/custom-coordinate.ts | 9 +- .../demo/custom-data-position.ts | 5 +- .../demo/custom-layout-arrange.ts | 13 +- .../demo/custom-layout-hierarchy.ts | 23 +- .../custom-layout/demo/custom-value-order.ts | 10 +- .../custom/custom-order/demo/custom-order.tsx | 25 +- .../custom-plugins/demo/custom-plugins.ts | 8 +- .../demo/custom-pivot-col-header.ts | 6 +- .../demo/custom-pivot-row-header.ts | 6 +- .../demo/custom-table-col-header.ts | 4 +- .../custom/custom-tree/demo/custom-tree.ts | 4 +- .../advanced/demo/custom-tree-link-jump.ts | 28 +- .../interaction/advanced/demo/merge-cell.ts | 45 +- .../advanced/demo/overscroll-behavior.ts | 8 +- .../advanced/demo/pivot-hide-columns.ts | 9 +- .../advanced/demo/pivot-link-jump.ts | 18 +- .../advanced/demo/resize-active.ts | 25 +- .../advanced/demo/resize-disable.ts | 9 +- .../advanced/demo/row-expand-depth.ts | 22 +- .../interaction/advanced/demo/scroll-loop.ts | 22 +- .../advanced/demo/scroll-speed-ratio.ts | 22 +- .../advanced/demo/scroll-to-cell.ts | 38 +- .../advanced/demo/table-hide-columns.ts | 17 +- .../advanced/demo/table-link-jump.ts | 17 +- .../basic/demo/auto-reset-sheet-style.ts | 8 +- .../interaction/basic/demo/brush-header.ts | 7 +- .../interaction/basic/demo/brush-selection.ts | 5 +- .../basic/demo/data-cell-click-selection.ts | 5 +- .../basic/demo/data-cell-range-selection.ts | 5 +- .../examples/interaction/basic/demo/frozen.ts | 16 +- .../basic/demo/header-cell-click-selection.ts | 4 +- .../examples/interaction/basic/demo/hover.ts | 5 +- .../examples/interaction/basic/demo/resize.ts | 7 +- .../custom/demo/double-click-hide-columns.ts | 17 +- .../custom/demo/row-col-hover-tooltip.ts | 8 +- .../adaptive/demo/container-adaptation.ts | 38 +- .../layout/adaptive/demo/react-adaptive.tsx | 15 +- .../layout/adaptive/demo/window-adaptation.ts | 37 +- .../examples/layout/basic/demo/colAdaptive.ts | 9 +- s2-site/examples/layout/basic/demo/compact.ts | 9 +- .../layout/custom/demo/custom-pivot-size.ts | 5 +- .../custom/demo/custom-row-col-cell-width.ts | 7 +- .../layout/custom/demo/custom-table-size.ts | 5 +- .../custom/demo/custom-tree-collapse-nodes.ts | 5 +- .../custom/demo/custom-tree-row-width.ts | 5 +- .../layout/custom/demo/hide-columns.ts | 11 +- .../examples/layout/custom/demo/hide-value.ts | 9 +- .../custom/demo/only-show-row-header.ts | 9 +- .../drill-dwon/demo/for-pivot.tsx | 13 +- .../react-component/export/demo/export.tsx | 7 +- .../react-component/pagination/demo/pivot.tsx | 4 +- .../react-component/pagination/demo/table.tsx | 7 +- .../react-component/sheet/demo/editable.tsx | 12 +- .../react-component/sheet/demo/pivot.tsx | 8 +- .../sheet/demo/strategy-mini-chart.tsx | 4 +- .../react-component/sheet/demo/table.tsx | 11 +- .../switcher/demo/pivot-header.tsx | 4 +- .../switcher/demo/pivot-with-children.tsx | 10 +- .../react-component/switcher/demo/pivot.tsx | 8 +- .../react-component/switcher/demo/table.tsx | 8 +- .../demo/custom-click-show-tooltip.tsx | 3 + .../tooltip/demo/custom-content.tsx | 8 +- .../tooltip/demo/custom-operation.tsx | 10 +- .../custom/demo/custom-generate-palette.tsx | 8 +- .../custom/demo/custom-manual-palette.tsx | 8 +- .../theme/custom/demo/custom-palette.ts | 18 +- .../theme/custom/demo/custom-schema.ts | 15 +- .../demo/custom-transparent-background.ts | 13 +- .../examples/theme/default/demo/colorful.ts | 10 +- .../examples/theme/default/demo/default.ts | 10 +- s2-site/examples/theme/default/demo/gray.ts | 10 +- s2-site/package.json | 10 +- s2-site/playground/sheet-component/index.tsx | 15 + 154 files changed, 1932 insertions(+), 977 deletions(-) rename s2-site/docs/manual/advanced/custom/{custom-g2-chart.en.md => custom-chart.en.md} (100%) create mode 100644 s2-site/docs/manual/advanced/custom/custom-chart.zh.md delete mode 100644 s2-site/docs/manual/advanced/custom/custom-g2-chart.zh.md create mode 100644 s2-site/docs/manual/basic/formatter.en.md create mode 100644 s2-site/docs/manual/basic/formatter.zh.md diff --git a/README.en-US.md b/README.en-US.md index 1b93f73601..c471d63a2b 100644 --- a/README.en-US.md +++ b/README.en-US.md @@ -12,35 +12,44 @@ A practical visualization library for tabular analysis. npm - Version + latest version - Version + next version ci test status - Coverage + test coverage - release-date + release date

- npm bundle size + npm bundle size - Discussions + GitHub discussions - issues-helper + issues helper - License: MIT@AntV + License: MIT@AntV + + contributors + + + issues closed + + + pr welcome +

@@ -229,9 +238,6 @@ pnpm site:start S2 - - S2 -

## 👬 Contributors diff --git a/README.md b/README.md index 5b32f0d71a..89eb8805c1 100644 --- a/README.md +++ b/README.md @@ -11,35 +11,44 @@ npm - Version + latest version - Version + next version ci test status - Coverage + test coverage - release-date + release date

- npm bundle size + npm bundle size - Discussions + GitHub discussions - issues-helper + issues helper - License: MIT@AntV + License: MIT@AntV + + contributors + + + issues closed + + + pr welcome +

@@ -175,13 +184,11 @@ s2.render(); | [@antv/s2-react](https://github.com/antvis/S2/tree/master/packages/s2-react) | ![latest](https://img.shields.io/npm/v/@antv/s2-react/latest.svg) | ![beta](https://img.shields.io/npm/v/@antv/s2-react/beta.svg) | ![alpha](https://img.shields.io/npm/v/@antv/s2-react/alpha.svg) | ![next](https://img.shields.io/npm/v/@antv/s2-react/next.svg)| ![size](https://img.badgesize.io/https:/unpkg.com/@antv/s2-react@latest/dist/index.min.js?label=gzip%20size&compression=gzip) | ![download](https://img.shields.io/npm/dm/@antv/s2-react.svg) | | [@antv/s2-vue](https://github.com/antvis/S2/tree/master/packages/s2-vue) | ![latest](https://img.shields.io/npm/v/@antv/s2-vue/latest.svg) | ![beta](https://img.shields.io/npm/v/@antv/s2-vue/beta.svg) | ![alpha](https://img.shields.io/npm/v/@antv/s2-vue/alpha.svg) | ![next](https://img.shields.io/npm/v/@antv/s2-vue/next.svg) | ![size](https://img.badgesize.io/https:/unpkg.com/@antv/s2-vue@latest/dist/index.min.js?label=gzip%20size&compression=gzip) | ![download](https://img.shields.io/npm/dm/@antv/s2-vue.svg) | -## 👤 作者 - -[**@AntV**](https://github.com/orgs/antvis/people) +## 🙋‍♂️ 问题反馈 -## 🤝 参与贡献 +有任何问题请严格按照模版 [提交 Issue](https://github.com/antvis/S2/issues/new/choose), 在这之前强烈建议阅读 [《⚠️ 提 Issue 前必读》](https://github.com/antvis/S2/issues/1904) -> S2 使用 pnpm 作为包管理器 +## ⌨️ 本地开发 ```bash git clone git@github.com:antvis/S2.git @@ -213,25 +220,32 @@ pnpm lint pnpm site:start ``` -## 👁️ 洞察 +## 🤝 参与贡献 + +请查看 [贡献指南](https://s2.antv.antgroup.com/manual/contribution) + +## 👁️ 项目洞察 ![Alt](https://repobeats.axiom.co/api/embed/ebb7eecb994dc0e3980044aefe43eb81302e3632.svg "Repobeats analytics image") ## 📧 联系我们 +群聊仅供交流,不提供任何答疑,有任何问题请 [提交 Issue](https://github.com/antvis/S2/issues/new/choose). +

DingTalk - - qq -

-## 👬 Contributors +## 👬 贡献者们 ![https://github.com/antvis/s2/graphs/contributors](https://contrib.rocks/image?repo=antvis/s2) +## 👤 作者 + +[**@AntV**](https://github.com/orgs/antvis/people) + ## 📄 License MIT@[AntV](https://github.com/antvis) diff --git a/packages/s2-core/README.en-US.md b/packages/s2-core/README.en-US.md index 599cf62fb4..7cf5dc406f 100644 --- a/packages/s2-core/README.en-US.md +++ b/packages/s2-core/README.en-US.md @@ -12,35 +12,44 @@ Data-driven multi-dimensional analysis table. npm - Version + latest version - Version + next version ci test status - Coverage + test coverage - release-date + release date

- npm bundle size + npm bundle size - Discussions + GitHub discussions - issues-helper + issues helper - License: MIT@AntV + License: MIT@AntV + + contributors + + + issues closed + + + pr welcome +

@@ -225,9 +234,6 @@ pnpm site:start DingTalk - - qq -

## 👬 Contributors diff --git a/packages/s2-core/README.md b/packages/s2-core/README.md index 80a489c909..6c95fdc7eb 100644 --- a/packages/s2-core/README.md +++ b/packages/s2-core/README.md @@ -4,42 +4,51 @@
-数据驱动的多维分析表格。 +开箱即用的多维可视分析表格。

npm - Version + latest version - Version + next version ci test status - Coverage + test coverage - release-date + release date

- npm bundle size + npm bundle size - Discussions + GitHub discussions - issues-helper + issues helper - License: MIT@AntV + License: MIT@AntV + + contributors + + + issues closed + + + pr welcome +

@@ -58,7 +67,7 @@ S2 是 AntV 在多维交叉分析表格领域的解决方案,完全基于数 1. 多维交叉分析: 告别单一分析维度,全面拥抱任意维度的自由组合分析。 2. 高性能:能支持全量百万数据下 `<8s` 渲染,也能通过局部下钻来实现秒级渲染。 3. 高扩展性:支持任意的自定义扩展(包括但不局限于布局,样式,交互,数据 hook 流等)。 -4. 开箱即用:提供不同分析场景下开箱即用的 `React` `Vue3` 版本表组件及配套分析组件,只需要简单的配置即可轻松实现复杂场景的表渲染。 +4. 开箱即用:提供不同分析场景下开箱即用的 `React`, `Vue3` 版本表组件及配套分析组件,只需要简单的配置即可轻松实现复杂场景的表渲染。 5. 可交互:支持丰富的交互形式(单选、圈选、行选、列选、冻结行头、宽高拖拽,自定义交互等) ## 📦 安装 @@ -66,7 +75,7 @@ S2 是 AntV 在多维交叉分析表格领域的解决方案,完全基于数 ```bash $ npm install @antv/s2 # yarn add @antv/s2 -# pnpm add @antv/s2 +# pnpm install @antv/s2 ``` ## 🔨 使用 @@ -167,21 +176,19 @@ s2.render(); ![result](https://gw.alipayobjects.com/zos/antfincdn/vCukbtVNvl/616f7ef1-e626-4225-99f8-dc8f6ca630dd.png) -### 📦 Packages +### 📦 版本 -| Package | Latest | Beta | Alpha | Next | Size | Download | -| ---------------------------------------------------------------------------- | ----------------------------------------------------------------- | ------------------------------------------------------------- | --------------------------------------------------------------- | ------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------- | -| [@antv/s2](https://github.com/antvis/S2/tree/master/packages/s2-core) | ![latest](https://img.shields.io/npm/v/@antv/s2/latest.svg) | ![beta](https://img.shields.io/npm/v/@antv/s2/beta.svg) | ![alpha](https://img.shields.io/npm/v/@antv/s2/alpha.svg) | ![next](https://img.shields.io/npm/v/@antv/s2/next.svg) | ![size](https://img.badgesize.io/https:/unpkg.com/@antv/s2@latest/dist/index.min.js?label=gzip%20size&compression=gzip) | ![download](https://img.shields.io/npm/dm/@antv/s2.svg) | -| [@antv/s2-react](https://github.com/antvis/S2/tree/master/packages/s2-react) | ![latest](https://img.shields.io/npm/v/@antv/s2-react/latest.svg) | ![beta](https://img.shields.io/npm/v/@antv/s2-react/beta.svg) | ![alpha](https://img.shields.io/npm/v/@antv/s2-react/alpha.svg) | ![next](https://img.shields.io/npm/v/@antv/s2-react/next.svg) | ![size](https://img.badgesize.io/https:/unpkg.com/@antv/s2-react@latest/dist/index.min.js?label=gzip%20size&compression=gzip) | ![download](https://img.shields.io/npm/dm/@antv/s2-react.svg) | -| [@antv/s2-vue](https://github.com/antvis/S2/tree/master/packages/s2-vue) | ![latest](https://img.shields.io/npm/v/@antv/s2-vue/latest.svg) | ![beta](https://img.shields.io/npm/v/@antv/s2-vue/beta.svg) | ![alpha](https://img.shields.io/npm/v/@antv/s2-vue/alpha.svg) | ![next](https://img.shields.io/npm/v/@antv/s2-vue/next.svg) | ![size](https://img.badgesize.io/https:/unpkg.com/@antv/s2-vue@latest/dist/index.min.js?label=gzip%20size&compression=gzip) | ![download](https://img.shields.io/npm/dm/@antv/s2-vue.svg) | +| Package | Latest | Beta | Alpha | Next | Size | Download | +| - | - | - | - | - | - | - | +| [@antv/s2](https://github.com/antvis/S2/tree/master/packages/s2-core) | ![latest](https://img.shields.io/npm/v/@antv/s2/latest.svg) | ![beta](https://img.shields.io/npm/v/@antv/s2/beta.svg) | ![alpha](https://img.shields.io/npm/v/@antv/s2/alpha.svg) | ![next](https://img.shields.io/npm/v/@antv/s2/next.svg) | ![size](https://img.badgesize.io/https:/unpkg.com/@antv/s2@latest/dist/index.min.js?label=gzip%20size&compression=gzip) | ![download](https://img.shields.io/npm/dm/@antv/s2.svg) | +| [@antv/s2-react](https://github.com/antvis/S2/tree/master/packages/s2-react) | ![latest](https://img.shields.io/npm/v/@antv/s2-react/latest.svg) | ![beta](https://img.shields.io/npm/v/@antv/s2-react/beta.svg) | ![alpha](https://img.shields.io/npm/v/@antv/s2-react/alpha.svg) | ![next](https://img.shields.io/npm/v/@antv/s2-react/next.svg)| ![size](https://img.badgesize.io/https:/unpkg.com/@antv/s2-react@latest/dist/index.min.js?label=gzip%20size&compression=gzip) | ![download](https://img.shields.io/npm/dm/@antv/s2-react.svg) | +| [@antv/s2-vue](https://github.com/antvis/S2/tree/master/packages/s2-vue) | ![latest](https://img.shields.io/npm/v/@antv/s2-vue/latest.svg) | ![beta](https://img.shields.io/npm/v/@antv/s2-vue/beta.svg) | ![alpha](https://img.shields.io/npm/v/@antv/s2-vue/alpha.svg) | ![next](https://img.shields.io/npm/v/@antv/s2-vue/next.svg) | ![size](https://img.badgesize.io/https:/unpkg.com/@antv/s2-vue@latest/dist/index.min.js?label=gzip%20size&compression=gzip) | ![download](https://img.shields.io/npm/dm/@antv/s2-vue.svg) | -## 👤 Author +## 问题反馈 -[**@AntV**](https://github.com/orgs/antvis/people) - -## 🤝 参与贡献 +有任何问题请严格按照模版 [提交 Issue](https://github.com/antvis/S2/issues/new/choose), 在这之前强烈建议阅读 [《⚠️ 提 Issue 前必读》](https://github.com/antvis/S2/issues/1904) -> S2 使用 pnpm 作为包管理器 +## ⌨️ 本地开发 ```bash git clone git@github.com:antvis/S2.git @@ -213,21 +220,32 @@ pnpm lint pnpm site:start ``` +## 🤝 参与贡献 + +请查看 [贡献指南](https://s2.antv.antgroup.com/manual/contribution) + +## 👁️ 项目洞察 + +![Alt](https://repobeats.axiom.co/api/embed/ebb7eecb994dc0e3980044aefe43eb81302e3632.svg "Repobeats analytics image") + ## 📧 联系我们 +仅供交流,不提供任何答疑,有任何问题请 [提交 Issue](https://github.com/antvis/S2/issues/new/choose). +

DingTalk - - qq -

-## 👬 Contributors +## 👬 贡献者们 ![https://github.com/antvis/s2/graphs/contributors](https://contrib.rocks/image?repo=antvis/s2) +## 👤 作者 + +[**@AntV**](https://github.com/orgs/antvis/people) + ## 📄 License MIT@[AntV](https://github.com/antvis) diff --git a/packages/s2-core/src/common/interface/tooltip.ts b/packages/s2-core/src/common/interface/tooltip.ts index 2b8f8db802..c62e7b73fb 100644 --- a/packages/s2-core/src/common/interface/tooltip.ts +++ b/packages/s2-core/src/common/interface/tooltip.ts @@ -26,7 +26,11 @@ export interface TooltipOperatorMenuItem { /** 点击回调 */ onClick?: TooltipOperatorClickHandler; /** 是否显示 */ - visible?: boolean | ((cell: S2CellType) => boolean); + visible?: + | boolean + | null + | undefined + | ((cell: S2CellType) => boolean | null | undefined); /** 子菜单 */ children?: TooltipOperatorMenuItem[]; } diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 499653def3..412d2a81cc 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -444,8 +444,8 @@ importers: specifier: ^5.2.6 version: 5.2.6(react-dom@18.2.0)(react@18.2.0) '@antv/dumi-theme-antv': - specifier: ^0.4.4 - version: 0.4.4(@babel/core@7.23.2)(dumi@2.2.15) + specifier: ^0.4.5 + version: 0.4.5(@babel/core@7.23.2)(dumi@2.2.16) '@antv/g-canvas': specifier: ^1.11.25 version: 1.11.25 @@ -456,8 +456,8 @@ importers: specifier: ^1.9.25 version: 1.9.25 '@antv/g2': - specifier: ^5.1.11 - version: 5.1.11 + specifier: ^5.1.13 + version: 5.1.13 '@antv/s2': specifier: next version: link:../packages/s2-core @@ -465,17 +465,17 @@ importers: specifier: next version: link:../packages/s2-react antd: - specifier: ^5.12.2 - version: 5.12.2(react-dom@18.2.0)(react@18.2.0) + specifier: ^5.12.5 + version: 5.12.5 copy-to-clipboard: specifier: ^3.3.3 version: 3.3.3 dumi: - specifier: ^2.2.15 - version: 2.2.15(@babel/core@7.23.2)(@types/node@20.8.9)(eslint@8.52.0)(jest@26.6.3)(postcss-less@6.0.0)(prettier@3.0.3)(rollup@4.1.5)(stylelint@15.11.0)(typescript@5.2.2) + specifier: ^2.2.16 + version: 2.2.16(@babel/core@7.23.2)(@types/node@20.8.9)(eslint@8.52.0)(jest@26.6.3)(postcss-less@6.0.0)(prettier@3.0.3)(rollup@4.1.5)(stylelint@15.11.0)(typescript@5.2.2) gh-pages: - specifier: ^6.1.0 - version: 6.1.0 + specifier: ^6.1.1 + version: 6.1.1 lodash: specifier: ^4.17.21 version: 4.17.21 @@ -753,6 +753,16 @@ packages: '@antv/scale': 0.4.13 '@antv/util': 3.3.5 svg-path-parser: 1.1.0 + dev: true + + /@antv/component@1.0.1-beta.0: + resolution: {integrity: sha512-syonGLy7bcpe+4qqKjtwBZMUUfZU8TKJRQAeYOB4pEiz2kr1Ky/qZLteT12QDQRugeMz9KnrUXMF+nAvUErKww==} + dependencies: + '@antv/g': 5.18.23 + '@antv/scale': 0.4.13 + '@antv/util': 3.3.5 + svg-path-parser: 1.1.0 + dev: false /@antv/coord@0.4.7: resolution: {integrity: sha512-UTbrMLhwJUkKzqJx5KFnSRpU3BqrdLORJbwUbHK2zHSCT3q3bjcFA//ZYLVfIlwqFDXp/hzfMyRtp0c77A9ZVA==} @@ -761,8 +771,8 @@ packages: '@antv/util': 2.0.17 gl-matrix: 3.4.3 - /@antv/dumi-theme-antv@0.4.4(@babel/core@7.23.2)(dumi@2.2.15): - resolution: {integrity: sha512-/5eB2bn9pZZmORcYFmQQ8xjgD22/W879E3XfHKvgYDNkYlxNUMmOknxiNbV5Pdf0s8oUgLEerKnSWqdkQc6Tvg==} + /@antv/dumi-theme-antv@0.4.5(@babel/core@7.23.2)(dumi@2.2.16): + resolution: {integrity: sha512-TMbgp+DhnXiTt63xf1iu/6Go/k5SZ4J//i9u5IHRA7n8kwL8iq3nQPmR27lOAahri/F0sTnihLUtDCgWymn0gQ==} peerDependencies: dumi: ^2.0.0 dependencies: @@ -778,7 +788,7 @@ packages: codesandbox: 2.2.3 d3-dsv: 3.0.1 docsearch.js: 2.6.3 - dumi: 2.2.15(@babel/core@7.23.2)(@types/node@20.8.9)(eslint@8.52.0)(jest@26.6.3)(postcss-less@6.0.0)(prettier@3.0.3)(rollup@4.1.5)(stylelint@15.11.0)(typescript@5.2.2) + dumi: 2.2.16(@babel/core@7.23.2)(@types/node@20.8.9)(eslint@8.52.0)(jest@26.6.3)(postcss-less@6.0.0)(prettier@3.0.3)(rollup@4.1.5)(stylelint@15.11.0)(typescript@5.2.2) front-matter: 4.0.2 fs-extra: 10.1.0 glob: 8.1.0 @@ -980,6 +990,34 @@ packages: flru: 1.0.2 fmin: 0.0.2 pdfast: 0.2.0 + dev: true + + /@antv/g2@5.1.13: + resolution: {integrity: sha512-Ak2QY9buhScqoII1pSlmtM4V6ubkp14IF5mYumiBun11sblKBtBFemBV/mmsYaWw/Eoq+hz3jmYbRX2zdb7pQw==} + dependencies: + '@antv/component': 1.0.1-beta.0 + '@antv/coord': 0.4.7 + '@antv/event-emitter': 0.1.3 + '@antv/g': 5.18.23 + '@antv/g-canvas': 1.11.25 + '@antv/g-plugin-dragndrop': 1.8.19 + '@antv/path-util': 3.0.1 + '@antv/scale': 0.4.13 + '@antv/util': 3.3.5 + d3-array: 3.2.4 + d3-dsv: 3.0.1 + d3-force: 3.0.0 + d3-format: 3.1.0 + d3-geo: 3.1.0 + d3-hierarchy: 3.1.2 + d3-path: 3.1.0 + d3-scale-chromatic: 3.0.0 + d3-shape: 3.2.0 + d3-voronoi: 1.1.4 + flru: 1.0.2 + fmin: 0.0.2 + pdfast: 0.2.0 + dev: false /@antv/g@5.18.23: resolution: {integrity: sha512-6O+ODt1w0FC4w98J00Ao7rtqztkV7AWqKF69kog3RqQWh40rYpM7JIfR0cFUAdHf8GLRyr4m+RQR+TZlt+QVEw==} @@ -6143,6 +6181,67 @@ packages: - date-fns - luxon - moment + dev: true + + /antd@5.12.5: + resolution: {integrity: sha512-m9r9VhTmANS4kdBwHcxI4QWIGoZh3LspXNb2SxoezRSUZ9RUFpf+gO0AjPx8EPeO/nLKsHAoCSLza9r041bAgw==} + peerDependencies: + react: '>=16.9.0' + react-dom: '>=16.9.0' + dependencies: + '@ant-design/colors': 7.0.0 + '@ant-design/cssinjs': 1.18.1(react-dom@18.2.0)(react@18.2.0) + '@ant-design/icons': 5.2.6(react-dom@18.2.0)(react@18.2.0) + '@ant-design/react-slick': 1.0.2(react@18.2.0) + '@babel/runtime': 7.23.5 + '@ctrl/tinycolor': 3.6.1 + '@rc-component/color-picker': 1.4.1(react-dom@18.2.0)(react@18.2.0) + '@rc-component/mutate-observer': 1.1.0(react-dom@18.2.0)(react@18.2.0) + '@rc-component/tour': 1.11.1(react-dom@18.2.0)(react@18.2.0) + '@rc-component/trigger': 1.18.2(react-dom@18.2.0)(react@18.2.0) + classnames: 2.3.2 + copy-to-clipboard: 3.3.3 + dayjs: 1.11.7 + qrcode.react: 3.1.0(react@18.2.0) + rc-cascader: 3.20.0(react-dom@18.2.0)(react@18.2.0) + rc-checkbox: 3.1.0(react-dom@18.2.0)(react@18.2.0) + rc-collapse: 3.7.2(react-dom@18.2.0)(react@18.2.0) + rc-dialog: 9.3.4(react-dom@18.2.0)(react@18.2.0) + rc-drawer: 6.5.2(react-dom@18.2.0)(react@18.2.0) + rc-dropdown: 4.1.0(react-dom@18.2.0)(react@18.2.0) + rc-field-form: 1.41.0(react-dom@18.2.0)(react@18.2.0) + rc-image: 7.5.1(react-dom@18.2.0)(react@18.2.0) + rc-input: 1.3.11 + rc-input-number: 8.4.0(react-dom@18.2.0)(react@18.2.0) + rc-mentions: 2.9.1(react-dom@18.2.0)(react@18.2.0) + rc-menu: 9.12.4(react-dom@18.2.0)(react@18.2.0) + rc-motion: 2.9.0(react-dom@18.2.0)(react@18.2.0) + rc-notification: 5.3.0(react-dom@18.2.0)(react@18.2.0) + rc-pagination: 4.0.3(react-dom@18.2.0)(react@18.2.0) + rc-picker: 3.14.6(dayjs@1.11.7)(react-dom@18.2.0)(react@18.2.0) + rc-progress: 3.5.1(react-dom@18.2.0)(react@18.2.0) + rc-rate: 2.12.0(react-dom@18.2.0)(react@18.2.0) + rc-resize-observer: 1.4.0(react-dom@18.2.0)(react@18.2.0) + rc-segmented: 2.2.2(react-dom@18.2.0)(react@18.2.0) + rc-select: 14.10.0(react-dom@18.2.0)(react@18.2.0) + rc-slider: 10.5.0(react-dom@18.2.0)(react@18.2.0) + rc-steps: 6.0.1(react-dom@18.2.0)(react@18.2.0) + rc-switch: 4.1.0(react-dom@18.2.0)(react@18.2.0) + rc-table: 7.36.1 + rc-tabs: 12.14.1(react-dom@18.2.0)(react@18.2.0) + rc-textarea: 1.5.3(react-dom@18.2.0)(react@18.2.0) + rc-tooltip: 6.1.3 + rc-tree: 5.8.2(react-dom@18.2.0)(react@18.2.0) + rc-tree-select: 5.15.0(react-dom@18.2.0)(react@18.2.0) + rc-upload: 4.3.5(react-dom@18.2.0)(react@18.2.0) + rc-util: 5.38.1(react-dom@18.2.0)(react@18.2.0) + scroll-into-view-if-needed: 3.1.0 + throttle-debounce: 5.0.0 + transitivePeerDependencies: + - date-fns + - luxon + - moment + dev: false /anymatch@1.3.2: resolution: {integrity: sha512-0XNayC8lTHQ2OI8aljNCN3sSx6hsr/1+rlcDAotXJR7C1oZZHCNsfpbKwMjRA3Uqb5tF1Rae2oloTr4xpq+WjA==} @@ -8961,8 +9060,8 @@ packages: resolution: {integrity: sha512-a/Y5lf0G6gwsEQ9hop/n03CcjmHsGBk384Cz/AEX6mRYrfSpUx/lQvP9HLoXkCzScl9PL1sSmLPnMkgaXDCZLA==} dev: false - /dumi@2.2.15(@babel/core@7.23.2)(@types/node@20.8.9)(eslint@8.52.0)(jest@26.6.3)(postcss-less@6.0.0)(prettier@3.0.3)(rollup@4.1.5)(stylelint@15.11.0)(typescript@5.2.2): - resolution: {integrity: sha512-O6bUZvqYictU1p5kuwD26Vrn4g5HuMaw41GBhjEEG0rjAveNvnQdgJBJS6YarNCTTLJ9fUZ4t86aBt31MUCTHw==} + /dumi@2.2.16(@babel/core@7.23.2)(@types/node@20.8.9)(eslint@8.52.0)(jest@26.6.3)(postcss-less@6.0.0)(prettier@3.0.3)(rollup@4.1.5)(stylelint@15.11.0)(typescript@5.2.2): + resolution: {integrity: sha512-r2x/CY0fR8/YZOwEnG4JsLEpn8jOg94Qyd1u+7pRD9SCx7dF9It+GwkGbdNEsyenGsO/ZU9wD+Kz7KO+HU7/EA==} hasBin: true peerDependencies: react: '>=16.8' @@ -11134,8 +11233,8 @@ packages: globby: 6.1.0 dev: true - /gh-pages@6.1.0: - resolution: {integrity: sha512-MdXigvqN3I66Y+tAZsQJMzpBWQOI1snD6BYuECmP+GEdryYMMOQvzn4AConk/+qNg/XIuQhB1xNGrl3Rmj1iow==} + /gh-pages@6.1.1: + resolution: {integrity: sha512-upnohfjBwN5hBP9w2dPE7HO5JJTHzSGMV1JrLrHvNuqmjoYHg6TBrCcnEoorjG/e0ejbuvnwyKMdTyM40PEByw==} engines: {node: '>=10'} hasBin: true dependencies: @@ -18593,6 +18692,17 @@ packages: react-dom: 18.2.0(react@18.2.0) dev: false + /rc-input@1.3.11: + resolution: {integrity: sha512-jhH7QP5rILanSHCGSUkdoFE5DEtpv8FIseYhuYkOZzUBeiVAiwM3q26YqZ6xBB0QFEZ/yUAgms4xW4iuub3xFQ==} + peerDependencies: + react: '>=16.0.0' + react-dom: '>=16.0.0' + dependencies: + '@babel/runtime': 7.23.5 + classnames: 2.3.2 + rc-util: 5.38.1(react-dom@18.2.0)(react@18.2.0) + dev: false + /rc-input@1.3.6(react-dom@18.2.0)(react@18.2.0): resolution: {integrity: sha512-/HjTaKi8/Ts4zNbYaB5oWCquxFyFQO4Co1MnMgoCeGJlpe7k8Eir2HN0a0F9IHDmmo+GYiGgPpz7w/d/krzsJA==} peerDependencies: @@ -19032,6 +19142,22 @@ packages: rc-virtual-list: 3.11.3(react-dom@18.2.0)(react@18.2.0) react: 18.2.0 react-dom: 18.2.0(react@18.2.0) + dev: true + + /rc-table@7.36.1: + resolution: {integrity: sha512-9qMxEm/3Y8ukdW8I8ZvmhX0QImfNKzH0JEUlSbyaUlsYTB+/tQEbfaB8YkG4sHVZ1io4pxqK/BXoZYqebi/TIQ==} + engines: {node: '>=8.x'} + peerDependencies: + react: '>=16.9.0' + react-dom: '>=16.9.0' + dependencies: + '@babel/runtime': 7.23.5 + '@rc-component/context': 1.4.0(react-dom@18.2.0)(react@18.2.0) + classnames: 2.3.2 + rc-resize-observer: 1.4.0(react-dom@18.2.0)(react@18.2.0) + rc-util: 5.38.1(react-dom@18.2.0)(react@18.2.0) + rc-virtual-list: 3.11.3(react-dom@18.2.0)(react@18.2.0) + dev: false /rc-tabs@12.14.1(react-dom@18.2.0)(react@18.2.0): resolution: {integrity: sha512-1xlE7JQNYxD5RwBsM7jf2xSdUrkmTSDFLFEm2gqAgnsRlOGydEzXXNAVTOT6QcgM1G/gCm+AgG+FYPUGb4Hs4g==} @@ -19121,6 +19247,18 @@ packages: classnames: 2.3.2 react: 18.2.0 react-dom: 18.2.0(react@18.2.0) + dev: true + + /rc-tooltip@6.1.3: + resolution: {integrity: sha512-HMSbSs5oieZ7XddtINUddBLSVgsnlaSb3bZrzzGWjXa7/B7nNedmsuz72s7EWFEro9mNa7RyF3gOXKYqvJiTcQ==} + peerDependencies: + react: '>=16.9.0' + react-dom: '>=16.9.0' + dependencies: + '@babel/runtime': 7.23.5 + '@rc-component/trigger': 1.18.2(react-dom@18.2.0)(react@18.2.0) + classnames: 2.3.2 + dev: false /rc-tree-select@5.15.0(react-dom@18.2.0)(react@18.2.0): resolution: {integrity: sha512-YJHfdO6azFnR0/JuNBZLDptGE4/RGfVeHAafUIYcm2T3RBkL1O8aVqiHvwIyLzdK59ry0NLrByd+3TkfpRM+9Q==} diff --git a/s2-site/.dumirc.ts b/s2-site/.dumirc.ts index 02bb941894..3bd1dc5b1d 100644 --- a/s2-site/.dumirc.ts +++ b/s2-site/.dumirc.ts @@ -1,4 +1,5 @@ import { defineConfig } from 'dumi'; +// import { version } from '@antv/s2'; import { repository } from './package.json'; export default defineConfig({ @@ -31,6 +32,12 @@ export default defineConfig({ showChartResize: true, // 是否在 demo 页展示图表视图切换 showAPIDoc: true, // 是否在 demo 页展示API文档 themeSwitcher: 'g2', + versions: { + // 历史版本以及切换下拉菜单 + // [version || '2.x']: 'https://s2.antv.antgroup.com', + '2.x': 'https://s2.antv.antgroup.com', + '1.x': 'https://s2-v1.antv.vision', + }, docsearchOptions: { // 头部搜索框配置 versionV3: true, diff --git a/s2-site/docs/api/general/S2DataConfig.zh.md b/s2-site/docs/api/general/S2DataConfig.zh.md index d4c62940cf..dbcc6186ef 100644 --- a/s2-site/docs/api/general/S2DataConfig.zh.md +++ b/s2-site/docs/api/general/S2DataConfig.zh.md @@ -119,6 +119,8 @@ object **必选**,_default:null_ ### MiniChartData +[了解更多](/manual/advanced/custom/custom-chart#1-%E7%BB%98%E5%88%B6-mini-%E5%9B%BE%E8%A1%A8) + ### MultiData diff --git a/s2-site/docs/common/browser.zh.md b/s2-site/docs/common/browser.zh.md index 5a77535180..61857de531 100644 --- a/s2-site/docs/common/browser.zh.md +++ b/s2-site/docs/common/browser.zh.md @@ -12,11 +12,12 @@ order: 5 ```ts ``` diff --git a/s2-site/docs/common/contact-us.zh.md b/s2-site/docs/common/contact-us.zh.md index 59ae6f1dba..ffa8f7f142 100644 --- a/s2-site/docs/common/contact-us.zh.md +++ b/s2-site/docs/common/contact-us.zh.md @@ -3,11 +3,14 @@ title: 联系我们 order: 5 --- +:::info{title="注意"} + +群聊仅供交流,不提供任何答疑,有任何问题请 [提交 Issue](https://github.com/antvis/S2/issues/new/choose). + +::: +

DingTalk - - qq -

diff --git a/s2-site/docs/common/development.zh.md b/s2-site/docs/common/development.zh.md index b284351730..037a89feb8 100644 --- a/s2-site/docs/common/development.zh.md +++ b/s2-site/docs/common/development.zh.md @@ -1,6 +1,8 @@ -跃跃欲试想贡献?[查看贡献指南](https://s2.antv.antgroup.com/manual/contribution) +:::info{title="跃跃欲试想贡献?"} -> S2 使用 pnpm 作为包管理器 +[查看贡献指南](/manual/contribution) + +::: ```bash git clone git@github.com:antvis/S2.git diff --git a/s2-site/docs/common/mini-chart.zh.md b/s2-site/docs/common/mini-chart.zh.md index c0cbed655b..e751c68e3d 100644 --- a/s2-site/docs/common/mini-chart.zh.md +++ b/s2-site/docs/common/mini-chart.zh.md @@ -5,7 +5,7 @@ order: 6 #### renderMiniChart -在单元格内绘制 mini 图(支持 折线图、子弹图、柱状图). [查看示例](/examples/react-component/sheet/#strategy-mini-chart) +在单元格内绘制 `mini` 图(支持 折线图、子弹图、柱状图). [查看示例](/zh/examples/custom/custom-cell/#mini-chart) ```ts renderMiniChart = (cell: S2CellType, data?: BaseChartData | BulletValue) => void; @@ -13,7 +13,7 @@ order: 6 #### BaseChartData -折线图、柱状图数据配置项,数据格式参考 `g2` +折线图、柱状图数据配置项,数据格式参考 [`G2`](https://g2.antv.antgroup.com/manual/core/api) | 参数 | 说明 | 类型 | 必选 | 默认值 | | --- | ---- | --- | ---- | ------ | diff --git a/s2-site/docs/manual/advanced/adaptive.zh.md b/s2-site/docs/manual/advanced/adaptive.zh.md index c5c9083f53..ddf795e593 100644 --- a/s2-site/docs/manual/advanced/adaptive.zh.md +++ b/s2-site/docs/manual/advanced/adaptive.zh.md @@ -12,7 +12,8 @@ const s2Options = { } ``` -需要注意的是,表格基于 `Canvas` 渲染,配置的宽高其实就是设置 `canvas` 的 `width` 和 `height`, 也就是意味着 `100%`, `80vw` 之类的配置是不生效的: +:::warning{title="注意"} +表格基于 `Canvas` 渲染,配置的宽高其实就是设置 `` 的 `width` 和 `height`, 也就是意味着 `100%`, `80vw` 之类的配置是不生效的: ```ts const s2Options = { @@ -21,11 +22,13 @@ const s2Options = { } ``` +::: + ![preview](https://gw.alipayobjects.com/zos/antfincdn/WmM9%24SLfu/2396a53f-8946-497a-9e68-fd89f01077ff.png) ### 窗口自适应 -如果想让表格撑满整个父容器,可以监听 窗口的 `resize` 事件,或使用 [ResizeObserver](https://developer.mozilla.org/zh-CN/docs/Web/API/ResizeObserver) 监听容器大小变化,然后更新表格宽高: +如果想让表格撑满整个父容器,可以监听窗口的 `resize` 事件,或使用 [ResizeObserver](https://developer.mozilla.org/zh-CN/docs/Web/API/ResizeObserver) 监听容器大小变化,然后更新表格宽高: ```ts import { PivotSheet } from '@antv/s2' @@ -33,15 +36,19 @@ import { debounce } from 'lodash' const s2 = new PivotSheet(...) -const debounceRender = debounce((width, height) => { +const debounceRender = debounce(async (width, height) => { s2.changeSheetSize(width, height) - s2.render(false) // 不重新加载数据 + await s2.render(false) // 不重新加载数据 }, 200) -new ResizeObserver(([entry] = []) => { - const [size] = entry.borderBoxSize || []; - debounceRender(size.inlineSize, size.blockSize) -}).observe(document.body); // 通过监听 document.body 来实现监听窗口大小变化 +const resizeObserver = new ResizeObserver(([entry] = []) => { + const [size] = entry.borderBoxSize || []; + debounceRender(size.inlineSize, size.blockSize) +}) + +// 通过监听 document.body 来实现监听窗口大小变化 +resizeObserver.observe(document.body); + ``` ![preview](https://gw.alipayobjects.com/zos/antfincdn/8kmgXX%267U/Kapture%2525202021-11-23%252520at%25252017.59.16.gif) @@ -60,9 +67,9 @@ const s2 = new PivotSheet(...) const parent = /* 你的容器节点 */ -const debounceRender = debounce((width, height) => { +const debounceRender = debounce(async (width, height) => { s2.changeSheetSize(width, height) - s2.render(false) // 不重新加载数据 + await s2.render(false) // 不重新加载数据 }, 200) const resizeObserver = new ResizeObserver(([entry] = []) => { diff --git a/s2-site/docs/manual/advanced/custom/custom-g2-chart.en.md b/s2-site/docs/manual/advanced/custom/custom-chart.en.md similarity index 100% rename from s2-site/docs/manual/advanced/custom/custom-g2-chart.en.md rename to s2-site/docs/manual/advanced/custom/custom-chart.en.md diff --git a/s2-site/docs/manual/advanced/custom/custom-chart.zh.md b/s2-site/docs/manual/advanced/custom/custom-chart.zh.md new file mode 100644 index 0000000000..24bdcd4816 --- /dev/null +++ b/s2-site/docs/manual/advanced/custom/custom-chart.zh.md @@ -0,0 +1,413 @@ +--- +title: 单元格内绘制图表 +order: 8 +--- + +如果纯文本的表格不够直观,S2 支持 [自定义单元格](/examples#custom-custom-cell),也内置了 [简单的 mini 图绘制](/examples/custom/custom-cell/#mini-chart) + +### 数据格式 + +将普通数值替换成 { values: [G2 图表数据 (Spec)](https://g2.antv.antgroup.com/examples/general/interval/#column) } + +```diff +{ +- number: string ++ number: { ++ values: { ...G2 Spec } ++ } +} +``` + +```diff +const s2DataConfig = { + data: [ + { +- number: 123, ++ number: { ++ values: { ++ type: 'line', ++ data: [ ++ { ++ year: '2017', ++ value: -368, ++ }, ++ ], ++ encode: { x: 'year', y: 'value' }, ++ } ++ }, + } + ] +} +``` + +### 1. 绘制 mini 图表 + + + +#### 1.1 数据准备 + +```ts +const s2DataConfig = { + fields: { + rows: ['province', 'city'], + columns: ['type', 'sub_type'], + values: ['number'], + }, + data: [ + // 用于绘制 mini 图的数据 + { + province: '海南省', + city: '三亚市', + type: '家具', + sub_type: '桌子', + number: { + // 折线图 + values: { + type: 'line', + data: [ + { + year: '2017', + value: -368, + }, + { + year: '2018', + value: 368, + }, + { + year: '2019', + value: 368, + }, + { + year: '2020', + value: 368, + }, + { + year: '2021', + value: 268, + }, + { + year: '2022', + value: 168, + }, + ], + encode: { x: 'year', y: 'value' }, + }, + }, + }, + { + province: '海南省', + city: '三亚市', + type: '家具', + sub_type: '沙发', + number: { + // 柱状图 + values: { + type: 'bar', + data: [ + { + year: '2017', + value: -368, + }, + { + year: '2018', + value: 328, + }, + { + year: '2019', + value: 38, + }, + { + year: '2020', + value: 168, + }, + { + year: '2021', + value: 268, + }, + { + year: '2022', + value: 368, + }, + ], + encode: { x: 'year', y: 'value' }, + }, + }, + }, + { + province: '海南省', + city: '三亚市', + type: '办公用品', + sub_type: '笔', + number: { + // 多列文本 + values: [ + [3877, -4324, '42%'], + [3877, 4324, '-42%'], + ], + }, + }, + { + province: '海南省', + city: '三亚市', + type: '办公用品', + sub_type: '纸张', + number: { + // 子弹图 + values: { + type: 'bullet', + measure: 0.3, + target: 0.76, + }, + }, + }, + ], +}; +``` + +#### 1.2 自定义单元格 + +自定义 `DataCell`, 然后使用 `drawObjectText` 接管绘制逻辑 + +```ts +import { DataCell, drawObjectText } from '@antv/s2'; + +class CustomDataCell extends DataCell { + // 当数值为对象时,完全接管绘制,使用内置的 `drawObjectText` 根据不同的数据结构 (见下方) 绘制不同的图形 + drawTextShape() { + if (this.isMultiData()) { + drawObjectText(this); + return; + } + + super.drawTextShape(); + } +} + +const s2Options = { + dataCell: (viewMeta) => { + return new CustomDataCell(viewMeta, viewMeta?.spreadsheet); + }, +}; +``` + +#### 1.3 图表类型 + +:::info{title="提示"} + +S2 内置了一些基于 [`AntV/G`](https://g.antv.antgroup.com/) 简单的图形绘制能力,适用于轻量简单使用,不希望有额外依赖的场景。 + +::: + +- `line`: 折线图 +- `bar`: 柱状图 +- `bullet`: 子弹图 + +```ts +{ + number: { + values: { + measure: 0.3, + target: 0.76, + } + } +} +``` + +- `多列文本` + +```ts +{ + number: { + values: [ + [3877, -4324, '42%'], + [3877, 4324, '-42%'], + ] +} +``` + +#### 1.4 效果 + +[查看示例](/examples/custom/custom-cell/#mini-chart) + +preview + +#### 1.5 数据格式 + + + +### 2. 绘制 G2 图表 + +如果上诉功能都无法满足使用,那么还可以使用专业的可视化图表库 [`AntV/G2`](https://g2.antv.antgroup.com/). + +:::info{title="提示"} +`S2` 和 `G2` 底层都使用 [AntV/G](https://g.antv.antgroup.com/) 渲染引擎绘制,也就意味着可以**共享渲染引擎**, 实现在 `S2` 表格中绘制 `G2` 图表的梦幻联动,实现真 `图·表`. +::: + + + +
+ +#### 2.1 数据准备 + +:::info{title="提示"} +数据源类型为 [MultiData](https://s2.antv.antgroup.com/api/general/s2-data-config#multidata) 支持 `普通数值单元格` 和 `图表单元格` 共存。图表数据源为标准的 [G2 Spec](https://g2.antv.antgroup.com/examples/general/interval/#column). +::: + +```ts +const s2DataConfig = { + data: [ + // 普通数据 + { + number: 1343, + province: '浙江省', + city: '杭州市', + type: '办公用品', + sub_type: '纸张', + }, + { + number: { + // G2 图表数据 (Spec) https://g2.antv.antgroup.com/examples/general/interval/#column + values: { + type: 'view', + autoFit: true, + padding: 0, + axis: false, + children: [ + { + type: 'image', + style: { + src: 'https://gw.alipayobjects.com/zos/rmsportal/NeUTMwKtPcPxIFNTWZOZ.png', + x: '50%', + y: '50%', + width: '100%', + height: '100%', + }, + tooltip: false, + }, + { + type: 'heatmap', + data: { + type: 'fetch', + value: 'https://assets.antv.antgroup.com/g2/heatmap.json', + }, + encode: { x: 'g', y: 'l', color: 'tmp' }, + style: { opacity: 0 }, + tooltip: false, + }, + ], + }, + }, + province: '浙江省', + city: '舟山市', + type: '办公用品', + sub_type: '笔', + }, + ], +}; +``` + +#### 2.2 安装 G2 + +:::warning{title="该功能依赖 G2 的 `5.x` 版本,请确保使用了正确的版本 "} + +```bash +yarn add @antv/g2 --save +``` + +使用 `G2` 提供的 `renderToMountedElement` 方法 + +```ts +import { renderToMountedElement } from '@antv/g2'; +``` + +::: + +#### 2.3 在 `@antv/s2` 中使用 + +##### 1. 自定义 `DataCell`, 如果是图表数据,则不渲染默认的文本 + +```ts +import { PivotSheet, DataCell } from '@antv/s2'; + +class ChartSheetDataCell extends DataCell { + public drawTextShape(options) { + if (this.isMultiData()) { + return null; + } + + super.drawTextShape(options); + } +} + +const s2 = new PivotSheet(container, s2DataConfig, { + dataCell: (viewMeta) => new ChartSheetDataCell(viewMeta, viewMeta.spreadsheet) +}); + +await s2.render(); + +``` + +##### 2. 监听数值单元格渲染完成后,使用 `G2` 提供的 `renderToMountedElement` 将图表挂载在 `S2` 单元格实例上 + +:::warning{title="提示"} +由于 `G2` 按需加载的特性,请根据你渲染的图表,自行选择适合的 [`library`](https://g2.antv.antgroup.com/manual/extra-topics/bundle#g2stdlib) +::: + +```ts +import { renderToMountedElement, stdlib } from '@antv/g2'; + +s2.on(S2Event.DATA_CELL_RENDER, (cell) => { + // 如果是普通数值单元格正常展示 + if (!cell.isChartData()) { + return; + } + + const chartOptions = cell.getRenderChartOptions(); + + renderToMountedElement(chartOptions, { + group: cell, + // https://g2.antv.antgroup.com/manual/extra-topics/bundle#g2stdlib + library: stdlib(), + }); +}); +``` + +#### 2.4 在 `@antv/s2-react` 使用 + +如果希望在 `React` 中使用,除了上诉的方式外,也可以直接使用 ``, 内部封装了 `自定义 DateCell` 的步骤 + +```tsx +import { SheetComponent } from '@antv/s2-react'; +import { renderToMountedElement, stdlib } from '@antv/g2'; + +function App() { + const onDataCellRender = (cell) => { + // 如果是普通数值单元格正常展示 + if (!cell.isChartData()) { + return; + } + + const chartOptions = cell.getRenderChartOptions(); + + renderToMountedElement(chartOptions, { + group: cell, + // 根据实际需要渲染的图表,选择 library:https://g2.antv.antgroup.com/manual/extra-topics/bundle#g2stdlib + library: stdlib(), + }); + }; + + return ( + + ) +} +``` + +#### 2.5 效果 + +[查看示例](/examples/custom/custom-cell#custom-g2-chart) + +preview diff --git a/s2-site/docs/manual/advanced/custom/custom-g2-chart.zh.md b/s2-site/docs/manual/advanced/custom/custom-g2-chart.zh.md deleted file mode 100644 index 8ca9ef3283..0000000000 --- a/s2-site/docs/manual/advanced/custom/custom-g2-chart.zh.md +++ /dev/null @@ -1,175 +0,0 @@ ---- -title: 自定义单元格内绘制 G2 图表 -order: 8 ---- - -S2 支持 [自定义单元格](https://s2.antv.antgroup.com/examples#custom-custom-cell),也内置了 [简单的 mini 图绘制](https://s2.antv.antgroup.com/examples/custom/custom-cell/#mini-chart), 如果上诉功能都无法满足使用,那么还可以使用专业的可视化图表库 [`AntV/G2`](https://g2.antv.antgroup.com/). - -`S2` 和 `G2` 底层都使用 [AntV/G](https://g.antv.antgroup.com/) 渲染引擎绘制,也就意味着可以**共享渲染引擎**, 实现在 `S2` 表格中绘制 `G2` 图表的梦幻联动,实现真 `图·表`. - - - -
- -## 数据准备 - -数据源类型为 [MultiData](https://s2.antv.antgroup.com/api/general/s2-data-config#multidata) 支持 `普通数值单元格` 和 `图表单元格` 共存。图表数据源为标准的 [G2 Spec](https://g2.antv.antgroup.com/examples/general/interval/#column). - -```ts -const s2DataConfig = { - data: [ - // 普通数据 - { - number: 1343, - province: '浙江省', - city: '杭州市', - type: '办公用品', - sub_type: '纸张', - }, - { - number: { - // G2 图表数据 (Spec) https://g2.antv.antgroup.com/examples/general/interval/#column - values: { - type: 'view', - autoFit: true, - padding: 0, - axis: false, - children: [ - { - type: 'image', - style: { - src: 'https://gw.alipayobjects.com/zos/rmsportal/NeUTMwKtPcPxIFNTWZOZ.png', - x: '50%', - y: '50%', - width: '100%', - height: '100%', - }, - tooltip: false, - }, - { - type: 'heatmap', - data: { - type: 'fetch', - value: 'https://assets.antv.antgroup.com/g2/heatmap.json', - }, - encode: { x: 'g', y: 'l', color: 'tmp' }, - style: { opacity: 0 }, - tooltip: false, - }, - ], - }, - }, - province: '浙江省', - city: '舟山市', - type: '办公用品', - sub_type: '笔', - }, - ], -}; -``` - -### 安装 G2 - -:::warning{title="该功能依赖 G2 的 `5.x` 版本,请确保使用了正确的版本 "} - -```bash -yarn add @antv/g2 --save -``` - -使用 `G2` 提供的 `renderToMountedElement` 方法 - -```ts -import { renderToMountedElement } from '@antv/g2'; -``` - -::: - -### 在 `@antv/s2` 中使用 - -#### 1. 自定义 `DataCell`, 如果是图表数据,则不渲染默认的文本 - -```ts -import { PivotSheet, DataCell } from '@antv/s2'; - -class ChartSheetDataCell extends DataCell { - public drawTextShape(options) { - if (this.isMultiData()) { - return null; - } - - super.drawTextShape(options); - } -} - -const s2 = new PivotSheet(container, s2DataConfig, { - dataCell: (viewMeta) => new ChartSheetDataCell(viewMeta, viewMeta.spreadsheet) -}); - -s2.render(); - -``` - -#### 2. 监听数值单元格渲染完成后,使用 `G2` 提供的 `renderToMountedElement` 将图表挂载在 `S2` 单元格实例上 - -:::warning{title="提示"} -由于 `G2` 按需加载的特性,请根据你渲染的图表,自行选择适合的 [`library`](https://g2.antv.antgroup.com/manual/extra-topics/bundle#g2stdlib) -::: - -```ts -import { renderToMountedElement, stdlib } from '@antv/g2'; - -s2.on(S2Event.DATA_CELL_RENDER, (cell) => { - // 如果是普通数值单元格正常展示 - if (!cell.isChartData()) { - return; - } - - const chartOptions = cell.getRenderChartOptions(); - - renderToMountedElement(chartOptions, { - group: cell, - // https://g2.antv.antgroup.com/manual/extra-topics/bundle#g2stdlib - library: stdlib(), - }); -}); -``` - -### 在 `@antv/s2-react` 使用 - -如果希望在 `React` 中使用,除了上诉的方式外,也可以直接使用 ``, 内部封装了 `自定义 DateCell` 的步骤 - -```tsx -import { SheetComponent } from '@antv/s2-react'; -import { renderToMountedElement, stdlib } from '@antv/g2'; - -function App() { - const onDataCellRender = (cell) => { - // 如果是普通数值单元格正常展示 - if (!cell.isChartData()) { - return; - } - - const chartOptions = cell.getRenderChartOptions(); - - renderToMountedElement(chartOptions, { - group: cell, - // 根据实际需要渲染的图表,选择 library:https://g2.antv.antgroup.com/manual/extra-topics/bundle#g2stdlib - library: stdlib(), - }); - }; - - return ( - - ) -} -``` - -### 效果 - -[查看示例](/examples#custom-custom-g2-chart) - -preview diff --git a/s2-site/docs/manual/advanced/interaction/custom.zh.md b/s2-site/docs/manual/advanced/interaction/custom.zh.md index 6e6bfed0f2..287fdd8579 100644 --- a/s2-site/docs/manual/advanced/interaction/custom.zh.md +++ b/s2-site/docs/manual/advanced/interaction/custom.zh.md @@ -16,8 +16,7 @@ import { BaseEvent } from '@antv/s2'; // 继承 BaseEvent, 可以拿到 this.spreadsheet class HiddenInteraction extends BaseEvent { - bindEvents() { - } + bindEvents() { } } ``` @@ -54,15 +53,16 @@ const s2Options = { customInteractions: [ { // 交互的唯一标识,需要保证和已有交互不冲突 - key: 'MyInteraction', - interaction: MyInteraction, + key: 'HiddenInteraction', + interaction: HiddenInteraction, }, ], } }; + const s2 = new TableSheet(container, s2DataConfig, s2Options); -s2.render(); +await s2.render(); ``` ## 3. 多个自定义交互 @@ -87,8 +87,8 @@ const s2Options = { interaction: { customInteractions: [ { - key: 'MyInteraction', - interaction: MyInteraction, + key: 'HiddenInteraction', + interaction: HiddenInteraction, }, { key: 'ContextMenuInteraction', @@ -100,7 +100,7 @@ const s2Options = { const s2 = new TableSheet(container, s2DataConfig, s2Options); -s2.render(); +await s2.render(); ``` diff --git a/s2-site/docs/manual/advanced/interaction/link-jump.zh.md b/s2-site/docs/manual/advanced/interaction/link-jump.zh.md index 6837239add..bcdd7c0d0e 100644 --- a/s2-site/docs/manual/advanced/interaction/link-jump.zh.md +++ b/s2-site/docs/manual/advanced/interaction/link-jump.zh.md @@ -70,7 +70,7 @@ s2.on(S2Event.GLOBAL_LINK_FIELD_JUMP, (data) => { location.href = `https://path/to/${key}=${value}}`; }); -s2.render(); +await s2.render(); ``` @@ -105,7 +105,7 @@ s2.on(S2Event.GLOBAL_LINK_FIELD_JUMP, (data) => { location.href = `https://path/to/${key}=${value}}`; }); -s2.render(); +await s2.render(); ``` diff --git a/s2-site/docs/manual/advanced/interaction/merge-cell.zh.md b/s2-site/docs/manual/advanced/interaction/merge-cell.zh.md index 6085f010c8..0571e6898c 100644 --- a/s2-site/docs/manual/advanced/interaction/merge-cell.zh.md +++ b/s2-site/docs/manual/advanced/interaction/merge-cell.zh.md @@ -335,7 +335,7 @@ s2.on(S2Event.MERGED_CELLS_CLICK, (event) => { }); }); -s2.render(); +await s2.render(); ``` ## demo 演示 diff --git a/s2-site/docs/manual/basic/analysis/copy-export.zh.md b/s2-site/docs/manual/basic/analysis/copy-export.zh.md index ed3d130023..89baf8636a 100644 --- a/s2-site/docs/manual/basic/analysis/copy-export.zh.md +++ b/s2-site/docs/manual/basic/analysis/copy-export.zh.md @@ -26,7 +26,7 @@ S2 的导出组件,分别提供了原始数据的复制和格式化后数据 #### 局部复制 -使用快捷键 `command/ctrl + c` 即可复制选中区域(局部复制) +使用快捷键 `Command/Ctrl + C` 即可复制选中区域(局部复制) ```ts const s2Options = { @@ -77,7 +77,7 @@ const s2Options = { `@antv/s2-react` 组件层提供了导出功能 -```ts +```tsx import { SheetComponent } from '@antv/s2-react' + +## 自定义行列头维值名称 + +```ts {7,10} + const s2DataConfig = { + fields: { + rows: ['province', 'city'], + columns: ['type', 'sub_type'], + values: ['number'], + }, + meta: [ + { + field: 'province', + name: '省份', + }, + { + field: 'city', + name: '城市', + }, + { + field: 'type', + name: '商品类别', + }, + { + field: 'sub_type', + name: '子类别', + }, + { + field: 'number', + name: '数量', + }, + ] +}; +``` + +## 自定义数值格式 + +可以通过 `formatter` 自定义数值的格式,可以拿到 + +- `value`: 当前单元格数值 +- `record`: 当前单元格整行数据 +- `meta`: 当前单元格原信息 + +```ts {7,27-29} + const s2DataConfig = { + fields: { + rows: ['province', 'city'], + columns: ['type', 'sub_type'], + values: ['number'], + }, + meta: [ + { + field: 'province', + name: '省份', + }, + { + field: 'city', + name: '城市', + }, + { + field: 'type', + name: '商品类别', + }, + { + field: 'sub_type', + name: '子类别', + }, + { + field: 'number', + name: '数量', + formatter: (value, record, meta) => { + return `${value / 100} %` + }, + }, + ] +}; +``` + +## 复制导出时保留格式化信息 + +复制导出默认使用原数据进行处理,开启 `copyWithFormat` 后,则以 `meta` 中的 `name` 和 `formatter` 进行复制导出。 + +```ts +const s2Options = { + interaction: { + copyWithFormat: true + } +} +``` diff --git a/s2-site/docs/manual/basic/i18n.zh.md b/s2-site/docs/manual/basic/i18n.zh.md index 23ead6051b..f90c34cfaf 100644 --- a/s2-site/docs/manual/basic/i18n.zh.md +++ b/s2-site/docs/manual/basic/i18n.zh.md @@ -15,8 +15,8 @@ import { setLang, PivotSheet } from '@antv/s2' setLang('en_US') // setLang('zh_CN') -const s2 = new PivotSheet() -s2.render() +const s2 = new PivotSheet(...) +await s2.render() ``` ## 扩展国际化文案 diff --git a/s2-site/docs/manual/basic/sheet-type/pivot-mode.zh.md b/s2-site/docs/manual/basic/sheet-type/pivot-mode.zh.md index cc6e38d1dc..2f550dcbee 100644 --- a/s2-site/docs/manual/basic/sheet-type/pivot-mode.zh.md +++ b/s2-site/docs/manual/basic/sheet-type/pivot-mode.zh.md @@ -92,7 +92,8 @@ import { PivotSheet } from "@antv/s2"; const container = document.getElementById('container'); const s2 = new PivotSheet(container, dataCfg, options); -s2.render(); + +await s2.render(); ``` ​📊 查看 [类方式透视表示例](/examples/basic/pivot#grid) 和 [API 文档](/api/general/s2options)。 diff --git a/s2-site/docs/manual/basic/sheet-type/table-mode.zh.md b/s2-site/docs/manual/basic/sheet-type/table-mode.zh.md index ef69c7c391..bf4e70f983 100644 --- a/s2-site/docs/manual/basic/sheet-type/table-mode.zh.md +++ b/s2-site/docs/manual/basic/sheet-type/table-mode.zh.md @@ -94,7 +94,8 @@ import { TableSheet } from "@antv/s2"; const container = document.getElementById('container'); const s2 = new TableSheet(container, dataCfg, options); -s2.render(); + +await s2.render(); ``` ## 特性 diff --git a/s2-site/docs/manual/basic/theme.zh.md b/s2-site/docs/manual/basic/theme.zh.md index e0953d51b0..aa9d5fe1b5 100644 --- a/s2-site/docs/manual/basic/theme.zh.md +++ b/s2-site/docs/manual/basic/theme.zh.md @@ -46,7 +46,7 @@ s2.setTheme({ color: '#353c59', }, }); -s2.render(false); +await s2.render(false); ``` ## 自定义主题 @@ -55,7 +55,7 @@ s2 实例上的 `setThemeCfg` 方法是一切主题配置的入口,该方法 - 通过 ThemeCfg.name 使用预置主题 - 通过 ThemeCfg.palette 自定义色板生成主题 -- 通过 ThemeCfg.theme 自定义 schema 生成主题(可与上两个属性同时使用,即覆盖由它们生成的主题) +- 通过 ThemeCfg.theme (`s2.setTheme(...)`) 自定义 schema 生成主题(可与上两个属性同时使用,即覆盖由它们生成的主题) ### 选择预置主题 @@ -66,7 +66,7 @@ const s2 = new PivotSheet(container, s2DataConfig, s2Options); // name 可为 default, colorful, gray s2.setThemeCfg({ name: 'colorful' }); -s2.render(false); +await s2.render(false); ``` S2 内置 3 套主题效果: @@ -121,9 +121,9 @@ const customTheme = { }, }; -// s2.setThemeCfg({ theme: customTheme }) +// 等价与:s2.setThemeCfg({ theme: customTheme }) s2.setTheme(customTheme) -s2.render(false); +await s2.render(false); ``` @@ -209,8 +209,9 @@ const s2Palette = { green: '#29A294', }, }; + s2.setThemeCfg({ palette: s2Palette }); -s2.render(false); +await s2.render(false); ``` @@ -236,7 +237,7 @@ const newPalette = generatePalette({ ...palette, brandColor: themeColor }); s2.setThemeCfg({ palette: newPalette, }); -s2.render(false); +await s2.render(false); ``` diff --git a/s2-site/docs/manual/faq.zh.md b/s2-site/docs/manual/faq.zh.md index e398b58424..8d2e14bd46 100644 --- a/s2-site/docs/manual/faq.zh.md +++ b/s2-site/docs/manual/faq.zh.md @@ -51,7 +51,7 @@ const s2Options = { ```ts const scale = 0.8 s2.changeSheetSize(width * scale, height * scale) -s2.render(false) +await s2.render(false) ``` 可参考 issue [#808](https://github.com/antvis/S2/issues/808) [#990](https://github.com/antvis/S2/pull/990) (感谢 [@cylnet](https://github.com/cylnet) [@xiaochong44](https://github.com/xiaochong44)) @@ -66,35 +66,35 @@ const pivotSheet = new PivotSheet(document.getElementById('container'), dataCfg, ```ts pivotSheet.setOptions({ ... }) -pivotSheet.render(false) // 重新渲染,不更新数据 +await pivotSheet.render(false) // 重新渲染,不更新数据 ``` 重置 options: [可选项](/docs/api/general/S2Options),直接使用传入的 option,不会与上次的数据进行合并 ```ts pivotSheet.setOptions({ ... }, true) -pivotSheet.render(false) // 重新渲染,不更新数据 +await pivotSheet.render(false) // 重新渲染,不更新数据 ``` 更新 dataCfg: [可选项](/docs/api/general/S2DataConfig),会与上次的数据进行合并 ```ts pivotSheet.setDataCfg({ ... }) -pivotSheet.render(true) // 重新渲染,且更新数据 +await pivotSheet.render(true) // 重新渲染,且更新数据 ``` 重置 dataCfg: [可选项](/docs/api/general/S2DataConfig),直接使用传入的 dataCfg,不会与上次的数据进行合并 ```ts pivotSheet.setDataCfg({ ... }, true) -pivotSheet.render(true) // 重新渲染,且更新数据 +await pivotSheet.render(true) // 重新渲染,且更新数据 ``` 更新 theme: [可选项](/docs/api/general/S2Theme) ```ts pivotSheet.setThemeCfg({ ... }) -pivotSheet.render(false) // 重新渲染,不更新数据 +await pivotSheet.render(false) // 重新渲染,不更新数据 ``` ### 图表渲染不出来,怎么回事? @@ -124,7 +124,7 @@ const pivotSheet = new PivotSheet('#container > div[title="xx"]', dataCfg, optio ```ts s2.changeSheetSize(200, 200) -s2.render(false) +await s2.render(false) ``` ### 表格可以根据外部容器的宽高自动撑满吗? diff --git a/s2-site/docs/manual/getting-started.zh.md b/s2-site/docs/manual/getting-started.zh.md index 03f0b4bf31..a749bddf6e 100644 --- a/s2-site/docs/manual/getting-started.zh.md +++ b/s2-site/docs/manual/getting-started.zh.md @@ -171,7 +171,7 @@ const s2Options = { ```ts import { PivotSheet } from '@antv/s2'; -async function run() { +async function bootstrap() { const container = document.getElementById('container'); const s2 = new PivotSheet(container, s2DataConfig, s2Options); @@ -179,7 +179,7 @@ async function run() { await s2.render(); // 返回 Promise } -run(); +bootstrap(); ``` #### 4. 结果 diff --git a/s2-site/docs/manual/introduction.zh.md b/s2-site/docs/manual/introduction.zh.md index 9b982f76fb..fe9dfb192e 100644 --- a/s2-site/docs/manual/introduction.zh.md +++ b/s2-site/docs/manual/introduction.zh.md @@ -6,23 +6,52 @@ redirect_from: --- ## ❓ 什么是 S2 @@ -33,17 +62,18 @@ redirect_from: ## ✨ 特性 -1. 开箱即用:提供不同场景下开箱即用的 `React`, `Vue3` 表组件及配套分析组件,只需要简单的配置即可轻松实现复杂场景。 -2. 多维交叉分析: 告别单一分析维度,全面拥抱任意维度的自由组合分析。 -3. 高性能:能支持全量百万数据下 `<4s` 渲染,也能通过局部下钻来实现秒级渲染。 -4. 高扩展性:支持任意的自定义扩展(包括但不局限于布局,样式,交互,数据流等)。 -5. 交互友好:支持丰富的交互形式(单选、圈选、行选、列选、冻结行头、宽高拖拽,自定义交互等) +1. **开箱即用**:提供不同场景下开箱即用的 `React`, `Vue3` 表组件及配套分析组件,只需要简单的配置即可轻松实现复杂场景。 +2. **多维交叉分析**: 告别单一分析维度,全面拥抱任意维度的自由组合分析。 +3. **高性能**:能支持全量百万数据下 `<4s` 渲染,也能通过局部下钻来实现秒级渲染。 +4. **高扩展性**:支持任意的自定义扩展(包括但不局限于布局,样式,交互,数据流等)。 +5. **交互友好**:支持丰富的交互形式(单选、圈选、行选、列选、冻结行头、宽高拖拽,自定义交互等) ## 📦 安装 ```bash -npm install @antv/s2 -# yarn add @antv/s2 +pnpm install @antv/s2 --save +# npm install @antv/s2 --save +# yarn add @antv/s2 --save ``` ## 🔨 使用 @@ -181,41 +211,53 @@ const s2Options = { ```ts import { PivotSheet } from '@antv/s2'; -async function run() { +async function bootstrap() { const container = document.getElementById('container'); const s2 = new PivotSheet(container, s2DataConfig, s2Options); - await s2.render(); // 返回 Promise + await s2.render(); // 异步渲染 } -run(); +bootstrap(); ``` ### 4. 结果 -preview +preview ## 📦 版本 -## 👤 作者 +## 🙋‍♂️ 问题反馈 -[**@AntV**](https://github.com/orgs/antvis/people) +有任何问题请严格按照模版 [提交 Issue](https://github.com/antvis/S2/issues/new/choose), 在这之前强烈建议阅读 [《⚠️ 提 Issue 前必读》](https://github.com/antvis/S2/issues/1904) -## 🤝 参与贡献 +## ⌨️ 本地开发 +## 🤝 参与贡献 + +请查看 [贡献指南](https://s2.antv.antgroup.com/manual/contribution) + +## 👁️ 项目洞察 + +![Alt](https://repobeats.axiom.co/api/embed/ebb7eecb994dc0e3980044aefe43eb81302e3632.svg "Repobeats analytics image") + ## 📧 联系我们 -## 👬 Contributors +## 👬 贡献者们 ![https://github.com/antvis/s2/graphs/contributors](https://contrib.rocks/image?repo=antvis/s2) +## 👤 作者 + +[**@AntV**](https://github.com/orgs/antvis/people) + ## 📄 License -MIT@[AntV](https://github.com/antvis). +MIT@[AntV](https://github.com/antvis) diff --git a/s2-site/examples/analysis/conditions/demo/background.ts b/s2-site/examples/analysis/conditions/demo/background.ts index 4213ad03d3..45ac837055 100644 --- a/s2-site/examples/analysis/conditions/demo/background.ts +++ b/s2-site/examples/analysis/conditions/demo/background.ts @@ -1,13 +1,13 @@ -import { PivotSheet, EXTRA_FIELD } from '@antv/s2'; +import { PivotSheet, EXTRA_FIELD, S2Options } from '@antv/s2'; fetch( 'https://gw.alipayobjects.com/os/bmw-prod/2a5dbbc8-d0a7-4d02-b7c9-34f6ca63cff6.json', ) .then((res) => res.json()) - .then((dataCfg) => { + .then(async (dataCfg) => { const container = document.getElementById('container'); - const s2Options = { + const s2Options: S2Options = { width: 600, height: 480, interaction: { @@ -66,7 +66,8 @@ fetch( ], }, }; + const s2 = new PivotSheet(container, dataCfg, s2Options); - s2.render(); + await s2.render(); }); diff --git a/s2-site/examples/analysis/conditions/demo/bidirectional-interval.ts b/s2-site/examples/analysis/conditions/demo/bidirectional-interval.ts index 11edd7e502..df0f7cdcb5 100644 --- a/s2-site/examples/analysis/conditions/demo/bidirectional-interval.ts +++ b/s2-site/examples/analysis/conditions/demo/bidirectional-interval.ts @@ -1,13 +1,13 @@ -import { PivotSheet } from '@antv/s2'; +import { PivotSheet, S2Options } from '@antv/s2'; fetch( 'https://gw.alipayobjects.com/os/bmw-prod/4e49b398-5121-4f00-9607-4854aedd5a21.json', ) .then((res) => res.json()) - .then((dataCfg) => { + .then(async (dataCfg) => { const container = document.getElementById('container'); - const s2Options = { + const s2Options: S2Options = { width: 600, height: 480, interaction: { @@ -26,7 +26,8 @@ fetch( ], }, }; + const s2 = new PivotSheet(container, dataCfg, s2Options); - s2.render(); + await s2.render(); }); diff --git a/s2-site/examples/analysis/conditions/demo/gradient-interval.ts b/s2-site/examples/analysis/conditions/demo/gradient-interval.ts index 2a2394fcba..d56edf53fb 100644 --- a/s2-site/examples/analysis/conditions/demo/gradient-interval.ts +++ b/s2-site/examples/analysis/conditions/demo/gradient-interval.ts @@ -1,12 +1,13 @@ import { PivotSheet } from '@antv/s2'; // 可借助 tinygradient 完成功能更全面的颜色过渡 -function getGradient(rate, startColor, endColor) { - function toGgb(color) { +function getGradient(rate: number, startColor: string, endColor: string) { + function toGgb(color: string) { color = color.slice(1); const r = parseInt(color.substring(0, 2), 16); const g = parseInt(color.substring(2, 4), 16); const b = parseInt(color.substring(4, 6), 16); + return [r, g, b]; } const start = toGgb(startColor); @@ -14,6 +15,7 @@ function getGradient(rate, startColor, endColor) { const r = start[0] + (end[0] - start[0]) * rate; const g = start[1] + (end[1] - start[1]) * rate; const b = start[2] + (end[2] - start[2]) * rate; + return `rgb(${r},${g},${b})`; } @@ -21,7 +23,7 @@ fetch( 'https://gw.alipayobjects.com/os/bmw-prod/2a5dbbc8-d0a7-4d02-b7c9-34f6ca63cff6.json', ) .then((res) => res.json()) - .then((dataCfg) => { + .then(async (dataCfg) => { const container = document.getElementById('container'); const s2Options = { @@ -40,6 +42,7 @@ fetch( const rage = (fieldValue - minValue) / (maxValue - minValue); const color = getGradient(rage, '#95F0FF', '#3A9DBF'); + return { fill: `l(0) 0:#95F0FF 1:${color}`, isCompare: true, @@ -50,7 +53,8 @@ fetch( ], }, }; + const s2 = new PivotSheet(container, dataCfg, s2Options); - s2.render(); + await s2.render(); }); diff --git a/s2-site/examples/analysis/conditions/demo/icon.ts b/s2-site/examples/analysis/conditions/demo/icon.ts index 35483b0fe9..c87407699c 100644 --- a/s2-site/examples/analysis/conditions/demo/icon.ts +++ b/s2-site/examples/analysis/conditions/demo/icon.ts @@ -1,13 +1,13 @@ -import { PivotSheet } from '@antv/s2'; +import { PivotSheet, S2Options } from '@antv/s2'; fetch( 'https://gw.alipayobjects.com/os/bmw-prod/2a5dbbc8-d0a7-4d02-b7c9-34f6ca63cff6.json', ) .then((res) => res.json()) - .then((dataCfg) => { + .then(async (dataCfg) => { const container = document.getElementById('container'); - const s2Options = { + const s2Options: S2Options = { width: 600, height: 480, interaction: { @@ -52,7 +52,8 @@ fetch( ], }, }; + const s2 = new PivotSheet(container, dataCfg, s2Options); - s2.render(); + await s2.render(); }); diff --git a/s2-site/examples/analysis/conditions/demo/intelligent-background.ts b/s2-site/examples/analysis/conditions/demo/intelligent-background.ts index 18e8f53d3c..ce421fba5e 100644 --- a/s2-site/examples/analysis/conditions/demo/intelligent-background.ts +++ b/s2-site/examples/analysis/conditions/demo/intelligent-background.ts @@ -1,13 +1,13 @@ -import { PivotSheet } from '@antv/s2'; +import { PivotSheet, S2Options, S2Options } from '@antv/s2'; fetch( 'https://gw.alipayobjects.com/os/bmw-prod/2a5dbbc8-d0a7-4d02-b7c9-34f6ca63cff6.json', ) .then((res) => res.json()) - .then((dataCfg) => { + .then(async (dataCfg) => { const container = document.getElementById('container'); - const s2Options = { + const s2Options: S2Options = { width: 600, height: 480, interaction: { @@ -30,5 +30,5 @@ fetch( }; const s2 = new PivotSheet(container, dataCfg, s2Options); - s2.render(); + await s2.render(); }); diff --git a/s2-site/examples/analysis/conditions/demo/interval.ts b/s2-site/examples/analysis/conditions/demo/interval.ts index 2dce6f6e74..a31a322ae7 100644 --- a/s2-site/examples/analysis/conditions/demo/interval.ts +++ b/s2-site/examples/analysis/conditions/demo/interval.ts @@ -1,13 +1,13 @@ -import { PivotSheet } from '@antv/s2'; +import { PivotSheet, S2Options, S2Options } from '@antv/s2'; fetch( 'https://gw.alipayobjects.com/os/bmw-prod/2a5dbbc8-d0a7-4d02-b7c9-34f6ca63cff6.json', ) .then((res) => res.json()) - .then((dataCfg) => { + .then(async (dataCfg) => { const container = document.getElementById('container'); - const s2Options = { + const s2Options: S2Options = { width: 600, height: 480, interaction: { @@ -31,7 +31,8 @@ fetch( ], }, }; + const s2 = new PivotSheet(container, dataCfg, s2Options); - s2.render(); + await s2.render(); }); diff --git a/s2-site/examples/analysis/conditions/demo/multi-background.ts b/s2-site/examples/analysis/conditions/demo/multi-background.ts index 0d04d7ba69..81a48c8f31 100644 --- a/s2-site/examples/analysis/conditions/demo/multi-background.ts +++ b/s2-site/examples/analysis/conditions/demo/multi-background.ts @@ -1,13 +1,13 @@ -import { PivotSheet } from '@antv/s2'; +import { PivotSheet, S2Options } from '@antv/s2'; fetch( 'https://gw.alipayobjects.com/os/bmw-prod/2a5dbbc8-d0a7-4d02-b7c9-34f6ca63cff6.json', ) .then((res) => res.json()) - .then((dataCfg) => { + .then(async (dataCfg) => { const container = document.getElementById('container'); - const s2Options = { + const s2Options: S2Options = { width: 600, height: 480, interaction: { @@ -34,23 +34,32 @@ fetch( return { fill: '#B8E1FF', }; - } else if (fieldValue <= 2797) { + } + + if (fieldValue <= 2797) { return { fill: '#9AC5FF', }; - } else if (fieldValue <= 4191) { + } + + if (fieldValue <= 4191) { return { fill: '#7DAAFF', }; - } else if (fieldValue <= 5588) { + } + + if (fieldValue <= 5588) { return { fill: '#5B8FF9', }; - } else if (fieldValue <= 6985) { + } + + if (fieldValue <= 6985) { return { fill: '#3D76DD', }; } + return { fill: '#085EC0', }; @@ -59,7 +68,8 @@ fetch( ], }, }; + const s2 = new PivotSheet(container, dataCfg, s2Options); - s2.render(); + await s2.render(); }); diff --git a/s2-site/examples/analysis/conditions/demo/multi-conditions.ts b/s2-site/examples/analysis/conditions/demo/multi-conditions.ts index 9cff6c0aee..915de528a9 100644 --- a/s2-site/examples/analysis/conditions/demo/multi-conditions.ts +++ b/s2-site/examples/analysis/conditions/demo/multi-conditions.ts @@ -1,12 +1,13 @@ -import { PivotSheet } from '@antv/s2'; +import { PivotSheet, S2Options } from '@antv/s2'; // 可借助 tinygradient 完成功能更全面的颜色过渡 -function getGradient(rate, startColor, endColor) { - function toGgb(color) { +function getGradient(rate: number, startColor: string, endColor: string) { + function toGgb(color: string) { color = color.slice(1); const r = parseInt(color.substring(0, 2), 16); const g = parseInt(color.substring(2, 4), 16); const b = parseInt(color.substring(4, 6), 16); + return [r, g, b]; } const start = toGgb(startColor); @@ -14,6 +15,7 @@ function getGradient(rate, startColor, endColor) { const r = start[0] + (end[0] - start[0]) * rate; const g = start[1] + (end[1] - start[1]) * rate; const b = start[2] + (end[2] - start[2]) * rate; + return `rgb(${r},${g},${b})`; } @@ -21,11 +23,11 @@ fetch( 'https://gw.alipayobjects.com/os/bmw-prod/2a5dbbc8-d0a7-4d02-b7c9-34f6ca63cff6.json', ) .then((res) => res.json()) - .then((dataCfg) => { + .then(async (dataCfg) => { const container = document.getElementById('container'); const s2DataConfig = dataCfg; - const s2Options = { + const s2Options: S2Options = { width: 600, height: 480, interaction: { @@ -73,6 +75,7 @@ fetch( const rage = (fieldValue - minValue) / (maxValue - minValue); const color = getGradient(rage, '#5083F5', '#F7B46F'); + return { fill: `l(0) 0:#5083F5 1:${color}`, isCompare: true, @@ -83,7 +86,9 @@ fetch( ], }, }; + const s2 = new PivotSheet(container, s2DataConfig, s2Options); + s2.setThemeCfg({ name: 'colorful' }); - s2.render(); + await s2.render(); }); diff --git a/s2-site/examples/analysis/conditions/demo/table-text.ts b/s2-site/examples/analysis/conditions/demo/table-text.ts index 25c99f29eb..ac421e5bca 100644 --- a/s2-site/examples/analysis/conditions/demo/table-text.ts +++ b/s2-site/examples/analysis/conditions/demo/table-text.ts @@ -1,12 +1,12 @@ -import { TableSheet } from '@antv/s2'; +import { S2DataConfig, S2Options, S2Options, TableSheet } from '@antv/s2'; fetch( 'https://gw.alipayobjects.com/os/bmw-prod/986d48ce-cfdf-475d-980c-553762770928.json', ) .then((res) => res.json()) - .then((data) => { + .then(async (data) => { const container = document.getElementById('container'); - const s2DataConfig = { + const s2DataConfig: S2DataConfig = { fields: { columns: ['province', 'city', 'type', 'price', 'cost'], }, @@ -35,7 +35,7 @@ fetch( data, }; - const s2Options = { + const s2Options: S2Options = { width: 600, height: 480, interaction: { @@ -62,7 +62,8 @@ fetch( ], }, }; + const s2 = new TableSheet(container, s2DataConfig, s2Options); - s2.render(); + await s2.render(); }); diff --git a/s2-site/examples/analysis/conditions/demo/text.ts b/s2-site/examples/analysis/conditions/demo/text.ts index 4de67376e7..3bda6b622c 100644 --- a/s2-site/examples/analysis/conditions/demo/text.ts +++ b/s2-site/examples/analysis/conditions/demo/text.ts @@ -1,13 +1,13 @@ -import { PivotSheet, EXTRA_FIELD } from '@antv/s2'; +import { PivotSheet, EXTRA_FIELD, S2Options } from '@antv/s2'; fetch( 'https://gw.alipayobjects.com/os/bmw-prod/2a5dbbc8-d0a7-4d02-b7c9-34f6ca63cff6.json', ) .then((res) => res.json()) - .then((dataCfg) => { + .then(async (dataCfg) => { const container = document.getElementById('container'); - const s2Options = { + const s2Options: S2Options = { width: 600, height: 480, interaction: { @@ -66,7 +66,8 @@ fetch( ], }, }; + const s2 = new PivotSheet(container, dataCfg, s2Options); - s2.render(); + await s2.render(); }); diff --git a/s2-site/examples/analysis/sort/demo/custom-list.ts b/s2-site/examples/analysis/sort/demo/custom-list.ts index 67ea91caa4..ce21eed818 100644 --- a/s2-site/examples/analysis/sort/demo/custom-list.ts +++ b/s2-site/examples/analysis/sort/demo/custom-list.ts @@ -1,10 +1,10 @@ -import { PivotSheet } from '@antv/s2'; +import { PivotSheet, S2DataConfig, S2Options } from '@antv/s2'; fetch('https://assets.antv.antgroup.com/s2/basic.json') .then((res) => res.json()) - .then((data) => { + .then(async (data) => { const container = document.getElementById('container'); - const s2DataConfig = { + const s2DataConfig: S2DataConfig = { fields: { rows: ['province', 'city'], columns: ['type'], @@ -40,11 +40,12 @@ fetch('https://assets.antv.antgroup.com/s2/basic.json') ], }; - const s2Options = { + const s2Options: S2Options = { width: 600, height: 480, }; + const s2 = new PivotSheet(container, s2DataConfig, s2Options); - s2.render(); + await s2.render(); }); diff --git a/s2-site/examples/analysis/sort/demo/custom-measure.ts b/s2-site/examples/analysis/sort/demo/custom-measure.ts index 4508d5c7ea..1028b4247a 100644 --- a/s2-site/examples/analysis/sort/demo/custom-measure.ts +++ b/s2-site/examples/analysis/sort/demo/custom-measure.ts @@ -1,10 +1,10 @@ -import { PivotSheet, EXTRA_FIELD } from '@antv/s2'; +import { PivotSheet, EXTRA_FIELD, S2DataConfig, S2Options } from '@antv/s2'; fetch('https://assets.antv.antgroup.com/s2/basic.json') .then((res) => res.json()) - .then((data) => { + .then(async (data) => { const container = document.getElementById('container'); - const s2DataConfig = { + const s2DataConfig: S2DataConfig = { fields: { rows: ['province', 'city'], columns: ['type'], @@ -58,11 +58,12 @@ fetch('https://assets.antv.antgroup.com/s2/basic.json') ], }; - const s2Options = { + const s2Options: S2Options = { width: 600, height: 480, }; + const s2 = new PivotSheet(container, s2DataConfig, s2Options); - s2.render(); + await s2.render(); }); diff --git a/s2-site/examples/analysis/sort/demo/custom-method.ts b/s2-site/examples/analysis/sort/demo/custom-method.ts index f4a3c3d22f..32600cbd9b 100644 --- a/s2-site/examples/analysis/sort/demo/custom-method.ts +++ b/s2-site/examples/analysis/sort/demo/custom-method.ts @@ -1,10 +1,10 @@ -import { PivotSheet } from '@antv/s2'; +import { PivotSheet, S2DataConfig, S2Options } from '@antv/s2'; fetch('https://assets.antv.antgroup.com/s2/basic.json') .then((res) => res.json()) - .then((data) => { + .then(async (data) => { const container = document.getElementById('container'); - const s2DataConfig = { + const s2DataConfig: S2DataConfig = { fields: { rows: ['province', 'city'], columns: ['type'], @@ -40,11 +40,12 @@ fetch('https://assets.antv.antgroup.com/s2/basic.json') ], }; - const s2Options = { + const s2Options: S2Options = { width: 600, height: 480, }; + const s2 = new PivotSheet(container, s2DataConfig, s2Options); - s2.render(); + await s2.render(); }); diff --git a/s2-site/examples/analysis/sort/demo/custom-sort-func.ts b/s2-site/examples/analysis/sort/demo/custom-sort-func.ts index fd46142a81..86a5fc8610 100644 --- a/s2-site/examples/analysis/sort/demo/custom-sort-func.ts +++ b/s2-site/examples/analysis/sort/demo/custom-sort-func.ts @@ -1,10 +1,10 @@ -import { PivotSheet, EXTRA_FIELD } from '@antv/s2'; +import { PivotSheet, EXTRA_FIELD, S2DataConfig, S2Options } from '@antv/s2'; fetch('https://assets.antv.antgroup.com/s2/basic.json') .then((res) => res.json()) - .then((data) => { + .then(async (data) => { const container = document.getElementById('container'); - const s2DataConfig = { + const s2DataConfig: S2DataConfig = { fields: { rows: ['province', 'city'], columns: ['type'], @@ -39,6 +39,7 @@ fetch('https://assets.antv.antgroup.com/s2/basic.json') sortFieldId: 'province', sortFunc: (params) => { const { data } = params; + return data?.sort((a, b) => a?.localeCompare(b)); }, }, @@ -48,8 +49,9 @@ fetch('https://assets.antv.antgroup.com/s2/basic.json') sortByMeasure: 'price', // 当使用 sortByMeasure 时,可以传入 query 定位数值列表 // 如下方限定 params.data 为 type=纸张, 数值=price 的数据 - sortFunc: function (params) { + sortFunc(params) { const { data, sortByMeasure, sortFieldId } = params || {}; + return data ?.sort((a, b) => b[sortByMeasure] - a[sortByMeasure]) ?.map((item) => item[sortFieldId]); @@ -59,11 +61,12 @@ fetch('https://assets.antv.antgroup.com/s2/basic.json') ], }; - const s2Options = { + const s2Options: S2Options = { width: 600, height: 480, }; + const s2 = new PivotSheet(container, s2DataConfig, s2Options); - s2.render(); + await s2.render(); }); diff --git a/s2-site/examples/analysis/sort/demo/custom-totals.ts b/s2-site/examples/analysis/sort/demo/custom-totals.ts index fe8d1f5602..b958e952b3 100644 --- a/s2-site/examples/analysis/sort/demo/custom-totals.ts +++ b/s2-site/examples/analysis/sort/demo/custom-totals.ts @@ -1,12 +1,18 @@ -import { PivotSheet, EXTRA_FIELD, TOTAL_VALUE } from '@antv/s2'; +import { + PivotSheet, + EXTRA_FIELD, + TOTAL_VALUE, + S2DataConfig, + S2Options, +} from '@antv/s2'; fetch( 'https://gw.alipayobjects.com/os/bmw-prod/4347c2dd-6554-451b-9d44-15b04e5de657.json', ) .then((res) => res.json()) - .then((data) => { + .then(async (data) => { const container = document.getElementById('container'); - const s2DataConfig = { + const s2DataConfig: S2DataConfig = { fields: { rows: ['province', 'city'], columns: ['type'], @@ -54,7 +60,7 @@ fetch( ], }; - const s2Options = { + const s2Options: S2Options = { width: 600, height: 480, totals: { @@ -74,7 +80,8 @@ fetch( }, }, }; + const s2 = new PivotSheet(container, s2DataConfig, s2Options); - s2.render(); + await s2.render(); }); diff --git a/s2-site/examples/analysis/sort/demo/group-sort.tsx b/s2-site/examples/analysis/sort/demo/group-sort.tsx index bd2ec1d21a..29760ada2f 100644 --- a/s2-site/examples/analysis/sort/demo/group-sort.tsx +++ b/s2-site/examples/analysis/sort/demo/group-sort.tsx @@ -2,13 +2,14 @@ import React from 'react'; import ReactDOM from 'react-dom'; import { SheetComponent } from '@antv/s2-react'; import '@antv/s2-react/dist/style.min.css'; +import { S2DataConfig } from '@antv/s2'; fetch( 'https://gw.alipayobjects.com/os/bmw-prod/21ffc284-50a2-4a30-8bb0-b2f9ac4a8fbc.json', ) .then((res) => res.json()) .then((data) => { - const s2DataConfig = { + const s2DataConfig: S2DataConfig = { fields: { rows: ['province', 'city'], columns: ['type'], @@ -38,7 +39,7 @@ fetch( const s2Options = { width: 600, height: 480, - showDefaultHeaderActionIcon: true, // 默认打开 + showDefaultHeaderActionIcon: true, }; ReactDOM.render( diff --git a/s2-site/examples/analysis/sort/demo/table-sort.tsx b/s2-site/examples/analysis/sort/demo/table-sort.tsx index 7313e461d7..905ee0086f 100644 --- a/s2-site/examples/analysis/sort/demo/table-sort.tsx +++ b/s2-site/examples/analysis/sort/demo/table-sort.tsx @@ -1,20 +1,21 @@ -import React, { useState } from 'react'; -import ReactDOM from 'react-dom'; -import { orderBy } from 'lodash'; +import { S2DataConfig } from '@antv/s2'; +import { SheetComponent, SheetComponentOptions } from '@antv/s2-react'; +import '@antv/s2-react/dist/style.min.css'; import { Button } from 'antd'; -import { SheetComponent } from '@antv/s2-react'; import insertCss from 'insert-css'; -import '@antv/s2-react/dist/style.min.css'; +import { orderBy } from 'lodash'; +import React, { useState } from 'react'; +import ReactDOM from 'react-dom'; fetch('https://assets.antv.antgroup.com/s2/basic-table-mode.json') .then((res) => res.json()) .then((res) => { - const s2Options = { + const s2Options: SheetComponentOptions = { width: 600, height: 480, }; - const s2DataConfig = { + const s2DataConfig: S2DataConfig = { fields: { columns: ['province', 'city', 'type', 'price', 'cost'], }, @@ -51,6 +52,7 @@ fetch('https://assets.antv.antgroup.com/s2/basic-table-mode.json') const App = () => { const [dataCfg, setDataCfg] = useState(s2DataConfig); + return ( <>