Commit 3e0db5e7 authored by xinzhedeai's avatar xinzhedeai

add:水位图阴影效果 multiple 优化rev

parent 180e7a34
...@@ -291,9 +291,9 @@ export default { ...@@ -291,9 +291,9 @@ export default {
return; return;
} }
console.log("剖面接口数据", data); // console.log("剖面接口数据", data);
console.table(JSON.parse(JSON.stringify(data[0].jrxStepsDtoList))); // console.table(JSON.parse(JSON.stringify(data[0].jrxStepsDtoList)));
console.table(JSON.parse(JSON.stringify(data[0].equipmentDataList))); // console.table(JSON.parse(JSON.stringify(data[0].equipmentDataList)));
await this.handleCanvasData(data); await this.handleCanvasData(data);
this.initCanvas(); this.initCanvas();
...@@ -381,16 +381,16 @@ export default { ...@@ -381,16 +381,16 @@ export default {
}); });
}); });
console.log("坡面处理完毕数据", this.canvasDataReal); // console.log("坡面处理完毕数据", this.canvasDataReal);
console.table( // console.table(
JSON.parse(JSON.stringify(this.canvasDataReal.poConfigs)) // JSON.parse(JSON.stringify(this.canvasDataReal.poConfigs))
); // );
console.table( // console.table(
JSON.parse(JSON.stringify(this.canvasDataReal.guanConfigs)) // JSON.parse(JSON.stringify(this.canvasDataReal.guanConfigs))
); // );
console.table( // console.table(
JSON.parse(JSON.stringify(this.canvasDataReal.lineConfigs)) // JSON.parse(JSON.stringify(this.canvasDataReal.lineConfigs))
); // );
resolve(); // 数据处理完成后触发resolve resolve(); // 数据处理完成后触发resolve
}); });
...@@ -403,7 +403,7 @@ export default { ...@@ -403,7 +403,7 @@ export default {
console.error("Canvas 元素未找到"); console.error("Canvas 元素未找到");
return; return;
} }
console.log(this.canvas, "canvas"); // console.log(this.canvas, "canvas");
this.ctx = this.canvas.getContext("2d"); this.ctx = this.canvas.getContext("2d");
// 坐标系变换:将原点移至左下角(默认原点在左上角) // 坐标系变换:将原点移至左下角(默认原点在左上角)
...@@ -477,18 +477,18 @@ export default { ...@@ -477,18 +477,18 @@ export default {
}, },
// 绘制water.png(独立方法) // 绘制water.png(独立方法)
drawWaterImage() { // drawWaterImage() {
this.ctx.save(); // this.ctx.save();
this.ctx.setTransform(1, 0, 0, 1, 0, 0); // this.ctx.setTransform(1, 0, 0, 1, 0, 0);
this.ctx.drawImage( // this.ctx.drawImage(
this.waterImage, // this.waterImage,
0, // 0,
this.canvas.height - 255, // this.canvas.height - 255,
485, // 485,
255 // 255
); // );
this.ctx.restore(); // this.ctx.restore();
}, // },
// 重构后的统一绘制入口(通过配置驱动) // 重构后的统一绘制入口(通过配置驱动)
drawAllImages() { drawAllImages() {
...@@ -496,13 +496,13 @@ export default { ...@@ -496,13 +496,13 @@ export default {
this.drawBackground(); this.drawBackground();
// 2. 绘制po.png(遍历配置数组) // 2. 绘制po.png(遍历配置数组)
console.log(this.canvasDataReal.poConfigs, "poConfigs"); // console.log(this.canvasDataReal.poConfigs, "poConfigs");
this.canvasDataReal.poConfigs.forEach((config, index) => { this.canvasDataReal.poConfigs.forEach((config, index) => {
this.drawPoImage(config); this.drawPoImage(config);
}); });
// 3. 绘制guan.png(遍历配置数组) // 3. 绘制guan.png(遍历配置数组)
console.log(this.canvasDataReal.guanConfigs, "guanConfigs"); // console.log(this.canvasDataReal.guanConfigs, "guanConfigs");
this.canvasDataReal.guanConfigs.forEach((config, index) => { this.canvasDataReal.guanConfigs.forEach((config, index) => {
this.drawGuanImage(config); this.drawGuanImage(config);
}); });
...@@ -539,45 +539,50 @@ export default { ...@@ -539,45 +539,50 @@ export default {
this.ctx.save(); this.ctx.save();
this.ctx.setTransform(1, 0, 0, 1, 0, 0); // 恢复默认坐标系(左上角原点,Y轴向下) this.ctx.setTransform(1, 0, 0, 1, 0, 0); // 恢复默认坐标系(左上角原点,Y轴向下)
// // 增加测试数据
// lineConfig.points.push({
// x: lineConfig.points[1].x - 150,
// y: lineConfig.points[1].y -150
// })
// 将警戒线坐标转换为默认坐标系(原坐标系Y轴向上) // 将警戒线坐标转换为默认坐标系(原坐标系Y轴向上)
const points = lineConfig.points.map(point => ({ const canvasHeight = this.canvas.height; // 缓存画布高度
const convertedPoints = lineConfig.points.map(point => ({
x: point.x, x: point.x,
y: point.y // 转换为默认Y轴向下的坐标 y: point.y // 转换为默认Y轴向下的坐标
})); }));
// 取警戒线的起点和终点(假设points按顺序排列) // 遍历相邻点对,生成梯形
const startPoint = points[0]; for (let i = 0; i < convertedPoints.length - 1; i++) {
const endPoint = points[points.length - 1]; const start = convertedPoints[i];
const end = convertedPoints[i + 1];
console.table(startPoint)
console.table(endPoint) // 构建当前线段对应的梯形四个顶点
const trapezoid = [
start, // 顶部左端点
// 构建梯形四个顶点(直角梯形) end, // 顶部右端点
const trapezoidPoints = [ { x: end.x, y: canvasHeight }, // 底部右端点(垂直投影到底边)
startPoint, // 顶部左端点 { x: start.x, y: canvasHeight }, // 底部左端点(垂直投影到底边)
endPoint, // 顶部右端点 ];
{ x: endPoint.x, y: endPoint.y + (this.canvas.height - endPoint.y) }, // 底部右端点(垂直投影到底边)
{ x: startPoint.x, y: startPoint.y + (this.canvas.height - endPoint.y) }, // 底部左端点(垂直投影到底边) // 绘制当前梯形
]; this.ctx.fillStyle = 'rgba(59, 175, 251, 0.3)'; // 海蓝色,透明度30%
this.ctx.beginPath();
// 绘制梯形路径并填充 trapezoid.forEach((point, index) => {
this.ctx.fillStyle = 'rgba(59, 175, 251, 0.3)'; // 海蓝色,透明度30% index === 0
this.ctx.beginPath(); ? this.ctx.moveTo(point.x, point.y)
trapezoidPoints.forEach((point, index) => { : this.ctx.lineTo(point.x, point.y);
index === 0 });
? this.ctx.moveTo(point.x, point.y) this.ctx.closePath();
: this.ctx.lineTo(point.x, point.y); this.ctx.fill();
}); }
this.ctx.closePath(); // 闭合路径
this.ctx.fill();
this.ctx.restore(); this.ctx.restore();
} }
}); });
// 5. 绘制water.png // 5. 绘制water.png
this.drawWaterImage(); // this.drawWaterImage();
}, },
/** 加载所有图片并绘制 */ /** 加载所有图片并绘制 */
loadAllImages() { loadAllImages() {
...@@ -585,9 +590,9 @@ export default { ...@@ -585,9 +590,9 @@ export default {
this.bgImage = new Image(); this.bgImage = new Image();
this.bgImage.src = require("@/assets/images/jrx/bg.png"); this.bgImage.src = require("@/assets/images/jrx/bg.png");
// 加载 water.png // // 加载 water.png
this.waterImage = new Image(); // this.waterImage = new Image();
this.waterImage.src = require("@/assets/images/jrx/water.png"); // this.waterImage.src = require("@/assets/images/jrx/water.png");
// 加载 po.png // 加载 po.png
this.poImage = new Image(); this.poImage = new Image();
...@@ -600,7 +605,7 @@ export default { ...@@ -600,7 +605,7 @@ export default {
// 等待所有图片加载完成 // 等待所有图片加载完成
Promise.all([ Promise.all([
new Promise((resolve) => (this.bgImage.onload = resolve)), new Promise((resolve) => (this.bgImage.onload = resolve)),
new Promise((resolve) => (this.waterImage.onload = resolve)), // new Promise((resolve) => (this.waterImage.onload = resolve)),
new Promise((resolve) => (this.poImage.onload = resolve)), new Promise((resolve) => (this.poImage.onload = resolve)),
new Promise((resolve) => (this.guanImage.onload = resolve)), new Promise((resolve) => (this.guanImage.onload = resolve)),
]) ])
...@@ -631,7 +636,7 @@ export default { ...@@ -631,7 +636,7 @@ export default {
}).then((res) => { }).then((res) => {
const data = res.body; const data = res.body;
// const data = this.getChartData().body // const data = this.getChartData().body
console.log("data", data); // console.log("data", data);
const chartData = this.seriesDataFormat(data, { datekey: "date" }); const chartData = this.seriesDataFormat(data, { datekey: "date" });
var warningLine = undefined; // this.form.config.warningLine; var warningLine = undefined; // this.form.config.warningLine;
...@@ -649,7 +654,7 @@ export default { ...@@ -649,7 +654,7 @@ export default {
); );
// const chartData = data // const chartData = data
console.log("chartCData", chartData); // console.log("chartCData", chartData);
Highcharts.setOptions({ Highcharts.setOptions({
global: { global: {
useUTC: false, useUTC: false,
...@@ -929,7 +934,7 @@ export default { ...@@ -929,7 +934,7 @@ export default {
} }
}, },
loadData: function () { loadData: function () {
console.log(this.form, "form"); // console.log(this.form, "form");
this.initChart1(); this.initChart1();
this.getCanvasData(); this.getCanvasData();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment