|
|
@@ -25,10 +25,10 @@ const Y_KEYS = [
|
|
|
"cp",
|
|
|
"lambda",
|
|
|
];
|
|
|
-const SERIES_KEYS = ["engine_code", "series_id", "aggregate_id", "name", "cohort_id"];
|
|
|
+const SERIES_KEYS = ["engine_name", "engine_code", "series_id", "aggregate_id", "name", "cohort_id"];
|
|
|
|
|
|
const TABLE_COLUMNS = [
|
|
|
- ["engine_code", "机组"],
|
|
|
+ ["engine_name", "机组"],
|
|
|
["machine_type_code", "机型"],
|
|
|
["status_label", "检测结果"],
|
|
|
["actual", "实际情况"],
|
|
|
@@ -37,7 +37,7 @@ const TABLE_COLUMNS = [
|
|
|
];
|
|
|
|
|
|
const Y02_COLUMNS = [
|
|
|
- ["engine_code", "机组"],
|
|
|
+ ["engine_name", "机组"],
|
|
|
["machine_type_code", "机型"],
|
|
|
["mean", "均值"],
|
|
|
["std", "标准差"],
|
|
|
@@ -154,6 +154,42 @@ function findingUnit(alg, unit) {
|
|
|
return text;
|
|
|
}
|
|
|
|
|
|
+/** 后端 project-function 聚合返回的异常线索(result.review_clues 扁平列表)。 */
|
|
|
+export function reviewCluesOf(data) {
|
|
|
+ const clues = data && data.reviewClues;
|
|
|
+ return Array.isArray(clues) ? clues : [];
|
|
|
+}
|
|
|
+
|
|
|
+/** 把算法侧 review_clue 映射到「异常线索与排查建议」表格字段。 */
|
|
|
+export function findingFromClue(clue) {
|
|
|
+ const occurrence = (clue && clue.occurrence) || {};
|
|
|
+ const whenText = occurrence.description
|
|
|
+ || (occurrence.month ? `${occurrence.month}月统计线索` : "");
|
|
|
+ const causes = Array.isArray(clue && clue.possible_causes) ? clue.possible_causes : [];
|
|
|
+ const checks = Array.isArray(clue && clue.first_checks) ? clue.first_checks : [];
|
|
|
+ const metricValue = clue == null ? null : clue.metric_value;
|
|
|
+ const threshold = clue == null ? null : clue.threshold;
|
|
|
+ const unit = (clue && clue.unit) || "";
|
|
|
+ const finding = (clue && clue.finding) || "有情况需要复查";
|
|
|
+ const metricLine = metricValue != null || threshold != null
|
|
|
+ ? `指标值${metricValue == null ? "—" : formatGuide(metricValue)}${unit};判断线${threshold == null ? "—" : formatGuide(threshold)}${unit}`
|
|
|
+ : "";
|
|
|
+ const reviewReason = (clue && clue.review_reason) || "";
|
|
|
+ const evidence = [metricLine, reviewReason, whenText ? `出现时间:${whenText}` : ""]
|
|
|
+ .filter(Boolean)
|
|
|
+ .join(";");
|
|
|
+ const confirmed = !!(clue && clue.confirmed_fault);
|
|
|
+ return {
|
|
|
+ aspect: finding,
|
|
|
+ evidence,
|
|
|
+ cause: causes.join(";"),
|
|
|
+ check: checks.join(";"),
|
|
|
+ timing: confirmed ? "已确认故障" : "立即核对",
|
|
|
+ when: confirmed ? "已确认设备故障,安排登机处理。" : "近期查看趋势和检修记录;仍有偏差,再安排登机。",
|
|
|
+ rank: confirmed ? 0 : 1,
|
|
|
+ };
|
|
|
+}
|
|
|
+
|
|
|
export function conclusionCardOf(data, alg) {
|
|
|
if (!data) return null;
|
|
|
const status = data.status && typeof data.status === "object" ? data.status : {};
|
|
|
@@ -164,6 +200,7 @@ export function conclusionCardOf(data, alg) {
|
|
|
status.source_status,
|
|
|
result.status_label,
|
|
|
result.source_status,
|
|
|
+ result.status,
|
|
|
);
|
|
|
if (alg === "A06" || alg === "A07" || alg === "A21") return ratedConclusionCard(data, alg, statusText, display);
|
|
|
const slope = Number(result.annualized_slope_pct_per_year);
|
|
|
@@ -393,9 +430,307 @@ function filterDatasetChannel(dataset, channelCode) {
|
|
|
return kept;
|
|
|
}
|
|
|
|
|
|
+function isA23Graph(graph) {
|
|
|
+ if (!graph || typeof graph !== "object") return false;
|
|
|
+ if (graph.algorithm_id === "A23") return true;
|
|
|
+ const identity = graph.identity;
|
|
|
+ return !!(identity && (identity.function === "A23" || identity.function_code === "A23"));
|
|
|
+}
|
|
|
+
|
|
|
+/** A23 电气柜温度测点列表(来自 result.channels / tables)。 */
|
|
|
+export function a23ChannelsOf(data) {
|
|
|
+ const channels = [];
|
|
|
+ const push = (row) => {
|
|
|
+ if (!row || typeof row !== "object" || !row.code) return;
|
|
|
+ if (channels.some((item) => item.code === String(row.code))) return;
|
|
|
+ channels.push({
|
|
|
+ code: String(row.code),
|
|
|
+ name: row.name || row.code,
|
|
|
+ cabinet: row.cabinet || "",
|
|
|
+ status: row.status || row.label || "",
|
|
|
+ label: row.name || row.code,
|
|
|
+ explanation: row.label || "",
|
|
|
+ evidence: row.evidence || null,
|
|
|
+ });
|
|
|
+ };
|
|
|
+ const graph = data && (data.graphJson || data.graph);
|
|
|
+ if (graph) {
|
|
|
+ const result = graph.result || graph.algorithm_result;
|
|
|
+ if (result && Array.isArray(result.channels)) result.channels.forEach(push);
|
|
|
+ (graph.tables || []).forEach((table) => {
|
|
|
+ if (table && Array.isArray(table.rows)) table.rows.forEach(push);
|
|
|
+ });
|
|
|
+ }
|
|
|
+ const result = data && data.result;
|
|
|
+ if (result && Array.isArray(result.channels)) result.channels.forEach(push);
|
|
|
+ (data && data.tables ? data.tables : []).forEach((table) => {
|
|
|
+ if (table && Array.isArray(table.rows)) table.rows.forEach(push);
|
|
|
+ });
|
|
|
+ return channels;
|
|
|
+}
|
|
|
+
|
|
|
+/** A23 单个测点的结论快照(平均偏差 / 判断线 / 状态)。 */
|
|
|
+export function a23ChannelSnapshot(data, channelCode) {
|
|
|
+ const empty = { mean: null, threshold: null, status: "" };
|
|
|
+ if (!data || !channelCode) return empty;
|
|
|
+ const channel = a23ChannelsOf(data).find((item) => item.code === String(channelCode));
|
|
|
+ if (!channel) return empty;
|
|
|
+ const ev = channel.evidence || {};
|
|
|
+ const mean = ev.mean != null ? ev.mean : ev.prior_median;
|
|
|
+ return {
|
|
|
+ mean: Number.isFinite(Number(mean)) ? Number(mean) : null,
|
|
|
+ threshold: Number.isFinite(Number(ev.change_threshold)) ? Number(ev.change_threshold) : null,
|
|
|
+ status: channel.status || "",
|
|
|
+ };
|
|
|
+}
|
|
|
+
|
|
|
+/** 按测点过滤 A23 图表。 */
|
|
|
+export function filterChartsByChannel(data, channelCode) {
|
|
|
+ if (!data || !channelCode) return data;
|
|
|
+ const graph = data.graphJson || data.graph;
|
|
|
+ if (!graph || typeof graph !== "object" || !Array.isArray(graph.charts)) return data;
|
|
|
+ const nextGraph = Object.assign({}, graph, {
|
|
|
+ charts: graph.charts.filter((chart) => !chart || String(chart.channel || "") === String(channelCode)),
|
|
|
+ });
|
|
|
+ const copy = Object.assign({}, data);
|
|
|
+ if (data.graphJson) copy.graphJson = nextGraph;
|
|
|
+ if (data.graph) copy.graph = nextGraph;
|
|
|
+ return copy;
|
|
|
+}
|
|
|
+
|
|
|
+function a23BreakGaps(item, maxGapDays) {
|
|
|
+ const data = item && item.data;
|
|
|
+ if (!Array.isArray(data) || data.length < 2) return;
|
|
|
+ const out = [];
|
|
|
+ for (let i = 0; i < data.length; i += 1) {
|
|
|
+ out.push(data[i]);
|
|
|
+ if (i >= data.length - 1) continue;
|
|
|
+ const cur = new Date(data[i][0]);
|
|
|
+ const nxt = new Date(data[i + 1][0]);
|
|
|
+ if (Number.isNaN(cur.getTime()) || Number.isNaN(nxt.getTime())) continue;
|
|
|
+ if ((nxt - cur) / 86400000 <= (maxGapDays || 1.1)) continue;
|
|
|
+ const mid = new Date(cur.getTime() + 86400000);
|
|
|
+ const pad = (value) => String(value).padStart(2, "0");
|
|
|
+ out.push([`${mid.getFullYear()}-${pad(mid.getMonth() + 1)}-${pad(mid.getDate())}`, null]);
|
|
|
+ }
|
|
|
+ item.data = out;
|
|
|
+}
|
|
|
+
|
|
|
+function a23HighlightColor(name) {
|
|
|
+ if (name === "本月偏差") return "#ff8c42";
|
|
|
+ if (/P90|90百分位|90分位/.test(name)) return "#ffd166";
|
|
|
+ return null;
|
|
|
+}
|
|
|
+
|
|
|
+function a23ChartOption(chart) {
|
|
|
+ const rawSeries = Array.isArray(chart.series) ? chart.series : [];
|
|
|
+ const series = rawSeries.map((item, index) => {
|
|
|
+ const name = String(item.name || "");
|
|
|
+ const own = name === "本机";
|
|
|
+ const highlight = a23HighlightColor(name);
|
|
|
+ const color = item.color || highlight || (own ? "#3f79b3" : windColor(index, rawSeries.length));
|
|
|
+ const s = {
|
|
|
+ name: item.name || `序列${index + 1}`,
|
|
|
+ type: "line",
|
|
|
+ data: item.data || [],
|
|
|
+ showSymbol: chart.show_markers !== false,
|
|
|
+ symbol: "circle",
|
|
|
+ symbolSize: own ? 4 : highlight ? 3.5 : 3,
|
|
|
+ connectNulls: chart.connect_nulls !== false,
|
|
|
+ lineStyle: { width: own ? 2.4 : highlight ? 2.2 : 1.4, color },
|
|
|
+ itemStyle: { color },
|
|
|
+ };
|
|
|
+ if (chart.connect_nulls === false) a23BreakGaps(s, chart.max_gap_days);
|
|
|
+ return s;
|
|
|
+ });
|
|
|
+ if (!series.length) return null;
|
|
|
+ const yName = (chart.y_axis && chart.y_axis.unit) || "℃";
|
|
|
+ const xName = (chart.x_axis && chart.x_axis.label) || "日期";
|
|
|
+ return {
|
|
|
+ backgroundColor: "#0c1e36",
|
|
|
+ tooltip: {
|
|
|
+ trigger: "axis",
|
|
|
+ backgroundColor: "rgba(255,255,255,0.96)",
|
|
|
+ borderColor: "#dce5dd",
|
|
|
+ textStyle: { color: "#19392e", fontSize: 12 },
|
|
|
+ },
|
|
|
+ legend: {
|
|
|
+ type: "scroll",
|
|
|
+ bottom: 0,
|
|
|
+ left: "center",
|
|
|
+ textStyle: { color: "#8eabc0", fontSize: 11 },
|
|
|
+ pageIconColor: "#8eafcc",
|
|
|
+ pageTextStyle: { color: "#8eabc0" },
|
|
|
+ },
|
|
|
+ grid: { left: 56, right: 24, top: 36, bottom: 58 },
|
|
|
+ xAxis: {
|
|
|
+ type: "time",
|
|
|
+ name: xName,
|
|
|
+ nameLocation: "middle",
|
|
|
+ nameGap: 28,
|
|
|
+ nameTextStyle: { color: AXIS_TEXT, fontSize: 11 },
|
|
|
+ axisLabel: { color: AXIS_TEXT, fontSize: 11 },
|
|
|
+ axisLine: { lineStyle: { color: AXIS_LINE } },
|
|
|
+ splitLine: { lineStyle: { color: GRID_LINE } },
|
|
|
+ },
|
|
|
+ yAxis: {
|
|
|
+ type: "value",
|
|
|
+ name: yName,
|
|
|
+ scale: true,
|
|
|
+ axisLabel: { color: AXIS_TEXT, fontSize: 11 },
|
|
|
+ splitLine: { lineStyle: { color: GRID_LINE } },
|
|
|
+ },
|
|
|
+ series,
|
|
|
+ };
|
|
|
+}
|
|
|
+
|
|
|
+function a23BarView(chart) {
|
|
|
+ if (!chart || !Array.isArray(chart.data) || !chart.data.length) return null;
|
|
|
+ const categories = chart.data.map((item) => String(item[0]));
|
|
|
+ const values = chart.data.map((item) => (item[1] == null ? null : Number(item[1])));
|
|
|
+ const unit = chart.unit || "个";
|
|
|
+ const color = "#4c8fd6";
|
|
|
+ const barMaxWidth = 18;
|
|
|
+ // 横向柱状图:纵轴为机组(分类),横轴为需复核测点数(数值)。
|
|
|
+ // 按机组数动态定高让柱子更紧凑;数值+单位统一标注在右侧。
|
|
|
+ const height = Math.max(180, categories.length * 36 + 70);
|
|
|
+ return {
|
|
|
+ id: chart.id,
|
|
|
+ title: chart.title || "各机组需复核的柜温测点",
|
|
|
+ height,
|
|
|
+ option: {
|
|
|
+ backgroundColor: "#0c1e36",
|
|
|
+ tooltip: {
|
|
|
+ trigger: "axis",
|
|
|
+ axisPointer: { type: "shadow" },
|
|
|
+ backgroundColor: "rgba(255,255,255,0.96)",
|
|
|
+ borderColor: "#dce5dd",
|
|
|
+ textStyle: { color: "#19392e", fontSize: 12 },
|
|
|
+ valueFormatter: (value) => (value == null ? "" : `${value}${unit}`),
|
|
|
+ },
|
|
|
+ grid: { left: 8, right: 72, top: 24, bottom: 36, containLabel: true },
|
|
|
+ xAxis: {
|
|
|
+ type: "value",
|
|
|
+ min: 0,
|
|
|
+ minInterval: 1,
|
|
|
+ axisLabel: { color: AXIS_TEXT, fontSize: 11 },
|
|
|
+ axisLine: { lineStyle: { color: AXIS_LINE } },
|
|
|
+ splitLine: { lineStyle: { color: GRID_LINE } },
|
|
|
+ },
|
|
|
+ yAxis: {
|
|
|
+ type: "category",
|
|
|
+ data: categories,
|
|
|
+ inverse: true,
|
|
|
+ axisTick: { show: false },
|
|
|
+ axisLabel: { color: AXIS_TEXT, fontSize: 11 },
|
|
|
+ axisLine: { lineStyle: { color: AXIS_LINE } },
|
|
|
+ splitLine: { show: false },
|
|
|
+ },
|
|
|
+ series: [
|
|
|
+ {
|
|
|
+ name: chart.title || "需复核测点",
|
|
|
+ type: "bar",
|
|
|
+ data: values,
|
|
|
+ barMaxWidth,
|
|
|
+ itemStyle: { color, borderRadius: [0, 4, 4, 0] },
|
|
|
+ label: {
|
|
|
+ show: true,
|
|
|
+ position: "right",
|
|
|
+ color: "#d7e9f6",
|
|
|
+ fontSize: 12,
|
|
|
+ fontWeight: 600,
|
|
|
+ formatter: (p) => (p.value == null ? "" : `${p.value}${unit}`),
|
|
|
+ },
|
|
|
+ },
|
|
|
+ ],
|
|
|
+ },
|
|
|
+ };
|
|
|
+}
|
|
|
+
|
|
|
+function a23ChartViews(graph) {
|
|
|
+ const charts = Array.isArray(graph.charts) ? graph.charts : [];
|
|
|
+ return charts
|
|
|
+ .filter((chart) => chart && typeof chart === "object" && !/^matrix$/.test(String(chart.type || "")))
|
|
|
+ .map((chart) => {
|
|
|
+ if (Array.isArray(chart.series) && !/_peers?$/.test(String(chart.id || ""))) {
|
|
|
+ const option = a23ChartOption(chart);
|
|
|
+ if (!option) return null;
|
|
|
+ return { id: chart.id, title: chart.title || chart.id, option };
|
|
|
+ }
|
|
|
+ // 各机组需复核的柜温测点(type=bar)已按需求从页面移除,不再渲染
|
|
|
+ return null;
|
|
|
+ })
|
|
|
+ .filter(Boolean);
|
|
|
+}
|
|
|
+
|
|
|
+/** A23 总览柜温偏差矩阵(来自 cabinet_matrix 图表)。 */
|
|
|
+export function a23MatrixOf(data, modelName) {
|
|
|
+ const graph = data && (data.graphJson || data.graph);
|
|
|
+ const chart = (graph && Array.isArray(graph.charts) ? graph.charts : [])
|
|
|
+ .find((item) => item && item.type === "matrix");
|
|
|
+ if (!chart || !Array.isArray(chart.rows)) return null;
|
|
|
+ const columns = [];
|
|
|
+ const seen = new Set();
|
|
|
+ (chart.columns || []).forEach((code) => {
|
|
|
+ const key = String(code || "");
|
|
|
+ if (!key || seen.has(key)) return;
|
|
|
+ seen.add(key);
|
|
|
+ const cell = chart.rows.reduce(
|
|
|
+ (found, row) => found || (((row && row.cells) || []).find((c) => c && c.channel === code) || null),
|
|
|
+ null,
|
|
|
+ );
|
|
|
+ columns.push({ key, label: (cell && (cell.name || cell.channel)) || key });
|
|
|
+ });
|
|
|
+ const rows = (chart.rows || []).map((row) => {
|
|
|
+ const cells = {};
|
|
|
+ ((row && row.cells) || []).forEach((cell) => {
|
|
|
+ if (!cell) return;
|
|
|
+ cells[String(cell.channel || "")] = {
|
|
|
+ engineCode: row.tid,
|
|
|
+ channelCode: cell.channel,
|
|
|
+ channelName: cell.name || cell.channel,
|
|
|
+ value: cell.value,
|
|
|
+ status: cell.status || cell.label,
|
|
|
+ };
|
|
|
+ });
|
|
|
+ return { engineCode: row.tid, cells };
|
|
|
+ });
|
|
|
+ return { title: `总图 · ${modelName || ""} · 柜温偏差与结果`, columns, rows };
|
|
|
+}
|
|
|
+
|
|
|
+/** 图表的 legend_entries:group_values -> label 的显示名映射。 */
|
|
|
+function legendLabelMap(chart) {
|
|
|
+ const byGroup = {};
|
|
|
+ const byMetric = {};
|
|
|
+ const entries = chart && Array.isArray(chart.legend_entries) ? chart.legend_entries : [];
|
|
|
+ entries.forEach((entry) => {
|
|
|
+ if (!entry || !entry.label) return;
|
|
|
+ const gv = entry.group_values || [];
|
|
|
+ if (gv.length) byGroup[gv.map(String).join("|")] = entry.label;
|
|
|
+ if (gv.length === 1) byGroup[String(gv[0])] = entry.label;
|
|
|
+ if (entry.metric_key) byMetric[String(entry.metric_key)] = entry.label;
|
|
|
+ });
|
|
|
+ return { byGroup, byMetric };
|
|
|
+}
|
|
|
+
|
|
|
+/** 用 legend_entries 的更规范中文 label 替换系列名(优先按 metric_key,其次按 group_values)。 */
|
|
|
+function relabelSeries(option, labelMap) {
|
|
|
+ if (!option || !Array.isArray(option.series)) return option;
|
|
|
+ const byGroup = (labelMap && labelMap.byGroup) || {};
|
|
|
+ const byMetric = (labelMap && labelMap.byMetric) || {};
|
|
|
+ if (!Object.keys(byGroup).length && !Object.keys(byMetric).length) return option;
|
|
|
+ const series = option.series.map((item) => {
|
|
|
+ const name = String(item && item.name != null ? item.name : "");
|
|
|
+ const label = (item && item.metricKey && byMetric[item.metricKey]) || byGroup[name];
|
|
|
+ return label ? Object.assign({}, item, { name: label }) : item;
|
|
|
+ });
|
|
|
+ return Object.assign({}, option, { series });
|
|
|
+}
|
|
|
+
|
|
|
export function chartViewsOf(data) {
|
|
|
const graph = data && (data.graphJson || data.graph);
|
|
|
if (!graph || typeof graph !== "object") return [];
|
|
|
+ if (isA23Graph(graph)) return a23ChartViews(graph);
|
|
|
const wind = windFrequencyView(graph);
|
|
|
if (wind) return [wind];
|
|
|
const datasets = collectDatasets(graph);
|
|
|
@@ -406,18 +741,33 @@ export function chartViewsOf(data) {
|
|
|
const datasetIds = chartDatasetIds(chart);
|
|
|
const datasetId = datasetIds[0] || "";
|
|
|
const dataset = datasetId ? datasets[datasetId] : null;
|
|
|
- const title = chart.title || chart.name || DATASET_TITLES[datasetId] || `总图${index + 1}`;
|
|
|
+ const machineType = data && (data.machineTypeCode || (data.identity && data.identity.machine_type_code));
|
|
|
+ const title = splitScopeTitle(chart.title || chart.name || DATASET_TITLES[datasetId] || `总图${index + 1}`, chart.scope)
|
|
|
+ .replace(/\{machine_type_code\}/g, machineType || "")
|
|
|
+ .replace(/·\s*·/g, "·")
|
|
|
+ .replace(/\s{2,}/g, " ")
|
|
|
+ .trim();
|
|
|
const extras = companionDatasets(datasetId, datasetIds, datasets);
|
|
|
const view = dataset ? buildDatasetChart(datasetId || title, dataset, title, data, extras) : null;
|
|
|
if (view) {
|
|
|
+ // 同一数据集可能被多张图引用(如 A21 的 ambient_summary),用 chart.id/name 保证 key 唯一
|
|
|
+ view.id = chart.id || chart.name || `${view.id}-${index}`;
|
|
|
+ const chartNotes = Array.isArray(chart.notes)
|
|
|
+ ? chart.notes.filter((item) => item != null && item !== "").join("\n")
|
|
|
+ : "";
|
|
|
+ if (chartNotes) {
|
|
|
+ view.note = view.note ? `${view.note}\n${chartNotes}` : chartNotes;
|
|
|
+ }
|
|
|
+ const labelMap = legendLabelMap(chart);
|
|
|
+ if (view.option && (Object.keys(labelMap.byGroup).length || Object.keys(labelMap.byMetric).length)) {
|
|
|
+ view.option = relabelSeries(view.option, labelMap);
|
|
|
+ }
|
|
|
views.push(view);
|
|
|
return;
|
|
|
}
|
|
|
const reason = chartStatusText(chart.reason || chart.message || chart.status || graph.graph_status);
|
|
|
if (reason) {
|
|
|
- views.push({ id: datasetId || `chart-${index}`, title, option: null, reason });
|
|
|
- } else if (dataset && !companionOnly(datasetId)) {
|
|
|
- views.push({ id: datasetId || `chart-${index}`, title, option: null, reason: "图 JSON 里没有可绘制的序列" });
|
|
|
+ views.push({ id: chart.id || chart.name || datasetId || `chart-${index}`, title, option: null, reason });
|
|
|
}
|
|
|
});
|
|
|
}
|
|
|
@@ -459,7 +809,7 @@ function windFrequencyView(graph) {
|
|
|
if (speed > 15) return;
|
|
|
data.push([speed, ((Number(count) || 0) / total) * 100]);
|
|
|
});
|
|
|
- if (data.length) series.push({ name: item.engine_code || `机组${series.length + 1}`, data });
|
|
|
+ if (data.length) series.push({ name: item.engine_name || item.engine_code || `机组${series.length + 1}`, data });
|
|
|
});
|
|
|
if (!series.length) return null;
|
|
|
return {
|
|
|
@@ -600,11 +950,17 @@ function companionOnly(datasetId) {
|
|
|
function chartStatusText(status) {
|
|
|
const text = String(status || "").trim();
|
|
|
if (!text || /^(ok|ready|available|configured|partial)$/i.test(text)) return "";
|
|
|
- if (/no_data|not_provided|empty/i.test(text)) return "图 JSON 里这份数据是空的";
|
|
|
- if (/unavailable/i.test(text)) return "这份图当前不可用";
|
|
|
- if (/not_configured/i.test(text)) return "未配置这张图";
|
|
|
- if (/not_applicable/i.test(text)) return "本功能按配置不设分图。上方保留本机数值与文字结论,项目总览供同机型对比图。";
|
|
|
- return text;
|
|
|
+ return "暂无数据";
|
|
|
+}
|
|
|
+
|
|
|
+/** 算法侧部分图表把总图/分图标题合并成 "总图2 / 分图 · xxx",按 scope 拆开。 */
|
|
|
+export function splitScopeTitle(title, scope) {
|
|
|
+ if (typeof title !== "string" || !title.includes("/")) return title;
|
|
|
+ const parts = title.split("/").map((item) => item.trim()).filter(Boolean);
|
|
|
+ if (parts.length < 2) return title;
|
|
|
+ if (scope === "turbine") return parts[parts.length - 1];
|
|
|
+ const suffix = parts[parts.length - 1].replace(/^分图\s*·\s*/, "");
|
|
|
+ return suffix ? `${parts[0]} · ${suffix}` : parts[0];
|
|
|
}
|
|
|
|
|
|
function chartDatasetId(chart) {
|
|
|
@@ -799,7 +1155,7 @@ function darkLineOption(series, extra) {
|
|
|
color: AXIS_TEXT,
|
|
|
fontSize: 11,
|
|
|
margin: 10,
|
|
|
- rotate: opt.categories && opt.categories.length > 10 ? 35 : 0,
|
|
|
+ interval: "auto",
|
|
|
},
|
|
|
axisLine: { lineStyle: { color: AXIS_LINE } },
|
|
|
splitLine: { show: false },
|
|
|
@@ -940,9 +1296,19 @@ function schemaChart(id, rows, sourceKeys, title, extras) {
|
|
|
return found ? found.rows : [];
|
|
|
};
|
|
|
if (has("p05") && has("p50") && has("p95") && (has("date") || has("month"))) {
|
|
|
- return boxed(id, title, rows, has("date") ? "date" : "month");
|
|
|
+ if (has("sample_count")) {
|
|
|
+ return boxed(id, title, rows, has("date") ? "date" : "month");
|
|
|
+ }
|
|
|
+ // 三叶桨距角极差时序:P50 + P95 折线(V19)
|
|
|
+ return linesOf(id, title, rows, has("date") ? "date" : "month", [
|
|
|
+ ["p50", "日中位数"],
|
|
|
+ ["p95", "日P95", true],
|
|
|
+ ], "日期", "极差 °", null, false);
|
|
|
}
|
|
|
if (has("own_median_deg") && has("project_median_deg") && has("wind_ms")) {
|
|
|
+ if (has("difference_deg") && uniqueValues(rows, engineColumn(rows)).length > 1) {
|
|
|
+ return pitchHeatmap(id, title, rows);
|
|
|
+ }
|
|
|
return pitchLines(id, title, rows);
|
|
|
}
|
|
|
if (has("pitch_deg") && has("wind_ms") && has("power_kw")) {
|
|
|
@@ -1016,7 +1382,7 @@ function schemaChart(id, rows, sourceKeys, title, extras) {
|
|
|
if (has("load_pct") && has("observed_c")) return loadChart(id, title, rows);
|
|
|
if (has("density_per_deg") && has("bin_center_deg")) return yawHist(id, title, rows, extraRows("yaw_distribution_guides"));
|
|
|
if (has("ambient_mean_c") || has("difference_median_c")) return ambientBars(id, title, rows);
|
|
|
- if (has("offset_deg")) return engineBars(id, title, rows, "offset_deg", "偏航角 °", [], yawBandGuides(rows), false);
|
|
|
+ if (has("offset_deg")) return yawStaticOverview(id, title, rows);
|
|
|
if (has("mean_deg") && has("engine_code")) {
|
|
|
return engineBars(id, title, rows, "mean_deg", "均值 °", [
|
|
|
["lower_sigma_deg", "μ-σ"],
|
|
|
@@ -1035,13 +1401,15 @@ function schemaChart(id, rows, sourceKeys, title, extras) {
|
|
|
["negative_limit_ms", "负向门槛"],
|
|
|
], null, false);
|
|
|
}
|
|
|
- if (has("out_of_band_pct")) return engineBars(id, title, rows, "out_of_band_pct", "带外率 %", [["limit_pct", "门槛"]], null, false);
|
|
|
+ if (has("out_of_band_pct")) return engineScatter(id, title, rows, "out_of_band_pct", "带外率 %", [
|
|
|
+ { y: finiteOf(rows, "limit_pct", null), label: "门槛", color: "#d9504f" },
|
|
|
+ ], false);
|
|
|
if (has("peer_difference_pct")) {
|
|
|
- return engineBars(id, title, rows, "peer_difference_pct", "相对偏离 %", [], [
|
|
|
- { y: finiteOf(rows, "zero_reference_pct", 0), label: "零偏离", color: "#9eb6a6" },
|
|
|
+ return engineScatter(id, title, rows, "peer_difference_pct", "相对偏离 %", [
|
|
|
+ { y: finiteOf(rows, "zero_reference_pct", 0), label: "零偏离", color: "#d9504f" },
|
|
|
], false);
|
|
|
}
|
|
|
- if (has("deviation_pct") && has("engine_code") && !has("month") && !has("period") && !has("date")) {
|
|
|
+ if (has("deviation_pct") && (has("engine_code") || has("engine_name")) && !has("month") && !has("period") && !has("date")) {
|
|
|
return metricPoints(id, title, rows);
|
|
|
}
|
|
|
return null;
|
|
|
@@ -1050,14 +1418,14 @@ function schemaChart(id, rows, sourceKeys, title, extras) {
|
|
|
function boxed(id, title, rows, xKey) {
|
|
|
const sorted = rows.slice().sort((a, b) => String(a[xKey]).localeCompare(String(b[xKey])));
|
|
|
const categories = [];
|
|
|
- const data = [];
|
|
|
+ const boxData = [];
|
|
|
sorted.forEach((row) => {
|
|
|
const box = ["p05", "p25", "p50", "p75", "p95"].map((key) => Number(row[key]));
|
|
|
if (box.some((value) => !Number.isFinite(value))) return;
|
|
|
categories.push(row[xKey]);
|
|
|
- data.push(box);
|
|
|
+ boxData.push(box);
|
|
|
});
|
|
|
- if (!data.length) return null;
|
|
|
+ if (!boxData.length) return null;
|
|
|
return {
|
|
|
id,
|
|
|
title,
|
|
|
@@ -1075,7 +1443,15 @@ function boxed(id, title, rows, xKey) {
|
|
|
))).join("<br/>");
|
|
|
},
|
|
|
},
|
|
|
- grid: { left: 64, right: 24, top: 28, bottom: 48 },
|
|
|
+ legend: {
|
|
|
+ bottom: 0,
|
|
|
+ left: 12,
|
|
|
+ itemWidth: 18,
|
|
|
+ itemHeight: 8,
|
|
|
+ textStyle: { color: "#8eabc0", fontSize: 11 },
|
|
|
+ data: ["箱体(P25–P75)与须(P05–P95)"],
|
|
|
+ },
|
|
|
+ grid: { left: 64, right: 24, top: 28, bottom: 58 },
|
|
|
xAxis: {
|
|
|
type: "category",
|
|
|
data: categories,
|
|
|
@@ -1091,13 +1467,100 @@ function boxed(id, title, rows, xKey) {
|
|
|
axisLabel: { color: AXIS_TEXT, fontSize: 11 },
|
|
|
splitLine: { lineStyle: { color: GRID_LINE } },
|
|
|
},
|
|
|
- series: [{ type: "boxplot", data, itemStyle: { color: "#69a9c1", borderColor: "#d7e9f6" } }],
|
|
|
+ series: [
|
|
|
+ {
|
|
|
+ name: "箱体(P25–P75)与须(P05–P95)",
|
|
|
+ type: "boxplot",
|
|
|
+ data: boxData,
|
|
|
+ itemStyle: { color: "#69a9c1", borderColor: "#d7e9f6" },
|
|
|
+ },
|
|
|
+ ],
|
|
|
},
|
|
|
};
|
|
|
}
|
|
|
|
|
|
+function pitchHeatmap(id, title, rows) {
|
|
|
+ const engCol = engineColumn(rows);
|
|
|
+ const binSet = [];
|
|
|
+ rows.forEach((row) => {
|
|
|
+ const w = Math.floor(Number(row.wind_ms));
|
|
|
+ if (!binSet.includes(w)) binSet.push(w);
|
|
|
+ });
|
|
|
+ binSet.sort((a, b) => a - b);
|
|
|
+ const yCats = uniqueValues(rows, engCol);
|
|
|
+ const rawMap = new Map();
|
|
|
+ const data = [];
|
|
|
+ yCats.forEach((name, ri) => {
|
|
|
+ binSet.forEach((w, ci) => {
|
|
|
+ const row = rows.find((r) => String(r[engCol]) === name && Math.floor(Number(r.wind_ms)) === w);
|
|
|
+ const v = row && Number.isFinite(Number(row.difference_deg)) ? Number(row.difference_deg) : null;
|
|
|
+ const key = `${ci},${ri}`;
|
|
|
+ rawMap.set(key, v);
|
|
|
+ if (v == null) {
|
|
|
+ data.push({ value: [ci, ri, 0], itemStyle: { color: "#16283a" } });
|
|
|
+ } else {
|
|
|
+ data.push([ci, ri, v]);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ });
|
|
|
+ const fmt = (p) => {
|
|
|
+ const key = `${p.value[0]},${p.value[1]}`;
|
|
|
+ const v = rawMap.get(key);
|
|
|
+ return v == null ? "—" : (v >= 0 ? "+" : "") + Number(v).toFixed(1);
|
|
|
+ };
|
|
|
+ return {
|
|
|
+ id,
|
|
|
+ title,
|
|
|
+ height: Math.max(300, yCats.length * 26 + 90),
|
|
|
+ option: {
|
|
|
+ backgroundColor: "#0c1e36",
|
|
|
+ grid: { left: 96, right: 16, top: 46, bottom: 46 },
|
|
|
+ tooltip: {
|
|
|
+ backgroundColor: "rgba(255,255,255,0.96)",
|
|
|
+ borderColor: "#dce5dd",
|
|
|
+ textStyle: { color: "#19392e", fontSize: 12 },
|
|
|
+ formatter: (p) => {
|
|
|
+ const key = `${p.value[0]},${p.value[1]}`;
|
|
|
+ const v = rawMap.get(key);
|
|
|
+ return `${p.value[1]} ${binSet[p.value[0]]}–${binSet[p.value[0]] + 1}m/s<br/>差 ${v == null ? "—" : Number(v).toFixed(1)}°`;
|
|
|
+ },
|
|
|
+ },
|
|
|
+ xAxis: { type: "category", data: binSet.map((w) => `${w}–${w + 1}`), position: "top", splitArea: { show: true }, axisLabel: { color: "#9ebad0", fontSize: 10 } },
|
|
|
+ yAxis: { type: "category", data: yCats, inverse: true, splitArea: { show: true }, axisLabel: { color: "#9ebad0", fontSize: 10 } },
|
|
|
+ visualMap: {
|
|
|
+ min: -3.4,
|
|
|
+ max: 3.4,
|
|
|
+ calculable: false,
|
|
|
+ orient: "horizontal",
|
|
|
+ left: "center",
|
|
|
+ bottom: 0,
|
|
|
+ text: ["高于全项目中位", "低于全项目中位"],
|
|
|
+ textStyle: { color: "#9ebad0", fontSize: 11 },
|
|
|
+ inRange: { color: ["#2f6bd8", "#0c1e36", "#d9504f"] },
|
|
|
+ },
|
|
|
+ series: [
|
|
|
+ {
|
|
|
+ type: "heatmap",
|
|
|
+ data,
|
|
|
+ label: { show: true, fontSize: 9, color: "#eef7ff", formatter: fmt },
|
|
|
+ itemStyle: { borderColor: "#0c1e36", borderWidth: 1 },
|
|
|
+ },
|
|
|
+ ],
|
|
|
+ },
|
|
|
+ note: `风速段 m/s · 差值 ° 蓝:低于全项目中位;红:高于全项目中位;灰:该箱样本不足。颜色范围 ±3.4°,色彩仅表示方向和幅度,不是新增告警门。`,
|
|
|
+ };
|
|
|
+}
|
|
|
+
|
|
|
+function pitchHeatColor(v, maxAbs) {
|
|
|
+ if (v == null) return "#edf0ed";
|
|
|
+ const q = Math.min(1, Math.abs(v) / maxAbs);
|
|
|
+ if (v >= 0) return `rgb(${Math.round(245 - 66 * q)},${Math.round(245 - 155 * q)},${Math.round(245 - 148 * q)})`;
|
|
|
+ return `rgb(${Math.round(245 - 177 * q)},${Math.round(245 - 121 * q)},${Math.round(245 - 63 * q)})`;
|
|
|
+}
|
|
|
+
|
|
|
function pitchLines(id, title, rows) {
|
|
|
- const engines = uniqueValues(rows, "engine_code");
|
|
|
+ const engCol = engineColumn(rows);
|
|
|
+ const engines = uniqueValues(rows, engCol);
|
|
|
if (engines.length <= 1) {
|
|
|
return linesOf(id, title, rows, "wind_ms", [
|
|
|
["own_median_deg", "本机中位数"],
|
|
|
@@ -1105,7 +1568,7 @@ function pitchLines(id, title, rows) {
|
|
|
], "风速 m/s", "桨距角 °", null, false);
|
|
|
}
|
|
|
const series = engines.map((engine, index) => pairSeries(
|
|
|
- rows.filter((row) => String(row.engine_code) === engine),
|
|
|
+ rows.filter((row) => String(row[engCol]) === engine),
|
|
|
"wind_ms",
|
|
|
"own_median_deg",
|
|
|
engine,
|
|
|
@@ -1394,7 +1857,7 @@ function seriesEngine(row, label) {
|
|
|
if (row.series_engine_code) return String(row.series_engine_code);
|
|
|
const parts = String(label || "").split("|");
|
|
|
if (parts.length > 1) return parts.slice(0, -1).join("|");
|
|
|
- return String(row.engine_code || label || "");
|
|
|
+ return String(row.engine_name || row.engine_code || label || "");
|
|
|
}
|
|
|
|
|
|
function roleChart(id, title, rows, xKey, yKey, xName, yName, guide) {
|
|
|
@@ -1403,7 +1866,7 @@ function roleChart(id, title, rows, xKey, yKey, xName, yName, guide) {
|
|
|
if (highlightOwn) {
|
|
|
rows.forEach((row) => {
|
|
|
if (String(row.role || row.series_role || "").toLowerCase() !== "own") return;
|
|
|
- ownEngines.add(String(row.engine_code || row.series_engine_code || ""));
|
|
|
+ ownEngines.add(String(row.engine_name || row.engine_code || row.series_engine_code || ""));
|
|
|
});
|
|
|
}
|
|
|
const groups = new Map();
|
|
|
@@ -1412,7 +1875,8 @@ function roleChart(id, title, rows, xKey, yKey, xName, yName, guide) {
|
|
|
const y = Number(row[yKey]);
|
|
|
if (!Number.isFinite(x) || !Number.isFinite(y)) return;
|
|
|
const role = String(row.role || row.series_role || "").toLowerCase();
|
|
|
- const label = row.series_id || row.series_engine_code || row.engine_code || row.month || "序列";
|
|
|
+ if (!highlightOwn && role === "peer") return; // 总图不展示同型参考
|
|
|
+ const label = row.series_id || row.series_engine_code || row.engine_name || row.engine_code || row.month || "序列";
|
|
|
let key = String(label);
|
|
|
let name = String(label);
|
|
|
let dash = false;
|
|
|
@@ -1431,7 +1895,7 @@ function roleChart(id, title, rows, xKey, yKey, xName, yName, guide) {
|
|
|
name = String(row.month || label);
|
|
|
type = "scatter";
|
|
|
} else if (highlightOwn && role === "own") {
|
|
|
- const engine = String(row.engine_code || row.series_engine_code || label);
|
|
|
+ const engine = String(row.engine_name || row.engine_code || row.series_engine_code || label);
|
|
|
key = `own:${engine}`;
|
|
|
name = engine;
|
|
|
color = "#3f79b3";
|
|
|
@@ -1518,6 +1982,35 @@ function pairSeries(rows, xKey, yKey, name, index) {
|
|
|
return { name, data, color: index == null ? "#9ccbbd" : windColor(index, 6) };
|
|
|
}
|
|
|
|
|
|
+/** 数据不连贯(日期/月份有缺口)处插入 null,让折线断开、只保留散点 */
|
|
|
+function breakLineGaps(item) {
|
|
|
+ const data = item && item.data;
|
|
|
+ if (!Array.isArray(data) || data.length < 2) return;
|
|
|
+ const isMonth = String(data[0][0]).length === 7;
|
|
|
+ const sorted = data.slice().sort((a, b) => String(a[0]).localeCompare(String(b[0])));
|
|
|
+ const out = [];
|
|
|
+ for (let i = 0; i < sorted.length; i += 1) {
|
|
|
+ out.push(sorted[i]);
|
|
|
+ if (i < sorted.length - 1) {
|
|
|
+ const cur = new Date(isMonth ? `${sorted[i][0]}-01` : sorted[i][0]);
|
|
|
+ const nxt = new Date(isMonth ? `${sorted[i + 1][0]}-01` : sorted[i + 1][0]);
|
|
|
+ if (Number.isNaN(cur.getTime()) || Number.isNaN(nxt.getTime())) continue;
|
|
|
+ const step = isMonth
|
|
|
+ ? (nxt.getFullYear() - cur.getFullYear()) * 12 + (nxt.getMonth() - cur.getMonth())
|
|
|
+ : Math.round((nxt - cur) / 86400000);
|
|
|
+ if (step > 1) {
|
|
|
+ const gap = new Date(cur.getTime());
|
|
|
+ if (isMonth) gap.setMonth(gap.getMonth() + 1);
|
|
|
+ else gap.setDate(gap.getDate() + 1);
|
|
|
+ const y = gap.getFullYear();
|
|
|
+ const m = String(gap.getMonth() + 1).padStart(2, "0");
|
|
|
+ out.push([isMonth ? `${y}-${m}` : `${y}-${m}-${String(gap.getDate()).padStart(2, "0")}`, null]);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ item.data = out;
|
|
|
+}
|
|
|
+
|
|
|
function historyLines(id, title, rows, extras) {
|
|
|
const bundles = [{ id, rows }].concat((extras || []).filter((item) => (
|
|
|
item && item.rows && item.rows.some((row) => (
|
|
|
@@ -1551,6 +2044,7 @@ function historyLines(id, title, rows, extras) {
|
|
|
const yName = valueFields.find(([key]) => bundles.some((bundle) => columnHasNumber(bundle.rows, key)));
|
|
|
const residual = yName && yName[0] === "residual_c";
|
|
|
const series = [];
|
|
|
+ const guides = [];
|
|
|
bundles.forEach((bundle) => {
|
|
|
const bundleName = bundle.id === id
|
|
|
? (bundles.length > 1 && id === "daily_difference" ? "日温差" : "")
|
|
|
@@ -1562,6 +2056,7 @@ function historyLines(id, title, rows, extras) {
|
|
|
const groupName = residual && groups.length > 1 ? windowRoleLabel(group.name) : group.name;
|
|
|
const item = pairSeries(group.rows, xKey, key, historyName(bundleName, residual ? groupName : group.name, valueLabel));
|
|
|
if (!item) return;
|
|
|
+ item.metricKey = key;
|
|
|
if (label === "EWMA") {
|
|
|
item.dash = true;
|
|
|
item.color = "#c29345";
|
|
|
@@ -1572,16 +2067,28 @@ function historyLines(id, title, rows, extras) {
|
|
|
limitFields.forEach(([key, label]) => {
|
|
|
const limitLabel = residual && key === "threshold_c" ? "偏热判断线" : label;
|
|
|
const groupName = residual && groups.length > 1 ? windowRoleLabel(group.name) : group.name;
|
|
|
+ const constVal = constantLimit(group.rows, key);
|
|
|
+ if (constVal != null) {
|
|
|
+ guides.push({ y: constVal, label: `${limitLabel} ${formatGuide(constVal)}`, color: residual && key === "threshold_c" ? "#d08a3a" : "#e07070" });
|
|
|
+ return;
|
|
|
+ }
|
|
|
const item = pairSeries(group.rows, xKey, key, historyName(bundleName, residual ? groupName : group.name, limitLabel));
|
|
|
if (!item) return;
|
|
|
+ item.metricKey = key;
|
|
|
item.dash = true;
|
|
|
item.color = residual && key === "threshold_c" ? "#d08a3a" : "#e07070";
|
|
|
+ item.limit = true;
|
|
|
series.push(item);
|
|
|
});
|
|
|
});
|
|
|
});
|
|
|
if (!series.length) return null;
|
|
|
- const guides = [];
|
|
|
+ series.forEach((item) => {
|
|
|
+ if (item.limit) return;
|
|
|
+ item.showSymbol = true;
|
|
|
+ item.symbolSize = 4;
|
|
|
+ breakLineGaps(item);
|
|
|
+ });
|
|
|
bundles.forEach((bundle) => {
|
|
|
if (columnHasNumber(bundle.rows, "zero_c")) {
|
|
|
guides.push({ y: finiteOf(bundle.rows, "zero_c", 0), label: residual ? "零偏差" : "零残差", color: "#9eb6a6" });
|
|
|
@@ -1615,7 +2122,6 @@ function ambientKind(bundleId) {
|
|
|
}
|
|
|
|
|
|
function isAmbientHistory(id, title, bundles) {
|
|
|
- if (/历史变化与判定阈值/.test(`${id} ${title || ""}`)) return true;
|
|
|
const kinds = bundles.map((bundle) => ambientKind(bundle.id));
|
|
|
return kinds.includes("daily") && kinds.includes("daynight");
|
|
|
}
|
|
|
@@ -1644,6 +2150,7 @@ function ambientHistoryChart(id, title, bundles, xKey) {
|
|
|
line.width = 1.6;
|
|
|
line.showSymbol = true;
|
|
|
line.symbolSize = 4;
|
|
|
+ breakLineGaps(line);
|
|
|
series.push(line);
|
|
|
}
|
|
|
[
|
|
|
@@ -1795,6 +2302,18 @@ function yawHist(id, title, rows, guides) {
|
|
|
}
|
|
|
const series = [bars, normal].filter(Boolean);
|
|
|
if (!series.length) return null;
|
|
|
+ const degs = rows
|
|
|
+ .filter((row) => Number(row.density_per_deg) > 0)
|
|
|
+ .map((row) => Number(row.bin_center_deg));
|
|
|
+ let xMin = null;
|
|
|
+ let xMax = null;
|
|
|
+ if (degs.length) {
|
|
|
+ const lo = Math.min(...degs, 0);
|
|
|
+ const hi = Math.max(...degs, 0);
|
|
|
+ const pad = Math.max(2, (hi - lo) * 0.25);
|
|
|
+ xMin = lo - pad;
|
|
|
+ xMax = hi + pad;
|
|
|
+ }
|
|
|
const guide = [];
|
|
|
const row = (guides || [])[0] || {};
|
|
|
[
|
|
|
@@ -1809,7 +2328,7 @@ function yawHist(id, title, rows, guides) {
|
|
|
return {
|
|
|
id,
|
|
|
title,
|
|
|
- option: darkLineOption(series, { xName: "偏航角 °", yName: "密度 1/°", guide }),
|
|
|
+ option: darkLineOption(series, { xName: "偏航角 °", yName: "密度 1/°", guide, xMin, xMax }),
|
|
|
note,
|
|
|
};
|
|
|
}
|
|
|
@@ -1880,10 +2399,49 @@ function yawBandGuides(rows) {
|
|
|
];
|
|
|
}
|
|
|
|
|
|
+/** 静态偏航误差总图:按 abs_offset_band 分档着色(<3° 绿 / 3-5° 黄 / ≥5° 红)。 */
|
|
|
+function yawStaticOverview(id, title, rows) {
|
|
|
+ const engCol = engineColumn(rows);
|
|
|
+ const names = uniqueValues(rows, engCol);
|
|
|
+ if (!names.length) return null;
|
|
|
+ const rowOf = (name) => rows.find((item) => String(item[engCol]) === name);
|
|
|
+ const bands = [
|
|
|
+ ["<3", "偏航角 < 3°", "#288c50"],
|
|
|
+ ["3-5", "3° ≤ 偏航角 < 5°", "#c8a014"],
|
|
|
+ [">=5", "偏航角 ≥ 5°", "#c83c3c"],
|
|
|
+ ];
|
|
|
+ const series = [];
|
|
|
+ bands.forEach(([band, label, color]) => {
|
|
|
+ const data = names.map((name) => {
|
|
|
+ const row = rowOf(name);
|
|
|
+ if (String(row && row.abs_offset_band || "") !== band) return null;
|
|
|
+ const v = Number(row && row.offset_deg);
|
|
|
+ return Number.isFinite(v) ? v : null;
|
|
|
+ });
|
|
|
+ if (data.some((value) => value != null)) {
|
|
|
+ series.push({ name: label, type: "bar", barMaxWidth: 18, color, data });
|
|
|
+ }
|
|
|
+ });
|
|
|
+ if (!series.length) return null;
|
|
|
+ return {
|
|
|
+ id,
|
|
|
+ title,
|
|
|
+ option: darkLineOption(series, {
|
|
|
+ category: true,
|
|
|
+ categories: names,
|
|
|
+ boundaryGap: true,
|
|
|
+ xName: "机组",
|
|
|
+ yName: "偏航角 °",
|
|
|
+ guide: yawBandGuides(rows),
|
|
|
+ }),
|
|
|
+ };
|
|
|
+}
|
|
|
+
|
|
|
function metricPoints(id, title, rows) {
|
|
|
- const names = uniqueValues(rows, "engine_code");
|
|
|
+ const engCol = engineColumn(rows);
|
|
|
+ const names = uniqueValues(rows, engCol);
|
|
|
if (!names.length) return null;
|
|
|
- const rowOf = (name) => rows.find((item) => String(item.engine_code) === name);
|
|
|
+ const rowOf = (name) => rows.find((item) => String(item[engCol]) === name);
|
|
|
const pick = (row, keys) => {
|
|
|
const key = keys.find((item) => row && Number.isFinite(Number(row[item])));
|
|
|
return key ? Number(row[key]) : null;
|
|
|
@@ -1963,10 +2521,57 @@ function finiteOrNull(value) {
|
|
|
return Number.isFinite(number) ? number : null;
|
|
|
}
|
|
|
|
|
|
+function engineScatter(id, title, rows, yKey, yName, guide, yScale) {
|
|
|
+ const engCol = engineColumn(rows);
|
|
|
+ const names = uniqueValues(rows, engCol);
|
|
|
+ if (!names.length) return null;
|
|
|
+ const rowOf = (name) => rows.find((item) => String(item[engCol]) === name);
|
|
|
+ const values = names.map((name) => {
|
|
|
+ const row = rowOf(name);
|
|
|
+ return finiteOrNull(row && row[yKey]);
|
|
|
+ });
|
|
|
+ if (!values.some((value) => Number.isFinite(value))) return null;
|
|
|
+ const series = [{
|
|
|
+ name: yName,
|
|
|
+ type: "scatter",
|
|
|
+ symbol: "circle",
|
|
|
+ symbolSize: 8,
|
|
|
+ color: "#4c8fd6",
|
|
|
+ z: 4,
|
|
|
+ data: values,
|
|
|
+ }];
|
|
|
+ (guide || []).forEach((item) => {
|
|
|
+ if (!item || !Number.isFinite(Number(item.y))) return;
|
|
|
+ series.push({
|
|
|
+ name: item.label || "参考线",
|
|
|
+ type: "line",
|
|
|
+ color: item.color || "#d9504f",
|
|
|
+ width: 1.8,
|
|
|
+ z: 2,
|
|
|
+ dash: true,
|
|
|
+ showSymbol: false,
|
|
|
+ data: names.map(() => item.y),
|
|
|
+ });
|
|
|
+ });
|
|
|
+ return {
|
|
|
+ id,
|
|
|
+ title,
|
|
|
+ option: darkLineOption(series, {
|
|
|
+ category: true,
|
|
|
+ categories: names,
|
|
|
+ boundaryGap: true,
|
|
|
+ xName: "机组",
|
|
|
+ yName,
|
|
|
+ yScale: !!yScale,
|
|
|
+ }),
|
|
|
+ };
|
|
|
+}
|
|
|
+
|
|
|
function engineBars(id, title, rows, yKey, yName, limits, guide, yScale) {
|
|
|
- const names = uniqueValues(rows, "engine_code");
|
|
|
+ const engCol = engineColumn(rows);
|
|
|
+ const names = uniqueValues(rows, engCol);
|
|
|
if (!names.length) return null;
|
|
|
- const rowOf = (name) => rows.find((item) => String(item.engine_code) === name);
|
|
|
+ const rowOf = (name) => rows.find((item) => String(item[engCol]) === name);
|
|
|
const values = names.map((name) => {
|
|
|
const row = rowOf(name);
|
|
|
return finiteOrNull(row && row[yKey]);
|
|
|
@@ -2028,6 +2633,11 @@ function uniqueValues(rows, key) {
|
|
|
return names;
|
|
|
}
|
|
|
|
|
|
+/** 机组分组列:优先 engine_name,缺省回退 engine_code */
|
|
|
+function engineColumn(rows) {
|
|
|
+ return uniqueValues(rows, "engine_name").length ? "engine_name" : "engine_code";
|
|
|
+}
|
|
|
+
|
|
|
function dedupeRows(rows, xKey) {
|
|
|
const seen = new Set();
|
|
|
return rows.filter((row) => {
|
|
|
@@ -2039,7 +2649,7 @@ function dedupeRows(rows, xKey) {
|
|
|
}
|
|
|
|
|
|
function splitGroups(rows) {
|
|
|
- const key = ["channel_code", "engine_code", "window_role", "period_role"].find((name) => uniqueValues(rows, name).length > 1);
|
|
|
+ const key = ["channel_code", "engine_name", "engine_code", "window_role"].find((name) => uniqueValues(rows, name).length > 1);
|
|
|
if (!key) return [{ name: "", rows }];
|
|
|
return uniqueValues(rows, key).map((name) => ({
|
|
|
name,
|