From 4a8980b0c500c36c89d73d2a9ba5c2d94ecddcd9 Mon Sep 17 00:00:00 2001 From: xiaowuler Date: Tue, 26 Apr 2022 14:03:28 +0800 Subject: [PATCH] modify some value null handler --- .../Frontend/src/components/RamanLidar.vue | 39 ++++++++++++++----- .../Frontend/src/model/heat-map-drawer.ts | 9 +++-- .../Frontend/src/uilts/box-drawer.ts | 24 ++++++++++-- 3 files changed, 55 insertions(+), 17 deletions(-) diff --git a/04.系统编码/Frontend/src/components/RamanLidar.vue b/04.系统编码/Frontend/src/components/RamanLidar.vue index 02b1631..6a1f441 100644 --- a/04.系统编码/Frontend/src/components/RamanLidar.vue +++ b/04.系统编码/Frontend/src/components/RamanLidar.vue @@ -246,9 +246,10 @@ export default { backscatterDrawer: null } let options = reactive({ - currentTab: 'MWR', - // currentRegion: 'pk', - currentRegion: 'jn', + // currentTab: 'MWR', + currentTab: 'optical-property', + currentRegion: 'pk', + // currentRegion: 'jn', currentElement: 'PBLH', currentType: '边界层高度', date: moment('2022-04-01 12:00:00').format('YYYY-MM-DD HH:mm:ss'), @@ -362,10 +363,11 @@ export default { const onTabClick = (name) => { // initTimeLine() options.currentTab = name; - setTimeout(() => { - initEcharts(name) - reloadChangeData() - }, 500) + // setTimeout(() => { + + // }, 500) + initEcharts(name) + reloadChangeData() } const reloadChangeData = () => { @@ -654,16 +656,21 @@ export default { const drawOpticsExtinction = (result: CustomeArray) => { if (result.length != 12) return; + console.log(document.getElementById("extinction_optics_chart")) options.loadingExtinctionOpticsStatus = false; if (creates.opticsExtinctionDrawer != null) { creates.opticsExtinctionDrawer.close(); } + console.log("extinction_optics_chart") let matrix = converCloudRecognition(801, result, 'extinctionOptics'); + console.log(matrix) creates.opticsExtinctionDrawer = new HeatMapDrawer(800, 600, matrix, "extinction_optics_chart",'/km/sr'); + console.log(options.timeArray) creates.opticsExtinctionDrawer.setAxis(new CoordinateScale(options.timeArray), new CoordinateScale([0, 2000, 4000, 6000, 8000, 10000, 12000], true, true)); creates.opticsExtinctionDrawer.setColorChart(prepareExtinctionnColors()); creates.opticsExtinctionDrawer.draw(); + console.log(1) } const drawSingleWatervapor = (result: CustomeArray) => { @@ -788,8 +795,19 @@ export default { return; } const interval = Math.round(11 / r.data[0].length); - for (let h = 0, len = r.data.length; h < len; h++) { + for (let h = 0, len = capacity; h < len; h++) { let tempIndex = parseInt(index + ""); + if (r.data[h] == null){ + for(let i = 0; i < 11; i++){ + tempIndex++; + if (matrix[tempIndex] == null) { + matrix[tempIndex] = new Array(capacity); + } + matrix[tempIndex][h] = new Box(tempIndex, h, 0, 0, NaN, h * 15, time, "米"); + } + + continue; + } r.data[h] = r.data[h].slice(0, 11); for (let i = 0, len = r.data[h].length; i < len; i++) { for (let _i = 0; _i < interval; _i++) { @@ -822,9 +840,10 @@ export default { } setCloudRecognitionResult(capacity, time, response.message, response.data, result); - }).catch(error => { - setCloudRecognitionResult(capacity, time, error.message, null, result); }) + // .catch(error => { + // setCloudRecognitionResult(capacity, time, error.message, null, result); + // }) } // diff --git a/04.系统编码/Frontend/src/model/heat-map-drawer.ts b/04.系统编码/Frontend/src/model/heat-map-drawer.ts index 8597ca8..fc553e2 100644 --- a/04.系统编码/Frontend/src/model/heat-map-drawer.ts +++ b/04.系统编码/Frontend/src/model/heat-map-drawer.ts @@ -41,7 +41,9 @@ export class HeatMapDrawer{ private unit: string; private name: string; constructor(width: number, height: number, values: any, id: string, unit: string = '', name: string = '') { - if (id == null) return; + if (id == null) { + throw new Error("heat map drawer id not allow null"); + } this.id = id; this.width = width; @@ -127,7 +129,9 @@ export class HeatMapDrawer{ for(let dataIndex = 0, len = this.values.length, lastDataLen = len - 1; dataIndex < len; dataIndex++){ let value = this.values[dataIndex]; - for(let lastInfoLen = this.values[0].length - 1, infoIndex = lastInfoLen; infoIndex >= 0; infoIndex--){ + for(let lastInfoLen = value.length - 1, infoIndex = lastInfoLen; infoIndex >= 0; infoIndex--){ + // if (value[infoIndex] == null) continue; + let x = startX + dataIndex * this.verticalScaleIntervalLength; let y = startY + (this.borderHeight - infoIndex * this.horizontalScaleIntervalLength); let width = this.verticalScaleIntervalLength; @@ -158,7 +162,6 @@ export class HeatMapDrawer{ this.values[dataIndex] = this.values[dataIndex].reverse(); } - this.createCalc(this.values); } diff --git a/04.系统编码/Frontend/src/uilts/box-drawer.ts b/04.系统编码/Frontend/src/uilts/box-drawer.ts index d7af21f..5c12dfb 100644 --- a/04.系统编码/Frontend/src/uilts/box-drawer.ts +++ b/04.系统编码/Frontend/src/uilts/box-drawer.ts @@ -579,8 +579,8 @@ export class Calc{ private readonly paddingRight: number; private readonly paddingBottom: number; - private readonly boxWidth: number; - private readonly boxHeight: number; + private boxWidth: number; + private boxHeight: number; private xMax: number = null; private yMax: number = null; @@ -601,10 +601,25 @@ export class Calc{ this.boxes = boxes; this.boxWidth = this.boxes[1][1].width; this.boxHeight = this.boxes[1][1].height; - + + // this.setWidthAndHeight(); this.init(); } + private setWidthAndHeight() : void{ + for(let row = 0, rowLen = this.boxes.length; row < rowLen; row++){ + for(let col = 0, colLen = this.boxes[row].length; col < colLen; col++){ + let box = this.boxes[row][col]; + if (box == null) continue; + + console.log(box) + this.boxWidth = box.width; + this.boxHeight = box.height; + return; + } + } + } + private init(): void{ this.xMax = this.width - this.paddingRight; this.yMax = this.height - this.paddingBottom; @@ -619,7 +634,8 @@ export class Calc{ } const indexX = parseInt(((x - this.startX) * 1.0 / this.boxWidth).toString()); - const indexY = parseInt(((y - this.startY) * 1.0 / this.boxHeight).toString()) + const indexY = parseInt(((y - this.startY) * 1.0 / this.boxHeight).toString()); + console.log(indexX, indexY, this.boxes); return this.boxes[indexX][indexY]; } } \ No newline at end of file