fix: Interactive 图表刷选和切页时,重新判断y轴范围,让峰更好的展示

This commit is contained in:
Xu Zhimeng 2023-12-11 17:34:52 +08:00
parent a73571e686
commit bf2ceff880

View File

@ -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()