|
|
@@ -3,11 +3,13 @@
|
|
|
<div :id="`chart-${inds}`" style="width: 100%; height: 450px"></div>
|
|
|
</div>
|
|
|
</template>
|
|
|
+
|
|
|
<script>
|
|
|
import { nextTick } from "vue"; // 导入 nextTick
|
|
|
import { allTypesDatas } from "@/utils/allTypesOfAnalysisData.js";
|
|
|
import Plotly from "plotly.js-dist";
|
|
|
import axios from "axios";
|
|
|
+
|
|
|
export default {
|
|
|
props: {
|
|
|
inds: {
|
|
|
@@ -30,14 +32,13 @@ export default {
|
|
|
x: [],
|
|
|
y: [],
|
|
|
type: "heatmap",
|
|
|
- colorscale: "Viridis", //分钟scads
|
|
|
colorscale: [
|
|
|
- [0, "#FCFED4"], // 0% - 50%,保持 "#FCFED4"
|
|
|
- [0.5, "#FCFED4"], // 50%,结束 "#FCFED4"
|
|
|
- [0.5, "#5BA8BF"], // 50%-85%,开始 "#C4E4B9"
|
|
|
- [0.85, "#5BA8BF"], // 85%,结束 "#C4E4B9"
|
|
|
- [0.85, "#18276E"], // 85%-100%,开始 "#5BA8BF"
|
|
|
- [1, "#18276E"], // 100%,结束 "#5BA8BF"
|
|
|
+ [0, "#FCFED4"], // 0% - 50%
|
|
|
+ [0.5, "#FCFED4"], // 50%
|
|
|
+ [0.5, "#5BA8BF"], // 50% - 85%
|
|
|
+ [0.85, "#5BA8BF"], // 85%
|
|
|
+ [0.85, "#18276E"], // 85% - 100%
|
|
|
+ [1, "#18276E"], // 100%
|
|
|
],
|
|
|
showscale: true, // 显示色带(可选)
|
|
|
hoverongaps: false,
|
|
|
@@ -46,7 +47,6 @@ export default {
|
|
|
};
|
|
|
},
|
|
|
mounted() {
|
|
|
- // this.getData();
|
|
|
if (this.fileAddr) {
|
|
|
this.getData();
|
|
|
}
|
|
|
@@ -66,11 +66,9 @@ export default {
|
|
|
this.initData[0].x = this.chartData.data[0].xData;
|
|
|
this.initData[0].y = this.chartData.data[0].yData;
|
|
|
this.initData[0].z = this.chartData.data[0].ZData;
|
|
|
- // 使用 nextTick 来确保 DOM 渲染完成后绘制图表
|
|
|
+
|
|
|
nextTick(() => {
|
|
|
this.initcharts();
|
|
|
- // this.isError = false;
|
|
|
- // this.loading = false;
|
|
|
});
|
|
|
} catch (error) {
|
|
|
console.error("Error loading data:", error);
|
|
|
@@ -79,97 +77,50 @@ export default {
|
|
|
}
|
|
|
}
|
|
|
},
|
|
|
- initcharts() {
|
|
|
- const lineDatas = allTypesDatas.filter(
|
|
|
- (item) =>
|
|
|
- item.analysisTypeCode === "data_integrity_second" ||
|
|
|
- item.analysisTypeCode === "data_integrity_minute"
|
|
|
- )[0];
|
|
|
|
|
|
- // 生成 annotations 数据
|
|
|
+ initcharts() {
|
|
|
+ // 使用统一的颜色范围
|
|
|
+ const trace = {
|
|
|
+ type: "heatmap",
|
|
|
+ x: this.initData[0].x,
|
|
|
+ y: this.initData[0].y,
|
|
|
+ z: this.initData[0].z,
|
|
|
+ colorscale: this.initData[0].colorscale, // 使用新的颜色范围
|
|
|
+ text: this.initData[0].z.map((row) =>
|
|
|
+ row.map((value) => value.toString())
|
|
|
+ ),
|
|
|
+ hoverinfo: "text", // Hover时显示文本
|
|
|
+ showscale: true, // 显示颜色条
|
|
|
+ texttemplate: "%{text}", // 在热图块上显示z值
|
|
|
+ xgap: 2, // 设置水平方向格子之间的间距
|
|
|
+ ygap: 2, // 设置垂直方向格子之间的间距
|
|
|
+ };
|
|
|
|
|
|
const layout = {
|
|
|
- ...lineDatas.lableConfig,
|
|
|
showlegend: false,
|
|
|
- shapes: this.createShapesBorder(
|
|
|
- this.initData[0].y.length,
|
|
|
- this.initData[0].x.length + 1,
|
|
|
- 1,
|
|
|
- "white",
|
|
|
- 0
|
|
|
- ),
|
|
|
- // annotations: this.createAnnotations(this.initData[0].z),
|
|
|
- margin: {
|
|
|
- l: 100,
|
|
|
- r: 100,
|
|
|
- t: 100,
|
|
|
- b: 100,
|
|
|
- },
|
|
|
autosize: true,
|
|
|
- yaxis: {
|
|
|
- type: "category",
|
|
|
- tickvals: this.initData[0].y, // 确保 Y 轴的值和你的数据匹配
|
|
|
- ticktext: this.initData[0].y,
|
|
|
- showticks: false,
|
|
|
- showgrid: true,
|
|
|
- showline: false, // 隐藏 y 轴的轴线
|
|
|
- },
|
|
|
xaxis: {
|
|
|
+ title: this.chartData.xaixs,
|
|
|
tickvals: this.initData[0].x,
|
|
|
ticktext: this.initData[0].x,
|
|
|
- showticks: false,
|
|
|
- showgrid: true,
|
|
|
- showline: false, // 隐藏 y 轴的轴线
|
|
|
+ tickmode: "array",
|
|
|
},
|
|
|
- plot_bgcolor: "white", // 背景颜色设置为白色,确保背景和网格线一致
|
|
|
+ yaxis: {
|
|
|
+ tickmode: "array",
|
|
|
+ title: this.chartData.yaixs,
|
|
|
+ tickvals: this.initData[0].y,
|
|
|
+ ticktext: this.initData[0].y,
|
|
|
+ },
|
|
|
+ plot_bgcolor: "white",
|
|
|
gridcolor: "#d3d3d3", // 设置网格线颜色
|
|
|
};
|
|
|
- Plotly.newPlot(`chart-${this.inds}`, this.initData, layout, {
|
|
|
+
|
|
|
+ Plotly.newPlot(`chart-${this.inds}`, [trace], layout, {
|
|
|
responsive: true,
|
|
|
});
|
|
|
},
|
|
|
- createAnnotations(zData) {
|
|
|
- const annotations = [];
|
|
|
- for (let row = 0; row < zData.length; row++) {
|
|
|
- for (let col = 0; col < zData[row].length; col++) {
|
|
|
- if (!isNaN(zData[row][col])) {
|
|
|
- // 确保值不是 NaN
|
|
|
- annotations.push({
|
|
|
- x: this.initData[0].x[col],
|
|
|
- y: this.initData[0].y[row],
|
|
|
- text: zData[row][col].toString(),
|
|
|
- showarrow: false,
|
|
|
- font: {
|
|
|
- size: 10,
|
|
|
- color: "black",
|
|
|
- },
|
|
|
- align: "center",
|
|
|
- });
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- return annotations;
|
|
|
- },
|
|
|
- createShapesBorder(rows, cols, borderWidth, borderColor, offset) {
|
|
|
- var shapes = [];
|
|
|
- for (var row = 0; row < rows; row++) {
|
|
|
- for (var col = 0; col < cols; col++) {
|
|
|
- shapes.push({
|
|
|
- type: "rect",
|
|
|
- x0: col - 0.5 + offset,
|
|
|
- x1: col + 0.5 + offset,
|
|
|
- y0: row - 0.5 + offset,
|
|
|
- y1: row + 0.5 + offset,
|
|
|
- line: {
|
|
|
- color: borderColor,
|
|
|
- width: borderWidth,
|
|
|
- },
|
|
|
- });
|
|
|
- }
|
|
|
- }
|
|
|
- return shapes;
|
|
|
- },
|
|
|
},
|
|
|
};
|
|
|
</script>
|
|
|
+
|
|
|
<style scoped></style>
|