| 40 | } |
| 41 | |
| 42 | export function getAxesWithFilter(axes: ChartAxis[]): { |
| 43 | x: ChartAxis[] |
| 44 | y: ChartAxis[] // 过滤后的 y |
| 45 | series: ChartAxis[] |
| 46 | multiQuota: string[] // series 为空时返回 multi-quota 为 true 的 y 轴 value 列表 |
| 47 | multiQuotaName?: string |
| 48 | } { |
| 49 | const groups = { |
| 50 | x: [] as ChartAxis[], |
| 51 | y: [] as ChartAxis[], |
| 52 | series: [] as ChartAxis[], |
| 53 | multiQuota: [] as string[], |
| 54 | multiQuotaName: undefined as string | undefined, |
| 55 | } |
| 56 | |
| 57 | // 分组 |
| 58 | axes.forEach((axis) => { |
| 59 | if (axis.type === 'x') groups.x.push(axis) |
| 60 | else if (axis.type === 'y') groups.y.push(axis) |
| 61 | else if (axis.type === 'series') groups.series.push(axis) |
| 62 | else if (axis.type === 'other-info') groups.multiQuotaName = axis.value |
| 63 | }) |
| 64 | |
| 65 | // 应用过滤规则 |
| 66 | if (groups.series.length > 0) { |
| 67 | groups.y = groups.y.slice(0, 1) |
| 68 | } else { |
| 69 | const multiQuotaY = groups.y.filter((item) => item['multi-quota'] === true) |
| 70 | groups.multiQuota = multiQuotaY.map((item) => item.value) |
| 71 | if (multiQuotaY.length > 0) { |
| 72 | groups.y = multiQuotaY |
| 73 | } |
| 74 | } |
| 75 | |
| 76 | return groups |
| 77 | } |
| 78 | |
| 79 | export function processMultiQuotaData( |
| 80 | x: Array<ChartAxis>, |