diff --git a/src/views/spectrumAnalysis/components/Modals/AnalyzeInteractiveToolModal/index.vue b/src/views/spectrumAnalysis/components/Modals/AnalyzeInteractiveToolModal/index.vue index 46d6b31..661ad23 100644 --- a/src/views/spectrumAnalysis/components/Modals/AnalyzeInteractiveToolModal/index.vue +++ b/src/views/spectrumAnalysis/components/Modals/AnalyzeInteractiveToolModal/index.vue @@ -647,7 +647,6 @@ export default { this.selectedTableItem = selectedRow this.selectTableRow(selectedRow.index, i) this.getSelPosNuclide(selectedRow) - this.adjustArea(i) return } } @@ -660,7 +659,6 @@ export default { this.selectedTableItem = selectedRow this.selectTableRow(selectedRow.index, i) this.getSelPosNuclide(selectedRow) - this.adjustArea(i) return } } @@ -670,23 +668,49 @@ export default { /** * 根据当前Peak调整缩放范围 */ - adjustArea(index) { - const peak = this.channelPeakChart[index] - if (peak) { - const peakCountMax = Math.max(...peak.pointlist.map(({ y }) => y)) - const peakCountMin = Math.min(...peak.pointlist.map(({ y }) => y)) - const { - yAxis: { max, min }, - } = this.option + adjustArea() { + const { + xAxis: { max, min }, + } = this.option - if (max !== 'dataMax' && peakCountMin >= max) { - this.option.yAxis.max = 'dataMax' + // 找到最高点在这个范围内的峰 + const peaks = [] + for (let i = 0; i < this.channelPeakChart.length; i++) { + const peak = this.channelPeakChart[i] + const pointlist = peak.pointlist + + // 如果 第一个/最后一个 都 大于/小于 范围,跳过 + if (pointlist[0].x > max || pointlist[pointlist.length - 1].x < min) { + continue } - if (peakCountMax <= min) { - this.option.yAxis.min = 0.1 + // 找到峰最大值 + const peakMaxY = Math.max(...pointlist.map(({ y }) => y)) + const find = pointlist.find(({ y }) => y == peakMaxY) + + // 如果最大值在范围内 + if (find.x >= min && find.x <= max) { + peaks.push({ + max: peakMaxY, + min: Math.min(pointlist[0].y, pointlist[pointlist.length - 1].y), + }) } } + + const peaksMax = Math.max(...peaks.map(({ max }) => max)) + const peaksMin = Math.min(...peaks.map(({ min }) => min)) + + const { + yAxis: { max: yAxisMax, min: yAxisMin }, + } = this.option + + if (peaksMax > yAxisMax) { + this.option.yAxis.max = Math.ceil(peaksMax) + } + + if (peaksMin < yAxisMin) { + this.option.yAxis.min = Math.floor(peaksMin) + } }, selectTableRow(key, index) { @@ -712,6 +736,7 @@ export default { chartXAxisOption.min = nextMin < 1 ? 1 : nextMin this.setThumbnailRange(chartXAxisOption.min, chartXAxisOption.max) + this.adjustArea() } }, @@ -974,7 +999,7 @@ export default { this.selectedTableItem = row - this.adjustArea(index) + this.adjustArea() }, // 鼠标按下时开启可刷选状态 @@ -1038,6 +1063,8 @@ export default { this.option.yAxis.min = y1 this.option.yAxis.max = y2 + this.adjustArea() + this.setThumbnailRange(x1, x2) if (this.btnGroupType == 2) { this.buildRect()