fix: 键盘事件改为全局,在红线未出现时,点击Peak Infomation 箭头和键盘左右键逻辑优化

This commit is contained in:
Xu Zhimeng 2023-11-22 10:11:39 +08:00
parent d5491bfcee
commit 29bf022af9

View File

@ -42,7 +42,7 @@
<!-- 二级交互栏结束 -->
<!-- 主体部分 -->
<div class="gamma-analysis-main">
<div class="gamma-analysis-chart" ref="chartContainerRef" tabindex="0" @keydown="handleKeyboardEvent">
<div class="gamma-analysis-chart">
<CustomChart
ref="chartRef"
:option="option"
@ -239,12 +239,16 @@ export default {
this.$bus.$on('gammaRefresh', this.handleRefresh)
this.$bus.$on('accept', this.handleAccept)
window.addEventListener('keydown', this.handleKeyboardEvent)
},
destroyed() {
this.cancelLastRequest()
this.$bus.$off('gammaRefresh', this.handleRefresh)
this.$bus.$off('accept', this.handleAccept)
window.removeEventListener('keydown', this.handleKeyboardEvent)
},
mounted() {
this.option.brush = { toolbox: [] }
@ -895,7 +899,6 @@ export default {
// 线
handleChartClick(param) {
this.focusChart()
const { offsetX, offsetY } = param
const point = getXAxisAndYAxisByPosition(this.getChart(), offsetX, offsetY)
if (point) {
@ -910,10 +913,6 @@ export default {
}
},
// keydown
focusChart() {
this.$refs.chartContainerRef.focus()
},
//
setChartBottomTitle(channel, energy, counts) {
@ -926,6 +925,13 @@ export default {
// xAixschannelenergycounts
getEnergyAndCountsByXAxis(xAxis) {
if(-1 == xAxis) {
return {
channel: -1,
energy: 0,
counts: 0,
}
}
let channel, energy, counts
if (this.isEnergy) {
channel = this.getChannelByEnergy(xAxis)
@ -986,13 +992,10 @@ export default {
// peak info
handlePeakInfoChange(direction) {
this.moveMarkLine(direction)
this.focusChart()
},
// Peak Infomation
handleTogglePeak() {
this.focusChart()
const spectrumLineSeries = findSeriesByName(this.option.series, 'Spectrum')
const xAxis = spectrumLineSeries.markLine.data[0].xAxis
const channel = this.isEnergy ? this.getChannelByEnergy(xAxis) : parseInt(xAxis.toFixed())