fix: Interactive 图表刷选和切页时,重新判断y轴范围,让峰更好的展示
This commit is contained in:
parent
a73571e686
commit
bf2ceff880
|
@ -647,7 +647,6 @@ export default {
|
||||||
this.selectedTableItem = selectedRow
|
this.selectedTableItem = selectedRow
|
||||||
this.selectTableRow(selectedRow.index, i)
|
this.selectTableRow(selectedRow.index, i)
|
||||||
this.getSelPosNuclide(selectedRow)
|
this.getSelPosNuclide(selectedRow)
|
||||||
this.adjustArea(i)
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -660,7 +659,6 @@ export default {
|
||||||
this.selectedTableItem = selectedRow
|
this.selectedTableItem = selectedRow
|
||||||
this.selectTableRow(selectedRow.index, i)
|
this.selectTableRow(selectedRow.index, i)
|
||||||
this.getSelPosNuclide(selectedRow)
|
this.getSelPosNuclide(selectedRow)
|
||||||
this.adjustArea(i)
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -670,23 +668,49 @@ export default {
|
||||||
/**
|
/**
|
||||||
* 根据当前Peak调整缩放范围
|
* 根据当前Peak调整缩放范围
|
||||||
*/
|
*/
|
||||||
adjustArea(index) {
|
adjustArea() {
|
||||||
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 {
|
const {
|
||||||
yAxis: { max, min },
|
xAxis: { max, min },
|
||||||
} = this.option
|
} = 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) {
|
selectTableRow(key, index) {
|
||||||
|
@ -712,6 +736,7 @@ export default {
|
||||||
chartXAxisOption.min = nextMin < 1 ? 1 : nextMin
|
chartXAxisOption.min = nextMin < 1 ? 1 : nextMin
|
||||||
|
|
||||||
this.setThumbnailRange(chartXAxisOption.min, chartXAxisOption.max)
|
this.setThumbnailRange(chartXAxisOption.min, chartXAxisOption.max)
|
||||||
|
this.adjustArea()
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -974,7 +999,7 @@ export default {
|
||||||
|
|
||||||
this.selectedTableItem = row
|
this.selectedTableItem = row
|
||||||
|
|
||||||
this.adjustArea(index)
|
this.adjustArea()
|
||||||
},
|
},
|
||||||
|
|
||||||
// 鼠标按下时开启可刷选状态
|
// 鼠标按下时开启可刷选状态
|
||||||
|
@ -1038,6 +1063,8 @@ export default {
|
||||||
this.option.yAxis.min = y1
|
this.option.yAxis.min = y1
|
||||||
this.option.yAxis.max = y2
|
this.option.yAxis.max = y2
|
||||||
|
|
||||||
|
this.adjustArea()
|
||||||
|
|
||||||
this.setThumbnailRange(x1, x2)
|
this.setThumbnailRange(x1, x2)
|
||||||
if (this.btnGroupType == 2) {
|
if (this.btnGroupType == 2) {
|
||||||
this.buildRect()
|
this.buildRect()
|
||||||
|
|
Loading…
Reference in New Issue
Block a user