|
1 | 1 | import { uniq, isFunction, isObject, isString, isNumber, isEmpty } from '@antv/util';
|
2 | 2 | import { Params } from '../../core/adaptor';
|
3 |
| -import { ColorAttr, ShapeAttr, SizeAttr, StyleAttr, TooltipAttr, Options, Datum } from '../../types'; |
| 3 | +import { ColorAttr, ShapeAttr, SizeAttr, StyleAttr, TooltipAttr, Options, Datum, RawFields } from '../../types'; |
4 | 4 | import { Label } from '../../types/label';
|
5 | 5 | import { State } from '../../types/state';
|
6 | 6 | import { transformLabel } from '../../utils';
|
@@ -43,7 +43,7 @@ export type Geometry = {
|
43 | 43 | /** tooltip 的映射字段 */
|
44 | 44 | readonly tooltipFields?: string[] | false;
|
45 | 45 | /** 其他原始字段, 用于 mapping 回调参数 */
|
46 |
| - readonly rawFields?: string[]; |
| 46 | + readonly rawFields?: RawFields; |
47 | 47 | /** 图形映射规则 */
|
48 | 48 | readonly mapping?: MappingOptions;
|
49 | 49 | /** label 映射通道,因为历史原因导致实现略有区别 */
|
@@ -73,9 +73,11 @@ export function getMappingField(
|
73 | 73 | mappingFields: string[];
|
74 | 74 | tileMappingField: string;
|
75 | 75 | } {
|
76 |
| - const { type, xField, yField, colorField, shapeField, sizeField, styleField, rawFields = [] } = o; |
| 76 | + const { type, xField, yField, colorField, shapeField, sizeField, styleField } = o; |
| 77 | + let { rawFields } = o; |
77 | 78 |
|
78 | 79 | let fields = [];
|
| 80 | + rawFields = (isFunction(rawFields) ? rawFields(type, field) : rawFields) || []; |
79 | 81 |
|
80 | 82 | // 因为 color 会影响到数据分组,以及最后的图形映射。所以导致 bar 图中的 widthRatio 设置不生效
|
81 | 83 | // 所以对于 color 字段,仅仅保留 colorField 好了! + rawFields
|
|
0 commit comments