logo

S2

  • 使用文档
  • API 文档
  • 图表示例
  • 在线体验
  • 更新日志
  • 所有产品antv logo arrow
  • 2.x
  • 基础配置项
    • S2DataConfig
    • S2Options
      Updated
    • S2Theme
      Updated
    • S2Event
      Updated
  • 基础类
    • SpreadSheet
      Updated
    • Interaction
      Updated
    • Store
    • BaseCell
      Updated
    • BaseDataSet
      Updated
    • Node
    • BaseTooltip
    • BaseFacet
      Updated
    • Hierarchy
      New
    • BaseBBox
      New
    • CellData
      New
  • 分析组件
    • 表组件
      Updated
    • 维度下钻
      Updated
    • 维度切换组件
      Updated
    • 高级排序
      Updated
    • 导出
      Updated
  • 绘图属性
  • 透视组合图拓展 S2Options

表组件

上一篇
CellData
下一篇
维度下钻

Resources

Ant Design
Galacea Effects
Umi-React 应用开发框架
Dumi-组件/文档研发工具
ahooks-React Hooks 库

社区

体验科技专栏
seeconfSEE Conf-蚂蚁体验科技大会

帮助

GitHub
StackOverflow

more products更多产品

Ant DesignAnt Design-企业级 UI 设计语言
yuque语雀-知识创作与分享工具
EggEgg-企业级 Node 开发框架
kitchenKitchen-Sketch 工具集
GalaceanGalacean-互动图形解决方案
xtech蚂蚁体验科技
© Copyright 2025 Ant Group Co., Ltd..备案号:京ICP备15032932号-38

Loading...

React 表组件 @antv/s2-react

基于 @antv/s2 封装的 React 版开箱即用的组件 <SheetComponent />

import { SheetComponent } from '@antv/s2-react';
import '@antv/s2-react/dist/s2-react.min.css';
<SheetComponent sheetType="pivot" />

SpreadsheetProps

功能描述: React SheetComponent 组件的 props 参数

参数说明类型默认值必选
sheetType表格类型:
1. pivot: 透视表
2. table: 明细表
3. gridAnalysis: 网格分析表
4. strategy: 趋势分析表
5. editable: 编辑表
pivot | table | gridAnalysis | strategy | editablepivot
spreadsheet自定义表(container: HTMLElement | string, dataCfg: S2DataConfig, options: SheetComponentOptions) => SpreadSheet
dataCfg透视表数据映射相关配置项S2DataConfig✓
options透视表属性配置项SheetComponentOptions✓
partDrillDown维度下钻相关属性PartDrillDown
adaptive是否根据窗口大小自适应boolean | { width?: boolean, height?: boolean, getContainer: () => HTMLElement }false
themeCfg自定义透视表主题样式ThemeCfg
loading控制表格的加载状态boolean
header表头配置项HeaderCfgProps
onRangeSort组内排序时触发回调事件(params: SortParam[] ) => void;
onRowCellHover行头鼠标悬停事件(data: TargetCellInfo) => void
onRowCellClick行头鼠标单击事件(data: TargetCellInfo) => void
onRowCellDoubleClick行头鼠标双击事件(data: TargetCellInfo) => void
onRowCellContextMenu行头右键菜单事件(data: TargetCellInfo) => void
onRowCellMouseDown行头鼠标按下事件(data: TargetCellInfo) => void
onRowCellMouseUp行头鼠标放开事件(data: TargetCellInfo) => void
onRowCellMouseMove行头鼠标移动事件(data: TargetCellInfo) => void
onRowCellCollapsed节点展开/收起事件回调({ isCollapsed: boolean, collapseFields: Record<string, boolean>, node: Node }) => void;
onRowCellAllCollapsed节点全部展开/收起的事件回调(isCollapsed: boolean ) => void;
onRowCellScroll行头单元格滚动事件({position: CellScrollPosition} ) => void;
onRowCellRender行头单元格渲染事件( cell: Cell ) => void
onRowCellSelected行头单元格选中事件( cells: Cell[], detail: CellSelectedDetail ) => void
onColCellHover列头鼠标悬停事件(data: TargetCellInfo) => void
onColCellClick列头鼠标单击事件(data: TargetCellInfo) => void
onColCellDoubleClick列头鼠标双击事件(data: TargetCellInfo) => void
onColCellContextMenu列头右键菜单事件(data: TargetCellInfo) => void
onColCellMouseDown列头鼠标按下事件(data: TargetCellInfo) => void
onColCellMouseUp列头鼠标松开事件(data: TargetCellInfo) => void
onColCellMouseMove列头鼠标移动事件(data: TargetCellInfo) => void
onColCellExpanded开启隐藏列头(tooltip.operation.hiddenColumns = true)后,列头展开的事件回调(expandedNode: Node) => void;
onColCellHidden开启隐藏列头(tooltip.operation.hiddenColumns = true)后,列头隐藏的事件回调( data: { currentHiddenColumnsInfo:HiddenColumnsInfo; hiddenColumnsDetail:HiddenColumnsInfo[]} ) => void;
onColCellRender列头单元格渲染事件( cell: Cell ) => void
onColCellSelected列头单元格选中事件( cells: Cell[], detail: CellSelectedDetail ) => void
onDataCellHover数值单元格鼠标悬停事件(data: TargetCellInfo) => void
onDataCellClick数值单元格鼠标点击事件(data: TargetCellInfo) => void
onDataCellDoubleClick数值单元格双击事件(data: TargetCellInfo) => void
onDataCellContextMenu数值单元格右键菜单事件(data: TargetCellInfo) => void
onDataCellMouseDown数值单元格鼠标按下事件(data: TargetCellInfo) => void
onDataCellMouseUp数值单元格鼠标松开事件(data: TargetCellInfo) => void
onDataCellMouseMove数值单元格鼠标移动事件(data: TargetCellInfo) => void
onDataCellBrushSelection数值单元格刷选事件( dataCells: DataCell[] ) => void
onDataCellSelectMove数值单元格键盘方向键移动事件(metas: CellMeta[]) => void
onDataCellEditStart数值单元格编辑开始(暂只支持编辑表)(meta: ViewMeta, cell: S2CellType) => void
onDataCellEditEnd数值单元格编辑完成(暂只支持编辑表)(meta: ViewMeta, cell: S2CellType) => void
onDataCellRender数值单元格渲染事件( cell: Cell ) => void
onDataCellSelected数值单元格选中事件( cells: Cell[], detail: CellSelectedDetail ) => void
onCornerCellHover角头鼠标悬停事件(data: TargetCellInfo) => void
onCornerCellClick角头鼠标单击事件(data: TargetCellInfo) => void
onCornerCellDoubleClick角头鼠标双击事件(data: TargetCellInfo) => void
onCornerCellContextMenu角头右键菜单事件(data: TargetCellInfo) => void
onCornerCellMouseUp角头鼠标按下事件(data: TargetCellInfo) => void
onCornerCellMouseUp角头鼠标松开事件(data: TargetCellInfo) => void
onCornerCellMouseMove角头鼠标移动事件(data: TargetCellInfo) => void
onCornerCellRender角头单元格渲染事件( cell: Cell ) => void
onCornerCellSelected角头单元格选中事件( cells: Cell[], detail: CellSelectedDetail ) => void
onMergedCellsHover合并单元格鼠标悬停事件(data: TargetCellInfo) => void
onMergedCellsClick合并单元格鼠标点击事件(data: TargetCellInfo) => void
onMergedCellsDoubleClick合并单元格鼠标双击事件(data: TargetCellInfo) => void
onMergedCellsContextMenu合并单元格右键菜单事件(data: TargetCellInfo) => void
onMergedCellsMouseDown合并单元格按下事件(data: TargetCellInfo) => void
onMergedCellsMouseUp合并单元格松开事件(data: TargetCellInfo) => void
onMergedCellsMouseMove合并单元格移动事件(data: TargetCellInfo) => void
onMergedCellsRender合并单元格渲染事件( cell: Cell ) => void
onSeriesNumberCellRender序号单元格渲染事件( cell: Cell ) => void
onRangeSort组内排序时触发回调事件(暂只支持透视表)(params: SortParam[] ) => void;
onRangeSorted组内排序结束触发回调事件(暂只支持透视表)(event: FederatedPointerEvent ) => void;
onRangeFilter筛选时触发回调事件(data: { filterKey: string; filteredValues: string[] } ) => void;
onRangeFiltered筛选结束触发回调事件(data: DataType[] ) => void;
onLayoutCellRender单个单元格布局渲染完成事件cell: S2CellType
onLayoutAfterHeaderLayout表头布局结构准备完成事件(layoutResult: LayoutResult ) => void;
onLayoutPagination分页事件({ pageSize: number; pageCount: number; total: number; current: number;} ) => void;
onLayoutCellScroll单元格滚动事件 (已废弃,请使用 onScroll 代替)({position: CellScrollPosition} ) => void;
onLayoutAfterCollapseRows树状模式下收起行头后的事件回调({ collapseFields: Record<string, boolean>, meta: Node }) => void;
onBeforeRender开始 render 前的事件() => void;
onAfterRenderrender 完成的事件() => void;
onMounted组件层表格挂载完成事件,可拿到表实例 详情(spreadsheet: SpreadSheet) => void;
onUpdate组件层表格更新事件,当 数据 (S2DataConfig) 或 配置 (S2Options) 更新时触发,可手动控制更新时的 渲染模式(renderOptions: S2RenderOptions) => S2RenderOptions | void
onUpdateAfterRender组件层表格更新事件,当 数据 (S2DataConfig) 或 配置 (S2Options) 更新时,并且在重渲染 s2.render() 完成后触发(renderOptions: S2RenderOptions) => void
onLoading组件层加载状态变更事件(loading: boolean) => void
onDestroy表格销毁事件() => void;
onLayoutResize表格整体 changeSize 事件(params: ResizeParams) => void;
onLayoutResizeSeriesWidth表格序号行宽事件(params: ResizeParams) => void;
onLayoutResizeRowWidth行头单元格宽度更改事件(params: ResizeParams) => void;
onLayoutResizeRowHeight行头单元格高度更改事件(params: ResizeParams) => void;
onLayoutResizeColWidth列头单元格宽度更改事件(params: ResizeParams) => void;
onLayoutResizeColHeight列头单元格高度更改事件(params: ResizeParams) => void;
onLayoutResizeTreeWidth树状行头整体宽度更改事件(params: ResizeParams) => void;
onLayoutResizeMouseDownresize 热区鼠标按下事件( event: MouseEvent, resizeInfo?: ResizeInfo) => void;
onLayoutResizeMouseUpresize 热区鼠标松开事件( event: MouseEvent, resizeInfo?: ResizeInfo) => void;
onLayoutResizeMouseMoveresize 热区鼠标移动事件( event: MouseEvent, resizeInfo?: ResizeInfo) => void;
onKeyBoardDown键盘按下事件(event: KeyboardEvent) => void
onKeyBoardUp键盘松开事件(event: KeyboardEvent) => void
onCopied复制事件(data: CopyableList) => void
onActionIconHover行头操作 icon 悬停事件(event: FederatedPointerEvent) => void
onActionIconClick行头操作 icon 点击事件(event: FederatedPointerEvent) => void
onContextMenu右键单元格单击事件 (禁用右键菜单不生效?)(event: FederatedPointerEvent) => void
onMouseHover表格鼠标悬停事件(event: FederatedPointerEvent) => void
onMouseUp表格鼠标松开事件(event: FederatedPointerEvent) => void
onSelected单元格选中事件(cells: Cell[], detail: CellSelectedDetail ) => void
onReset交互状态重置事件(event: KeyboardEvent) => void
onLinkFieldJump链接字段跳转事件(data: { field: string; meta: Node | ViewMeta; record: Data }) => void
onScroll单元格滚动事件 (含行头和数值单元格)({position: CellScrollPosition} ) => void
onColCellBrushSelection批量选中刷选范围内的列头单元格,刷选过程中,显示刷选范围提示蒙层,刷选完成后,弹出 tooltip, 展示被刷选单元格信息(cells: ColCell[]) => void;
onRowCellBrushSelection批量选中刷选范围内的行头单元格,刷选过程中,显示刷选范围提示蒙层,刷选完成后,弹出 tooltip, 展示被刷选单元格信息(仅支持透视表)(cells: RowCell[]) => void;

SheetComponentOptions

注意

@antv/s2-react 组件的 options 继承于 S2Options , 有两点不同:

  • 类型由 S2Options 变更为 SheetComponentOptions.
  • tooltip 的 content 从 Element | string 变为了 ReactNode, 即可以是任意的 jsx 元素。
import type { S2Options } from '@antv/s2';
type SheetComponentOptions = S2Options<React.ReactNode>

Vue 表组件 @antv/s2-vue

注意

@antv/s2-vue 现已停止维护,由于精力投入有限,出于维护成本,包下载量等因素综合考虑,从 2.0.0 正式版后不再继续更新,请基于 @antv/s2 自行封装,或 fork 仓库进行二次开发社区版本。

基于 @antv/s2 层封装的 Vue 3.0 版开箱即用的组件 <SheetComponent />

props

功能描述: Vue SheetComponent 组件的 props,如 <SheetComponent :sheetType="pivot" />

参数说明类型默认值必选
sheetType表格类型:
1. pivot: 透视表
2. table: 明细表
3. editable: 编辑表
pivot | table | editablepivot
dataCfg透视表数据映射配置项S2DataConfig✓
options透视表属性配置项SheetComponentOptions✓
adaptive是否根据窗口大小自适应boolean | { width?: boolean, height?: boolean, getContainer: () => HTMLElement }false
showPagination是否显示默认分页
(只有在 options 配置过 pagination 属性才会生效)
boolean | {
onShowSizeChange?: (pageSize: number) => void,
onChange?: (current: number) => void
}
false
themeCfg自定义表格主题样式ThemeCfg
loading控制表格的加载状态boolean

events

功能描述: Vue SheetComponent 组件的 events,<SheetComponent @rowCellClick="handleRowCellClick" />

参数说明类型默认值必选
spreadsheet自定义表(container: HTMLElement | string, dataCfg: S2DataConfig, options: SheetComponentOptions) => SpreadSheet
rangeSort组内排序时触发回调事件(params: SortParam[] ) => void;
rowCellClick行头鼠标单击事件(data: TargetCellInfo) => void
rowCellHover行头鼠标悬停事件(data: TargetCellInfo) => void
rowCellClick行头鼠标单击事件(data: TargetCellInfo) => void
rowCellDoubleClick行头鼠标双击事件(data: TargetCellInfo) => void
rowCellContextMenu行头右键菜单事件(data: TargetCellInfo) => void
rowCellMouseDown行头鼠标按下事件(data: TargetCellInfo) => void
rowCellMouseUp行头鼠标放开事件(data: TargetCellInfo) => void
rowCellMouseMove行头鼠标移动事件(data: TargetCellInfo) => void
rowCellCollapseTreeRows树状结构下点击行头收起展开按钮(params: { id: number; isCollapsed: boolean; node: Node }) => void
rowCellScroll行头单元格滚动事件({position: CellScrollPosition} ) => void;
rowCellCollapsed节点展开/收起事件回调({ isCollapsed: boolean, collapseFields: Record<string, boolean>, node: Node }) => void;
rowCellAllCollapsed节点全部展开/收起的事件回调(isCollapsed: boolean ) => void;
rowCellRender行头单元格渲染事件( cell: Cell ) => void
rowCellSelected行头单元格选中事件( cells: Cell[], detail: CellSelectedDetail ) => void
colCellHover列头鼠标悬停事件(data: TargetCellInfo) => void
colCellClick列头鼠标单击事件(data: TargetCellInfo) => void
colCellDoubleClick列头鼠标双击事件(data: TargetCellInfo) => void
colCellContextMenu列头右键菜单事件(data: TargetCellInfo) => void
colCellMouseDown列头鼠标按下事件(data: TargetCellInfo) => void
colCellMouseUp列头鼠标松开事件(data: TargetCellInfo) => void
colCellMouseMove列头鼠标移动事件(data: TargetCellInfo) => void
colCellExpanded开启隐藏列头(tooltip.operation.hiddenColumns = true)后,列头展开的事件回调(expandedNode: Node) => void
colCellHidden开启隐藏列头(tooltip.operation.hiddenColumns = true)后,列头隐藏的事件回调(data: { currentHiddenColumnsInfo:HiddenColumnsInfo; hiddenColumnsDetail:HiddenColumnsInfo[] } ) => void;
colCellRender列头单元格渲染事件( cell: Cell ) => void
colCellSelected列头单元格选中事件( cells: Cell[], detail: CellSelectedDetail ) => void
dataCellHover数值单元格鼠标悬停事件(data: TargetCellInfo) => void
dataCellClick数值单元格鼠标点击事件(data: TargetCellInfo) => void
dataCellDoubleClick数值单元格双击事件(data: TargetCellInfo) => void
dataCellContextMenu数值单元格右键菜单事件(data: TargetCellInfo) => void
dataCellMouseDown数值单元格鼠标按下事件(data: TargetCellInfo) => void
dataCellMouseUp数值单元格鼠标松开事件(data: TargetCellInfo) => void
dataCellMouseMove数值单元格鼠标移动事件(data: TargetCellInfo) => void
dataCellBrushSelection数值单元格刷选事件(brushRangeDataCells: DataCell[] ) => void
dataCellScroll数值单元格滚动事件({position: CellScrollPosition} ) => void;
dataCellSelected数值单元格选中事件( cells: Cell[], detail: CellSelectedDetail ) => void
cornerCellHover角头鼠标悬停事件(data: TargetCellInfo) => void
cornerCellClick角头鼠标单击事件(data: TargetCellInfo) => void
cornerCellDoubleClick角头鼠标双击事件(data: TargetCellInfo) => void
cornerCellContextMenu角头右键菜单事件(data: TargetCellInfo) => void
cornerCellMouseUp角头鼠标按下事件(data: TargetCellInfo) => void
cornerCellMouseUp角头鼠标松开事件(data: TargetCellInfo) => void
cornerCellMouseMove角头鼠标移动事件(data: TargetCellInfo) => void
cornerCellRender角头单元格渲染事件( cell: Cell ) => void
cornerCellSelected角头单元格选中事件( cells: Cell[], detail: CellSelectedDetail ) => void
mergedCellsHover合并单元格鼠标悬停事件(data: TargetCellInfo) => void
mergedCellsClick合并单元格鼠标点击事件(data: TargetCellInfo) => void
mergedCellsDoubleClick合并单元格鼠标双击事件(data: TargetCellInfo) => void
mergedCellsContextMenu合并单元格右键菜单事件(data: TargetCellInfo) => void
mergedCellsMouseDown合并单元格按下事件(data: TargetCellInfo) => void
mergedCellsMouseUp合并单元格松开事件(data: TargetCellInfo) => void
mergedCellsMouseMove合并单元格移动事件(data: TargetCellInfo) => void
mergedCellsRender合并单元格渲染事件( cell: Cell ) => void
seriesNumberCellRender序号单元格渲染事件( cell: Cell ) => void
rangeSort组内排序时触发回调事件(暂只支持透视表)(params: SortParam[] ) => void;
rangeSorted组内排序结束触发回调事件(暂只支持透视表)(event: FederatedPointerEvent ) => void;
rangeFilter筛选时触发回调事件(data: { filterKey: string; filteredValues: string[] } ) => void;
rangeFiltered筛选结束触发回调事件(data: DataType[] ) => void;
layoutAfterHeaderLayout表头布局结构准备完成事件(layoutResult: LayoutResult ) => void;
layoutPagination分页事件({ pageSize: number; pageCount: number; total: number; current: number;} ) => void;
layoutCellScroll单元格滚动事件 (已废弃,请使用 onScroll 代替)({position: CellScrollPosition} ) => void;
beforeRender开始 render 前的事件() => void;
afterRenderrender 完成的事件() => void;
mounted表格加载完成事件,可拿到表实例 详情(spreadsheet: SpreadSheet) => void;
update组件层表格更新事件,当 数据 (S2DataConfig) 或 配置 (S2Options) 更新时触发,可手动控制更新时的 渲染模式(renderOptions: S2RenderOptions) => S2RenderOptions | void
updateAfterRender组件层表格更新事件,当 数据 (S2DataConfig) 或 配置 (S2Options) 更新时,并且在重渲染 s2.render() 完成后触发(renderOptions: S2RenderOptions) => void
destroy表格销毁事件() => void;
layoutResize表格整体 changeSize 事件(params: ResizeParams) => void;
layoutResizeSeriesWidth表格序号行宽事件(params: ResizeParams) => void;
layoutResizeRowWidth行头单元格宽度更改事件(params: ResizeParams) => void;
layoutResizeRowHeight行头单元格高度更改事件(params: ResizeParams) => void;
layoutResizeColWidth列头单元格宽度更改事件(params: ResizeParams) => void;
layoutResizeColHeight列头单元格高度更改事件(params: ResizeParams) => void;
layoutResizeTreeWidth树状行头整体宽度更改事件(params: ResizeParams) => void;
layoutResizeMouseDownresize 热区鼠标按下事件( event: MouseEvent, resizeInfo?: ResizeInfo) => void;
layoutResizeMouseUpresize 热区鼠标松开事件( event: MouseEvent, resizeInfo?: ResizeInfo) => void;
layoutResizeMouseMoveresize 热区鼠标移动事件( event: MouseEvent, resizeInfo?: ResizeInfo) => void;
keyBoardDown键盘按下事件(event: KeyboardEvent) => void
keyBoardUp键盘松开事件(event: KeyboardEvent) => void
copied复制事件(data: CopyableList) => void
actionIconHover行头操作 icon 悬停事件(event: FederatedPointerEvent) => void
actionIconClick行头操作 icon 点击事件(event: FederatedPointerEvent) => void
contextMenu右键单元格单击事件 (禁用右键菜单不生效?)(event: FederatedPointerEvent) => void
mouseHover表格鼠标悬停事件(event: FederatedPointerEvent) => void
mouseUp表格鼠标松开事件(event: FederatedPointerEvent) => void
selected单元格选中事件(cells: Cell[], detail: CellSelectedDetail ) => void
reset交互状态重置事件(event: KeyboardEvent) => void
linkFieldJump链接字段跳转事件(data: { field: string; meta: Node | ViewMeta; record: Data }) => void
scroll单元格滚动事件 (含行头和数值单元格)({position: CellScrollPosition} ) => void;
colCellBrushSelection批量选中刷选范围内的列头单元格,刷选过程中,显示刷选范围提示蒙层,刷选完成后,弹出 tooltip, 展示被刷选单元格信息(cells: ColCell[]) => void;
rowCellBrushSelection批量选中刷选范围内的行头单元格,刷选过程中,显示刷选范围提示蒙层,刷选完成后,弹出 tooltip, 展示被刷选单元格信息(仅支持透视表)(cells: RowCell[]) => void;

SheetComponentOptions

注意

@antv/s2-vue 组件 的 options 继承于 S2Options , 有两点不同:

  • 类型由 S2Options 变更为 SheetComponentOptions.
  • 分页配置从 S2 的分页配置 变为了 antd-design-vue 的分页配置,即支持对 antd-vue 分页组件 的 api 透传。
import type { Pagination, S2Options } from '@antv/s2';
import type { PaginationProps } from 'ant-design-vue';
type SheetComponentOptions = S2Options<
Element | string,
Pagination & PaginationProps
>;

公共对象

FederatedPointerEvent

别名:GEvent

https://g.antv.antgroup.com/api/event/event-object

TargetCellInfo

功能描述:交互回调函数的返回信息。

参数说明类型默认值必选
target交互作用对象S2CellType
eventAntV/G Event 事件FederatedPointerEvent
viewMeta当前节点信息Node

SortParams

功能描述:排序配置。查看 文档 和 示例

参数说明类型默认值必选
sortFieldId度量 Id,即要被排序的 Idstring-✓
sortMethod排序方式ASC | DESC | asc | desc-
sortBy自定义排序列表string[]-
sortByMeasure按照度量值(数值)排序(透视表适用)string-
query筛选条件,缩小排序范围 如 :{city:'白山'}Record<string, string>-
type组内排序用来显示 icon (透视表适用)string-
sortFunc自定义排序的 function(params: SortFuncParam) => string[]-

SortFuncParam

功能描述:自定义排序函数参数。查看 文档 和 示例

参数说明类型默认值必选
sortFieldId度量 Id,即要被排序的 Idstring-✓
sortMethod排序方式ASC | DESC | asc | desc-
sortBy自定义排序列表string[]-
sortByMeasure按照度量值(数值)排序(透视表适用)string-
query筛选条件,缩小排序范围 如 :{city:'白山'}Record<string, string>-
type组内排序用来显示 icon(透视表适用)string-
data当前排序数据列表Array<string | Record<string, any>>-

CellScrollPosition

功能描述:单元格滚动的位置信息。

参数说明类型默认值必选
scrollX水平方向滚动偏移量(相对滚动条轨道长度)number
scrollY垂直方向滚动偏移量(相对滚动条轨道长度)number

HiddenColumnsInfo

功能描述:开启 隐藏列头 后,隐藏列头的节点信息

参数说明类型默认值必选
hideColumnNodes当前隐藏的节点信息Node[]
displaySiblingNode展示的相邻节点信息{ prev:Node;next: Node }

ResizeParams

功能描述:表格 resize(单元格行高列宽拖动变化)和单元格样式信息

参数说明类型默认值必选
inforesize 配置信息ResizeInfo
styleoptions 中样式相关配置style

ResizeInfo

功能描述:表格 resize( 单元格行高列宽拖动变化)配置信息

参数说明类型默认值必选
themeresize 热区配置ResizeArea
typeresize 方向Horizontal | Vertical
offsetX横向偏移量number
offsetY纵向偏移量number
width拖拽的宽度number
height拖拽number
size热区尺寸number
effect拖拽更改影响的区域Field | Cell | Tree | Series
isResizeArea是否属于 resize 热区boolean
id字段 idstring
cellresize 热区对应单元格信息Node
metaresize 热区对应单元格元数据Node
resizedWidth拖拽后的宽度number
resizedHeight拖拽后的高度number

S2RenderOptions

功能描述:自定义渲染模式

参数说明类型默认值必选
reloadData是否重新加载数据boolean
rebuildDataSet是否重新生成数据集boolean
rebuildHiddenColumnsDetail是否重新生成列头隐藏信息boolean

ViewMeta

功能描述:数值单元格数据和位置等信息

参数类型必选默认值功能描述
spreadsheetSpreadSheet表格实例
idstring单元格唯一标识
xnumber单元格 x 坐标
ynumber单元格 y 坐标
widthnumber单元格宽度
heightnumber单元格高度
dataViewMetaData单元格数据
rowIndexnumber单元格在行叶子节点中的索引
colIndexnumber单元格在列叶子节点中的索引
valueFieldstring度量 id
fieldValueDataItem度量展示的真实值
isTotalsboolean 是否为总计:true 为总计 false 为小计
queryRecord<string, any>行列查询条件
rowQueryRecord<string, any>行查询条件
colQueryRecord<string, any>列查询条件
rowIdstring单元格的行 id
colIdstring单元格的列 id

RawData

DateItem
type RawData = Record<string, DataItem>;

SimpleData

type SimpleData = string | number | null | undefined;

MultiData

功能描述:用于支持多指标类型的自定义数据单元格渲染。例如:趋势分析表

配置项名称说明类型默认值必选
values格式化后的数据,直接展示在 dataCfg 中SimpleData[][]✓
originalValues原始数据,用于原始数据导出SimpleData[][]
label用作单元格小标题,单独占一行展示string
[key: string]其他透传字段,用于自定义单元格的定制化展示unknown``
{
"number": {
"originalValues": [1, 2, 3],
"values": ["1", "2", "3"]
}
}

DataItem

SimpleData | MultiData | MiniChartData

type DataItem = SimpleData | MultiData | MiniChartData | Record<string, unknown>;
{
"number": 7789,
"province": "浙江省",
"city": "杭州市",
"type": "家具",
"sub_type": "桌子"
}

ExtraData

import type { EXTRA_FIELD, VALUE_FIELD } from '@antv/s2';
type ExtraData = {
[EXTRA_FIELD]: string;
[VALUE_FIELD]: string | DataItem;
};
{
"$$extra$$": "number",
"$$value$$": 7789,
}

Data

type Data = RawData & ExtraData;

ViewMetaData

查看 CellData 定义
type ViewMetaData = Data | CellData;

Data

{
"city": "杭州市"
}

CellData

{
"extraField": "number",
"raw": {
"number": 7789,
"province": "浙江省",
"city": "杭州市",
"type": "家具",
"sub_type": "桌子"
},
"$$extra$$": "number",
"$$value$$": 7789,
"$$origin$$": {
"number": 7789,
"province": "浙江省",
"city": "杭州市",
"type": "家具",
"sub_type": "桌子"
}
}

MiniChartData

功能描述:在单元格内绘制 mini 图(支持 折线图、子弹图、柱状图). 查看 文档 和 示例

BaseChartData

功能描述:内置折线图、柱状图数据配置项,数据格式参考 G2

参数说明类型必选默认值
typemini 图类型line | bar✓
encode编码方式,声明 x 位置通道或 y 位置通道绑定的对应的列数据{x: string; y: string}✓
data原始数据Data[]✓
[key: string]其他透传字段,用于自定义单元格的定制化展示unknown

BulletValue

功能描述:内置子弹图数据配置项

参数说明类型必选默认值
typemini 图类型bullet✓bullet
measure当前指标number | string✓
target目标值number | string✓
[key: string]其他透传字段,用于自定义单元格的定制化展示unknown

ViewMeta

功能描述:数值单元格数据和位置等信息

参数类型必选默认值功能描述
spreadsheetSpreadSheet表格实例
idstring单元格唯一标识
xnumber单元格 x 坐标
ynumber单元格 y 坐标
widthnumber单元格宽度
heightnumber单元格高度
dataViewMetaData单元格数据
rowIndexnumber单元格在行叶子节点中的索引
colIndexnumber单元格在列叶子节点中的索引
valueFieldstring度量 id
fieldValueDataItem度量展示的真实值
isTotalsboolean 是否为总计:true 为总计 false 为小计
queryRecord<string, any>行列查询条件
rowQueryRecord<string, any>行查询条件
colQueryRecord<string, any>列查询条件
rowIdstring单元格的行 id
colIdstring单元格的列 id

RawData

DateItem
type RawData = Record<string, DataItem>;

SimpleData

type SimpleData = string | number | null | undefined;

MultiData

功能描述:用于支持多指标类型的自定义数据单元格渲染。例如:趋势分析表

配置项名称说明类型默认值必选
values格式化后的数据,直接展示在 dataCfg 中SimpleData[][]✓
originalValues原始数据,用于原始数据导出SimpleData[][]
label用作单元格小标题,单独占一行展示string
[key: string]其他透传字段,用于自定义单元格的定制化展示unknown``
{
"number": {
"originalValues": [1, 2, 3],
"values": ["1", "2", "3"]
}
}

DataItem

SimpleData | MultiData | MiniChartData

type DataItem = SimpleData | MultiData | MiniChartData | Record<string, unknown>;
{
"number": 7789,
"province": "浙江省",
"city": "杭州市",
"type": "家具",
"sub_type": "桌子"
}

ExtraData

import type { EXTRA_FIELD, VALUE_FIELD } from '@antv/s2';
type ExtraData = {
[EXTRA_FIELD]: string;
[VALUE_FIELD]: string | DataItem;
};
{
"$$extra$$": "number",
"$$value$$": 7789,
}

Data

type Data = RawData & ExtraData;

ViewMetaData

查看 CellData 定义
type ViewMetaData = Data | CellData;

Data

{
"city": "杭州市"
}

CellData

{
"extraField": "number",
"raw": {
"number": 7789,
"province": "浙江省",
"city": "杭州市",
"type": "家具",
"sub_type": "桌子"
},
"$$extra$$": "number",
"$$value$$": 7789,
"$$origin$$": {
"number": 7789,
"province": "浙江省",
"city": "杭州市",
"type": "家具",
"sub_type": "桌子"
}
}

MiniChartData

功能描述:在单元格内绘制 mini 图(支持 折线图、子弹图、柱状图). 查看 文档 和 示例

BaseChartData

功能描述:内置折线图、柱状图数据配置项,数据格式参考 G2

参数说明类型必选默认值
typemini 图类型line | bar✓
encode编码方式,声明 x 位置通道或 y 位置通道绑定的对应的列数据{x: string; y: string}✓
data原始数据Data[]✓
[key: string]其他透传字段,用于自定义单元格的定制化展示unknown

BulletValue

功能描述:内置子弹图数据配置项

参数说明类型必选默认值
typemini 图类型bullet✓bullet
measure当前指标number | string✓
target目标值number | string✓
[key: string]其他透传字段,用于自定义单元格的定制化展示unknown

Interaction

功能描述:交互配置。查看 文档 和 示例

参数说明类型默认值必选
linkFields标记字段为链接样式,用于外链跳转string[] | (meta: Node | ViewMeta) => boolean
selectedCellsSpotlight是否开启选中高亮聚光灯效果booleanfalse
hoverHighlight鼠标悬停时高亮当前单元格,以及所对应的行头,列头booleantrue
hoverFocus鼠标悬停在当前单元格超过默认 800ms 后,保持当前高亮,显示 tooltip,悬停时间通过设置 duration 来控制boolean | {duration: number}true
hiddenColumnFields用于配置默认隐藏的列,透视表 和多列头明细表 需要配置列头唯一 id, 单列头明细表 配置列头 field 字段即可 (即:s2DataConfig.fields.columns). 了解更多string[]
copy单元格复制配置Copy
customInteractions自定义交互 详情CustomInteraction[]
scrollSpeedRatio用于控制滚动速率,分水平和垂直两个方向,默认为 1ScrollSpeedRatio
autoResetSheetStyle用于控制点击表格外区域和按下 ESC 键时是否重置交互状态和关闭 Tooltip, 支持根据 event 动态判断boolean | (event: Event | FederatedPointerEvent, spreadsheet: SpreadSheet) => booleantrue
resize用于控制 resize 热区是否显示boolean | ResizeInteractionOptionstrue
brushSelection是否允许单元格(包含行头,列头,数值单元格)刷选。行头,列头刷选只支持透视表boolean | BrushSelectiontrue
multiSelection是否允许多选 (包含行头,列头,数值单元格)booleantrue
rangeSelection是否允许区间快捷多选booleantrue
scrollbarPosition用于控制滚动条展示在内容区边缘还是画布边缘content | canvascontent
eventListenerOptions事件监听函数 addEventListener 的 可选项配置, 可控制事件从冒泡阶段还是捕获阶段触发false
selectedCellHighlight选中数值单元格后的行列高亮联动
rowHeader:选中数值单元格后高亮对应行头
colHeader:选中数值单元格后高亮对应列头
currentRow:选中数值单元格后高亮整行
currentCol:选中数值单元格后高亮整列
true:同 { rowHeader: true, colHeader: true, currentRow: true, currentCol: true }
boolean | { rowHeader?: boolean, colHeader?: boolean, currentRow?: boolean, currentCol?: boolean }false
overscrollBehavior控制滚动至边界的行为,可禁用浏览器的默认滚动行为。详情auto | contain | none | nullauto

Copy

功能描述:单元格复制。查看 文档 和 示例

参数说明类型默认值必选
enable是否允许复制booleantrue
withFormat是否使用 s2DataConfig 的 formatter 格式复制数据booleantrue
withHeader复制数据是否带表头信息booleanfalse
customTransformer复制时支持自定义 (transformer) 数据格式化方法(transformer: Transformer) => Partial<Transformer>transformer

CustomInteraction

功能描述:自定义交互,继承 BaseEvent: 查看示例

参数说明类型默认值必选
key交互的唯一标识string✓
interaction交互实例InteractionConstructor✓

ScrollSpeedRatio

功能描述:滚动速率配置。查看示例

interface ScrollSpeedRatio {
horizontal?: number; // 水平滚动速率,默认为 1
vertical?: number; // 垂直滚动速率,默认为 1
}

ResizeInteractionOptions

功能描述:宽高调整配置。查看示例

参数说明类型默认值必选
rowCellVertical是否开启行头垂直方向 resize 热区booleantrue
cornerCellHorizontal是否开启角头水平方向 resize 热区booleantrue
colCellHorizontal是否开启列头水平方向 resize 热区booleantrue
colCellVertical是否开启列头垂直方向 resize 热区 (列头隐藏时该配置无效)booleantrue
rowResizeType用于控制行高 resize 时的生效范围
1. all: 对所有单元格生效(会覆盖默认的行高配置),2. current: 对当前单元格生效,3. selected: 对当前单元格生效,如果单元格是多选状态,调整任意选中单元格,对所有选中的生效。
all| current | selectedcurrent
colResizeType用于控制列宽 resize 时的生效范围
1. all: 对所有单元格生效(会覆盖默认的列宽配置),2. current: 对当前单元格生效,3. selected: 对当前单元格生效,如果单元格是多选状态,调整任意选中单元格,对所有选中的生效。
all| current | selectedcurrent
disable用于控制行高 resize 是否生效。查看示例(resizeInfo: S2CellType) => boolean
visible自定义当前单元格是否显示 resize 热区(cell: S2CellType) => boolean
minCellWidth单元格可拖拽最小宽度number40
minCellHeight单元格可拖拽最小高度number20

BrushSelection

功能描述:单元格刷选配置。查看示例

参数说明类型默认值必选
dataCell是否允许数值单元格刷选booleantrue
rowCell是否允许行头单元格刷选(仅支持透视表)booleanfalse
colCell是否允许列头单元格刷选booleanfalse

CellSelectedDetail

功能描述:单元格选中信息明细。

参数说明类型默认值必选
interactionName触发选中的交互名InteractionName
targetCell触发选中的单元格S2CellType
event触发选中的事件对象FederatedPointerEvent | Event | KeyboardEvent

InterceptType

功能描述:交互拦截类型。

enum InterceptType {
HOVER = 'hover',
CLICK = 'click',
DATA_CELL_BRUSH_SELECTION = 'dataCellBrushSelection',
ROW_CELL_BRUSH_SELECTION = 'rowCellBrushSelection',
COL_CELL_BRUSH_SELECTION = 'colCellBrushSelection',
MULTI_SELECTION = 'multiSelection',
RESIZE = 'resize',
}

InteractionName

功能描述:交互名称。

enum InteractionName {
CORNER_CELL_CLICK = 'cornerCellClick',
DATA_CELL_CLICK = 'dataCellClick',
ROW_CELL_CLICK = 'rowCellClick',
COL_CELL_CLICK = 'colCellClick',
MERGED_CELLS_CLICK = 'mergedCellsClick',
ROW_COLUMN_CLICK = 'rowColumnClick',
HEADER_CELL_LINK_CLICK = 'headerCellLinkClick',
HOVER = 'hover',
DATA_CELL_BRUSH_SELECTION = 'dataCellBrushSelection',
ROW_CELL_BRUSH_SELECTION = 'rowCellBrushSelection',
COL_CELL_BRUSH_SELECTION = 'colCellBrushSelection',
COL_ROW_RESIZE = 'rowColResize',
DATA_CELL_MULTI_SELECTION = 'dataCellMultiSelection',
ROW_CELL_MULTI_SELECTION = 'rowCellMultiSelection',
COL_CELL_MULTI_SELECTION = 'colCellMultiSelection',
RANGE_SELECTION = 'rangeSelection',
SELECTED_CELL_MOVE = 'selectedCellMove',
GLOBAL_RESET = 'globalReset',
}

InteractionStateName

功能描述:交互状态名称。

enum InteractionStateName {
ALL_SELECTED = 'allSelected',
SELECTED = 'selected',
ROW_CELL_BRUSH_SELECTED = 'rowCellBrushSelected',
COL_CELL_BRUSH_SELECTED = 'colCellBrushSelected',
DATA_CELL_BRUSH_SELECTED = 'dataCellBrushSelected',
UNSELECTED = 'unselected',
HOVER = 'hover',
HOVER_FOCUS = 'hoverFocus',
HIGHLIGHT = 'highlight',
SEARCH_RESULT = 'searchResult',
PREPARE_SELECT = 'prepareSelect',
}

CellType

功能描述:单元格类型。

enum CellType {
DATA_CELL = 'dataCell',
ROW_CELL = 'rowCell',
COL_CELL = 'colCell',
SERIES_NUMBER_CELL = 'seriesNumberCell',
CORNER_CELL = 'cornerCell',
MERGED_CELL = 'mergedCell',
}