|
1 |
| -import { filter } from '@antv/util'; |
2 | 1 | import { interaction, animation, theme, scale, tooltip, legend, annotation } from '../../adaptor/common';
|
3 | 2 | import { Params } from '../../core/adaptor';
|
4 |
| -import { flow, deepAssign, findGeometry, transformLabel, log, LEVEL } from '../../utils'; |
| 3 | +import { flow, deepAssign, findGeometry, transformLabel } from '../../utils'; |
5 | 4 | import { interval, point } from '../../adaptor/geometries';
|
| 5 | +import { processIllegalData } from '../../utils'; |
6 | 6 | import { RadialBarOptions } from './types';
|
7 | 7 | import { getScaleMax } from './utils';
|
8 |
| -/** |
9 |
| - * data 处理,过滤非法数据 |
10 |
| - * @param params |
11 |
| - */ |
12 |
| -function data(params: Params<RadialBarOptions>): Params<RadialBarOptions> { |
13 |
| - const { chart, options } = params; |
14 |
| - const { data } = options; |
15 |
| - const { yField } = options; |
16 |
| - |
17 |
| - const processData = filter(data, (d) => { |
18 |
| - const v = d[yField]; |
19 |
| - return v === null || (typeof v === 'number' && !isNaN(v)); |
20 |
| - }); |
21 |
| - |
22 |
| - // 打印异常数据情况 |
23 |
| - log(LEVEL.WARN, processData.length === data.length, 'illegal data existed in chart data.'); |
24 |
| - |
25 |
| - chart.data(processData); |
26 |
| - |
27 |
| - return params; |
28 |
| -} |
29 | 8 |
|
30 | 9 | /**
|
31 | 10 | * geometry 处理
|
32 | 11 | * @param params
|
33 | 12 | */
|
34 | 13 | function geometry(params: Params<RadialBarOptions>): Params<RadialBarOptions> {
|
35 | 14 | const { chart, options } = params;
|
36 |
| - const { barStyle: style, color, tooltip, colorField, type, xField, yField } = options; |
| 15 | + const { barStyle: style, color, tooltip, colorField, type, xField, yField, data } = options; |
| 16 | + |
| 17 | + // 处理不合法的数据 |
| 18 | + const processData = processIllegalData(data, yField); |
| 19 | + chart.data(processData); |
| 20 | + |
37 | 21 | const p = deepAssign({}, params, {
|
38 | 22 | options: {
|
39 | 23 | tooltip,
|
@@ -64,16 +48,15 @@ function geometry(params: Params<RadialBarOptions>): Params<RadialBarOptions> {
|
64 | 48 | * @param params
|
65 | 49 | */
|
66 | 50 | export function meta(params: Params<RadialBarOptions>): Params<RadialBarOptions> {
|
67 |
| - const { options, chart } = params; |
68 |
| - const { yField, maxAngle } = options; |
| 51 | + const { options } = params; |
| 52 | + const { yField, maxAngle, data } = options; |
69 | 53 |
|
70 |
| - // data使用chart.data()之后的,因为原始data中可能存在非法数据 |
71 |
| - const { data } = chart.getOptions(); |
| 54 | + const processData = processIllegalData(data, yField); |
72 | 55 | return flow(
|
73 | 56 | scale({
|
74 | 57 | [yField]: {
|
75 | 58 | min: 0,
|
76 |
| - max: getScaleMax(maxAngle, yField, data), |
| 59 | + max: getScaleMax(maxAngle, yField, processData), |
77 | 60 | },
|
78 | 61 | })
|
79 | 62 | )(params);
|
@@ -147,7 +130,6 @@ function label(params: Params<RadialBarOptions>): Params<RadialBarOptions> {
|
147 | 130 | */
|
148 | 131 | export function adaptor(params: Params<RadialBarOptions>) {
|
149 | 132 | return flow(
|
150 |
| - data, |
151 | 133 | geometry,
|
152 | 134 | meta,
|
153 | 135 | axis,
|
|
0 commit comments