logo

S2

  • Manual
  • API
  • Examples
  • Playground
  • ChangeLog
  • Productsantv logo arrow
  • 2.x
  • Common Configuration
    • S2DataConfig
    • S2Options
      Updated
    • S2Theme
      Updated
    • S2Event
  • Basic Class
    • SpreadSheet
    • Interaction
      Updated
    • Store
    • BaseCell
      Updated
    • BaseDataSet
    • Node
    • BaseTooltip
    • BaseFacet
      Updated
    • Hierarchy
      New
    • BaseBBox
      New
    • CellData
      New
  • Components
    • table component
    • DrillDown
    • Switcher
    • Advanced Sort
    • Export
      Updated
  • Graphic style
  • 透视组合图拓展 S2Options

Interaction

Previous
SpreadSheet
Next
Store

Resources

Ant Design
Galacea Effects
Umi-React Application Framework
Dumi-Component doc generator
ahooks-React Hooks Library

Community

Ant Financial Experience Tech
seeconfSEE Conf-Experience Tech Conference

Help

GitHub
StackOverflow

more productsMore Productions

Ant DesignAnt Design-Enterprise UI design language
yuqueYuque-Knowledge creation and Sharing tool
EggEgg-Enterprise-class Node development framework
kitchenKitchen-Sketch Tool set
GalaceanGalacean-互动图形解决方案
xtechLiven Experience technology
© Copyright 2025 Ant Group Co., Ltd..备案号:京ICP备15032932号-38

Loading...

Functional description: properties and methods related to the interaction class. details

s2.interaction.reset()
parameterillustratetype
spreadsheetForm exampleSpreadSheet
interactionscurrently registered interactionsMap<string, BaseEvent>
interceptCurrently intercepted interactions to prevent conflicts between different interactionsSet<Intercept>
destroyUnloads all interactive instances and resets to initial state() => void
resetreset all interactions() => void
setStateset state(data: InteractionStateInfo ) => void
getStateget current state() => void
resetStatereset to initial state() => void
clearStateClear state and redraw() => void
changeStateupdate status(data: InteractionStateInfo ) => void
setInteractedCellsSet the currently changed cell(cell: S2CellType ) => void
getInteractedCellsGet the currently changed cell() => S2CellType []
getCurrentStateNameGet the current state name() => void
isEqualStateNameIs it the same state name(name: InteractionStateName) => void
isSelectedStateIs it selected() => void
isHoverStateIs it a hover state() => void
isHoverFocusStateIs it the hovering focus state (hovering at the cell focusTime : after 800ms by default)() => void
isSelectedCellIs it the selected cell(cell: S2CellType ) => void
isActiveCellis the active cell(cell: S2CellType ) => void
getCellsGet the Cells metadata list of the current interaction record, including the cells not in the viewport() => Partial<ViewMeta>[]
getActiveCellsGet the cell instance currently in the visible area() => S2CellType[]
clearStyleIndependentclear cell styles() => void
getPanelGroupAllUnSelectedDataCellsGet the selected value cell in the visible area() => DataCell[]
getPanelGroupAllDataCellsGet all numerical cells in the visible area() => DataCell[]
getAllRowHeaderCellsGet row header cell() => RowCell[]
getAllColHeaderCellsGet column header cell() => ColCell[]
getRowColActiveCellsGet the active cell of row header and column header() => RowCell[] | ColCell[]
getAllCellsGet all cells in the visible area() => S2CellType []
selectAllselect all cells() => void
changeCellSelect the specified row and column header cell(changeCellInfo: ChangeCellOptions ) => boolean
getCellChildrenNodesGet all child nodes of the current cell(cell: S2CellType ) => Node []
hideColumnsHidden column (when forceRender is false , if the hidden column is empty, the table update will no longer be triggered)(hiddenColumnFields: string[], forceRender?: boolean = true) => void
mergeCellsMerge Cells(cellsInfo?: MergedCellInfo [], hideData?: boolean) => void
unmergeCellsunmerge cells(removedCells: MergedCell[]) => void
updateAllDataCellsupdate all value cells() => void
updateCellsUpdate the specified cell(cells: S2CellType []) => void
addInterceptsAdded interactive interception(interceptTypes: InterceptType []) => void
hasInterceptsWhether there is an interaction specified for interception(interceptTypes: InterceptType []) => boolean
removeInterceptsRemove specified interaction interception(interceptTypes: InterceptType []) => void
highlightNodesHighlight the cell corresponding to the node(nodes: Node []) => void

Interaction

parameterillustratetypeDefaultsrequired
linkFieldsThe mark field is a link style, which is used for external link jumpsstring[] | (meta: Node | ViewMeta) => boolean
selectedCellsSpotlightWhether to enable the selected highlight spotlight effectbooleanfalse
hoverHighlightHighlight the current cell, and the corresponding row and column headers when the mouse hoversbooleantrue
hoverFocusAfter the mouse hovers over the current cell for more than the default 800ms, it will keep the current highlight and display the tooltip. The hovering time is controlled by setting the duration`boolean\{duration: number}`true
hiddenColumnFieldsIt is used to configure the columns that are hidden by default. The pivot table needs to configure the unique id of the column header, and the detail table can be configured with the field field of the column header.string[]
enableCopyWhether to allow copyingbooleanfalse
withHeaderWhether to copy data with header informationbooleanfalse
withFormatWhether to use the field format format to copybooleanfalse
customInteractionsCustomize interaction detailsCustomInteraction[]
scrollSpeedRatioUsed to control the scroll rate, divided into horizontal and vertical directions, the default is 1ScrollSpeedRatio
autoResetSheetStyleUsed to control whether to reset the interactive state when clicking the area outside the table and pressing the esc keybooleantrue
resizeUsed to control whether the resize hotspot is displayedboolean \ResizeInteractionOptionstrue
brushSelectionWhether to allow cells (including row headers, column headers, and value cells) to be selected. Row header, column header selection only supports pivot tablesboolean \Brush Selectiontrue
multiSelectionWhether to allow multiple selection (including row headers, column headers, and value cells)booleantrue
rangeSelectionWhether to allow quick multiple selection of intervalsbooleantrue
scrollbarPositionUsed to control whether the scroll bar is displayed on the edge of the content area or the edge of the canvas`content\canvas`content
eventListenerOptionsOptional configuration of the event listening function addEventListener , which can control whether the event is triggered from the bubbling phase or the capturing phasefalse
selectedCellHighlightHighlight behavior after grid is selected
rowHeader: Whether to highlight the row header where the selected grid is located
colHeader: Whether to highlight the column header where the selected grid is located
currentRow: Whether to highlight the row where the grid is located
currentCol: whether to highlight the column where the grid is located
true: Same as {rowHeader: true, colHeader: true}
`boolean{ rowHeader?: boolean, colHeader?: boolean, currentRow?: boolean, currentCol?: boolean }`
overscrollBehaviorControls the behavior of scrolling to bounds, which disables the browser's default scrolling behavior. detailsauto | contain | none | nullauto

CustomInteraction

Function description: custom interaction, inherit baseEvent: concrete example

parameterillustratetypeDefaultsrequired
keyunique identifier for the interactionstring✓
interactionInteraction Constructor✓

ScrollSpeedRatio

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

ResizeInteractionOptions

parameterillustratetypeDefaultsrequired
rowCellVerticalWhether to open the line header vertical resize hot zonebooleantrue
cornerCellHorizontalWhether to enable the resize hotspot in the horizontal direction of the corner headbooleantrue
colCellHorizontalWhether to enable the horizontal resize hotspot of the column headerbooleantrue
colCellVerticalWhether to enable the column header vertical resize hot zone (this configuration is invalid when the column header is hidden)booleantrue
rowResizeTypeIt is used to control whether the row height resize will take effect for all Cells at the same time, or only for the current row. Applies to all rows by defaultall | currentall
disableIt is used to control whether the row height resize is effective or not. View example(resizeInfo: S2CellType ) => boolean
visibleCustomize whether the current cell displays the resize hotspot(cell: S2CellType ) => boolean

brushSelection

parameterillustratetypeDefaultsrequired
dataCellWhether to allow numerical cell selectionbooleantrue
rowCellWhether to allow row header cell selection (only supports pivot tables)booleanfalse
colCellWhether to allow column header cell selection (only supports pivot tables)booleanfalse

Interaction Constructor

export type InteractionConstructor = new (
spreadsheet: SpreadSheet,
) => BaseEvent;

BaseEvent

export abstract class BaseEvent {
public spreadsheet: SpreadSheet;
constructor(spreadsheet: SpreadSheet) {
this.spreadsheet = spreadsheet;
this.bindEvents();
}
public abstract bindEvents(): void;
}

InterceptType

export 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',
}

S2CellType

type S2CellType<T extends SimpleBBox = ViewMeta> =
| DataCell
| HeaderCell
| ColCell
| CornerCell
| RowCell
| MergedCell
| BaseCell<T>;

ChangeCellOptions

interface ChangeCellOptions {
cell: S2CellType<ViewMeta>; // 目标单元格
isMultiSelection?: boolean; // 是否是多选
}

MergedCellInfo

interface MergedCellInfo {
colIndex?: number;
rowIndex?: number;
showText?: boolean;
}

InteractionStateInfo

interface InteractionStateInfo {
stateName?: InteractionStateName;
cells?: CellMeta[];
interactedCells?: S2CellType[];
nodes?: Node[];
force?: boolean;
}

ViewMeta

object is required, default: {} function description: information such as cell data and position

parametertyperequiredDefaultsFunctional description
spreadsheetSpreadSheetTable class instance, which can access any configuration information
idstringcell unique identifier
xnumbercell x-coordinate
the ynumbercell y coordinate
widthnumbercell width
heightnumbercell height
dataRecord<string, any>Cell Raw Data Metrics
rowIndexnumberThe index of the cell in the row leaf node
colIndexnumberThe index of the cell in the column leaf node
valueFieldstringmetric-id
fieldValueDataItemThe true value of the metric display
isTotalsbooleanWhether it is a total: true is a total, false is a subtotal
rowQueryRecord<string, any>Row query condition
colQueryRecord<string, any>Column query condition
rowIdstringthe row id of the cell
colIdstringthe column id of the cell