Loading...
This article introduces the basic concepts of pivot tables.
In statistics, a pivot table is a table in matrix format that displays multivariate frequency distributions. They provide a basic picture of the relationship between two variables (or more), which can help discover the interaction between them and help businesses conduct cross-exploration analysis. They are currently one of the most frequently used charts in the field of commercial BI
analysis. one.
A pivot table consists of five parts, namely row header, column header, corner header, data cell, and frame, as shown in the following figure:
The structure of the row header is determined by s2DataConfig.fields.rows
, which is used for row analysis dimension display. The line head supports two display forms:平铺模式(grid)
and树状模式(tree)
.
For example, the line header data configures province, city
fields
const s2DataConfig = {fields: {rows: ['province', 'city']}}
Displayed in tiled mode as:
const s2Options = {hierarchyType: 'grid'}
Displayed in tree mode as:
const s2Options = {hierarchyType: 'tree'}
Note that when it is a detailed table, only columns need to be set.
The structure of the column header is determined by s2DataConfig.fields.columns
, which is used for column analysis dimension display.
For example, the column header data configures two fields, type, sub_type
, which are displayed as:
const s2DataConfig = {fields: {columns: ['type', 'sub_type']}}
The corner header refers to the upper left corner of the table and plays an important role in the layout of the table.
In the layout of the table, S2
is extended based on the corner header to calculate the size and coordinates of rows and columns.
Corner headers are also used to display row headers and column header names, such as省份
and城市
in the example.
In addition, S2
also provides custom extensions for scenarios that require custom corner headers, see cornerCell and cornerHeader for details.
The data cell is the data area generated by the intersection of the row and column dimension values of the table. Usually, it should be the measurement value, and it is the core data presentation area of the table data analysis.
In the data cell area, we can display basic cross data, use field tags to assist analysis, and display derivative indicators such as year-on- year comparisons. You can also customize data cells by customizing Hooks
. For more information, refer to dataCell .
The frame layout area, located above the other four areas, is used as a spacer frame between areas, or logic such as scroll bars, and shadows of frame interval lines.