| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354 |
- function getRowColorbar(row) {
- return Array.isArray(row?.colorbar)
- ? row.colorbar
- : Array.isArray(row?.colorBar)
- ? row.colorBar
- : [];
- }
- function getRowColorbarTitle(row) {
- return row?.colorbarTitle || row?.colorbartitle || "";
- }
- function pitchColorFarmKind(row) {
- const text = `${row?.originalLabel || ""} ${row?.label || ""}`;
- if (/异常/.test(text) && !/正常/.test(text)) return "异常点";
- if (/正常/.test(text)) return "正常数据";
- return row?.originalLabel || row?.label || "数据";
- }
- /**
- * 将变桨协调的桨距角色带图合并为正常/异常系列。
- * 只重组系列,不抽样任何坐标点。
- */
- export function mergePitchColorFarmRows(rows = [], useTimeData = false) {
- const groups = new Map();
- rows.forEach((row) => {
- const key = pitchColorFarmKind(row);
- const prev = groups.get(key);
- const xData = [...(prev?.xData || []), ...(row?.xData || [])];
- const yData = [...(prev?.yData || []), ...(row?.yData || [])];
- const colorbar = [
- ...(prev?.colorbar || []),
- ...getRowColorbar(row),
- ];
- const len = Math.min(xData.length, yData.length);
- groups.set(key, {
- ...row,
- label: key,
- originalLabel: key,
- extra: undefined,
- pointData: undefined,
- xData: xData.slice(0, len),
- yData: yData.slice(0, len),
- timeData: useTimeData ? xData.slice(0, len) : [],
- colorbar: colorbar.slice(0, len),
- colorbarTitle:
- getRowColorbarTitle(row) ||
- prev?.colorbarTitle ||
- "桨距角 (°)",
- turbineIndex: undefined,
- });
- });
- return [...groups.values()];
- }
|