-
Notifications
You must be signed in to change notification settings - Fork 199
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
docs: 完善 ViewMeta 和 CellData 文档 close #2845 #2868
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -23,8 +23,8 @@ s2.dataSet.getFieldName('type') | |
| getField | 获取字段 | (field: [CustomHeaderField](#customheaderfield)) => [Meta](/docs/api/general/S2DataConfig#meta) | | | ||
| getFieldMeta | 获取字段元数据信息 | (field: [CustomHeaderField](#customheaderfield), meta?: [Meta[]](/docs/api/general/S2DataConfig#meta)) => [Meta](/docs/api/general/S2DataConfig#meta) | | ||
| getFieldName | 获取字段名 | (field: [CustomHeaderField](#customheaderfield), defaultValue?: string) => `string` | | | ||
| getCustomRowFieldName | 获取自定义单元格字段名称 | (cell: S2CellType<ViewMeta \| Node>) => `string` | | | ||
| getCustomFieldDescription | 获取自定义单元格字段描述 | (cell: S2CellType<ViewMeta \| Node>) => `string` | | | ||
| getCustomRowFieldName | 获取自定义单元格字段名称 | (cell: S2CellType<[`ViewMeta`](#viewmeta) \| [`Node`](/api/basic-class/node)>) => `string` | | | ||
| getCustomFieldDescription | 获取自定义单元格字段描述 | (cell: S2CellType<[`ViewMeta`](#viewmeta) \| [`Node`](/api/basic-class/node)>) => `string` | | | ||
| getFieldFormatter | 获取字段格式化函数 | (field: [CustomHeaderField](#customheaderfield)) => [Formatter](#formatter) | | | ||
| getFieldDescription | 获取字段描述 | (field: [CustomHeaderField](#customheaderfield)) => [Formatter](#formatter) | | | ||
| setDataCfg | 设置数据配置 | `<T extends boolean = false>(dataCfg: T extends true ?` [`S2DataConfig`](/docs/api/general/S2DataConfig) `: Partial<`[`S2DataConfig`](/docs/api/general/S2DataConfig)`>, reset?: T) => void` | `reset` 参数需在 `@antv/s2^1.34.0`版本使用 | | ||
|
@@ -37,68 +37,6 @@ s2.dataSet.getFieldName('type') | |
| displayFormattedValueMap | 单元格所对应格式化后的值(用于编辑表) | `Map<string, string>` | | | ||
| getValueRangeByField | 获取数值最大最小值区间 | `(field: string) => { minValue: number, maxValue: number }` | | | ||
|
||
### SimpleData | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
|
||
```ts | ||
type SimpleData = string | number | null | undefined; | ||
``` | ||
|
||
### MultiData | ||
|
||
```ts | ||
interface MultiData<T = SimpleData[][]> { | ||
values: T; | ||
originalValues?: T; | ||
label?: string; | ||
[key: string]: unknown; | ||
} | ||
``` | ||
|
||
### DataItem | ||
|
||
```ts | ||
|
||
type DataItem = | ||
| SimpleData | ||
| MultiData | ||
| Record<string, unknown> | ||
| undefined | ||
| null; | ||
``` | ||
|
||
### RawData | ||
|
||
```ts | ||
type RawData = Record<string, DataItem>; | ||
``` | ||
|
||
### DataType | ||
|
||
```ts | ||
type DataType = Record<string, unknown>; | ||
``` | ||
|
||
### ExtraData | ||
|
||
```ts | ||
type ExtraData = { | ||
[EXTRA_FIELD]: string; | ||
[VALUE_FIELD]: string | DataItem; | ||
}; | ||
``` | ||
|
||
### Data | ||
|
||
```ts | ||
type Data = RawData & ExtraData; | ||
``` | ||
|
||
### ViewMetaData | ||
|
||
```ts | ||
type ViewMetaData = Data | CellData; | ||
``` | ||
|
||
### Formatter | ||
|
||
```ts | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
title: CellData | ||
order: 10 | ||
tag: New | ||
--- |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
--- | ||
title: CellData | ||
order: 10 | ||
tag: New | ||
--- | ||
|
||
功能描述:透视表数值单元格元数据。[详情](https://github.com/antvis/S2/blob/next/packages/s2-core/src/data-set/cell-data.ts) | ||
|
||
```ts | ||
this.meta.data | ||
``` | ||
|
||
| 参数 | 说明 | 类型 | | ||
| --- | --- | --- | | ||
| extraField | `string` | 虚拟度量字段 | | ||
| raw | 原始数据 | [RawData](#rawdata) | | ||
| getValueByField | 获取数值 | (field: `string`) => [DataItem](#dataitem) | | ||
| $$value$$ | 指标值(内部使用) | [DataItem](#dataitem) | | ||
| $$extra$$ | 虚拟度量字段 (内部使用,等价于 `extraField`) | `string` | | ||
| $$origin$$ | 原始数据 (内部使用,等价于 `raw`) | [RawData](#rawdata) | | ||
|
||
## 静态方法 | ||
|
||
```ts | pure | ||
import { CellData } from '@antv/s2' | ||
``` | ||
|
||
### getCellData | ||
|
||
```ts | ||
CellData.getCellData(raw: RawData, extraField: string) | ||
``` | ||
|
||
### getCellDataList | ||
|
||
```ts | ||
CellData.getCellDataList(raw: RawData, extraFields: string[]) | ||
``` | ||
|
||
### getFieldValue | ||
|
||
```ts | ||
CellData.getFieldValue(data: ViewMetaData, field?: string) | ||
``` | ||
|
||
<embed src="@/docs/common/view-meta.zh.md"></embed> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -28,72 +28,6 @@ const s2DataConfig = { | |
| sortParams | 排序参数配置 | [SortParam](#sortparam)[] | | | | ||
| filterParams | 筛选参数配置 | [FilterParam](#filterparam)[] | | | | ||
|
||
### RawData | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 同上 |
||
|
||
[SimpleData](#simpledata) | [MiniChartData](#minichartdata) | [MultiData](#multidata) | ||
|
||
功能描述:表格数据源 | ||
|
||
```ts | ||
type RawData = Record<string, DataItem> | ||
type DataItem = SimpleData | MultiData | ||
``` | ||
|
||
#### SimpleData | ||
|
||
功能描述:基础数据类型 | ||
|
||
```ts | ||
type SimpleData = string | number | ||
``` | ||
|
||
```ts | ||
const data = [ | ||
{ | ||
area: '东北', | ||
province: '吉林', | ||
city: '白山', | ||
type: '办公用品', | ||
subType: '纸张', | ||
cost: '2', | ||
}, | ||
{ | ||
area: '东北', | ||
province: '吉林', | ||
city: '白山', | ||
type: '办公用品', | ||
subType: '笔', | ||
cost: '3', | ||
} | ||
]; | ||
``` | ||
|
||
#### MiniChartData | ||
|
||
<embed src="@/docs/common/mini-chart.zh.md"></embed> | ||
|
||
#### MultiData | ||
|
||
功能描述:用于支持多指标类型的自定义数据单元格渲染。例如:[趋势分析表](/examples/react-component/sheet#strategy) | ||
|
||
| 配置项名称 | 说明 | 类型 | 默认值 | 必选 | | ||
| :--------------- | :----------------------------------------- | :---------------------------- | :----- | :--- | | ||
| `values` | 格式化后的数据,直接展示在 dataCfg 中 | [SimpleData](#simpledata)[][] | ✓ | | ||
| `originalValues` | 原始数据,用于原始数据导出 | [SimpleData](#simpledata)[][] | | | | ||
| `label` | 用作单元格小标题,单独占一行展示 | `string` | | | | ||
| `[key: string]` | 其他透传字段,用于自定义单元格的定制化展示 | `unknown` | `` | | | ||
|
||
```ts | ||
const data = [ | ||
{ | ||
number: { | ||
originalValues: [1, 2, 3], | ||
values: ['1', '2', '3'] | ||
} | ||
} | ||
]; | ||
``` | ||
|
||
### Fields | ||
|
||
功能描述: 配置表格的维度域,即对应行列维度。 | ||
|
@@ -115,11 +49,10 @@ const data = [ | |
| field | 字段 id (即 [Fields](#fields) 中配置的字段) | `string \| string[] \| RegExp` | | | | ||
| name | 字段名称 | `string` | | | | ||
| description | 字段描述,会显示在行头、列头、单元格对应的 tooltip 中 | `string` | | | | ||
| formatter | 格式化 <br/> 单元格、行头和列头支持格式化,角头不支持格式化。只有单元格存在第二个参数。 <br/>数值字段:一般用于格式化数字单位<br/>文本字段:一般用于做字段枚举值的别名<br/> 第二个参数在以下情况会传入:data cell 格式化,复制/导出,tooltip 展示(**且仅在选择多个单元格时,data 类型为数组**) | `(value: unknown, data?: Data \| Data[], meta?: Node \| ViewMeta) => string` | | | | ||
| formatter | 格式化 <br/> 单元格、行头和列头支持格式化,角头不支持格式化。只有单元格存在第二个参数。 <br/>数值字段:一般用于格式化数字单位<br/>文本字段:一般用于做字段枚举值的别名<br/> 第二个参数在以下情况会传入:data cell 格式化,复制/导出,tooltip 展示(**且仅在选择多个单元格时,data 类型为数组**) | (value: unknown, data?: [`Data`](#data) \| [`Data`](#data)[], meta?: [`Node`](/api/basic-class/node) \| [`ViewMeta`](#viewmeta)) => string | | | | ||
|
||
<embed src="@/docs/common/custom/customTreeNode.zh.md"></embed> | ||
|
||
<embed src="@/docs/common/sort-param.zh.md"></embed> | ||
<embed src="@/docs/common/view-meta.zh.md"></embed> | ||
|
||
### FilterParam | ||
|
||
|
@@ -130,3 +63,5 @@ const data = [ | |
| `filterKey` | 需要筛选的字段 id | `string` | | ✓ | | ||
| `filteredValues` | 不包含的维度值 | `unknown[]` | | | | ||
| `customFilter` | 自定义筛选函数,最终筛选的结果是同时满足 customFilter 且不在 filteredValues 中 | `(raw: Record<string, string>) => boolean` | | | | ||
|
||
<embed src="@/docs/common/sort-param.zh.md"></embed> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
dataCell 的 meta 中没有
value
和valueField
, 是类型错误