|
5 | 5 | * 支持 line、bar、pie、scatter、area、radar、gauge 图表类型 |
6 | 6 | */ |
7 | 7 |
|
8 | | -import { useMemo, useRef, useEffect } from 'react'; |
9 | 8 | import * as echarts from 'echarts'; |
10 | 9 | import type { ECharts, EChartsOption } from 'echarts'; |
| 10 | +import { useMemo, useRef, useEffect } from 'react'; |
11 | 11 |
|
12 | 12 | import { useTheme } from '../context/theme'; |
13 | 13 | import type { |
@@ -65,12 +65,14 @@ function resolveValue<T>( |
65 | 65 |
|
66 | 66 | const arrayData = processor.getData(component, arrayPath!, surfaceId); |
67 | 67 | if (Array.isArray(arrayData)) { |
68 | | - return arrayData.map(item => { |
69 | | - if (item && typeof item === 'object' && fieldName! in item) { |
70 | | - return (item as Record<string, unknown>)[fieldName!]; |
71 | | - } |
72 | | - return undefined; |
73 | | - }).filter(v => v !== undefined) as T; |
| 68 | + return arrayData |
| 69 | + .map((item) => { |
| 70 | + if (item && typeof item === 'object' && fieldName! in item) { |
| 71 | + return (item as Record<string, unknown>)[fieldName!]; |
| 72 | + } |
| 73 | + return undefined; |
| 74 | + }) |
| 75 | + .filter((v) => v !== undefined) as T; |
74 | 76 | } |
75 | 77 | return undefined; |
76 | 78 | } |
@@ -183,7 +185,9 @@ export function Chart({ |
183 | 185 | if (chartType !== 'radar') return undefined; |
184 | 186 |
|
185 | 187 | // 从 xAxis.data 获取 indicator |
186 | | - const indicatorData = xAxis?.data ? resolveValue(xAxis.data, component, processor, surfaceId) : undefined; |
| 188 | + const indicatorData = xAxis?.data |
| 189 | + ? resolveValue(xAxis.data, component, processor, surfaceId) |
| 190 | + : undefined; |
187 | 191 | if (!indicatorData || !Array.isArray(indicatorData)) return { indicator: [] }; |
188 | 192 |
|
189 | 193 | return { |
@@ -293,4 +297,3 @@ export function Chart({ |
293 | 297 | </div> |
294 | 298 | ); |
295 | 299 | } |
296 | | - |
|
0 commit comments