From 2ec6c7f3cde9c43a9c57741a358531cec28a0760 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=BB=BB=E7=8F=AE=E5=AE=87?= Date: Thu, 18 Jan 2024 11:01:51 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A4=84=E7=90=86=E7=82=B9=E8=BF=87=20update?= =?UTF-8?q?=20=E4=B9=8B=E5=90=8E=20=E9=87=8D=E6=96=B0=E6=8B=96=E5=8A=A8=20?= =?UTF-8?q?=E7=82=B9=E5=87=BB=20unzoom=20=E4=B8=8D=E7=94=9F=E6=95=88?= =?UTF-8?q?=E7=9A=84=E9=97=AE=E9=A2=98=20=E5=A4=84=E7=90=86=E5=88=B7?= =?UTF-8?q?=E9=80=89=E5=AE=8C=E6=AF=95=E6=94=BE=E5=A4=A7=E5=90=8E=EF=BC=8C?= =?UTF-8?q?=E7=82=B9=E5=87=BB=20unzoom=20=E4=B8=8D=E8=83=BD=E9=80=89?= =?UTF-8?q?=E4=B8=AD=E6=8B=96=E6=8B=BD=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../components/BetaGammaSpectrum.vue | 67 +++++++++++++++++-- 1 file changed, 60 insertions(+), 7 deletions(-) diff --git a/src/views/spectrumAnalysis/components/BetaGammaSpectrum.vue b/src/views/spectrumAnalysis/components/BetaGammaSpectrum.vue index 8f0c7e7..7848706 100644 --- a/src/views/spectrumAnalysis/components/BetaGammaSpectrum.vue +++ b/src/views/spectrumAnalysis/components/BetaGammaSpectrum.vue @@ -171,8 +171,10 @@ const dragOption = { position: [], draggable: true, style: { - fill: 'rgba(0,0,0,0)', // fill: 'rgba(0,0,0,0.03)', 方便观察 - stroke: 'rgba(0,0,0,0)', // stroke: 'rgba(0,0,0,0.03)', 方便观察 + fill: 'rgba(0,0,0,0)', + stroke: 'rgba(0,0,0,0)', + // fill: 'rgba(255,0,0,0.5)', // 方便观察 + // stroke: 'rgba(255,0,0,0.5)', // 方便观察 lineWidth: 10, }, cursor: 'move', @@ -190,8 +192,10 @@ const dragOption = { position: [], draggable: true, style: { - fill: 'rgba(0,0,0,0)', // fill: 'rgba(0,0,0,0.03)', 方便观察 - stroke: 'rgba(0,0,0,0)', // stroke: 'rgba(0,0,0,0.03)', 方便观察 + fill: 'rgba(0,0,0,0)', + stroke: 'rgba(0,0,0,0)', + // fill: 'rgba(255,0,0,0.5)', // 方便观察 + // stroke: 'rgba(255,0,0,0.5)', // 方便观察 lineWidth: 10, }, cursor: 'move', @@ -575,6 +579,8 @@ export default { }, // 点击unzoom handleUnzoom() { + const [graphic1, graphic2] = this.dragOption.graphic + const { minX, maxX, minY, maxY, color } = this.boundaryData this.twoDOption.xAxis.min = 0 this.twoDOption.xAxis.max = 1024 this.twoDOption.yAxis.min = 0 @@ -582,8 +588,19 @@ export default { // this.emitRangeChange([0, 256, 0, 256]) this.reDrawRect() - this.buildScatterList() + this.$nextTick(() => { + const myChart = this.$refs.chartTwoDRef.getChartInstance() + graphic1.position = [ + myChart.convertToPixel({ xAxisId: '2' }, minX), + myChart.convertToPixel({ yAxisId: '3' }, maxY), + ] + graphic2.position = [ + myChart.convertToPixel({ xAxisId: '2' }, maxX), + myChart.convertToPixel({ yAxisId: '3' }, maxY), + ] + myChart.setOption(this.dragOption) + }) }, // 鼠标按下时开启可刷选状态 handleMouseDown() { @@ -607,6 +624,8 @@ export default { }, // 刷选完毕时 handleBrushEnd(param) { + const [graphic1, graphic2] = this.dragOption.graphic + const { minX: lineMinX, maxX: lineMaxX, minY: lineMinY, maxY: lineMaxY } = this.boundaryData const chart = this.$refs.chartTwoDRef.getChartInstance() const areas = param.areas[0] if (areas) { @@ -625,12 +644,46 @@ export default { this.twoDOption.xAxis.max = rangeNumberFuncX(x2) this.twoDOption.yAxis.min = rangeNumberFuncY(y1) this.twoDOption.yAxis.max = rangeNumberFuncY(y2) + this.buildScatterList() + this.$nextTick(() => { + const myChart = this.$refs.chartTwoDRef.getChartInstance() + if (lineMinX > rangeNumberFuncX(x1) && lineMinX < rangeNumberFuncX(x2) && lineMaxX > rangeNumberFuncX(x2)) { + graphic1.position = [ + myChart.convertToPixel({ xAxisId: '2' }, lineMinX), + myChart.convertToPixel({ yAxisId: '3' }, rangeNumberFuncY(y2)), + ] + myChart.setOption(this.dragOption) + } else if ( + lineMinX < rangeNumberFuncX(x1) && + lineMaxX > rangeNumberFuncX(x1) && + lineMaxX < rangeNumberFuncX(x2) + ) { + graphic2.position = [ + myChart.convertToPixel({ xAxisId: '2' }, lineMaxX), + myChart.convertToPixel({ yAxisId: '3' }, rangeNumberFuncY(y2)), + ] + myChart.setOption(this.dragOption) + } else if ( + lineMinX > rangeNumberFuncX(x1) && + lineMinX < rangeNumberFuncX(x2) && + lineMaxX > rangeNumberFuncX(x1) && + lineMaxX < rangeNumberFuncX(x2) + ) { + graphic1.position = [ + myChart.convertToPixel({ xAxisId: '2' }, lineMinX), + myChart.convertToPixel({ yAxisId: '3' }, rangeNumberFuncY(y2)), + ] + graphic2.position = [ + myChart.convertToPixel({ xAxisId: '2' }, lineMaxX), + myChart.convertToPixel({ yAxisId: '3' }, rangeNumberFuncY(y2)), + ] + myChart.setOption(this.dragOption) + } + }) // this.emitRangeChange([x1, x2, y1, y2]) // this.reDrawRect() - - this.buildScatterList() } this.clearBrush(chart)