fix: 键盘事件改为全局,在红线未出现时,点击Peak Infomation 箭头和键盘左右键逻辑优化
This commit is contained in:
parent
d5491bfcee
commit
29bf022af9
|
@ -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 {
|
|||
|
||||
// 根据xAixs值找channel、energy和counts
|
||||
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())
|
||||
|
|
Loading…
Reference in New Issue
Block a user