|
@@ -2,7 +2,13 @@
|
|
|
<div>
|
|
|
<div class="FD">
|
|
|
<div v-if="TZshow" class="eigenvalue">
|
|
|
- <h5>特征值</h5>
|
|
|
+ <el-checkbox
|
|
|
+ v-for="(item, index) in checkList"
|
|
|
+ :key="index"
|
|
|
+ v-model="checked[index]"
|
|
|
+ >{{ item.val }}</el-checkbox
|
|
|
+ >
|
|
|
+ <!-- <h5>特征值</h5>
|
|
|
<p>有效值:{{ this.spectrumList.Xrms }}</p>
|
|
|
<p>平均值:{{ this.spectrumList.mean_value }}</p>
|
|
|
<p>最大值:{{ this.spectrumList.max_value }}</p>
|
|
@@ -13,7 +19,7 @@
|
|
|
<p>脉冲指标:{{ this.spectrumList.If }}</p>
|
|
|
<p>裕度指标:{{ this.spectrumList.Ce }}</p>
|
|
|
<p>偏度指标:{{ this.spectrumList.Cw }}</p>
|
|
|
- <p>峭度指标:{{ this.spectrumList.Cq }}</p>
|
|
|
+ <p>峭度指标:{{ this.spectrumList.Cq }}</p> -->
|
|
|
</div>
|
|
|
</div>
|
|
|
<!-- ECharts 图表容器 -->
|
|
@@ -49,7 +55,6 @@ export default {
|
|
|
type: Object,
|
|
|
default: () => ({}),
|
|
|
},
|
|
|
-
|
|
|
windCode: {
|
|
|
type: String,
|
|
|
default: "",
|
|
@@ -61,6 +66,8 @@ export default {
|
|
|
option: null,
|
|
|
TZshow: false,
|
|
|
spectrumList: {},
|
|
|
+ checkList: [{ val: "BPFI" }, { val: "BPFO" }, { val: "BPO" }, { val: "FT" }],
|
|
|
+ checked:""
|
|
|
};
|
|
|
},
|
|
|
watch: {
|
|
@@ -77,7 +84,6 @@ export default {
|
|
|
this.updateChart(this.spectrumList.y, this.spectrumList.x); // 更新图表
|
|
|
}
|
|
|
},
|
|
|
- // 监听 spectrumList 的变化
|
|
|
spectrumList: {
|
|
|
handler(newValue) {
|
|
|
if (this.chartInstance) {
|
|
@@ -92,7 +98,7 @@ export default {
|
|
|
setTimeout(() => {
|
|
|
this.initializeChart(); // 延迟2秒后调用
|
|
|
this.getTime();
|
|
|
- }, 2000); // 2000毫秒,即2秒
|
|
|
+ }, 500); // 500毫秒,即0.5秒
|
|
|
});
|
|
|
},
|
|
|
|
|
@@ -100,12 +106,12 @@ export default {
|
|
|
initializeChart() {
|
|
|
const chartDom = this.$refs.chart;
|
|
|
if (chartDom && !this.chartInstance) {
|
|
|
- this.chartInstance = echarts.init(chartDom); // Initialize chart only once
|
|
|
+ this.chartInstance = echarts.init(chartDom); // 仅初始化一次
|
|
|
}
|
|
|
|
|
|
- // Update the chart with the initial data if available
|
|
|
+ // 使用 $nextTick 确保数据更新后再渲染图表
|
|
|
this.$nextTick(() => {
|
|
|
- if (this.chartInstance) {
|
|
|
+ if (this.chartInstance && this.spectrumList.y && this.spectrumList.x) {
|
|
|
this.updateChart(this.spectrumList.y, this.spectrumList.x); // 更新图表
|
|
|
}
|
|
|
});
|
|
@@ -113,27 +119,20 @@ export default {
|
|
|
|
|
|
// 更新图表数据
|
|
|
updateChart(data, labels) {
|
|
|
- if (!this.chartInstance || !labels || !data) return; // Check if chartInstance, labels, or data are not available
|
|
|
+ if (!this.chartInstance || !labels || !data) return; // 确保数据存在
|
|
|
|
|
|
- // Ensure labels is an array
|
|
|
+ // 确保 labels 是数组
|
|
|
if (!Array.isArray(labels)) {
|
|
|
console.error("Labels are not an array");
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
- // Ensure data and labels have the same length
|
|
|
+ // 确保 data 和 labels 长度一致
|
|
|
if (labels.length !== data.length) {
|
|
|
console.error("Data and labels length mismatch");
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
- const maxX = Math.max(...labels);
|
|
|
- const maxAxisValue = Math.ceil(maxX / 5) * 5;
|
|
|
- const ticks = [];
|
|
|
- for (let i = 0; i <= maxAxisValue; i += 5) {
|
|
|
- ticks.push(i);
|
|
|
- }
|
|
|
-
|
|
|
const option = {
|
|
|
title: {
|
|
|
text: this.spectrumList.title,
|
|
@@ -159,109 +158,109 @@ export default {
|
|
|
myCustomTool3: {
|
|
|
show: true,
|
|
|
title: "特征值",
|
|
|
- icon: `image://${require("@/assets/analyse/10.png")}`,
|
|
|
+ icon: `image://${require("@/assets/analyse/11.png")}`,
|
|
|
onclick: () => this.Show(),
|
|
|
},
|
|
|
},
|
|
|
},
|
|
|
xAxis: {
|
|
|
- type: "value", // Use numeric x-axis
|
|
|
- name: this.spectrumList.xaxis, // Set X-axis title
|
|
|
- nameLocation: "center", // Title position
|
|
|
+ type: "value",
|
|
|
+ name: this.spectrumList.xaxis,
|
|
|
+ nameLocation: "center",
|
|
|
nameTextStyle: {
|
|
|
fontSize: 14,
|
|
|
- color: "#333", // Title color
|
|
|
- padding: [10, 0, 0, 0], // Padding for title
|
|
|
+ color: "#333",
|
|
|
+ padding: [10, 0, 0, 0],
|
|
|
},
|
|
|
axisLabel: {
|
|
|
- formatter: (value) => {
|
|
|
- return value; // Show values without formatting
|
|
|
- },
|
|
|
+ formatter: (value) => value,
|
|
|
},
|
|
|
axisTick: {
|
|
|
- show: true, // Show tick marks
|
|
|
+ show: true,
|
|
|
},
|
|
|
axisLine: {
|
|
|
- show: true, // Show axis line
|
|
|
+ show: true,
|
|
|
},
|
|
|
- data: ticks, // Set tick values
|
|
|
},
|
|
|
-
|
|
|
yAxis: {
|
|
|
- type: "value", // Y-axis type as numeric
|
|
|
- name: this.spectrumList.yaxis, // Set Y-axis title
|
|
|
+ type: "value",
|
|
|
+ name: this.spectrumList.yaxis,
|
|
|
nameTextStyle: {
|
|
|
fontSize: 14,
|
|
|
- color: "#333", // Title color
|
|
|
- padding: [10, 0, 0, 0], // Padding for title
|
|
|
+ color: "#333",
|
|
|
+ padding: [10, 0, 0, 0],
|
|
|
},
|
|
|
axisLabel: {
|
|
|
- formatter: (value) => {
|
|
|
- return value; // Show values without formatting
|
|
|
- },
|
|
|
+ formatter: (value) => value,
|
|
|
},
|
|
|
axisTick: {
|
|
|
- show: true, // Show tick marks
|
|
|
+ show: true,
|
|
|
},
|
|
|
axisLine: {
|
|
|
- show: true, // Show axis line
|
|
|
+ show: true,
|
|
|
},
|
|
|
},
|
|
|
-
|
|
|
tooltip: {
|
|
|
trigger: "axis",
|
|
|
formatter: (params) => {
|
|
|
- const xValue = params[0].value[0]; // Get x value
|
|
|
- const yValue = params[0].value[1]; // Get y value
|
|
|
+ const xValue = params[0].value[0];
|
|
|
+ const yValue = params[0].value[1];
|
|
|
return `X: ${xValue}<br/>Y: ${yValue}`;
|
|
|
},
|
|
|
axisPointer: {
|
|
|
- type: "line", // Crosshair line
|
|
|
+ type: "line",
|
|
|
},
|
|
|
},
|
|
|
-
|
|
|
+ dataZoom: [
|
|
|
+ {
|
|
|
+ type: "inside", // 内置型数据区域缩放组件
|
|
|
+ start: 0,
|
|
|
+ end: 10, // 初始显示前 10% 的数据
|
|
|
+ },
|
|
|
+ {
|
|
|
+ type: "slider", // 滑动条型数据区域缩放组件
|
|
|
+ start: 0,
|
|
|
+ end: 10, // 初始显示前 10% 的数据
|
|
|
+ handleSize: "80%", // 控制手柄大小
|
|
|
+ showDataShadow: false, // 不显示数据阴影
|
|
|
+ },
|
|
|
+ ],
|
|
|
series: [
|
|
|
{
|
|
|
name: "数据系列",
|
|
|
- type: "line", // Line chart
|
|
|
- data: labels.map((item, index) => [item, data[index]]), // Map x, y values
|
|
|
- symbol: "none", // No symbols at data points
|
|
|
- symbolSize: 8, // Set data point size
|
|
|
+ type: "line",
|
|
|
+ data: labels.map((item, index) => [item, data[index]]),
|
|
|
+ symbol: "none",
|
|
|
+ symbolSize: 8,
|
|
|
lineStyle: {
|
|
|
- color: "#162961",
|
|
|
- width: 1, // Line width
|
|
|
+ color: "#162961",
|
|
|
+ width: 1,
|
|
|
},
|
|
|
itemStyle: {
|
|
|
- color: "#162961",
|
|
|
+ color: "#162961",
|
|
|
borderColor: "#fff",
|
|
|
borderWidth: 1,
|
|
|
},
|
|
|
+ large: true, // 开启大数据量优化
|
|
|
+ progressive: 2000, // 渐进式渲染,每 2000 个数据点渲染一次
|
|
|
},
|
|
|
],
|
|
|
};
|
|
|
|
|
|
- this.chartInstance.setOption(option); // Update the chart with the new option
|
|
|
+ this.chartInstance.setOption(option);
|
|
|
},
|
|
|
|
|
|
getTime() {
|
|
|
this.$emit("handleLoading", null, true, this.activeIndex);
|
|
|
const params = {
|
|
|
ids: this.ids,
|
|
|
- // windCode: "SKF001",
|
|
|
windCode: this.windCode,
|
|
|
analysisType: "frequency",
|
|
|
};
|
|
|
axios
|
|
|
.post("/WJapi/analysis/frequency", params)
|
|
|
.then((res) => {
|
|
|
- const parsedData = JSON.parse(res.data);
|
|
|
- // 使用 $set 或者扩展运算符确保 Vue 检测到变化
|
|
|
- this.spectrumList = { ...parsedData }; // 或者 this.$set(this, 'spectrumList', parsedData);
|
|
|
- this.$nextTick(() => {
|
|
|
- if (this.chartInstance) {
|
|
|
- this.updateChart(this.spectrumList.y, this.spectrumList.x); // 更新图表
|
|
|
- }
|
|
|
- });
|
|
|
+ this.spectrumList = JSON.parse(res.data);
|
|
|
})
|
|
|
.catch((error) => {
|
|
|
console.error(error);
|
|
@@ -275,17 +274,16 @@ export default {
|
|
|
this.$emit("update-previous-row", 2, this.activeIndex);
|
|
|
},
|
|
|
|
|
|
- // 触发下一条
|
|
|
nextRow() {
|
|
|
this.$emit("update-next-row", 2, this.activeIndex);
|
|
|
},
|
|
|
+
|
|
|
Show() {
|
|
|
this.TZshow = !this.TZshow;
|
|
|
},
|
|
|
},
|
|
|
};
|
|
|
</script>
|
|
|
-
|
|
|
<style lang="scss" scoped>
|
|
|
.line-chart {
|
|
|
width: 100%;
|