|
@@ -1,48 +1,18 @@
|
|
|
<template>
|
|
|
<div>
|
|
|
<div class="FD">
|
|
|
- <div v-if="TZshow" class="eigenvalue">
|
|
|
- <el-checkbox-group v-model="checkedCheckList">
|
|
|
- <el-checkbox
|
|
|
- v-for="(item, index) in checkList"
|
|
|
- :key="index"
|
|
|
- :label="item.val"
|
|
|
- >
|
|
|
- {{ item.val }}
|
|
|
- </el-checkbox>
|
|
|
- </el-checkbox-group>
|
|
|
- <!-- <h5>特征值</h5>
|
|
|
- <p>有效值:{{ this.spectrumList.Xrms }}</p>
|
|
|
- <p>平均值:{{ this.spectrumList.mean_value }}</p>
|
|
|
- <p>最大值:{{ this.spectrumList.max_value }}</p>
|
|
|
- <p>最小值:{{ this.spectrumList.min_value }}</p>
|
|
|
- <p>峰值:{{ this.spectrumList.Xp }}</p>
|
|
|
- <p>峰峰值:{{ this.spectrumList.Xpp }}</p>
|
|
|
- <p>波形因子:{{ this.spectrumList.Sf }}</p>
|
|
|
- <p>脉冲指标:{{ this.spectrumList.If }}</p>
|
|
|
- <p>裕度指标:{{ this.spectrumList.Ce }}</p>
|
|
|
- <p>偏度指标:{{ this.spectrumList.Cw }}</p>
|
|
|
- <p>峭度指标:{{ this.spectrumList.Cq }}</p> -->
|
|
|
- </div>
|
|
|
-
|
|
|
+ <!-- 光标 -->
|
|
|
<div v-if="BGshow" class="eigenvalue">
|
|
|
<el-checkbox-group v-model="checkedGB">
|
|
|
- <el-checkbox
|
|
|
- v-for="(item, index) in GBcheckList"
|
|
|
- :key="index"
|
|
|
- :label="item.val"
|
|
|
- >
|
|
|
+ <el-checkbox v-for="(item, index) in GBcheckList" :key="index" :label="item.val">
|
|
|
{{ item.val }}
|
|
|
</el-checkbox>
|
|
|
</el-checkbox-group>
|
|
|
</div>
|
|
|
+ <!-- 特征值 -->
|
|
|
<div v-if="PXshow" class="eigenvalue">
|
|
|
- <el-checkbox-group v-model="checkedValues">
|
|
|
- <el-checkbox
|
|
|
- v-for="(item, index) in PXcheckList"
|
|
|
- :key="index"
|
|
|
- :label="item.val"
|
|
|
- >
|
|
|
+ <el-checkbox-group v-model="checkedValues" @change="handleCheckChange">
|
|
|
+ <el-checkbox v-for="(item, index) in PXcheckList" :key="index" :label="item.val">
|
|
|
{{ item.val }}
|
|
|
</el-checkbox>
|
|
|
</el-checkbox-group>
|
|
@@ -57,7 +27,6 @@
|
|
|
<script>
|
|
|
import axios from "axios";
|
|
|
import * as echarts from "echarts"; // 导入 echarts 库
|
|
|
-import { e } from "plotly.js-dist";
|
|
|
|
|
|
export default {
|
|
|
name: "TimedomainCharts", // 组件名称
|
|
@@ -95,12 +64,7 @@ export default {
|
|
|
BGshow: false,
|
|
|
PXshow: false,
|
|
|
spectrumList: {},
|
|
|
- checkList: [
|
|
|
- { val: "BPFI" },
|
|
|
- { val: "BPFO" },
|
|
|
- { val: "BPO" },
|
|
|
- { val: "FT" },
|
|
|
- ],
|
|
|
+
|
|
|
GBcheckList: [
|
|
|
{ val: "添加光标" },
|
|
|
{ val: "谐波光标" },
|
|
@@ -108,29 +72,25 @@ export default {
|
|
|
{ val: "移动峰值" },
|
|
|
],
|
|
|
PXcheckList: [
|
|
|
- { val: "Fr" },
|
|
|
- { val: "BPFI" },
|
|
|
- { val: "BPFO" },
|
|
|
- { val: "FT" },
|
|
|
- { val: "GMF" },
|
|
|
- { val: "±5Fr" },
|
|
|
+ { val: "Fr", checked: false },
|
|
|
+ { val: "BPFI", checked: false },
|
|
|
+ { val: "BPFO", checked: false },
|
|
|
+ { val: "BSF", checked: false },
|
|
|
+ { val: "FTF", checked: false },
|
|
|
+ { val: "3P", checked: false },
|
|
|
],
|
|
|
+ Fr: [],
|
|
|
+ BPFI: [],
|
|
|
+ BPFO: [],
|
|
|
+ BSF: [],
|
|
|
+ FTF: [],
|
|
|
+ B3P: [],
|
|
|
|
|
|
checkedGB: [],
|
|
|
- checkedCheckList: [],
|
|
|
checkedValues: [],
|
|
|
};
|
|
|
},
|
|
|
watch: {
|
|
|
- checkedGB(newValues) {
|
|
|
- console.log("当前选中的复选框值:", newValues);
|
|
|
- },
|
|
|
- checkedCheckList(newValues) {
|
|
|
- console.log("当前选中的复选框值:", newValues);
|
|
|
- },
|
|
|
- checkedValues(newValues) {
|
|
|
- console.log("当前选中的复选框值:", newValues);
|
|
|
- },
|
|
|
// 监听 chartData 和 chartLabels 的变化,重新绘制图表
|
|
|
chartData(newData) {
|
|
|
this.updateChart(newData, this.chartLabels);
|
|
@@ -146,6 +106,8 @@ export default {
|
|
|
},
|
|
|
spectrumList: {
|
|
|
handler(newValue) {
|
|
|
+ if (!newValue) return;
|
|
|
+ console.log(newValue, "newValue");
|
|
|
if (this.chartInstance) {
|
|
|
this.updateChart(newValue.y, newValue.x); // 只在 chartInstance 初始化后更新图表
|
|
|
}
|
|
@@ -154,6 +116,7 @@ export default {
|
|
|
},
|
|
|
},
|
|
|
mounted() {
|
|
|
+
|
|
|
this.$nextTick(() => {
|
|
|
setTimeout(() => {
|
|
|
this.initializeChart(); // 延迟2秒后调用
|
|
@@ -179,25 +142,54 @@ export default {
|
|
|
|
|
|
// 更新图表数据
|
|
|
updateChart(data, labels) {
|
|
|
- if (!this.chartInstance || !labels || !data) return; // 确保数据存在
|
|
|
-
|
|
|
- // 确保 labels 是数组
|
|
|
- if (!Array.isArray(labels)) {
|
|
|
- console.error("Labels are not an array");
|
|
|
+ if (
|
|
|
+ !this.chartInstance ||
|
|
|
+ !Array.isArray(labels) ||
|
|
|
+ !Array.isArray(data) ||
|
|
|
+ labels.length !== data.length
|
|
|
+ ) {
|
|
|
+ console.error("Invalid data or labels");
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
- // 确保 data 和 labels 长度一致
|
|
|
- if (labels.length !== data.length) {
|
|
|
- console.error("Data and labels length mismatch");
|
|
|
- return;
|
|
|
- }
|
|
|
+ const createMarkLine = (dataSource, color) => ({
|
|
|
+ type: "line",
|
|
|
+ markLine: {
|
|
|
+ silent: false,
|
|
|
+ lineStyle: { color, type: "solid", width: 2 },
|
|
|
+ symbol: ["arrow", "none"],
|
|
|
+ label: {
|
|
|
+ show: true,
|
|
|
+ position: "end",
|
|
|
+ formatter: ({ data }) => data.val,
|
|
|
+ },
|
|
|
+ emphasis: {
|
|
|
+ lineStyle: { color: "#FF6A00", width: 4 },
|
|
|
+ label: {
|
|
|
+ show: true,
|
|
|
+ formatter: ({ value }) => `特征值: ${value}`,
|
|
|
+ color: "#000",
|
|
|
+ backgroundColor: "#FFF",
|
|
|
+ padding: [2, 4],
|
|
|
+ borderRadius: 3,
|
|
|
+ fontSize: 12,
|
|
|
+ },
|
|
|
+ },
|
|
|
+ data: dataSource.map(({ Xaxis, val }) => ({ xAxis: Xaxis, val })),
|
|
|
+ },
|
|
|
+ });
|
|
|
+
|
|
|
+ const markLines = [
|
|
|
+ { data: this.Fr, color: "#A633FF" },
|
|
|
+ { data: this.BPFI, color: "#23357e" },
|
|
|
+ { data: this.BPFO, color: "#42a0ae" },
|
|
|
+ { data: this.BSF, color: "#008080" },
|
|
|
+ { data: this.FTF, color: "#af254f" },
|
|
|
+ { data: this.B3P, color: "#FFD700" },
|
|
|
+ ].map(({ data, color }) => createMarkLine(data, color));
|
|
|
|
|
|
const option = {
|
|
|
- title: {
|
|
|
- text: this.spectrumList.title,
|
|
|
- left: "center",
|
|
|
- },
|
|
|
+ title: { text: this.spectrumList.title, left: "center" },
|
|
|
toolbox: {
|
|
|
feature: {
|
|
|
dataZoom: { yAxisIndex: "none" },
|
|
@@ -215,12 +207,6 @@ export default {
|
|
|
icon: `image://${require("@/assets/analyse/09.png")}`,
|
|
|
onclick: () => this.nextRow(),
|
|
|
},
|
|
|
- myCustomTool3: {
|
|
|
- show: true,
|
|
|
- title: "齿轮特征值",
|
|
|
- icon: `image://${require("@/assets/analyse/11.png")}`,
|
|
|
- onclick: () => this.Show("1"),
|
|
|
- },
|
|
|
myCustomTool4: {
|
|
|
show: true,
|
|
|
title: "光标",
|
|
@@ -244,15 +230,6 @@ export default {
|
|
|
color: "#333",
|
|
|
padding: [10, 0, 0, 0],
|
|
|
},
|
|
|
- axisLabel: {
|
|
|
- formatter: (value) => value,
|
|
|
- },
|
|
|
- axisTick: {
|
|
|
- show: true,
|
|
|
- },
|
|
|
- axisLine: {
|
|
|
- show: true,
|
|
|
- },
|
|
|
},
|
|
|
yAxis: {
|
|
|
type: "value",
|
|
@@ -262,66 +239,128 @@ export default {
|
|
|
color: "#333",
|
|
|
padding: [10, 0, 0, 0],
|
|
|
},
|
|
|
- axisLabel: {
|
|
|
- formatter: (value) => value,
|
|
|
- },
|
|
|
- axisTick: {
|
|
|
- show: true,
|
|
|
- },
|
|
|
- axisLine: {
|
|
|
- show: true,
|
|
|
- },
|
|
|
},
|
|
|
tooltip: {
|
|
|
trigger: "axis",
|
|
|
- formatter: (params) => {
|
|
|
- const xValue = params[0].value[0];
|
|
|
- const yValue = params[0].value[1];
|
|
|
- return `X: ${xValue}<br/>Y: ${yValue}`;
|
|
|
- },
|
|
|
- axisPointer: {
|
|
|
- type: "line",
|
|
|
- },
|
|
|
+ formatter: ([
|
|
|
+ {
|
|
|
+ value: [x, y],
|
|
|
+ },
|
|
|
+ ]) => `X: ${x}<br/>Y: ${y}`,
|
|
|
+ axisPointer: { type: "line" },
|
|
|
},
|
|
|
dataZoom: [
|
|
|
+ { type: "inside", start: 0, end: 10 },
|
|
|
{
|
|
|
- type: "inside", // 内置型数据区域缩放组件
|
|
|
+ type: "slider",
|
|
|
start: 0,
|
|
|
- end: 10, // 初始显示前 10% 的数据
|
|
|
- },
|
|
|
- {
|
|
|
- type: "slider", // 滑动条型数据区域缩放组件
|
|
|
- start: 0,
|
|
|
- end: 10, // 初始显示前 10% 的数据
|
|
|
- handleSize: "80%", // 控制手柄大小
|
|
|
- showDataShadow: false, // 不显示数据阴影
|
|
|
+ end: 10,
|
|
|
+ handleSize: "80%",
|
|
|
+ showDataShadow: false,
|
|
|
},
|
|
|
],
|
|
|
series: [
|
|
|
{
|
|
|
name: "数据系列",
|
|
|
type: "line",
|
|
|
- data: labels.map((item, index) => [item, data[index]]),
|
|
|
+ data: labels.map((x, i) => [x, data[i]]),
|
|
|
symbol: "none",
|
|
|
- symbolSize: 8,
|
|
|
- lineStyle: {
|
|
|
- color: "#162961",
|
|
|
- width: 1,
|
|
|
- },
|
|
|
+ lineStyle: { color: "#162961", width: 1 },
|
|
|
itemStyle: {
|
|
|
color: "#162961",
|
|
|
borderColor: "#fff",
|
|
|
borderWidth: 1,
|
|
|
},
|
|
|
- large: true, // 开启大数据量优化
|
|
|
- progressive: 2000, // 渐进式渲染,每 2000 个数据点渲染一次
|
|
|
+ large: true,
|
|
|
+ progressive: 2000,
|
|
|
},
|
|
|
+ ...markLines,
|
|
|
],
|
|
|
};
|
|
|
|
|
|
this.chartInstance.setOption(option);
|
|
|
},
|
|
|
|
|
|
+ handleCheckChange() {
|
|
|
+ this.PXcheckList.forEach((item) => {
|
|
|
+ item.checked = this.checkedValues.includes(item.val);
|
|
|
+ });
|
|
|
+
|
|
|
+ // 构建新的特征频率数据
|
|
|
+ const newFeatureLines = {
|
|
|
+ Fr: this.checkedValues.includes("Fr") ? this.spectrumList.fn_Gen : [],
|
|
|
+ BPFI: this.checkedValues.includes("BPFI") ? this.spectrumList.BPFI : [],
|
|
|
+ BPFO: this.checkedValues.includes("BPFO") ? this.spectrumList.BPFO : [],
|
|
|
+ BSF: this.checkedValues.includes("BSF") ? this.spectrumList.BSF : [],
|
|
|
+ FTF: this.checkedValues.includes("FTF") ? this.spectrumList.FTF : [],
|
|
|
+ B3P: this.checkedValues.includes("3P")
|
|
|
+ ? Array.isArray(this.spectrumList.B3P)
|
|
|
+ ? this.spectrumList.B3P
|
|
|
+ : [{ Xaxis: this.spectrumList.B3P, val: "3P" }]
|
|
|
+ : [],
|
|
|
+ };
|
|
|
+
|
|
|
+ // 仅更新 `series`,避免重新渲染整个 ECharts 组件
|
|
|
+ if (this.chartInstance) {
|
|
|
+ this.chartInstance.setOption(
|
|
|
+ {
|
|
|
+ series: this.generateSeries(newFeatureLines),
|
|
|
+ },
|
|
|
+ { replaceMerge: ["series"] }
|
|
|
+ );
|
|
|
+ }
|
|
|
+ },
|
|
|
+
|
|
|
+ generateSeries(featureLines) {
|
|
|
+ const createMarkLine = (dataSource, color) => ({
|
|
|
+ type: "line",
|
|
|
+ markLine: {
|
|
|
+ silent: false,
|
|
|
+ lineStyle: { color, type: "dashed", width:1 },
|
|
|
+ symbol: ["arrow", "none"],
|
|
|
+ label: {
|
|
|
+ show: true,
|
|
|
+ position: "end",
|
|
|
+ formatter: ({ data }) => data.val,
|
|
|
+ },
|
|
|
+ emphasis: {
|
|
|
+ lineStyle: { color: "#FF6A00", width: 2 },
|
|
|
+ label: {
|
|
|
+ show: true,
|
|
|
+ formatter: ({ value }) => `特征值: ${value}`,
|
|
|
+ color: "#000",
|
|
|
+ },
|
|
|
+ },
|
|
|
+ data: dataSource.map(({ Xaxis, val }) => ({ xAxis: Xaxis, val })),
|
|
|
+ },
|
|
|
+ });
|
|
|
+
|
|
|
+ const markLines = [
|
|
|
+ { data: featureLines.Fr, color: "#A633FF" },
|
|
|
+ { data: featureLines.BPFI, color: "#23357e" },
|
|
|
+ { data: featureLines.BPFO, color: "#42a0ae" },
|
|
|
+ { data: featureLines.BSF, color: "#008080" },
|
|
|
+ { data: featureLines.FTF, color: "#af254f" },
|
|
|
+ { data: featureLines.B3P, color: "#FFD700" },
|
|
|
+ ].map(({ data, color }) => createMarkLine(data, color));
|
|
|
+
|
|
|
+ return [
|
|
|
+ {
|
|
|
+ name: "数据系列",
|
|
|
+ type: "line",
|
|
|
+ data: this.spectrumList.x.map((x, i) => [x, this.spectrumList.y[i]]),
|
|
|
+ symbol: "none",
|
|
|
+ lineStyle: { color: "#162961", width: 1 },
|
|
|
+ itemStyle: { color: "#162961", borderColor: "#fff", borderWidth: 1 },
|
|
|
+ large: true,
|
|
|
+ },
|
|
|
+ ...markLines,
|
|
|
+ ];
|
|
|
+ },
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
getTime() {
|
|
|
this.$emit("handleLoading", null, true, this.activeIndex);
|
|
|
const params = {
|
|
@@ -332,7 +371,40 @@ export default {
|
|
|
axios
|
|
|
.post("/WJapi/analysis/frequency", params)
|
|
|
.then((res) => {
|
|
|
- this.spectrumList = JSON.parse(res.data);
|
|
|
+ console.log(res, "频谱图数据");
|
|
|
+ this.spectrumList = { ...JSON.parse(res.data) };
|
|
|
+ console.log(this.spectrumList, "频谱图数据1");
|
|
|
+ const XrmsValue = this.spectrumList?.Xrms;
|
|
|
+ // 通过 $emit 传递 XrmsValue 给父组件
|
|
|
+ this.$emit("updateXrms", XrmsValue);
|
|
|
+ this.PXcheckList.forEach((item) => {
|
|
|
+ if (item.checked) {
|
|
|
+ switch (item.val) {
|
|
|
+ case "Fr":
|
|
|
+ this.Fr = this.spectrumList.fn_Gen;
|
|
|
+ break;
|
|
|
+ case "BPFI":
|
|
|
+ this.BPFI = this.spectrumList.BPFI;
|
|
|
+ break;
|
|
|
+ case "BPFO":
|
|
|
+ this.BPFO = this.spectrumList.BPFO;
|
|
|
+ break;
|
|
|
+ case "BSF":
|
|
|
+ this.BSF = this.spectrumList.BSF;
|
|
|
+ break;
|
|
|
+ case "FTF":
|
|
|
+ this.FTF = this.spectrumList.FTF;
|
|
|
+ break;
|
|
|
+ case "3P":
|
|
|
+ this.B3P = Array.isArray(this.spectrumList.B3P)
|
|
|
+ ? this.spectrumList.B3P
|
|
|
+ : [{ Xaxis: this.spectrumList.B3P, val: "3P" }];
|
|
|
+ break;
|
|
|
+ default:
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
})
|
|
|
.catch((error) => {
|
|
|
console.error(error);
|
|
@@ -364,6 +436,57 @@ export default {
|
|
|
this.PXshow = value === "3" ? !this.PXshow : false;
|
|
|
}
|
|
|
},
|
|
|
+
|
|
|
+ // handleCheckChange() {
|
|
|
+ // this.PXcheckList.forEach((item) => {
|
|
|
+ // // 如果 `checkedValues` 里有这个项,则 checked=true,否则 checked=false
|
|
|
+ // item.checked = this.checkedValues.includes(item.val);
|
|
|
+ // });
|
|
|
+
|
|
|
+ // // 重置数据数组
|
|
|
+ // this.Fr = [];
|
|
|
+ // this.BPFI = [];
|
|
|
+ // this.BPFO = [];
|
|
|
+ // this.BSF = [];
|
|
|
+ // this.FTF = [];
|
|
|
+ // this.B3P = [];
|
|
|
+
|
|
|
+ // // 找到刚刚被点击的项
|
|
|
+ // const changedItem = this.PXcheckList.find(
|
|
|
+ // (item) => !this.checkedValues.includes(item.val) !== item.checked
|
|
|
+ // );
|
|
|
+
|
|
|
+ // if (changedItem) {
|
|
|
+ // console.log("当前点击项:", changedItem);
|
|
|
+ // // 根据选中状态赋值
|
|
|
+ // if (this.checkedValues.includes("Fr")) {
|
|
|
+ // this.Fr = this.spectrumList.fn_Gen;
|
|
|
+ // }
|
|
|
+ // if (this.checkedValues.includes("BPFI")) {
|
|
|
+ // this.BPFI = this.spectrumList.BPFI;
|
|
|
+ // }
|
|
|
+ // if (this.checkedValues.includes("BPFO")) {
|
|
|
+ // this.BPFO = this.spectrumList.BPFO;
|
|
|
+ // }
|
|
|
+ // if (this.checkedValues.includes("BSF")) {
|
|
|
+ // this.BSF = this.spectrumList.BSF;
|
|
|
+ // }
|
|
|
+ // if (this.checkedValues.includes("FTF")) {
|
|
|
+ // this.FTF = this.spectrumList.FTF;
|
|
|
+ // }
|
|
|
+ // if (this.checkedValues.includes("3P")) {
|
|
|
+ // this.B3P = Array.isArray(this.spectrumList.B3P)
|
|
|
+ // ? this.spectrumList.B3P
|
|
|
+ // : [{ Xaxis: this.spectrumList.B3P, val: "3P" }];
|
|
|
+ // }
|
|
|
+ // // 更新 ECharts 图表数据
|
|
|
+ // if (this.chartInstance) {
|
|
|
+ // this.updateChart(this.spectrumList.y, this.spectrumList.x);
|
|
|
+ // }
|
|
|
+ // }
|
|
|
+ // },
|
|
|
+
|
|
|
+
|
|
|
},
|
|
|
};
|
|
|
</script>
|
|
@@ -372,6 +495,7 @@ export default {
|
|
|
width: 100%;
|
|
|
height: 280px;
|
|
|
}
|
|
|
+
|
|
|
.FD {
|
|
|
width: 100%;
|
|
|
height: 1px;
|
|
@@ -388,6 +512,7 @@ export default {
|
|
|
padding: 5px;
|
|
|
background: #fff;
|
|
|
z-index: 99;
|
|
|
+
|
|
|
h5 {
|
|
|
line-height: 16px;
|
|
|
height: 16px;
|