From 9d5d8b77c9d02d22b33490ec7708fe4990d59d08 Mon Sep 17 00:00:00 2001 From: stone Date: Wed, 3 Aug 2022 14:44:45 +0800 Subject: [PATCH] =?UTF-8?q?docs:=20=E4=BC=98=E5=8C=96=E6=96=87=E6=A1=A3?= =?UTF-8?q?=E8=AF=B4=E6=B3=95=E5=92=8C=E6=A0=A1=E6=AD=A3=E6=9C=89=E8=AF=AF?= =?UTF-8?q?=E7=9A=84=E5=86=85=E5=AE=B9=20(#1640)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * docs: 让 demo 展示符合主题 * docs: 排序文档优化 * docs: 合并单元格文档更新 * docs: getAllCells()获取数据说明问题 --- packages/s2-react/playground/index.tsx | 5 ++ .../docs/api/basic-class/interaction.zh.md | 82 +++++++++---------- s2-site/docs/api/general/S2Options.zh.md | 6 +- s2-site/docs/common/merged-cell.en.md | 5 ++ s2-site/docs/common/merged-cell.zh.md | 14 ++++ .../advanced/interaction/merge-cell.zh.md | 12 +-- s2-site/docs/manual/basic/sort/basic.zh.md | 2 +- .../comparison/demo/measure-comparison.tsx | 2 +- s2-site/examples/data/index-comparison.json | 8 +- 9 files changed, 75 insertions(+), 61 deletions(-) create mode 100644 s2-site/docs/common/merged-cell.en.md create mode 100644 s2-site/docs/common/merged-cell.zh.md diff --git a/packages/s2-react/playground/index.tsx b/packages/s2-react/playground/index.tsx index a52df6776d..7ee6461491 100644 --- a/packages/s2-react/playground/index.tsx +++ b/packages/s2-react/playground/index.tsx @@ -910,6 +910,11 @@ function MainLayout() { exportCfg: { open: true }, advancedSortCfg: { open: true }, }} + getSpreadSheet={(s2) => { + // eslint-disable-next-line @typescript-eslint/ban-ts-comment + // @ts-ignore + window.s2 = s2; + }} onDataCellTrendIconClick={logHandler('onDataCellTrendIconClick')} onAfterRender={logHandler('onAfterRender')} onDestroy={logHandler('onDestroy')} diff --git a/s2-site/docs/api/basic-class/interaction.zh.md b/s2-site/docs/api/basic-class/interaction.zh.md index a92fa049b3..c0b673905f 100644 --- a/s2-site/docs/api/basic-class/interaction.zh.md +++ b/s2-site/docs/api/basic-class/interaction.zh.md @@ -9,48 +9,48 @@ order: 2 s2.interaction.xx() ``` -| 参数 | 说明 | 类型 | -| --- | --- | --- | -| spreadsheet | 表格实例 | [SpreadSheet](/zh/docs/api/basic-class/spreadsheet) | -| interactions | 当前已注册的交互 | `Map` | -| intercept | 当前拦截的交互,防止不同交互之间冲突 | `Set` | -| destroy | 卸载所有交互实例,并重置为初始状态 | `() => void` | -| reset | 重置所有交互 | `() => void` | -| setState | 设置状态 | (data: [InteractionStateInfo](#interactionstateinfo)) => void | -| getState | 获取当前状态 | `() => void` | -| resetState | 重置为初始状态 | `() => void` | -| clearState | 清空状态,并重绘 | `() => void` | -| changeState | 更新状态 | (data: [InteractionStateInfo](#interactionstateinfo)) => void | -| setInteractedCells | 设置当前发生改变的单元格 | (cell: [S2CellType](#s2celltype)) => void | -| getInteractedCells | 获取当前发生改变的单元格 | () => [S2CellType](#s2celltype)[] | -| getCurrentStateName | 获取当前状态名 | `() => void` | -| isEqualStateName | 是否是相同的状态名 | `(name: InteractionStateName) => void` | -| isSelectedState | 是否是选中状态 | `() => void` | -| isHoverState | 是否是悬停状态 | `() => void` | -| isHoverFocusState | 是否是悬停聚焦状态 (悬停在单元格 `focusTime`: 默认 800ms 后) | `() => void` | -| isSelectedCell | 是否是选中的单元格 | (cell: [S2CellType](#s2celltype)) => void | -| isActiveCell | 是否是激活的单元格 | (cell: [S2CellType](#s2celltype)) => void | -| getCells | 获取当前 interaction 记录的 Cells 元信息列表,包括不在视口内的格子 | `() => Partial[]` | -| getActiveCells | 获取当前在可视区域的单元格实例 | `() => S2CellType[]` | -| clearStyleIndependent | 清除单元格样式 | `() => void` | -| getPanelGroupAllUnSelectedDataCells | 获取可视区域内选中的数值单元格 | `() => DataCell[]` | -| getPanelGroupAllDataCells | 获取可视区域内的所有数值单元格 | `() => DataCell[]` | -| getAllRowHeaderCells | 获取行头单元格 | `() => RowCell[]` | -| getAllColHeaderCells | 获取列头单元格 | `() => ColCell[]` | -| getRowColActiveCells | 获取行头和列头激活的单元格 | `() => RowCell[] | ColCell[]` | -| getAllCells | 获取所有单元格 | () => [S2CellType](#s2celltype)[] | -| selectAll | 选中所有单元格 | `() => void` | -| selectHeaderCell | 选中指定行列头单元格 | (selectHeaderCellInfo: [SelectHeaderCellInfo](#selectheadercellinfo)) => boolean | -| getCellChildrenNodes | 获取当前单元格的所以子节点 | (cell: [S2CellType](#s2celltype)) => [Node]((/zh/docs/api/basic-class/node))[] | +| 参数 | 说明 | 类型 | +| --- |--------------------------------------------------| --- | +| spreadsheet | 表格实例 | [SpreadSheet](/zh/docs/api/basic-class/spreadsheet) | +| interactions | 当前已注册的交互 | `Map` | +| intercept | 当前拦截的交互,防止不同交互之间冲突 | `Set` | +| destroy | 卸载所有交互实例,并重置为初始状态 | `() => void` | +| reset | 重置所有交互 | `() => void` | +| setState | 设置状态 | (data: [InteractionStateInfo](#interactionstateinfo)) => void | +| getState | 获取当前状态 | `() => void` | +| resetState | 重置为初始状态 | `() => void` | +| clearState | 清空状态,并重绘 | `() => void` | +| changeState | 更新状态 | (data: [InteractionStateInfo](#interactionstateinfo)) => void | +| setInteractedCells | 设置当前发生改变的单元格 | (cell: [S2CellType](#s2celltype)) => void | +| getInteractedCells | 获取当前发生改变的单元格 | () => [S2CellType](#s2celltype)[] | +| getCurrentStateName | 获取当前状态名 | `() => void` | +| isEqualStateName | 是否是相同的状态名 | `(name: InteractionStateName) => void` | +| isSelectedState | 是否是选中状态 | `() => void` | +| isHoverState | 是否是悬停状态 | `() => void` | +| isHoverFocusState | 是否是悬停聚焦状态 (悬停在单元格 `focusTime`: 默认 800ms 后) | `() => void` | +| isSelectedCell | 是否是选中的单元格 | (cell: [S2CellType](#s2celltype)) => void | +| isActiveCell | 是否是激活的单元格 | (cell: [S2CellType](#s2celltype)) => void | +| getCells | 获取当前 interaction 记录的 Cells 元信息列表,包括不在视口内的格子 | `() => Partial[]` | +| getActiveCells | 获取当前在可视区域的单元格实例 | `() => S2CellType[]` | +| clearStyleIndependent | 清除单元格样式 | `() => void` | +| getPanelGroupAllUnSelectedDataCells | 获取可视区域内选中的数值单元格 | `() => DataCell[]` | +| getPanelGroupAllDataCells | 获取可视区域内的所有数值单元格 | `() => DataCell[]` | +| getAllRowHeaderCells | 获取行头单元格 | `() => RowCell[]` | +| getAllColHeaderCells | 获取列头单元格 | `() => ColCell[]` | +| getRowColActiveCells | 获取行头和列头激活的单元格 | `() => RowCell[] | ColCell[]` | +| getAllCells | 获取所有可视区域内的单元格 | () => [S2CellType](#s2celltype)[] | +| selectAll | 选中所有单元格 | `() => void` | +| selectHeaderCell | 选中指定行列头单元格 | (selectHeaderCellInfo: [SelectHeaderCellInfo](#selectheadercellinfo)) => boolean | +| getCellChildrenNodes | 获取当前单元格的所以子节点 | (cell: [S2CellType](#s2celltype)) => [Node]((/zh/docs/api/basic-class/node))[] | | hideColumns | 隐藏列 (forceRender 为 `false` 时,隐藏列为空的情况下,不再触发表格更新) | `(hiddenColumnFields: string[], forceRender?: boolean = true) => void` | -| mergeCells | 合并单元格 | (cellsInfo?: [MergedCellInfo](#mergedcellinfo)[], hideData?: boolean) => void | -| unmergeCells | 取消合并单元格 | `(removedCells: MergedCell[]) => void` | -| updatePanelGroupAllDataCells | 更新所有数值单元格 | `() => void` | -| updateCells | 更新指定单元格 | (cells: [S2CellType](#s2celltype)[]) => void | -| addIntercepts | 新增交互拦截 | (interceptTypes: [InterceptType](#intercepttype)[]) => void | -| hasIntercepts | 是否有指定拦截的交互 | (interceptTypes: [InterceptType](#intercepttype)[]) => boolean | -| removeIntercepts | 移除指定交互拦截 | (interceptTypes: [InterceptType](#intercepttype)[]) => void | -| highlightNodes | 高亮节点对应的单元格 | (nodes: [Node](/zh/docs/api/basic-class/node)[]) => void | +| mergeCells | 合并单元格 | (cellsInfo?: [MergedCellInfo](#mergedcellinfo)[], hideData?: boolean) => void | +| unmergeCells | 取消合并单元格 | `(removedCells: MergedCell[]) => void` | +| updatePanelGroupAllDataCells | 更新所有数值单元格 | `() => void` | +| updateCells | 更新指定单元格 | (cells: [S2CellType](#s2celltype)[]) => void | +| addIntercepts | 新增交互拦截 | (interceptTypes: [InterceptType](#intercepttype)[]) => void | +| hasIntercepts | 是否有指定拦截的交互 | (interceptTypes: [InterceptType](#intercepttype)[]) => boolean | +| removeIntercepts | 移除指定交互拦截 | (interceptTypes: [InterceptType](#intercepttype)[]) => void | +| highlightNodes | 高亮节点对应的单元格 | (nodes: [Node](/zh/docs/api/basic-class/node)[]) => void | `markdown:docs/common/interaction.zh.md` diff --git a/s2-site/docs/api/general/S2Options.zh.md b/s2-site/docs/api/general/S2Options.zh.md index 10bb13f8ca..aa5db85a13 100644 --- a/s2-site/docs/api/general/S2Options.zh.md +++ b/s2-site/docs/api/general/S2Options.zh.md @@ -182,8 +182,4 @@ DataSet = (spreadsheet: SpreadSheet) => BaseDataSet; ## MergedCellInfo -| 参数 | 说明 | 类型 | 默认值 | 必选 | -| --------------- | ------------------ | ---------------------- | ------ | ---- | -| colIndex | 单元格的列索引 | `number` | - | | -| rowIndex | 单元格的行索引 | `number` | - | | -| showText | 合并单元格是否展示当前单元格的 meta 信息,只需要对一个单元格进行标识,
若未对单元格进行标识,会默认使用第一个选中点击的单元格的 meta 信息 | `booelan` | - | | +`markdown:docs/common/merged-cell.zh.md` diff --git a/s2-site/docs/common/merged-cell.en.md b/s2-site/docs/common/merged-cell.en.md new file mode 100644 index 0000000000..a15c661413 --- /dev/null +++ b/s2-site/docs/common/merged-cell.en.md @@ -0,0 +1,5 @@ +--- +title: Merge-Cell +order: 10 +--- +`markdown:docs/common/merge-cell.zh.md` diff --git a/s2-site/docs/common/merged-cell.zh.md b/s2-site/docs/common/merged-cell.zh.md new file mode 100644 index 0000000000..f8caf5a6f7 --- /dev/null +++ b/s2-site/docs/common/merged-cell.zh.md @@ -0,0 +1,14 @@ +--- +title: 合并单元 +order: 10 +--- + + **optional** _MergedCellInfo[][]_ default: `undefined` + +设置默认合并的单元格信息 + +| 参数 | 说明 | 类型 | 默认值 | 必选 | +| --------------- |--------------------------------------------------------------------------------| ---------------------- | ------ | ---- | +| colIndex | 单元格的列索引 | `number` | - | | +| rowIndex | 单元格的行索引 | `number` | - | | +| showText | 设置 `showText: true` 时,则展示当前格子的 `meta` 信息为合并后单元格的 `meta`。
默认使用第一个选中点击的单元格。 | `booelan` | - | | 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 f030e76c10..1bfb656b05 100644 --- a/s2-site/docs/manual/advanced/interaction/merge-cell.zh.md +++ b/s2-site/docs/manual/advanced/interaction/merge-cell.zh.md @@ -343,17 +343,11 @@ s2.render(); ## 配置和方法说明 -### mergedCellsInfo +### MergedCellInfo - **optional** _MergedCellInfo[][]_ default: `undefined` +`markdown:docs/common/merged-cell.zh.md` -设置默认合并的单元格信息 - -| 参数 | 说明 | 类型 | 默认值 | 必选 | -| --------------- | ------------------ | ---------------------- | ------ | ---- | -| colIndex | 单元格的列索引 | `number` | - | | -| rowIndex | 单元格的行索引 | `number` | - | | -| showText | 合并单元格是否展示当前单元格的 meta 信息,只需要对一个单元格进行标识,
若未对单元格进行标识,会默认使用第一个选中点击的单元格的 meta 信息 | `booelan` | - | | +![合并单元格](https://gw.alipayobjects.com/zos/antfincdn/kHAYfFaJA/ae92e636-6574-487b-8d78-57dcae21e1d4.png) ### mergeCells diff --git a/s2-site/docs/manual/basic/sort/basic.zh.md b/s2-site/docs/manual/basic/sort/basic.zh.md index 08ad32ccc1..2a7c64e222 100644 --- a/s2-site/docs/manual/basic/sort/basic.zh.md +++ b/s2-site/docs/manual/basic/sort/basic.zh.md @@ -7,7 +7,7 @@ order: 0 根据 `数值升/降序` 对 `行头/列头` 进行排序 -`组内排序` 代表只影响一个分组内部的排序,例如下图中 `笔-价格` 选择 `组内升序` 时,`province` 的排序方式不会更改,只会更改每个 `province` 内部 `city` 的顺序 +`组内排序` 代表只影响一个分组内部的排序,例如下图中 `笔-价格` 选择 `组内升序` 时,`省份` 的排序方式不会更改,只会更改每个 `省份` 内部 `城市` 的顺序 row diff --git a/s2-site/examples/case/comparison/demo/measure-comparison.tsx b/s2-site/examples/case/comparison/demo/measure-comparison.tsx index 780f4d1f7e..87c58ecfaf 100644 --- a/s2-site/examples/case/comparison/demo/measure-comparison.tsx +++ b/s2-site/examples/case/comparison/demo/measure-comparison.tsx @@ -424,7 +424,7 @@ fetch('../data/index-comparison.json') }, { field: 'price', - name: '金额', + name: '销售量', }, { field: 'uv', diff --git a/s2-site/examples/data/index-comparison.json b/s2-site/examples/data/index-comparison.json index 64dee6156b..1a2bb32360 100644 --- a/s2-site/examples/data/index-comparison.json +++ b/s2-site/examples/data/index-comparison.json @@ -2,7 +2,7 @@ { "tag": "本周成交情况", "type": "女装", - "price": "200" + "price": "500" }, { "tag": "本周成交情况", @@ -22,7 +22,7 @@ { "tag": "本周成交情况", "type": "男装", - "price": "300" + "price": "200" }, { "tag": "本周成交情况", @@ -62,7 +62,7 @@ { "tag": "本周成交情况", "type": "男/女鞋", - "price": "600" + "price": "60" }, { "tag": "本周成交情况", @@ -82,7 +82,7 @@ { "tag": "本周成交情况", "type": "箱包配饰", - "price": "3000" + "price": "1000" }, { "tag": "本周成交情况",