Loading...
S2 supports configuring collapsed/expanded nodes in the tree structure, and expands all nodes by default.
Tiling mode, follow-up support
const s2Options = {hierarchyType: 'tree',style: {rowCell: {// 折叠节点collapseFields: {},// 展开层级expandDepth: 0,// 折叠所有collapseAll: true},},}
Configure collapseFields
to support two ways of维值id
and维度field
, that is, root[&] 浙江省
and city
const s2Options = {style: {rowCell: {collapseFields: {},},},}
Specify id
to fold the specified node, if configured as root[&] 浙江省
, then all nodes浙江省
will be folded
const s2Options = {style: {rowCell: {collapseFields: { 'root[&] 浙江省': true },},},}
Specifies that the field
can collapse the node corresponding to the dimension of the node. For example, if the line header is configured with two dimensions of province
and city
, and collapseFields
is configured as ['city']
, then all cities will be collapsed
const s2DataConfig = {fields: {rows: ['province', 'city']}}const s2Options = {style: {rowCell: {collapseFields: { province: false, city: true }},},}
const s2Options = {style: {dataCell: {width: 100,height: 90},},}
Just configure collapseAll
, the priority is lower than collapseFields
, see configuration priority for details
const s2Options = {style: {rowCell: {collapseAll: true,},},}
The table expands all nodes by default. collapseFields
needs to know the corresponding node id
or field
in advance. When you don’t care about the specific node but only the node level, you can use the expandDepth
syntactic sugar to configure the expansion level (starting from 0) with a lower priority than collapseFields
. For details, see configuration priority
const s2Options = {style: {rowCell: {// 展开两层expandDepth: 1,},},}
S2 provides three folding/expanding related configurations to meet different usage scenarios, and the priorities are as follows:
collapseFields
> expandDepth
> collapseAll
If you want collapseAll
to take effect, you can set collapseFields
and expandDepth
to null
const s2Options = {style: {rowCell: {collapseFields: null, // 无效collapseAll: true, // 生效expandDepth: null, // 无效},},}
object is required , default: null Function description: style setting
parameter | type | required | Defaults | Functional description |
---|---|---|---|---|
layoutWidthType | adaptive | colAdaptive | compact | Cell Width Layout Typeadaptive : Rows and columns are equal in width, equally dividing the entire Canvas canvas widthcolAdaptive : Equal width of columns, compact layout of line headers, the remaining width of the column equally divided canvas width minus the width of line headerscompact : compact row and column layout, when the indicator dimension is small, it cannot cover the entire canvas | ||
dataCell | DataCell | Value cell configuration | ||
colCell | ColCell | Column header cell configuration | ||
rowCell | RowCell | Row header cell configuration |
object is required , default: null Function description: Numerical cell configuration
parameter | illustrate | type | Defaults | required |
---|---|---|---|---|
width | cell width | number | 96 | - |
height | cell height | number | 30 | - |
valuesCfg | cell configuration | { originalValueField?: string, widthPercent?: number[], showOriginalValue?: boolean } | - |
object is required , default: null Function description: Column header cell configuration
parameter | illustrate | type | Defaults | required |
---|---|---|---|---|
width | Cell width, which can be dynamically set according to the current column header node (leaf nodes are valid) | number | (colNode: Node) => number | 96 | |
height | Cell height, which can be dynamically set according to the current column header node (leaf nodes are valid) | number | (colNode: Node) => number | 30 | |
widthByField | Set the width according to the measurement value (drag or preset width scene), field corresponds to the field or column header id in s2DataConfig.fields.columns , see details | Record<string, number> | - | |
heightByField | Set the height according to the measurement value (drag or preset height scene), the field corresponds to the field or column header id in s2DataConfig.fields.columns , see details | Record<string, number> | - | |
hideValue | The default value hangs the column header, which will display the column header and the value at the same time, and hide the value to make it more beautiful. (that is, s2DataConfig.fields.values and it is only valid for a single value, and it is recommended to use hidden column headers for multiple values) | boolean | false |
object is required , default: null Function description: row header cell configuration
parameter | illustrate | type | Defaults | required |
---|---|---|---|---|
width | The row cell width can be dynamically set according to the current row header node, and the tree structure is also applicable | number | (rowNode: Node) => number | Tiles: 96 , Trees: 120 | |
height | Row cell height, which can be dynamically set according to the current row header node | number | (rowNode: Node) => number | 30 | |
collapseFields | Custom folded nodes for row headers in tree mode. Supports two formats: id ( 'root[&] 行头维度值' ) and dimension field ( 'city' ). The priority is higher than collapseAll and expandDepth , and the priority is the lowest when it is set to null . view demo | Record<string, boolean> | ||
collapseAll | Whether to collapse all line headers by default in tree structure mode. | boolean | false | |
expandDepth | In the tree structure mode, the row header expands the expanded level by default (the level starts from 0), and when it is set to null , the priority is the lowest | number | ||
showTreeLeafNodeAlignDot | In the tree mode, whether the row header leaf nodes display the hierarchical placeholders | boolean | false | |
withByField | Set the width of each line according to field . field corresponds to the field or column header id in s2DataConfig.fields.rows , see details | Record<string, number> | - | |
heightByField | Set the height of each row according to field .1. Pivot table: field corresponds to field or column header id in s2DataConfig.fields.rows .2. Detailed table: field corresponds to the row number, starting from 1 . check the details | Record<string, number> | - |